Added in API level 1

ServiceConnection


public interface ServiceConnection

android.content.ServiceConnection


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

default void onBindingDied(ComponentName name)

Called when the binding to this connection is dead.

default void onNullBinding(ComponentName name)

Called when the service being bound has returned null from its onBind() method.

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

onBindingDied

Added in API level 26
public void onBindingDied (ComponentName name)

Called when the binding to this connection is dead. This means the interface will never receive another connection. The application will need to unbind and rebind the connection to activate it again. This may happen, for example, if the application hosting the service it is bound to has been updated.

Note: The app that requested the binding must call Context.unbindService(ServiceConnection) to release the tracking resources associated with this ServiceConnection even if this callback wa