added in version 27.1.0
belongs to Maven artifact com.android.support:wear:28.0.0-alpha1

AmbientModeSupport

public final class AmbientModeSupport
extends Fragment

java.lang.Object
   ↳ android.support.v4.app.Fragment
     ↳ android.support.wear.ambient.AmbientModeSupport


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();
 

Summary

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. 

Constants

String EXTRA_BURN_IN_PROTECTION

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

String EXTRA_LOWBIT_AMBIENT

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

String FRAGMENT_TAG

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

Public constructors

AmbientModeSupport()

Constructor

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