Bind Enum

Definition

Enumerates values returned by several methods of Bind

This enumeration supports a bitwise combination of its member values.

[System.Flags]
public enum Bind
[<System.Flags>]
type Bind = 
Inheritance
Bind
Attributes

Fields

Name Value Description
ExternalService -2147483648

Flag for bindService(Intent, BindServiceFlags, Executor, ServiceConnection) : The service being bound is an isolated , external service. This binds the service into the calling application's package, rather than the package in which the service is declared. When using this flag, the code for the service being bound will execute under the calling application's package name and user ID. Because the service must be an isolated process, it will not have direct access to the application's data, though. The purpose of this flag is to allow applications to provide services that are attributed to the app using the service, rather than the application providing the service. This flag is NOT compatible with BindServiceFlags . If you need to use BindServiceFlags , you must use BIND_EXTERNAL_SERVICE_LONG instead.

None 0

Specifies that no binding flags are set.

AutoCreate 1

Flag for bindService(Intent, BindServiceFlags, Executor, ServiceConnection) : automatically create the service as long as the binding exists. Note that while this will create the service, its Service.onStartCommand(Intent, int, int) method will still only be called due to an explicit call to startService(Intent) . Even without that, though, this still provides you with access to the service object while the service is created. Note that prior to Build.VERSION_CODES.ICE_CREAM_SANDWICH , not supplying this flag would also impact how important the system consider's the target service's process to be. When set, the only way for it to be raised was by binding from a service in which case it will only be important when that activity is in the foreground. Now to achieve this behavior you must explicitly supply the new flag BIND_ADJUST_WITH_ACTIVITY . For compatibility, old applications that don't specify BIND_AUTO_CREATE will automatically have the flags BIND_WAIVE_PRIORITY and BIND_ADJUST_WITH_ACTIVITY set for them in order to achieve the same result.

DebugUnbind 2

Flag for bindService(Intent, BindServiceFlags, Executor, ServiceConnection) : include debugging help for mismatched calls to unbind. When this flag is set, the callstack of the following unbindService(ServiceConnection) call is retained, to be printed if a later incorrect unbind call is made. Note that doing this requires retaining information about the binding that was made for the lifetime of the app, resulting in a leak -- this should only be used for debugging.

NotForeground 4

Flag for bindService(Intent, BindServiceFlags, Executor, ServiceConnection) : don't allow this binding to raise the target service's process to the foreground scheduling priority. It will still be raised to at least the same memory priority as the client (so that its process will not be killable in any situation where the client is not killable), but for CPU scheduling purposes it may be left in the background. This only has an impact in the situation where the binding client is a foreground process and the target service is in a background process.

AboveClient 8

Flag for bindService(Intent, BindServiceFlags, Executor, ServiceConnection) : indicates that the client application binding to this service considers the service to be more important than the app itself. When set, the platform will try to have the out of memory killer kill the app before it kills the service it is bound to, though this is not guaranteed to be the case.

AllowOomManagement 16

Flag for bindService(Intent, BindServiceFlags, Executor, ServiceConnection) : allow the process hosting the bound service to go through its normal memory management. It will be treated more like a running service, allowing the system to (temporarily) expunge the process if low on memory or for some other whim it may have, and being more aggressive about making it a candidate to be killed (and restarted) if running for a long time.

WaivePriority 32

Flag for bindService(Intent, BindServiceFlags, Executor, ServiceConnection) : don't impact the scheduling or memory management priority of the target service's hosting process. Allows the service's process to be managed on the background LRU list just like a regular application process in the background.

Important 64

Flag for bindService(Intent, BindServiceFlags, Executor, ServiceConnection) : this service is very important to the client, so should be brought to the foreground process level when the client is. Normally a process can only be raised to the visibility level by a client, even if that client is in the foreground.

AdjustWithActivity 128

Flag for bindService(Intent, BindServiceFlags, Executor, ServiceConnection) : If binding from an activity, allow the target service's process importance to be raised based on whether the activity is visible to the user, regardless whether another flag is used to reduce the amount that the client process's overall importance is used to impact it.

NotPerceptible 256

Flag for bindService(Intent, BindServiceFlags, Executor, ServiceConnection) : If binding from an app that is visible or user-perceptible, lower the target service's importance to below the perceptible level. This allows the system to (temporarily) expunge the bound process from memory to make room for more important user-perceptible processes.

AllowActivityStarts 512

Flag for bindService(Intent, BindServiceFlags, Executor, ServiceConnection) : If binding from an app that is visible, the bound service is allowed to start an activity from background. This was the default behavior before SDK version Build.VERSION_CODES.UPSIDE_DOWN_CAKE . Since then, the default behavior changed to disallow the bound service to start a background activity even if the app bound to it is in foreground, unless this flag is specified when binding.

IncludeCapabilities 4096

Flag for bindService(Intent, BindServiceFlags, Executor, ServiceConnection) : If binding from an app that has specific capabilities due to its foreground state such as an activity or foreground service, then this flag will allow the bound app to get the same capabilities, as long as it has the required permissions as well. If binding from a top app and its target SDK version is at or above Build.VERSION_CODES.R , the app needs to explicitly use BIND_INCLUDE_CAPABILITIES flag to pass all capabilities to the service so the other app can have while-in-use access such as location, camera, microphone from background. If binding from a top app and its target SDK version is below Build.VERSION_CODES.R , BIND_INCLUDE_CAPABILITIES is implicit.

SharedIsolatedProcess 8192

Flag for bindIsolatedService(Intent, BindServiceFlags, String, Executor, ServiceConnection) : Bind the service into a shared isolated process. Specifying this flag allows multiple isolated services to be running in a single shared isolated process. The shared isolated process instance is identified by the instanceName parameter in bindIsolatedService(Intent,int,String,Executor,ServiceConnection) . Subsequent calls to bindIsolatedService(Intent, BindServiceFlags, String, Executor, ServiceConnection) with the same instanceName will cause the isolated service to be co-located in the same shared isolated process. Note that the shared isolated process is scoped to the calling app; once created, only the calling app can bind additional isolated services into the shared process. However, the services themselves can come from different APKs and therefore different vendors. Only services that set the R.attr.allowSharedIsolatedProcess attribute to true are allowed to be bound into a shared isolated process.

PackageIsolatedProcess 16384

Flag for bindIsolatedService(Intent, BindServiceFlags, String, Executor, ServiceConnection) : Bind the service into a shared isolated process, but only with other isolated services from the same package that declare the same process name. Specifying this flag allows multiple isolated services defined in the same package to be running in a single shared isolated process. This shared isolated process must be specified since this flag will not work with the default application process. This flag is different from BIND_SHARED_ISOLATED_PROCESS since it only allows binding services from the same package in the same shared isolated process. This also means the shared package isolated process is global, and not scoped to each potential calling app. The shared isolated process instance is identified by the "android:process" attribute defined by the service. This flag cannot be used without this attribute set. Constant Value: 16384 (0x00004000)

Remarks

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to