ServiceLifecycleDispatcher

public class ServiceLifecycleDispatcher


Helper class to dispatch lifecycle events for a Service. Use it only if it is impossible to use LifecycleService.

Summary

Public constructors

Public methods

@NonNull Lifecycle

Lifecycle for the given LifecycleOwner

void

Must be a first call in Service.onBind method, even before super.onBind call.

void

Must be a first call in Service.onCreate method, even before super.onCreate call.

void

Must be a first call in Service.onDestroy method, even before super.OnDestroy call.

void

Must be a first call in Service.onStart or Service.onStartCommand methods, even before a corresponding super call.

Public constructors

ServiceLifecycleDispatcher

Added in 2.0.0
public ServiceLifecycleDispatcher(@NonNull LifecycleOwner provider)
Parameters
@NonNull LifecycleOwner provider

LifecycleOwner for a service, usually it is a service itself

Public methods

getLifecycle

Added in 2.0.0
public @NonNull Lifecycle getLifecycle()

Lifecycle for the given LifecycleOwner

onServicePreSuperOnBind

Added in 2.0.0
public void onServicePreSuperOnBind()

Must be a first call in Service.onBind method, even before super.onBind call.

onServicePreSuperOnCreate

Added in 2.0.0
public void onServicePreSuperOnCreate()

Must be a first call in Service.onCreate method, even before super.onCreate call.

onServicePreSuperOnDestroy

Added in 2.0.0
public void onServicePreSuperOnDestroy()

Must be a first call in Service.onDestroy method, even before super.OnDestroy call.

onServicePreSuperOnStart

Added in 2.0.0
public void onServicePreSuperOnStart()

Must be a first call in Service.onStart or Service.onStartCommand methods, even before a corresponding super call.