added in [version 27.1.0](https://developer.android.com/topic/libraries/support-library/revisions)   
belongs to Maven artifact com.android.support:wear:28.0.0-alpha1 Summary: [Nested Classes](https://developer.android.com/reference/android/support/wear/ambient/AmbientModeSupport#nestedclasses) \| [Constants](https://developer.android.com/reference/android/support/wear/ambient/AmbientModeSupport#constants) \| [Ctors](https://developer.android.com/reference/android/support/wear/ambient/AmbientModeSupport#pubctors) \| [Methods](https://developer.android.com/reference/android/support/wear/ambient/AmbientModeSupport#pubmethods) \| [Inherited Methods](https://developer.android.com/reference/android/support/wear/ambient/AmbientModeSupport#inhmethods) \| [\[Expand All\]](https://developer.android.com/reference/android/support/wear/ambient/AmbientModeSupport#)

# AmbientModeSupport

| This package is part of the Android [support library](https://developer.android.com/topic/libraries/support-library) which is no longer maintained. The support library has been superseded by [AndroidX](https://developer.android.com/jetpack/androidx) which is part of [Jetpack](https://developer.android.com/jetpack). We recommend using the AndroidX libraries in all new projects. You should also consider [migrating](https://developer.android.com/jetpack/androidx/migrate) existing projects to AndroidX. To find the AndroidX class that maps to this deprecated class, see the AndroidX support library [class
| mappings](https://developer.android.com/jetpack/androidx/migrate/class-mappings).


`
public

final

class
AmbientModeSupport
`


`


`

`

extends https://developer.android.com/reference/android/support/v4/app/Fragment


`

`


`

|---|---|---|
| java.lang.Object |||
| ↳ | [android.support.v4.app.Fragment](https://developer.android.com/reference/android/support/v4/app/Fragment) ||
|   | ↳ | android.support.wear.ambient.AmbientModeSupport |

<br />

*** ** * ** ***

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


The application that uses this should add the `https://developer.android.com/reference/android/Manifest.permission#WAKE_LOCK`
permission to its manifest.


The primary entry point for this code is the `https://developer.android.com/reference/android/support/wear/ambient/AmbientModeSupport#attach(T)` method.
It should be called with an `https://developer.android.com/reference/android/support/v4/app/FragmentActivity` as an argument and that
`https://developer.android.com/reference/android/support/v4/app/FragmentActivity` will then be able to receive ambient lifecycle events through
an `https://developer.android.com/reference/android/support/wear/ambient/AmbientModeSupport.AmbientCallback`. The `https://developer.android.com/reference/android/support/v4/app/FragmentActivity` will also receive a
`https://developer.android.com/reference/android/support/wear/ambient/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 `https://developer.android.com/reference/android/support/wear/ambient/AmbientModeSupport` to your
`https://developer.android.com/reference/android/support/v4/app/FragmentActivity` and use the `https://developer.android.com/reference/android/support/wear/ambient/AmbientModeSupport.AmbientController` can be found below:


    AmbientMode.AmbientController controller = AmbientMode.attachAmbientSupport(this);
         boolean isAmbient =  controller.isAmbient();
     
<br />

## Summary

| ### Nested classes ||
|---|---|
| ` class` | `https://developer.android.com/reference/android/support/wear/ambient/AmbientModeSupport.AmbientCallback` Callback to receive ambient mode state changes. |
| ` interface` | `https://developer.android.com/reference/android/support/wear/ambient/AmbientModeSupport.AmbientCallbackProvider` Interface for any `https://developer.android.com/reference/android/app/Activity.html` that wishes to implement Ambient Mode. |
| ` class` | `https://developer.android.com/reference/android/support/wear/ambient/AmbientModeSupport.AmbientController` A class for interacting with the ambient mode on a wearable device. |

| ### Constants ||
|---|---|
| `String` | `https://developer.android.com/reference/android/support/wear/ambient/AmbientModeSupport#EXTRA_BURN_IN_PROTECTION` Property in bundle passed to `AmbientCallback#onEnterAmbient(Bundle)` to indicate whether burn-in protection is required. |
| `String` | `https://developer.android.com/reference/android/support/wear/ambient/AmbientModeSupport#EXTRA_LOWBIT_AMBIENT` Property in bundle passed to `AmbientCallback#onEnterAmbient(Bundle)` to indicate whether the device has low-bit ambient mode. |
| `String` | `https://developer.android.com/reference/android/support/wear/ambient/AmbientModeSupport#FRAGMENT_TAG` Fragment tag used by default when adding `https://developer.android.com/reference/android/support/wear/ambient/AmbientModeSupport` to add ambient support to a `https://developer.android.com/reference/android/support/v4/app/FragmentActivity`. |

| ### Public constructors ||
|---|---|
| ` https://developer.android.com/reference/android/support/wear/ambient/AmbientModeSupport#AmbientModeSupport()() ` Constructor |

| ### Public methods ||
|---|---|
| ` static <T extends https://developer.android.com/reference/android/support/v4/app/FragmentActivity> https://developer.android.com/reference/android/support/wear/ambient/AmbientModeSupport.AmbientController` | ` https://developer.android.com/reference/android/support/wear/ambient/AmbientModeSupport#attach(T)(T activity) ` Attach ambient support to the given activity. |
| ` void` | ` https://developer.android.com/reference/android/support/wear/ambient/AmbientModeSupport#dump(java.lang.String, java.io.FileDescriptor, java.io.PrintWriter, java.lang.String[])(String prefix, FileDescriptor fd, PrintWriter writer, String[] args) ` Print the Fragments's state into the given stream. |
| ` void` | ` https://developer.android.com/reference/android/support/wear/ambient/AmbientModeSupport#onAttach(android.content.Context)(https://developer.android.com/reference/android/content/Context.html context) ` Called when a fragment is first attached to its context. |
| ` void` | ` https://developer.android.com/reference/android/support/wear/ambient/AmbientModeSupport#onCreate(android.os.Bundle)(https://developer.android.com/reference/android/os/Bundle.html savedInstanceState) ` Called to do initial creation of a fragment. |
| ` void` | ` https://developer.android.com/reference/android/support/wear/ambient/AmbientModeSupport#onDestroy()() ` Called when the fragment is no longer in use. |
| ` void` | ` https://developer.android.com/reference/android/support/wear/ambient/AmbientModeSupport#onDetach()() ` Called when the fragment is no longer attached to its activity. |
| ` void` | ` https://developer.android.com/reference/android/support/wear/ambient/AmbientModeSupport#onPause()() ` Called when the Fragment is no longer resumed. |
| ` void` | ` https://developer.android.com/reference/android/support/wear/ambient/AmbientModeSupport#onResume()() ` Called when the fragment is visible to the user and actively running. |
| ` void` | ` https://developer.android.com/reference/android/support/wear/ambient/AmbientModeSupport#onStop()() ` Called when the Fragment is no longer started. |

| ### Inherited methods |
|---|---|
| [![](https://developer.android.com/static/assets/images/styles/disclosure_down.png)](https://developer.android.com/reference/android/support/wear/ambient/AmbientModeSupport#)From class ` https://developer.android.com/reference/android/support/v4/app/Fragment ` |---|---| | ` void` | ` https://developer.android.com/reference/android/support/v4/app/Fragment#dump(java.lang.String, java.io.FileDescriptor, java.io.PrintWriter, java.lang.String[])(String prefix, FileDescriptor fd, PrintWriter writer, String[] args) ` Print the Fragments's state into the given stream. | | ` final boolean` | ` https://developer.android.com/reference/android/support/v4/app/Fragment#equals(java.lang.Object)(Object o) ` Subclasses can not override equals(). | | ` final https://developer.android.com/reference/android/support/v4/app/FragmentActivity` | ` https://developer.android.com/reference/android/support/v4/app/Fragment#getActivity()() ` Return the `https://developer.android.com/reference/android/support/v4/app/FragmentActivity` this fragment is currently associated with. | | ` boolean` | ` https://developer.android.com/reference/android/support/v4/app/Fragment#getAllowEnterTransitionOverlap()() ` Returns whether the the exit transition and enter transition overlap or not. | | ` boolean` | ` https://developer.android.com/reference/android/support/v4/app/Fragment#getAllowReturnTransitionOverlap()() ` Returns whether the the return transition and reenter transition overlap or not. | | ` final https://developer.android.com/reference/android/os/Bundle.html` | ` https://developer.android.com/reference/android/support/v4/app/Fragment#getArguments()() ` Return the arguments supplied when the fragment was instantiated, if any. | | ` final https://developer.android.com/reference/android/support/v4/app/FragmentManager` | ` https://developer.android.com/reference/android/support/v4/app/Fragment#getChildFragmentManager()() ` Return a private FragmentManager for placing and managing Fragments inside of this Fragment. | | ` https://developer.android.com/reference/android/content/Context.html` | ` https://developer.android.com/reference/android/support/v4/app/Fragment#getContext()() ` Return the `https://developer.android.com/reference/android/content/Context.html` this fragment is currently associated with. | | ` Object` | ` https://developer.android.com/reference/android/support/v4/app/Fragment#getEnterTransition()() ` Returns the Transition that will be used to move Views into the initial scene. | | ` Object` | ` https://developer.android.com/reference/android/support/v4/app/Fragment#getExitTransition()() ` Returns the Transition that will be used to move Views out of the scene when the fragment is removed, hidden, or detached when not popping the back stack. | | ` final https://developer.android.com/reference/android/support/v4/app/FragmentManager` | ` https://developer.android.com/reference/android/support/v4/app/Fragment#getFragmentManager()() ` Return the FragmentManager for interacting with fragments associated with this fragment's activity. | | ` final Object` | ` https://developer.android.com/reference/android/support/v4/app/Fragment#getHost()() ` Return the host object of this fragment. | | ` final int` | ` https://developer.android.com/reference/android/support/v4/app/Fragment#getId()() ` Return the identifier this fragment is known by. | | ` final https://developer.android.com/reference/android/view/LayoutInflater.html` | ` https://developer.android.com/reference/android/support/v4/app/Fragment#getLayoutInflater()() ` Returns the cached LayoutInflater used to inflate Views of this Fragment. | | ` Lifecycle` | ` https://developer.android.com/reference/android/support/v4/app/Fragment#getLifecycle()() ` | | ` https://developer.android.com/reference/android/support/v4/app/LoaderManager` | ` https://developer.android.com/reference/android/support/v4/app/Fragment#getLoaderManager()() ` Return the LoaderManager for this fragment. | | ` final https://developer.android.com/reference/android/support/v4/app/Fragment` | ` https://developer.android.com/reference/android/support/v4/app/Fragment#getParentFragment()() ` Returns the parent Fragment containing this Fragment. | | ` Object` | ` https://developer.android.com/reference/android/support/v4/app/Fragment#getReenterTransition()() ` Returns the Transition that will be used to move Views in to the scene when returning due to popping a back stack. | | ` final https://developer.android.com/reference/android/content/res/Resources.html` | ` https://developer.android.com/reference/android/support/v4/app/Fragment#getResources()() ` Return `requireActivity().getResources()`. | | ` final boolean` | ` https://developer.android.com/reference/android/support/v4/app/Fragment#getRetainInstance()() ` | | ` Object` | ` https://developer.android.com/reference/android/support/v4/app/Fragment#getReturnTransition()() ` Returns the Transition that will be used to move Views out of the scene when the Fragment is preparing to be removed, hidden, or detached because of popping the back stack. | | ` Object` | ` https://developer.android.com/reference/android/support/v4/app/Fragment#getSharedElementEnterTransition()() ` Returns the Transition that will be used for shared elements transferred into the content Scene. | | ` Object` | ` https://developer.android.com/reference/android/support/v4/app/Fragment#getSharedElementReturnTransition()() ` Return the Transition that will be used for shared elements transferred back during a pop of the back stack. | | ` final String` | ` https://developer.android.com/reference/android/support/v4/app/Fragment#getString(int, java.lang.Object...)(int resId, Object... formatArgs) ` Return a localized formatted string from the application's package's default string table, substituting the format arguments as defined in `https://developer.android.com/reference/java/util/Formatter` and `https://developer.android.com/reference/java/lang/String#format(java.lang.String, java.lang.Object...)`. | | ` final String` | ` https://developer.android.com/reference/android/support/v4/app/Fragment#getString(int)(int resId) ` Return a localized string from the application's package's default string table. | | ` final String` | ` https://developer.android.com/reference/android/support/v4/app/Fragment#getTag()() ` Get the tag name of the fragment, if specified. | | ` final https://developer.android.com/reference/android/support/v4/app/Fragment` | ` https://developer.android.com/reference/android/support/v4/app/Fragment#getTargetFragment()() ` Return the target fragment set by `https://developer.android.com/reference/android/support/v4/app/Fragment#setTargetFragment(android.support.v4.app.Fragment, int)`. | | ` final int` | ` https://developer.android.com/reference/android/support/v4/app/Fragment#getTargetRequestCode()() ` Return the target request code set by `https://developer.android.com/reference/android/support/v4/app/Fragment#setTargetFragment(android.support.v4.app.Fragment, int)`. | | ` final CharSequence` | ` https://developer.android.com/reference/android/support/v4/app/Fragment#getText(int)(int resId) ` Return a localized, styled CharSequence from the application's package's default string table. | | ` boolean` | ` https://developer.android.com/reference/android/support/v4/app/Fragment#getUserVisibleHint()() ` | | ` https://developer.android.com/reference/android/view/View.html` | ` https://developer.android.com/reference/android/support/v4/app/Fragment#getView()() ` Get the root view for the fragment's layout (the one returned by `https://developer.android.com/reference/android/support/v4/app/Fragment#onCreateView(android.view.LayoutInflater, android.view.ViewGroup, android.os.Bundle)`), if provided. | | ` ViewModelStore` | ` https://developer.android.com/reference/android/support/v4/app/Fragment#getViewModelStore()() ` | | ` final int` | ` https://developer.android.com/reference/android/support/v4/app/Fragment#hashCode()() ` Subclasses can not override hashCode(). | | ` static https://developer.android.com/reference/android/support/v4/app/Fragment` | ` https://developer.android.com/reference/android/support/v4/app/Fragment#instantiate(android.content.Context, java.lang.String)(https://developer.android.com/reference/android/content/Context.html context, String fname) ` Like `https://developer.android.com/reference/android/support/v4/app/Fragment#instantiate(android.content.Context, java.lang.String, android.os.Bundle)` but with a null argument Bundle. | | ` static https://developer.android.com/reference/android/support/v4/app/Fragment` | ` https://developer.android.com/reference/android/support/v4/app/Fragment#instantiate(android.content.Context, java.lang.String, android.os.Bundle)(https://developer.android.com/reference/android/content/Context.html context, String fname, https://developer.android.com/reference/android/os/Bundle.html args) ` Create a new instance of a Fragment with the given class name. | | ` final boolean` | ` https://developer.android.com/reference/android/support/v4/app/Fragment#isAdded()() ` Return true if the fragment is currently added to its activity. | | ` final boolean` | ` https://developer.android.com/reference/android/support/v4/app/Fragment#isDetached()() ` Return true if the fragment has been explicitly detached from the UI. | | ` final boolean` | ` https://developer.android.com/reference/android/support/v4/app/Fragment#isHidden()() ` Return true if the fragment has been hidden. | | ` final boolean` | ` https://developer.android.com/reference/android/support/v4/app/Fragment#isInLayout()() ` Return true if the layout is included as part of an activity view hierarchy via the \<fragment\> tag. | | ` final boolean` | ` https://developer.android.com/reference/android/support/v4/app/Fragment#isRemoving()() ` Return true if this fragment is currently being removed from its activity. | | ` final boolean` | ` https://developer.android.com/reference/android/support/v4/app/Fragment#isResumed()() ` Return true if the fragment is in the resumed state. | | ` final boolean` | ` https://developer.android.com/reference/android/support/v4/app/Fragment#isStateSaved()() ` Returns true if this fragment is added and its state has already been saved by its host. | | ` final boolean` | ` https://developer.android.com/reference/android/support/v4/app/Fragment#isVisible()() ` Return true if the fragment is currently visible to the user. | | ` void` | ` https://developer.android.com/reference/android/support/v4/app/Fragment#onActivityCreated(android.os.Bundle)(https://developer.android.com/reference/android/os/Bundle.html savedInstanceState) ` Called when the fragment's activity has been created and this fragment's view hierarchy instantiated. | | ` void` | ` https://developer.android.com/reference/android/support/v4/app/Fragment#onActivityResult(int, int, android.content.Intent)(int requestCode, int resultCode, https://developer.android.com/reference/android/content/Intent.html data) ` Receive the result from a previous call to `https://developer.android.com/reference/android/support/v4/app/Fragment#startActivityForResult(android.content.Intent, int)`. | | ` void` | ` https://developer.android.com/reference/android/support/v4/app/Fragment#onAttach(android.app.Activity)(https://developer.android.com/reference/android/app/Activity.html activity) ` *This method was deprecated in API level 24.1.0. See `https://developer.android.com/reference/android/support/v4/app/Fragment#onAttach(android.content.Context)`.* | | ` void` | ` https://developer.android.com/reference/android/support/v4/app/Fragment#onAttach(android.content.Context)(https://developer.android.com/reference/android/content/Context.html context) ` Called when a fragment is first attached to its context. | | ` void` | ` https://developer.android.com/reference/android/support/v4/app/Fragment#onAttachFragment(android.support.v4.app.Fragment)(https://developer.android.com/reference/android/support/v4/app/Fragment childFragment) ` Called when a fragment is attached as a child of this fragment. | | ` void` | ` https://developer.android.com/reference/android/support/v4/app/Fragment#onConfigurationChanged(android.content.res.Configuration)(https://developer.android.com/reference/android/content/res/Configuration.html newConfig) ` | | ` boolean` | ` https://developer.android.com/reference/android/support/v4/app/Fragment#onContextItemSelected(android.view.MenuItem)(https://developer.android.com/reference/android/view/MenuItem.html item) ` This hook is called whenever an item in a context menu is selected. | | ` void` | ` https://developer.android.com/reference/android/support/v4/app/Fragment#onCreate(android.os.Bundle)(https://developer.android.com/reference/android/os/Bundle.html savedInstanceState) ` Called to do initial creation of a fragment. | | ` https://developer.android.com/reference/android/view/animation/Animation.html` | ` https://developer.android.com/reference/android/support/v4/app/Fragment#onCreateAnimation(int, boolean, int)(int transit, boolean enter, int nextAnim) ` Called when a fragment loads an animation. | | ` https://developer.android.com/reference/android/animation/Animator.html` | ` https://developer.android.com/reference/android/support/v4/app/Fragment#onCreateAnimator(int, boolean, int)(int transit, boolean enter, int nextAnim) ` Called when a fragment loads an animator. | | ` void` | ` https://developer.android.com/reference/android/support/v4/app/Fragment#onCreateContextMenu(android.view.ContextMenu, android.view.View, android.view.ContextMenu.ContextMenuInfo)(https://developer.android.com/reference/android/view/ContextMenu.html menu, https://developer.android.com/reference/android/view/View.html v, https://developer.android.com/reference/android/view/ContextMenu.ContextMenuInfo.html menuInfo) ` Called when a context menu for the `view` is about to be shown. | | ` void` | ` https://developer.android.com/reference/android/support/v4/app/Fragment#onCreateOptionsMenu(android.view.Menu, android.view.MenuInflater)(https://developer.android.com/reference/android/view/Menu.html menu, https://developer.android.com/reference/android/view/MenuInflater.html inflater) ` Initialize the contents of the Fragment host's standard options menu. | | ` https://developer.android.com/reference/android/view/View.html` | ` https://developer.android.com/reference/android/support/v4/app/Fragment#onCreateView(android.view.LayoutInflater, android.view.ViewGroup, android.os.Bundle)(https://developer.android.com/reference/android/view/LayoutInflater.html inflater, https://developer.android.com/reference/android/view/ViewGroup.html container, https://developer.android.com/reference/android/os/Bundle.html savedInstanceState) ` Called to have the fragment instantiate its user interface view. | | ` void` | ` https://developer.android.com/reference/android/support/v4/app/Fragment#onDestroy()() ` Called when the fragment is no longer in use. | | ` void` | ` https://developer.android.com/reference/android/support/v4/app/Fragment#onDestroyOptionsMenu()() ` Called when this fragment's option menu items are no longer being included in the overall options menu. | | ` void` | ` https://developer.android.com/reference/android/support/v4/app/Fragment#onDestroyView()() ` Called when the view previously created by `https://developer.android.com/reference/android/support/v4/app/Fragment#onCreateView(android.view.LayoutInflater, android.view.ViewGroup, android.os.Bundle)` has been detached from the fragment. | | ` void` | ` https://developer.android.com/reference/android/support/v4/app/Fragment#onDetach()() ` Called when the fragment is no longer attached to its activity. | | ` https://developer.android.com/reference/android/view/LayoutInflater.html` | ` https://developer.android.com/reference/android/support/v4/app/Fragment#onGetLayoutInflater(android.os.Bundle)(https://developer.android.com/reference/android/os/Bundle.html savedInstanceState) ` Returns the LayoutInflater used to inflate Views of this Fragment. | | ` void` | ` https://developer.android.com/reference/android/support/v4/app/Fragment#onHiddenChanged(boolean)(boolean hidden) ` Called when the hidden state (as returned by `https://developer.android.com/reference/android/support/v4/app/Fragment#isHidden()` of the fragment has changed. | | ` void` | ` https://developer.android.com/reference/android/support/v4/app/Fragment#onInflate(android.app.Activity, android.util.AttributeSet, android.os.Bundle)(https://developer.android.com/reference/android/app/Activity.html activity, https://developer.android.com/reference/android/util/AttributeSet.html attrs, https://developer.android.com/reference/android/os/Bundle.html savedInstanceState) ` *This method was deprecated in API level 24.1.0. See `https://developer.android.com/reference/android/support/v4/app/Fragment#onInflate(android.content.Context, android.util.AttributeSet, android.os.Bundle)`.* | | ` void` | ` https://developer.android.com/reference/android/support/v4/app/Fragment#onInflate(android.content.Context, android.util.AttributeSet, android.os.Bundle)(https://developer.android.com/reference/android/content/Context.html context, https://developer.android.com/reference/android/util/AttributeSet.html attrs, https://developer.android.com/reference/android/os/Bundle.html savedInstanceState) ` Called when a fragment is being created as part of a view layout inflation, typically from setting the content view of an activity. | | ` void` | ` https://developer.android.com/reference/android/support/v4/app/Fragment#onLowMemory()() ` | | ` void` | ` https://developer.android.com/reference/android/support/v4/app/Fragment#onMultiWindowModeChanged(boolean)(boolean isInMultiWindowMode) ` Called when the Fragment's activity changes from fullscreen mode to multi-window mode and visa-versa. | | ` boolean` | ` https://developer.android.com/reference/android/support/v4/app/Fragment#onOptionsItemSelected(android.view.MenuItem)(https://developer.android.com/reference/android/view/MenuItem.html item) ` This hook is called whenever an item in your options menu is selected. | | ` void` | ` https://developer.android.com/reference/android/support/v4/app/Fragment#onOptionsMenuClosed(android.view.Menu)(https://developer.android.com/reference/android/view/Menu.html menu) ` This hook is called whenever the options menu is being closed (either by the user canceling the menu with the back/menu button, or when an item is selected). | | ` void` | ` https://developer.android.com/reference/android/support/v4/app/Fragment#onPause()() ` Called when the Fragment is no longer resumed. | | ` void` | ` https://developer.android.com/reference/android/support/v4/app/Fragment#onPictureInPictureModeChanged(boolean)(boolean isInPictureInPictureMode) ` Called by the system when the activity changes to and from picture-in-picture mode. | | ` void` | ` https://developer.android.com/reference/android/support/v4/app/Fragment#onPrepareOptionsMenu(android.view.Menu)(https://developer.android.com/reference/android/view/Menu.html menu) ` Prepare the Fragment host's standard options menu to be displayed. | | ` void` | ` https://developer.android.com/reference/android/support/v4/app/Fragment#onRequestPermissionsResult(int, java.lang.String[], int[])(int requestCode, String[] permissions, int[] grantResults) ` Callback for the result from requesting permissions. | | ` void` | ` https://developer.android.com/reference/android/support/v4/app/Fragment#onResume()() ` Called when the fragment is visible to the user and actively running. | | ` void` | ` https://developer.android.com/reference/android/support/v4/app/Fragment#onSaveInstanceState(android.os.Bundle)(https://developer.android.com/reference/android/os/Bundle.html outState) ` Called to ask the fragment to save its current dynamic state, so it can later be reconstructed in a new instance of its process is restarted. | | ` void` | ` https://developer.android.com/reference/android/support/v4/app/Fragment#onStart()() ` Called when the Fragment is visible to the user. | | ` void` | ` https://developer.android.com/reference/android/support/v4/app/Fragment#onStop()() ` Called when the Fragment is no longer started. | | ` void` | ` https://developer.android.com/reference/android/support/v4/app/Fragment#onViewCreated(android.view.View, android.os.Bundle)(https://developer.android.com/reference/android/view/View.html view, https://developer.android.com/reference/android/os/Bundle.html savedInstanceState) ` Called immediately after `https://developer.android.com/reference/android/support/v4/app/Fragment#onCreateView(android.view.LayoutInflater, android.view.ViewGroup, android.os.Bundle)` has returned, but before any saved state has been restored in to the view. | | ` void` | ` https://developer.android.com/reference/android/support/v4/app/Fragment#onViewStateRestored(android.os.Bundle)(https://developer.android.com/reference/android/os/Bundle.html savedInstanceState) ` Called when all saved state has been restored into the view hierarchy of the fragment. | | ` void` | ` https://developer.android.com/reference/android/support/v4/app/Fragment#postponeEnterTransition()() ` Postpone the entering Fragment transition until `https://developer.android.com/reference/android/support/v4/app/Fragment#startPostponedEnterTransition()` or `https://developer.android.com/reference/android/support/v4/app/FragmentManager#executePendingTransactions()` has been called. | | ` void` | ` https://developer.android.com/reference/android/support/v4/app/Fragment#registerForContextMenu(android.view.View)(https://developer.android.com/reference/android/view/View.html view) ` Registers a context menu to be shown for the given view (multiple views can show the context menu). | | ` final void` | ` https://developer.android.com/reference/android/support/v4/app/Fragment#requestPermissions(java.lang.String[], int)(String[] permissions, int requestCode) ` Requests permissions to be granted to this application. | | ` final https://developer.android.com/reference/android/support/v4/app/FragmentActivity` | ` https://developer.android.com/reference/android/support/v4/app/Fragment#requireActivity()() ` Return the `https://developer.android.com/reference/android/support/v4/app/FragmentActivity` this fragment is currently associated with. | | ` final https://developer.android.com/reference/android/content/Context.html` | ` https://developer.android.com/reference/android/support/v4/app/Fragment#requireContext()() ` Return the `https://developer.android.com/reference/android/content/Context.html` this fragment is currently associated with. | | ` final https://developer.android.com/reference/android/support/v4/app/FragmentManager` | ` https://developer.android.com/reference/android/support/v4/app/Fragment#requireFragmentManager()() ` Return the FragmentManager for interacting with fragments associated with this fragment's activity. | | ` final Object` | ` https://developer.android.com/reference/android/support/v4/app/Fragment#requireHost()() ` Return the host object of this fragment. | | ` void` | ` https://developer.android.com/reference/android/support/v4/app/Fragment#setAllowEnterTransitionOverlap(boolean)(boolean allow) ` Sets whether the the exit transition and enter transition overlap or not. | | ` void` | ` https://developer.android.com/reference/android/support/v4/app/Fragment#setAllowReturnTransitionOverlap(boolean)(boolean allow) ` Sets whether the the return transition and reenter transition overlap or not. | | ` void` | ` https://developer.android.com/reference/android/support/v4/app/Fragment#setArguments(android.os.Bundle)(https://developer.android.com/reference/android/os/Bundle.html args) ` Supply the construction arguments for this fragment. | | ` void` | ` https://developer.android.com/reference/android/support/v4/app/Fragment#setEnterSharedElementCallback(android.support.v4.app.SharedElementCallback)(https://developer.android.com/reference/android/support/v4/app/SharedElementCallback callback) ` When custom transitions are used with Fragments, the enter transition callback is called when this Fragment is attached or detached when not popping the back stack. | | ` void` | ` https://developer.android.com/reference/android/support/v4/app/Fragment#setEnterTransition(java.lang.Object)(Object transition) ` Sets the Transition that will be used to move Views into the initial scene. | | ` void` | ` https://developer.android.com/reference/android/support/v4/app/Fragment#setExitSharedElementCallback(android.support.v4.app.SharedElementCallback)(https://developer.android.com/reference/android/support/v4/app/SharedElementCallback callback) ` When custom transitions are used with Fragments, the exit transition callback is called when this Fragment is attached or detached when popping the back stack. | | ` void` | ` https://developer.android.com/reference/android/support/v4/app/Fragment#setExitTransition(java.lang.Object)(Object transition) ` Sets the Transition that will be used to move Views out of the scene when the fragment is removed, hidden, or detached when not popping the back stack. | | ` void` | ` https://developer.android.com/reference/android/support/v4/app/Fragment#setHasOptionsMenu(boolean)(boolean hasMenu) ` Report that this fragment would like to participate in populating the options menu by receiving a call to `https://developer.android.com/reference/android/support/v4/app/Fragment#onCreateOptionsMenu(android.view.Menu, android.view.MenuInflater)` and related methods. | | ` void` | ` https://developer.android.com/reference/android/support/v4/app/Fragment#setInitialSavedState(android.support.v4.app.Fragment.SavedState)(https://developer.android.com/reference/android/support/v4/app/Fragment.SavedState state) ` Set the initial saved state that this Fragment should restore itself from when first being constructed, as returned by `https://developer.android.com/reference/android/support/v4/app/FragmentManager#saveFragmentInstanceState(android.support.v4.app.Fragment)`. | | ` void` | ` https://developer.android.com/reference/android/support/v4/app/Fragment#setMenuVisibility(boolean)(boolean menuVisible) ` Set a hint for whether this fragment's menu should be visible. | | ` void` | ` https://developer.android.com/reference/android/support/v4/app/Fragment#setReenterTransition(java.lang.Object)(Object transition) ` Sets the Transition that will be used to move Views in to the scene when returning due to popping a back stack. | | ` void` | ` https://developer.android.com/reference/android/support/v4/app/Fragment#setRetainInstance(boolean)(boolean retain) ` Control whether a fragment instance is retained across Activity re-creation (such as from a configuration change). | | ` void` | ` https://developer.android.com/reference/android/support/v4/app/Fragment#setReturnTransition(java.lang.Object)(Object transition) ` Sets the Transition that will be used to move Views out of the scene when the Fragment is preparing to be removed, hidden, or detached because of popping the back stack. | | ` void` | ` https://developer.android.com/reference/android/support/v4/app/Fragment#setSharedElementEnterTransition(java.lang.Object)(Object transition) ` Sets the Transition that will be used for shared elements transferred into the content Scene. | | ` void` | ` https://developer.android.com/reference/android/support/v4/app/Fragment#setSharedElementReturnTransition(java.lang.Object)(Object transition) ` Sets the Transition that will be used for shared elements transferred back during a pop of the back stack. | | ` void` | ` https://developer.android.com/reference/android/support/v4/app/Fragment#setTargetFragment(android.support.v4.app.Fragment, int)(https://developer.android.com/reference/android/support/v4/app/Fragment fragment, int requestCode) ` Optional target for this fragment. | | ` void` | ` https://developer.android.com/reference/android/support/v4/app/Fragment#setUserVisibleHint(boolean)(boolean isVisibleToUser) ` Set a hint to the system about whether this fragment's UI is currently visible to the user. | | ` boolean` | ` https://developer.android.com/reference/android/support/v4/app/Fragment#shouldShowRequestPermissionRationale(java.lang.String)(String permission) ` Gets whether you should show UI with rationale for requesting a permission. | | ` void` | ` https://developer.android.com/reference/android/support/v4/app/Fragment#startActivity(android.content.Intent)(https://developer.android.com/reference/android/content/Intent.html intent) ` Call `https://developer.android.com/reference/android/app/Activity.html#startActivity(android.content.Intent)` from the fragment's containing Activity. | | ` void` | ` https://developer.android.com/reference/android/support/v4/app/Fragment#startActivity(android.content.Intent, android.os.Bundle)(https://developer.android.com/reference/android/content/Intent.html intent, https://developer.android.com/reference/android/os/Bundle.html options) ` Call `https://developer.android.com/reference/android/app/Activity.html#startActivity(android.content.Intent, android.os.Bundle)` from the fragment's containing Activity. | | ` void` | ` https://developer.android.com/reference/android/support/v4/app/Fragment#startActivityForResult(android.content.Intent, int)(https://developer.android.com/reference/android/content/Intent.html intent, int requestCode) ` Call `https://developer.android.com/reference/android/app/Activity.html#startActivityForResult(android.content.Intent, int)` from the fragment's containing Activity. | | ` void` | ` https://developer.android.com/reference/android/support/v4/app/Fragment#startActivityForResult(android.content.Intent, int, android.os.Bundle)(https://developer.android.com/reference/android/content/Intent.html intent, int requestCode, https://developer.android.com/reference/android/os/Bundle.html options) ` Call `https://developer.android.com/reference/android/app/Activity.html#startActivityForResult(android.content.Intent, int, android.os.Bundle)` from the fragment's containing Activity. | | ` void` | ` https://developer.android.com/reference/android/support/v4/app/Fragment#startIntentSenderForResult(android.content.IntentSender, int, android.content.Intent, int, int, int, android.os.Bundle)(https://developer.android.com/reference/android/content/IntentSender.html intent, int requestCode, https://developer.android.com/reference/android/content/Intent.html fillInIntent, int flagsMask, int flagsValues, int extraFlags, https://developer.android.com/reference/android/os/Bundle.html options) ` Call `https://developer.android.com/reference/android/app/Activity.html#startIntentSenderForResult(android.content.IntentSender, int, android.content.Intent, int, int, int, android.os.Bundle)` from the fragment's containing Activity. | | ` void` | ` https://developer.android.com/reference/android/support/v4/app/Fragment#startPostponedEnterTransition()() ` Begin postponed transitions after `https://developer.android.com/reference/android/support/v4/app/Fragment#postponeEnterTransition()` was called. | | ` String` | ` https://developer.android.com/reference/android/support/v4/app/Fragment#toString()() ` | | ` void` | ` https://developer.android.com/reference/android/support/v4/app/Fragment#unregisterForContextMenu(android.view.View)(https://developer.android.com/reference/android/view/View.html view) ` Prevents a context menu to be shown for the given view. | ||
| [![](https://developer.android.com/static/assets/images/styles/disclosure_down.png)](https://developer.android.com/reference/android/support/wear/ambient/AmbientModeSupport#)From class ` java.lang.Object ` |---|---| | ` Object` | ` clone() ` | | ` boolean` | ` equals(Object arg0) ` | | ` void` | ` finalize() ` | | ` final Class<?>` | ` getClass() ` | | ` int` | ` hashCode() ` | | ` final void` | ` notify() ` | | ` final void` | ` notifyAll() ` | | ` String` | ` toString() ` | | ` final void` | ` wait(long arg0, int arg1) ` | | ` final void` | ` wait(long arg0) ` | | ` final void` | ` wait() ` | ||
| [![](https://developer.android.com/static/assets/images/styles/disclosure_down.png)](https://developer.android.com/reference/android/support/wear/ambient/AmbientModeSupport#)From interface ` https://developer.android.com/reference/android/content/ComponentCallbacks.html ` |---|---| | ` abstract void` | ` onConfigurationChanged(https://developer.android.com/reference/android/content/res/Configuration.html arg0) ` | | ` abstract void` | ` onLowMemory() ` | ||
| [![](https://developer.android.com/static/assets/images/styles/disclosure_down.png)](https://developer.android.com/reference/android/support/wear/ambient/AmbientModeSupport#)From interface ` https://developer.android.com/reference/android/view/View.OnCreateContextMenuListener.html ` |---|---| | ` abstract void` | ` onCreateContextMenu(https://developer.android.com/reference/android/view/ContextMenu.html arg0, https://developer.android.com/reference/android/view/View.html arg1, https://developer.android.com/reference/android/view/ContextMenu.ContextMenuInfo.html arg2) ` | ||
| [![](https://developer.android.com/static/assets/images/styles/disclosure_down.png)](https://developer.android.com/reference/android/support/wear/ambient/AmbientModeSupport#)From interface ` android.arch.lifecycle.LifecycleOwner ` |---|---| | ` abstract Lifecycle` | ` getLifecycle() ` | ||
| [![](https://developer.android.com/static/assets/images/styles/disclosure_down.png)](https://developer.android.com/reference/android/support/wear/ambient/AmbientModeSupport#)From interface ` android.arch.lifecycle.ViewModelStoreOwner ` |---|---| | ` abstract ViewModelStore` | ` getViewModelStore() ` | ||

## Constants

### EXTRA_BURN_IN_PROTECTION

added in [version 27.1.0](https://developer.android.com/topic/libraries/support-library/revisions)

```
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.

<br />

Constant Value:

"com.google.android.wearable.compat.extra.BURN_IN_PROTECTION"


### EXTRA_LOWBIT_AMBIENT

added in [version 27.1.0](https://developer.android.com/topic/libraries/support-library/revisions)

```
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.

<br />

Constant Value:

"com.google.android.wearable.compat.extra.LOWBIT_AMBIENT"


### FRAGMENT_TAG

added in [version 27.1.0](https://developer.android.com/topic/libraries/support-library/revisions)

```
String FRAGMENT_TAG
```

Fragment tag used by default when adding `https://developer.android.com/reference/android/support/wear/ambient/AmbientModeSupport` to add ambient support to
a `https://developer.android.com/reference/android/support/v4/app/FragmentActivity`.

<br />

Constant Value:

"android.support.wearable.ambient.AmbientMode"


## Public constructors

### AmbientModeSupport

added in [version 27.1.0](https://developer.android.com/topic/libraries/support-library/revisions)

```
AmbientModeSupport ()
```

Constructor

<br />

## Public methods

### attach

added in [version 27.1.0](https://developer.android.com/topic/libraries/support-library/revisions)

```
AmbientModeSupport.AmbientController attach (T activity)
```

Attach ambient support to the given activity. Calling this method with an Activity
implementing the `https://developer.android.com/reference/android/support/wear/ambient/AmbientModeSupport.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 `https://developer.android.com/reference/android/support/wear/ambient/AmbientModeSupport.AmbientCallbackProvider` interface and that will only enable the auto-resume
functionality. This is equivalent to providing (@code null} from
the `https://developer.android.com/reference/android/support/wear/ambient/AmbientModeSupport.AmbientCallbackProvider`.

<br />

| Parameters ||
|---|---|
| `activity` | `T`: the activity to attach ambient support to. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/support/wear/ambient/AmbientModeSupport.AmbientController` | the associated `https://developer.android.com/reference/android/support/wear/ambient/AmbientModeSupport.AmbientController` which can be used to query the state of ambient mode. <br /> |

### dump

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

Print the Fragments's state into the given stream.

<br />

| Parameters ||
|---|---|
| `prefix` | `String`: Text to print at the front of each line. <br /> |
| `fd` | `FileDescriptor`: The raw file descriptor that the dump is being sent to. <br /> |
| `writer` | `PrintWriter`: The PrintWriter to which you should dump your state. This will be closed for you after you return. <br /> |
| `args` | `String`: additional arguments to the dump request. <br /> |

### onAttach

```
void onAttach (Context context)
```

Called when a fragment is first attached to its context.
`https://developer.android.com/reference/android/support/v4/app/Fragment#onCreate(android.os.Bundle)` will be called after this.

<br />

| Parameters ||
|---|---|
| `context` | `Context` <br /> |

### onCreate

```
void onCreate (Bundle savedInstanceState)
```

Called to do initial creation of a fragment. This is called after
`https://developer.android.com/reference/android/support/v4/app/Fragment#onAttach(android.app.Activity)` and before
`https://developer.android.com/reference/android/support/v4/app/Fragment#onCreateView(android.view.LayoutInflater, android.view.ViewGroup, android.os.Bundle)`.

Note that this can be called while the fragment's activity is
still in the process of being created. As such, you can not rely
on things like the activity's content view hierarchy being initialized
at this point. If you want to do work once the activity itself is
created, see `https://developer.android.com/reference/android/support/v4/app/Fragment#onActivityCreated(android.os.Bundle)`.

Any restored child fragments will be created before the base
`Fragment.onCreate` method returns.

<br />

<br />

| Parameters ||
|---|---|
| `savedInstanceState` | `Bundle`: If the fragment is being re-created from a previous saved state, this is the state. <br /> |

### onDestroy

```
void onDestroy ()
```

Called when the fragment is no longer in use. This is called
after `https://developer.android.com/reference/android/support/v4/app/Fragment#onStop()` and before `https://developer.android.com/reference/android/support/v4/app/Fragment#onDetach()`.

<br />

### onDetach

```
void onDetach ()
```

Called when the fragment is no longer attached to its activity. This
is called after `https://developer.android.com/reference/android/support/v4/app/Fragment#onDestroy()`.

<br />

### onPause

```
void onPause ()
```

Called when the Fragment is no longer resumed. This is generally
tied to `https://developer.android.com/reference/android/app/Activity.html#onPause()` of the containing
Activity's lifecycle.

<br />

### onResume

```
void onResume ()
```

Called when the fragment is visible to the user and actively running.
This is generally
tied to `https://developer.android.com/reference/android/app/Activity.html#onResume()` of the containing
Activity's lifecycle.

<br />

### onStop

```
void onStop ()
```

Called when the Fragment is no longer started. This is generally
tied to `https://developer.android.com/reference/android/app/Activity.html#onStop()` of the containing
Activity's lifecycle.

<br />

-

  ## Interfaces

  - [AmbientMode.AmbientCallbackProvider](https://developer.android.com/reference/android/support/wear/ambient/AmbientMode.AmbientCallbackProvider)
  - [AmbientModeSupport.AmbientCallbackProvider](https://developer.android.com/reference/android/support/wear/ambient/AmbientModeSupport.AmbientCallbackProvider)
-

  ## Classes

  - [AmbientMode](https://developer.android.com/reference/android/support/wear/ambient/AmbientMode)
  - [AmbientMode.AmbientCallback](https://developer.android.com/reference/android/support/wear/ambient/AmbientMode.AmbientCallback)
  - [AmbientMode.AmbientController](https://developer.android.com/reference/android/support/wear/ambient/AmbientMode.AmbientController)
  - [AmbientModeSupport](https://developer.android.com/reference/android/support/wear/ambient/AmbientModeSupport)
  - [AmbientModeSupport.AmbientCallback](https://developer.android.com/reference/android/support/wear/ambient/AmbientModeSupport.AmbientCallback)
  - [AmbientModeSupport.AmbientController](https://developer.android.com/reference/android/support/wear/ambient/AmbientModeSupport.AmbientController)