Join us on the livestream at Android Dev Summit on 7-8 November 2018, starting at 10AM PDT!

DefaultLifecycleObserver

public interface DefaultLifecycleObserver
implements LifecycleObserver

androidx.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

public 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

public void onDestroy (LifecycleOwner owner)

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

public 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

public 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

public 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

public 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