Context.BindService Method

Definition

Overloads

BindService(Intent, IServiceConnection, Bind)

Connect to an application service, creating it if needed.

BindService(Intent, Bind, IExecutor, IServiceConnection)

Same as #bindService(Intent, ServiceConnection, int) with executor to control ServiceConnection callbacks.

BindService(Intent, IServiceConnection, Bind)

Connect to an application service, creating it if needed.

[Android.Runtime.Register("bindService", "(Landroid/content/Intent;Landroid/content/ServiceConnection;I)Z", "GetBindService_Landroid_content_Intent_Landroid_content_ServiceConnection_IHandler")]
public abstract bool BindService (Android.Content.Intent? service, Android.Content.IServiceConnection conn, Android.Content.Bind flags);
[<Android.Runtime.Register("bindService", "(Landroid/content/Intent;Landroid/content/ServiceConnection;I)Z", "GetBindService_Landroid_content_Intent_Landroid_content_ServiceConnection_IHandler")>]
abstract member BindService : Android.Content.Intent * Android.Content.IServiceConnection * Android.Content.Bind -> bool

Parameters

service
Intent

Identifies the service to connect to. The Intent must specify an explicit component name.

conn
IServiceConnection

Receives information as the service is started and stopped. This must be a valid ServiceConnection object; it must not be null.

flags
Bind

Operation options for the binding. May be 0, #BIND_AUTO_CREATE, #BIND_DEBUG_UNBIND, #BIND_NOT_FOREGROUND, #BIND_ABOVE_CLIENT, #BIND_ALLOW_OOM_MANAGEMENT, #BIND_WAIVE_PRIORITY. #BIND_IMPORTANT, #BIND_ADJUST_WITH_ACTIVITY, #BIND_NOT_PERCEPTIBLE, or #BIND_INCLUDE_CAPABILITIES.

Returns

Boolean

true if the system is in the process of bringing up a service that your client has permission to bind to; false if the system couldn't find the service or if your client doesn't have permission to bind to it. If this value is true, you should later call #unbindService to release the connection.

Attributes

Exceptions

Remarks

Java documentation for android.content.Context.bindService(android.content.Intent, android.content.ServiceConnection, int).

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.

See also

Applies to

BindService(Intent, Bind, IExecutor, IServiceConnection)

Same as #bindService(Intent, ServiceConnection, int) with executor to control ServiceConnection callbacks.

[Android.Runtime.Register("bindService", "(Landroid/content/Intent;ILjava/util/concurrent/Executor;Landroid/content/ServiceConnection;)Z", "GetBindService_Landroid_content_Intent_ILjava_util_concurrent_Executor_Landroid_content_ServiceConnection_Handler", ApiSince=29)]
public virtual bool BindService (Android.Content.Intent service, Android.Content.Bind flags, Java.Util.Concurrent.IExecutor executor, Android.Content.IServiceConnection conn);
[<Android.Runtime.Register("bindService", "(Landroid/content/Intent;ILjava/util/concurrent/Executor;Landroid/content/ServiceConnection;)Z", "GetBindService_Landroid_content_Intent_ILjava_util_concurrent_Executor_Landroid_content_ServiceConnection_Handler", ApiSince=29)>]
abstract member BindService : Android.Content.Intent * Android.Content.Bind * Java.Util.Concurrent.IExecutor * Android.Content.IServiceConnection -> bool
override this.BindService : Android.Content.Intent * Android.Content.Bind * Java.Util.Concurrent.IExecutor * Android.Content.IServiceConnection -> bool

Parameters

service
Intent
flags
Bind
executor
IExecutor

Callbacks on ServiceConnection will be called on executor. Must use same instance for the same instance of ServiceConnection.

Returns

Boolean
Attributes

Remarks

Java documentation for android.content.Context.bindService(android.content.Intent, int, java.util.concurrent.Executor, android.content.ServiceConnection).

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