AmbientManager.AmbientComponentListener
public
static
interface
AmbientManager.AmbientComponentListener
| com.google.wear.services.ambient.AmbientManager.AmbientComponentListener |
The callbacks that an ambient component must implement and provide to the AmbientManager at the time of registration via AmbientOptions i.e. AmbientManager.createController(Context,AmbientOptions) in order to integrate with and
implement support for ambient mode.
Summary
Public methods | |
|---|---|
default
void
|
onEnterAmbient(AmbientManager.ConfigurationDetails details, boolean transitionComplete)
The component will receive this callback on the main/UI thread when the system is ready to enter ambient mode and the always-on-display setting is enabled. |
default
void
|
onExitAmbient()
The component will receive this callback on the main/UI thread while in ambient mode, signifying that the system is waking up and returning to interactive mode. |
default
void
|
onUpdateAmbient()
The component will receive this callback on the main/UI thread as the system wakes up briefly/periodically while in ambient mode in order to update the UI before returning to a low power state. |
Public methods
onEnterAmbient
public void onEnterAmbient (AmbientManager.ConfigurationDetails details, boolean transitionComplete)
The component will receive this callback on the main/UI thread when the system is ready to enter ambient mode and the always-on-display setting is enabled. It indicates that the application processor is about to suspend and will no longer be able to update the component UI. Components should avoid doing expensive/time consuming work here and focus on ensuring that their UI is in the appropriate state for display in ambient mode.
Components that wish to provide a visual transition (e.g. view animations etc) when
entering ambient mode should implement the AmbientTransitionListener in addition
to these callbacks, which are intended to serve more lifecycle/state transitions.
Note that AmbientTransitionListener.onStartAmbientTransition(AmbientManager.TransitionDetails,AmbientTransitionFinishedNotifier) will precede this
callback provided that there is time available for an extended transition.
In the event that the ambient entry transition implemented via the AmbientTransitionListener.onStartAmbientTransition(AmbientManager.TransitionDetails,AmbientTransitionFinishedNotifier) exceeds the maximum duration provided, as specified
by AmbientManager.TransitionDetails.getMaxTransitionDurationMillis() then the
component will receive the AmbientTransitionListener.onCancelAmbientTransition(boolean) (async) to indicate that
that the transition may not be completed in its entirety.
The state of the entry transition is reflected in this callback by the value of transitionComplete which indicates whether or not the transition was able to complete in
the available time. If transitionComplete is false here, then that means
the transition may be incomplete and components can take this final opportunity to update
their UI and ensure that they are ready to display in ambient mode (without any
additional animations etc).
| Parameters | |
|---|---|
details |
AmbientManager.ConfigurationDetails: the AmbientManager.ConfigurationDetails pertinent to the current
ambient transition/state change event. |
transitionComplete |
boolean: true if a transition successfully completed prior to
this state change event, otherwise false - meaning there either was no
transition or there was and it was cancelled, likely due to timeout. |
onExitAmbient
public void onExitAmbient ()
The component will receive this callback on the main/UI thread while in ambient mode, signifying that the system is waking up and returning to interactive mode.
Components that wish to provide a visual transition (e.g. view animations etc) when
exiting ambient mode should implement the AmbientTransitionListener in addition
to these callbacks, which are intended to serve more lifecycle/state transitions.
Note that AmbientTransitionListener.onStartAmbientTransition(AmbientManager.TransitionDetails,AmbientTransitionFinishedNotifier) will precede this
callback provided that there is time available for an extended transition.
In the event that the ambient exit transition implemented via the AmbientTransitionListener.onStartAmbientTransition(AmbientManager.TransitionDetails,AmbientTransitionFinishedNotifier) exceeds the maximum duration provided, as specified
by AmbientManager.TransitionDetails.getMaxTransitionDurationMillis() then the
component will receive the AmbientTransitionListener.onCancelAmbientTransition(boolean) (async) to indicate that
that the transition may not be completed in its entirety.
onUpdateAmbient
public void onUpdateAmbient ()
The component will receive this callback on the main/UI thread as the system wakes up briefly/periodically while in ambient mode in order to update the UI before returning to a low power state. Here again, components should avoid doing any expensive/time consuming work in their implementation.