Save the date! Android Dev Summit is coming to Mountain View, CA on November 7-8, 2018.
added in version 2.0.0
belongs to Maven artifact androidx.lifecycle:lifecycle-process:2.0.0-rc01

ProcessLifecycleOwner

public class ProcessLifecycleOwner
extends Object implements LifecycleOwner

java.lang.Object
   ↳ androidx.lifecycle.ProcessLifecycleOwner


Class that provides lifecycle for the whole application process.

You can consider this LifecycleOwner as the composite of all of your Activities, except that Lifecycle.Event.ON_CREATE will be dispatched once and Lifecycle.Event.ON_DESTROY will never be dispatched. Other lifecycle events will be dispatched with following rules: ProcessLifecycleOwner will dispatch Lifecycle.Event.ON_START, Lifecycle.Event.ON_RESUME events, as a first activity moves through these events. Lifecycle.Event.ON_PAUSE, Lifecycle.Event.ON_STOP, events will be dispatched with a delay after a last activity passed through them. This delay is long enough to guarantee that ProcessLifecycleOwner won't send any events if activities are destroyed and recreated due to a configuration change.

It is useful for use cases where you would like to react on your app coming to the foreground or going to the background and you don't need a milliseconds accuracy in receiving lifecycle events.

Summary

Public methods

static LifecycleOwner get()

The LifecycleOwner for the whole application process.

Lifecycle getLifecycle()

Returns the Lifecycle of the provider.

Inherited methods

Public methods

get

added in version 2.0.0
public static LifecycleOwner get ()

The LifecycleOwner for the whole application process. Note that if your application has multiple processes, this provider does not know about other processes.

Returns
LifecycleOwner LifecycleOwner for the whole application.

getLifecycle

added in version 2.0.0
public Lifecycle getLifecycle ()

Returns the Lifecycle of the provider.

Returns
Lifecycle The lifecycle of the provider.