added in version 27.1.0
belongs to Maven artifact


public final class AmbientModeSupport
extends Fragment


Use this as a headless Fragment to add ambient support to an Activity on Wearable devices.

The application that uses this should add the WAKE_LOCK permission to its manifest.

The primary entry point for this code is the attach(FragmentActivity) method. It should be called with an FragmentActivity as an argument and that FragmentActivity will then be able to receive ambient lifecycle events through an AmbientModeSupport.AmbientCallback. The FragmentActivity will also receive a AmbientModeSupport.AmbientController object from the attachment which can be used to query the current status of the ambient mode. An example of how to attach AmbientModeSupport to your FragmentActivity and use the AmbientModeSupport.AmbientController can be found below:

AmbientMode.AmbientController controller = AmbientMode.attachAmbientSupport(this);
     boolean isAmbient =  controller.isAmbient();


Nested classes

class AmbientModeSupport.AmbientCallback

Callback to receive ambient mode state changes. 

interface AmbientModeSupport.AmbientCallbackProvider

Interface for any Activity that wishes to implement Ambient Mode. 

class AmbientModeSupport.AmbientController

A class for interacting with the ambient mode on a wearable device. 



Property in bundle passed to AmbientCallback#onEnterAmbient(Bundle) to indicate whether burn-in protection is required.


Property in bundle passed to AmbientCallback#onEnterAmbient(Bundle) to indicate whether the device has low-bit ambient mode.


Fragment tag used by default when adding AmbientModeSupport to add ambient support to a FragmentActivity.

Public constructors



Public methods

static <T extends FragmentActivity> AmbientModeSupport.AmbientController attach(T activity)

Attach ambient support to the given activity.

void dump(String prefix, FileDescriptor fd, PrintWriter writer, String[] args)

Print the Fragments's state into the given stream.

void onAttach(Context context)

Called when a fragment is first attached to its context.

void onCreate(Bundle savedInstanceState)

Called to do initial creation of a fragment.

void onDestroy()

Called when the fragment is no longer in use.

void onDetach()

Called when the fragment is no longer attached to its activity.

void onPause()

Called when the Fragment is no longer resumed.

void onResume()

Called when the fragment is visible to the user and actively running.

void onStop()

Called when the Fragment is no longer started.

Inherited methods

From class