DefaultLifecycleObserver

interface DefaultLifecycleObserver : FullLifecycleObserver
androidx.lifecycle.DefaultLifecycleObserver

Callback interface for listening to LifecycleOwner state changes.

If you use Java 8 language, always prefer it over annotations.

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(LifecycleOwner, Lifecycle.Event)

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

Summary

Public methods

open Unit
onCreate(@NonNull owner: LifecycleOwner)

Notifies that ON_CREATE event occurred.

open Unit
onDestroy(@NonNull owner: LifecycleOwner)

Notifies that ON_DESTROY event occurred.

open Unit
onPause(@NonNull owner: LifecycleOwner)

Notifies that ON_PAUSE event occurred.

open Unit
onResume(@NonNull owner: LifecycleOwner)

Notifies that ON_RESUME event occurred.

open Unit
onStart(@NonNull owner: LifecycleOwner)

Notifies that ON_START event occurred.

open Unit
onStop(@NonNull owner: LifecycleOwner)

Notifies that ON_STOP event occurred.

Public methods

onCreate

open fun onCreate(@NonNull owner: LifecycleOwner): Unit

Notifies that ON_CREATE event occurred.

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

Parameters
owner LifecycleOwner: the component, whose state was changed

onDestroy

open fun onDestroy(@NonNull owner: LifecycleOwner): Unit

Notifies that ON_DESTROY event occurred.

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

Parameters
owner LifecycleOwner: the component, whose state was changed

onPause

open fun onPause(@NonNull owner: LifecycleOwner): Unit

Notifies that ON_PAUSE event occurred.

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

Parameters
owner LifecycleOwner: the component, whose state was changed

onResume

open fun onResume(@NonNull owner: LifecycleOwner): Unit

Notifies that ON_RESUME event occurred.

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

Parameters
owner LifecycleOwner: the component, whose state was changed

onStart

open fun onStart(@NonNull owner: LifecycleOwner): Unit

Notifies that ON_START event occurred.

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

Parameters
owner LifecycleOwner: the component, whose state was changed

onStop

open fun onStop(@NonNull owner: LifecycleOwner): Unit

Notifies that ON_STOP event occurred.

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

Parameters
owner LifecycleOwner: the component, whose state was changed