belongs to Maven artifact com.android.support:wear:28.0.0-alpha1
Deprecated since version 27.1.0
AmbientMode
public
final
class
AmbientMode
extends Fragment
java.lang.Object | ||
↳ | android.app.Fragment | |
↳ | android.support.wear.ambient.AmbientMode |
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
Nested classes | |
---|---|
class |
AmbientMode.AmbientCallback
Callback to receive ambient mode state changes. |
interface |
AmbientMode.AmbientCallbackProvider
Interface for any |
class |
AmbientMode.AmbientController
A class for interacting with the ambient mode on a wearable device. |
Constants | |
---|---|
String |
EXTRA_BURN_IN_PROTECTION
Property in bundle passed to |
String |
EXTRA_LOWBIT_AMBIENT
Property in bundle passed to |
String |
FRAGMENT_TAG
Fragment tag used by default when adding |
Inherited constants |
---|
From
interface
android.content.ComponentCallbacks2
|
Public constructors | |
---|---|
AmbientMode()
Constructor |
Public methods | |
---|---|
static
<T extends Activity>
AmbientMode.AmbientController
|
attachAmbientSupport(T activity)
Attach ambient support to the given activity. |
void
|
dump(String prefix, FileDescriptor fd, PrintWriter writer, String[] args)
|
void
|
onAttach(Context context)
|
void
|
onCreate(Bundle savedInstanceState)
|
void
|
onDestroy()
|
void
|
onDetach()
|
void
|
onPause()
|
void
|
onResume()
|
void
|
onStop()
|
Inherited methods | |
---|---|
From
class
android.app.Fragment
| |
From
class
java.lang.Object
| |
From
interface
android.content.ComponentCallbacks2
| |
From
interface
android.view.View.OnCreateContextMenuListener
| |
From
interface
android.content.ComponentCallbacks
|
Constants
EXTRA_BURN_IN_PROTECTION
String EXTRA_BURN_IN_PROTECTION
Property in bundle passed to AmbientCallback#onEnterAmbient(Bundle)
to indicate
whether burn-in protection is required. When this property is set to true, views must be
shifted around periodically in ambient mode. To ensure that content isn't shifted off
the screen, avoid placing content within 10 pixels of the edge of the screen. Activities
should also avoid solid white areas to prevent pixel burn-in. Both of these requirements
only apply in ambient mode, and only when this property is set to true.
Constant Value: "com.google.android.wearable.compat.extra.BURN_IN_PROTECTION"
EXTRA_LOWBIT_AMBIENT
String EXTRA_LOWBIT_AMBIENT
Property in bundle passed to AmbientCallback#onEnterAmbient(Bundle)
to indicate
whether the device has low-bit ambient mode. When this property is set to true, the screen
supports fewer bits for each color in ambient mode. In this case, activities should disable
anti-aliasing in ambient mode.
Constant Value: "com.google.android.wearable.compat.extra.LOWBIT_AMBIENT"
FRAGMENT_TAG
String FRAGMENT_TAG
Fragment tag used by default when adding AmbientMode
to add ambient support to an
Activity
.
Constant Value: "android.support.wearable.ambient.AmbientMode"
Public constructors
Public methods
attachAmbientSupport
AmbientMode.AmbientController attachAmbientSupport (T activity)
Attach ambient support to the given activity. Calling this method with an Activity
implementing the AmbientMode.AmbientCallbackProvider
interface will provide you with an
opportunity to react to ambient events such as onEnterAmbient
. Alternatively,
you can call this method with an Activity which does not implement
the AmbientMode.AmbientCallbackProvider
interface and that will only enable the auto-resume
functionality. This is equivalent to providing (@code null} from
the AmbientMode.AmbientCallbackProvider
.
Parameters | |
---|---|
activity |
T : the activity to attach ambient support to. |
Returns | |
---|---|
AmbientMode.AmbientController |
the associated AmbientMode.AmbientController which can be used to query the state of
ambient mode.
|
dump
void dump (String prefix, FileDescriptor fd, PrintWriter writer, String[] args)
Parameters | |
---|---|
prefix |
String |
fd |
FileDescriptor |
writer |
PrintWriter |
args |
String |
onDestroy
void onDestroy ()
onDetach
void onDetach ()
onPause
void onPause ()
onResume
void onResume ()
onStop
void onStop ()
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2024-04-11 UTC.