DefaultLifecycleObserver


public interface DefaultLifecycleObserver extends LifecycleObserver

Known direct subclasses
AmbientLifecycleObserver

Interface for LifecycleObservers which are used to add ambient mode support to activities on Wearable devices.


Callback interface for listening to LifecycleOwner state changes.

If a class implements both this interface and LifecycleEventObserver, the methods of DefaultLifecycleObserver are called first, followed by LifecycleEventObserver.onStateChanged.

Note: If a class implements this interface and also uses the deprecated androidx.lifecycle.OnLifecycleEvent annotations, those annotations are ignored.

Summary

Public methods

default void

Notifies that Lifecycle.Event.ON_CREATE event occurred.

default void

Notifies that Lifecycle.Event.ON_DESTROY event occurred.

default void

Notifies that Lifecycle.Event.ON_PAUSE event occurred.

default void

Notifies that Lifecycle.Event.ON_RESUME event occurred.

default void

Notifies that Lifecycle.Event.ON_START event occurred.

default void

Notifies that Lifecycle.Event.ON_STOP event occurred.

Public methods

onCreate

Added in 2.4.0
default void onCreate(@NonNull LifecycleOwner owner)

Notifies that Lifecycle.Event.ON_CREATE event occurred.

Called after the LifecycleOwner's onCreate method returns.

Parameters
@NonNull LifecycleOwner owner

The component whose state changed.

onDestroy

Added in 2.4.0
default void onDestroy(@NonNull LifecycleOwner owner)

Notifies that Lifecycle.Event.ON_DESTROY event occurred.

Called before the LifecycleOwner's onDestroy method is called.

Parameters
@NonNull LifecycleOwner owner

The component whose state changed.

onPause

Added in 2.4.0
default void onPause(@NonNull LifecycleOwner owner)

Notifies that Lifecycle.Event.ON_PAUSE event occurred.

Called before the LifecycleOwner's onPause method is called.

Parameters
@NonNull LifecycleOwner owner

The component whose state changed.

onResume

Added in 2.4.0
default void onResume(@NonNull LifecycleOwner owner)

Notifies that Lifecycle.Event.ON_RESUME event occurred.

Called after the LifecycleOwner's onResume method returns.

Parameters
@NonNull LifecycleOwner owner

The component whose state changed.

onStart

Added in 2.4.0
default void onStart(@NonNull LifecycleOwner owner)

Notifies that Lifecycle.Event.ON_START event occurred.

Called after the LifecycleOwner's onStart method returns.

Parameters
@NonNull LifecycleOwner owner

The component whose state changed.

onStop

Added in 2.4.0
default void onStop(@NonNull LifecycleOwner owner)

Notifies that Lifecycle.Event.ON_STOP event occurred.

Called before the LifecycleOwner's onStop method is called.

Parameters
@NonNull LifecycleOwner owner

The component whose state changed.