AmbientMode

This package is part of the Android support library which is no longer maintained. The support library has been superseded by AndroidX which is part of Jetpack. We recommend using the AndroidX libraries in all new projects. You should also consider migrating existing projects to AndroidX.

public final class AmbientMode

extends Fragment

This class was deprecated in API level 27.1.0.

please use AmbientModeSupport instead.

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 attachAmbientSupport(Activity) method. It should be called with an Activity as an argument and that Activity will then be able to receive ambient lifecycle events through an AmbientMode.AmbientCallback . The Activity will also receive a AmbientMode.AmbientController object from the attachment which can be used to query the current status of the ambient mode. An example of how to attach AmbientMode to your Activity and use the AmbientMode.AmbientController can be found below:

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

Summary