Skip to content

Most visited

Recently visited

navigation
added in version 1.0.0
belongs to Maven artifact android.arch.lifecycle:common-java8:1.0.0

DefaultLifecycleObserver

public interface DefaultLifecycleObserver
implements LifecycleObserver

android.arch.lifecycle.DefaultLifecycleObserver


Callback interface for listening to LifecycleOwner state changes.

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

Summary

Public methods

default void onCreate(LifecycleOwner owner)

Notifies that ON_CREATE event occurred.

default void onDestroy(LifecycleOwner owner)

Notifies that ON_DESTROY event occurred.

default void onPause(LifecycleOwner owner)

Notifies that ON_PAUSE event occurred.

default void onResume(LifecycleOwner owner)

Notifies that ON_RESUME event occurred.

default void onStart(LifecycleOwner owner)

Notifies that ON_START event occurred.

default void onStop(LifecycleOwner owner)

Notifies that ON_STOP event occurred.

Public methods

onCreate

added in version 1.0.0
void onCreate (LifecycleOwner owner)

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

added in version 1.0.0
void onDestroy (LifecycleOwner owner)

Notifies that ON_DESTROY event occurred.

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

Parameters
owner LifecycleOwner: the component, whose state was changed

onPause

added in version 1.0.0
void onPause (LifecycleOwner owner)

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

added in version 1.0.0
void onResume (LifecycleOwner owner)

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

added in version 1.0.0
void onStart (LifecycleOwner owner)

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

added in version 1.0.0
void onStop (LifecycleOwner owner)

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

This site uses cookies to store your preferences for site-specific language and display options.

Get the latest Android developer news and tips that will help you find success on Google Play.

* Required Fields

Hooray!

Follow Google Developers on WeChat

Browse this site in ?

You requested a page in , but your language preference for this site is .

Would you like to change your language preference and browse this site in ? If you want to change your language preference later, use the language menu at the bottom of each page.

This class requires API level or higher

This doc is hidden because your selected API level for the documentation is . You can change the documentation API level with the selector above the left navigation.

For more information about specifying the API level your app requires, read Supporting Different Platform Versions.

Take a short survey?
Help us improve the Android developer experience. (Dec 2017 Android Platform & Tools Survey)