services-api / com.keecker.services.interfaces / EphemeralServiceConnection

EphemeralServiceConnection

class EphemeralServiceConnection : ServiceConnection

Wraps an Android android.content.ServiceConnection to be used in coroutines.

Like an Android ServiceConnection, it may attempt to bind again if the remote service crashed, but it won’t do it if dead or unbound.

Constructors

<init> EphemeralServiceConnection(context: Context, intent: Intent)
Wraps an Android android.content.ServiceConnection to be used in coroutines.

Properties

context val context: Context
intent val intent: Intent

Functions

getBinder suspend fun getBinder(): IBinder?
Returns a binder, waiting for the onServiceConnected callback if not already received. This suspending function can block forever if something went wrong when binding, it is intended to be used with a timeout.
onBindingDied fun onBindingDied(name: ComponentName?): Unit
Note: Since API 26. Not sure if it really gets called.
onServiceConnected fun onServiceConnected(name: ComponentName?, service: IBinder?): Unit
Called when a connection to the Service has been established, with the android.os.IBinder of the communication channel to the Service.
onServiceDisconnected fun onServiceDisconnected(name: ComponentName?): Unit
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 {@link #onServiceConnected} when the Service is next running.
unbind fun unbind(): Unit
Kills that connection, it will never attempt to bind again.