Please note that the contents of this offline web site may be out of date. To access the most recent documentation visit the online version .
Note that links that point to online resources are green in color and will open in a new window.
We would love it if you could give us feedback about this material by filling this form (You have to be online to fill it)
Android APIs
public interface

ServiceConnection

android.content.ServiceConnection
Known Indirect Subclasses

Class Overview

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

public abstract void onServiceConnected ( ComponentName name, IBinder service)

Added in API level 1

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

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

public abstract void onServiceDisconnected ( ComponentName name)

Added in API level 1

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 The concrete component name of the service whose connection has been lost.