{% setvar book_path %}/reference/androidx/_book.yaml{% endsetvar %} {% include "_shared/_reference-head-tags.html" %}

DefaultLifecycleObserver

public interface DefaultLifecycleObserver extends LifecycleObserver


Callback interface for listening to LifecycleOwner state changes. If a class implements both this interface and LifecycleEventObserver, then methods of DefaultLifecycleObserver will be called first, and then followed by the call of LifecycleEventObserver.onStateChanged

If a class implements this interface and in the same time uses OnLifecycleEvent, then annotations will be ignored.

Summary

Public methods

default void

Notifies that ON_CREATE event occurred.

default void

Notifies that ON_DESTROY event occurred.

default void

Notifies that ON_PAUSE event occurred.

default void

Notifies that ON_RESUME event occurred.

default void

Notifies that ON_START event occurred.

default void

Notifies that ON_STOP event occurred.

Public methods

onCreate

default void onCreate(@NonNull LifecycleOwner owner)

Notifies that ON_CREATE event occurred.

This method will be called after the LifecycleOwner's onCreate method returns.

Parameters
@NonNull LifecycleOwner owner

the component, whose state was changed

onDestroy

default void onDestroy(@NonNull LifecycleOwner owner)

Notifies that ON_DESTROY event occurred.

This method will be called before the LifecycleOwner's onDestroy method is called.

Parameters
@NonNull LifecycleOwner owner

the component, whose state was changed

onPause

default void onPause(@NonNull LifecycleOwner owner)

Notifies that ON_PAUSE event occurred.

This method will be called before the LifecycleOwner's onPause method is called.

Parameters
@NonNull LifecycleOwner owner

the component, whose state was changed

onResume

default void onResume(@NonNull LifecycleOwner owner)

Notifies that ON_RESUME event occurred.

This method will be called after the LifecycleOwner's onResume method returns.

Parameters
@NonNull LifecycleOwner owner

the component, whose state was changed

onStart

default void onStart(@NonNull LifecycleOwner owner)

Notifies that ON_START event occurred.

This method will be called after the LifecycleOwner's onStart method returns.

Parameters
@NonNull LifecycleOwner owner

the component, whose state was changed

onStop

default void onStop(@NonNull LifecycleOwner owner)

Notifies that ON_STOP event occurred.

This method will be called before the LifecycleOwner's onStop method is called.

Parameters
@NonNull LifecycleOwner owner

the component, whose state was changed