Skip to content

Most visited

Recently visited

navigation
Added in API level 1

ServiceConnection

public interface ServiceConnection

android.content.ServiceConnection
Known Indirect Subclasses


Interface for monitoring the state of an application service. See Service and Context.bindService() for more information.

Like many callbacks from the system, the methods on this class are called from the main thread of your process.

Summary

Public methods

abstract void onServiceConnected(ComponentName name, IBinder service)

Called when a connection to the Service has been established, with the IBinder of the communication channel to the Service.

abstract void onServiceDisconnected(ComponentName name)

Called when a connection to the Service has been lost.

Public methods

onServiceConnected

Added in API level 1
void onServiceConnected (ComponentName name, 
                IBinder service)

Called when a connection to the Service has been established, with the IBinder of the communication channel to the Service.

Parameters
name ComponentName: The concrete component name of the service that has been connected.
service IBinder: The IBinder of the Service's communication channel, which you can now make calls on.

onServiceDisconnected

Added in API level 1
void onServiceDisconnected (ComponentName name)

Called when a connection to the Service has been lost. This typically happens when the process hosting the service has crashed or been killed. This does not remove the ServiceConnection itself -- this binding to the service will remain active, and you will receive a call to onServiceConnected(ComponentName, IBinder) when the Service is next running.

Parameters
name ComponentName: The concrete component name of the service whose connection has been lost.
This site uses cookies to store your preferences for site-specific language and display options.

Hooray!

This class requires API level or higher

This doc is hidden because your selected API level for the documentation is . You can change the documentation API level with the selector above the left navigation.

For more information about specifying the API level your app requires, read Supporting Different Platform Versions.

Take a one-minute survey?
Help us improve Android tools and documentation.