public class LifecycleRegistry
extends Lifecycle

   ↳ androidx.lifecycle.Lifecycle
     ↳ androidx.lifecycle.LifecycleRegistry

An implementation of Lifecycle that can handle multiple observers.

It is used by Fragments and Support Library Activities. You can also directly use it if you have a custom LifecycleOwner.


Public constructors

LifecycleRegistry(LifecycleOwner provider)

Creates a new LifecycleRegistry for the given provider.

Public methods

void addObserver(LifecycleObserver observer)

Adds a LifecycleObserver that will be notified when the LifecycleOwner changes state.

static LifecycleRegistry createUnsafe(LifecycleOwner owner)

Creates a new LifecycleRegistry for the given provider, that doesn't check that its methods are called on the threads other than main.

Lifecycle.State getCurrentState()

Returns the current state of the Lifecycle.

int getObserverCount()

The number of observers.

void handleLifecycleEvent(Lifecycle.Event event)

Sets the current state and notifies the observers.

void markState(Lifecycle.State state)

This method is deprecated. Use setCurrentState(State).

void removeObserver(LifecycleObserver observer)

Removes the given observer from the observers list.

void setCurrentState(Lifecycle.State state)

Moves the Lifecycle to the given state and dispatches necessary events to the observers.

Inherited methods