AmbientLifecycleObserver.AmbientLifecycleCallback

Added in 1.3.0

public interface AmbientLifecycleObserver.AmbientLifecycleCallback


Callback to receive ambient mode state changes.

Summary

Public methods

default void

Called when an activity is entering ambient mode.

default void

Called when an activity should exit ambient mode.

default void

Called when the system is updating the display for ambient mode.

Public methods

onEnterAmbient

Added in 1.3.0
default void onEnterAmbient(
    @NonNull AmbientLifecycleObserver.AmbientDetails ambientDetails
)

Called when an activity is entering ambient mode. This event is sent while an activity is running (after onResume, before onPause). All drawing should complete by the conclusion of this method. Note that {@code invalidate()} calls will be executed before resuming lower-power mode.

Parameters
@NonNull AmbientLifecycleObserver.AmbientDetails ambientDetails

instance of AmbientDetails containing information about the display being used.

onExitAmbient

Added in 1.3.0
default void onExitAmbient()

Called when an activity should exit ambient mode. This event is sent while an activity is running (after onResume, before onPause).

onUpdateAmbient

Added in 1.3.0
default void onUpdateAmbient()

Called when the system is updating the display for ambient mode. Activities may use this opportunity to update or invalidate views.

Follow best practices, eliminate boilerplate code, and reduce fragmentation

Updated Mar 1, 2023

Discover the latest app development tools, platform updates, training, and documentation for developers across every Android device.

Updated Dec 15, 2023

Follow best practices, eliminate boilerplate code, and reduce fragmentation

Updated Jun 30, 2023