Most visited

Recently visited

Added in API level 1

ServiceConnection

public interface ServiceConnection

android.content.ServiceConnection
Known Indirect Subclasses


用于监视应用程序服务状态的接口。 有关更多信息,请参阅ServiceContext.bindService()

就像系统的许多回调一样,这个类的方法是从你的进程的主线程调用的。

Summary

Public methods

abstract void onServiceConnected(ComponentName name, IBinder service)

当与服务的连接已建立时调用,服务的通讯通道为 IBinder

abstract void onServiceDisconnected(ComponentName name)

当与服务的连接丢失时调用。

Public methods

onServiceConnected

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

与服务建立连接时调用,服务的通信通道为 IBinder

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)

当与服务的连接丢失时调用。 这通常发生在承载服务的进程崩溃或被杀死时。 这并不会删除ServiceConnection本身 - 与服务的绑定将保持活动状态,并且在下次运行服务时您将收到对onServiceConnected(ComponentName, IBinder)的呼叫。

Parameters
name ComponentName: The concrete component name of the service whose connection has been lost.

Hooray!