# AmbientModeSupport

Artifact: [androidx.wear:wear](https://developer.android.com/jetpack/androidx/releases/wear) [View Source](https://cs.android.com/search?q=file:androidx/wear/ambient/AmbientModeSupport.java+class:androidx.wear.ambient.AmbientModeSupport) Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/wear#1.1.0) Deprecated in [1.3.0](https://developer.android.com/jetpack/androidx/releases/wear#1.3.0)

*** ** * ** ***


```
public final class AmbientModeSupport extends Fragment
```

<br />

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

*** ** * ** ***

> [!CAUTION]
> **This class is deprecated.**   
>
> Use `https://developer.android.com/reference/androidx/wear/ambient/AmbientLifecycleObserver` instead. These classes use lifecycle components instead, preventing the need to hook these events using fragments.

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.html#WAKE_LOCK` permission to its manifest.

The following describes the general use of this class:

Create a subclass of one of the `https://developer.android.com/reference/androidx/fragment/app/FragmentActivity` classes and implement the `https://developer.android.com/reference/androidx/wear/ambient/AmbientModeSupport.AmbientCallbackProvider` interface. Override the `https://developer.android.com/reference/androidx/wear/ambient/AmbientModeSupport.AmbientCallbackProvider#getAmbientCallback()` method to provide the callbacks required for reacting to the ambient events from the Android system. If a valid `https://developer.android.com/reference/androidx/wear/ambient/AmbientModeSupport.AmbientCallback` is not provided (either no implementation of the `https://developer.android.com/reference/androidx/wear/ambient/AmbientModeSupport.AmbientCallbackProvider` interface, or returning null from `https://developer.android.com/reference/androidx/wear/ambient/AmbientModeSupport.AmbientCallbackProvider#getAmbientCallback()`), then ambient mode will NOT be enabled.

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

```
public class MyActivity extends FragmentActivity
    implements AmbientModeSupport.AmbientCallbackProvider {
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState)
        ...
        AmbientModeSupport.AmbientController controller = AmbientModeSupport.attach(this);
        boolean isAmbient = controller.isAmbient();
    }
    @Override
    AmbientModeSupport.AmbientCallback getAmbientCallback() {
        return new AmbientModeSupport.AmbientCallback() {
            public void onEnterAmbient(Bundle ambientDetails) {...}
            public void onExitAmbient(Bundle ambientDetails) {...}
        }
    }
}
```

## Summary

| ### Nested types |
|---|
| `public abstract class https://developer.android.com/reference/androidx/wear/ambient/AmbientModeSupport.AmbientCallback` **This class is deprecated.** Deprecated in Java |
| `public interface https://developer.android.com/reference/androidx/wear/ambient/AmbientModeSupport.AmbientCallbackProvider` **This interface is deprecated.** Deprecated in Java |
| `public final inner class https://developer.android.com/reference/androidx/wear/ambient/AmbientModeSupport.AmbientController` **This class is deprecated.** Deprecated in Java |

| ### Constants |
|---|---|
| `static final https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/androidx/wear/ambient/AmbientModeSupport#EXTRA_BURN_IN_PROTECTION() = "com.google.android.wearable.compat.extra.BURN_IN_PROTECTION"` **This field is deprecated.** Deprecated in Java |
| `static final https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/androidx/wear/ambient/AmbientModeSupport#EXTRA_LOWBIT_AMBIENT() = "com.google.android.wearable.compat.extra.LOWBIT_AMBIENT"` **This field is deprecated.** Deprecated in Java |
| `static final https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/androidx/wear/ambient/AmbientModeSupport#FRAGMENT_TAG() = "android.support.wearable.ambient.AmbientMode"` **This field is deprecated.** Deprecated in Java |

| ### Public constructors |
|---|
| `[AmbientModeSupport](https://developer.android.com/reference/androidx/wear/ambient/AmbientModeSupport#AmbientModeSupport())()` **This method is deprecated.** Deprecated in Java |

| ### Public methods |
|---|---|
| `static https://developer.android.com/reference/androidx/wear/ambient/AmbientModeSupport.AmbientController` | `<T extends https://developer.android.com/reference/androidx/fragment/app/FragmentActivity> [attach](https://developer.android.com/reference/androidx/wear/ambient/AmbientModeSupport#attach(T))(T activity)` **This method is deprecated.** Deprecated in Java |
| `void` | `[dump](https://developer.android.com/reference/androidx/wear/ambient/AmbientModeSupport#dump(java.lang.String,java.io.FileDescriptor,java.io.PrintWriter,java.lang.String[]))(https://developer.android.com/reference/java/lang/String.html prefix, https://developer.android.com/reference/java/io/FileDescriptor.html fd, https://developer.android.com/reference/java/io/PrintWriter.html writer, String[] args)` **This method is deprecated.** Deprecated in Java |
| `void` | `@https://developer.android.com/reference/androidx/annotation/CallSuper [onAttach](https://developer.android.com/reference/androidx/wear/ambient/AmbientModeSupport#onAttach(android.content.Context))(https://developer.android.com/reference/android/content/Context.html context)` **This method is deprecated.** Deprecated in Java |
| `void` | `@https://developer.android.com/reference/androidx/annotation/CallSuper [onCreate](https://developer.android.com/reference/androidx/wear/ambient/AmbientModeSupport#onCreate(android.os.Bundle))(https://developer.android.com/reference/android/os/Bundle.html savedInstanceState)` **This method is deprecated.** Deprecated in Java |
| `void` | `@https://developer.android.com/reference/androidx/annotation/CallSuper [onDestroy](https://developer.android.com/reference/androidx/wear/ambient/AmbientModeSupport#onDestroy())()` **This method is deprecated.** Deprecated in Java |
| `void` | `@https://developer.android.com/reference/androidx/annotation/CallSuper [onDetach](https://developer.android.com/reference/androidx/wear/ambient/AmbientModeSupport#onDetach())()` **This method is deprecated.** Deprecated in Java |
| `void` | `@https://developer.android.com/reference/androidx/annotation/CallSuper [onPause](https://developer.android.com/reference/androidx/wear/ambient/AmbientModeSupport#onPause())()` **This method is deprecated.** Deprecated in Java |
| `void` | `@https://developer.android.com/reference/androidx/annotation/CallSuper [onResume](https://developer.android.com/reference/androidx/wear/ambient/AmbientModeSupport#onResume())()` **This method is deprecated.** Deprecated in Java |
| `void` | `@https://developer.android.com/reference/androidx/annotation/CallSuper [onStop](https://developer.android.com/reference/androidx/wear/ambient/AmbientModeSupport#onStop())()` **This method is deprecated.** Deprecated in Java |

### Inherited methods

From [androidx.activity.result.ActivityResultCaller](https://developer.android.com/reference/androidx/activity/result/ActivityResultCaller) `abstract https://developer.android.com/reference/androidx/activity/result/ActivityResultLauncher<I>` `<I, O> [registerForActivityResult](https://developer.android.com/reference/androidx/activity/result/ActivityResultCaller#registerForActivityResult(androidx.activity.result.contract.ActivityResultContract<I,O>,androidx.activity.result.ActivityResultCallback<O>))(
https://developer.android.com/reference/androidx/activity/result/contract/ActivityResultContract<I, O> contract,
https://developer.android.com/reference/androidx/activity/result/ActivityResultCallback<O> callback
)`

**This method is deprecated.** Deprecated in Java
From [android.content.ComponentCallbacks](https://developer.android.com/reference/android/content/ComponentCallbacks.html) `abstract void` `[onConfigurationChanged](https://developer.android.com/reference/android/content/ComponentCallbacks.html#onConfigurationChanged(android.content.res.Configuration))(https://developer.android.com/reference/android/content/res/Configuration.html p)`

**This method is deprecated.** Deprecated in Java
`abstract void` `[onLowMemory](https://developer.android.com/reference/android/content/ComponentCallbacks.html#onLowMemory())()`

**This method is deprecated.**
From [androidx.activity.contextaware.ContextAware](https://developer.android.com/reference/androidx/activity/contextaware/ContextAware) `abstract void` `[addOnContextAvailableListener](https://developer.android.com/reference/androidx/activity/contextaware/ContextAware#addOnContextAvailableListener(androidx.activity.contextaware.OnContextAvailableListener))(https://developer.android.com/reference/androidx/activity/contextaware/OnContextAvailableListener listener)`

**This method is deprecated.** Deprecated in Java
`abstract https://developer.android.com/reference/android/content/Context.html` `[peekAvailableContext](https://developer.android.com/reference/androidx/activity/contextaware/ContextAware#peekAvailableContext())()`

**This method is deprecated.** Deprecated in Java
`abstract void` `[removeOnContextAvailableListener](https://developer.android.com/reference/androidx/activity/contextaware/ContextAware#removeOnContextAvailableListener(androidx.activity.contextaware.OnContextAvailableListener))(https://developer.android.com/reference/androidx/activity/contextaware/OnContextAvailableListener listener)`

**This method is deprecated.** Deprecated in Java
From [androidx.fragment.app.Fragment](https://developer.android.com/reference/androidx/fragment/app/Fragment) `void` `[addOnContextAvailableListener](https://developer.android.com/reference/androidx/fragment/app/Fragment#addOnContextAvailableListener(androidx.activity.contextaware.OnContextAvailableListener))(
@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/activity/contextaware/OnContextAvailableListener listener
)`

**This method is deprecated.** Deprecated in Java
`final boolean` `[equals](https://developer.android.com/reference/androidx/fragment/app/Fragment#equals(java.lang.Object))(@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/java/lang/Object.html o)`

**This method is deprecated.** Deprecated in Java
`final @https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/androidx/fragment/app/FragmentActivity` `[getActivity](https://developer.android.com/reference/androidx/fragment/app/Fragment#getActivity())()`

**This method is deprecated.** Deprecated in Java
`boolean` `[getAllowEnterTransitionOverlap](https://developer.android.com/reference/androidx/fragment/app/Fragment#getAllowEnterTransitionOverlap())()`

**This method is deprecated.** Deprecated in Java
`boolean` `[getAllowReturnTransitionOverlap](https://developer.android.com/reference/androidx/fragment/app/Fragment#getAllowReturnTransitionOverlap())()`

**This method is deprecated.** Deprecated in Java
`final @https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/android/os/Bundle.html` `[getArguments](https://developer.android.com/reference/androidx/fragment/app/Fragment#getArguments())()`

**This method is deprecated.** Deprecated in Java
`final @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/fragment/app/FragmentManager` `[getChildFragmentManager](https://developer.android.com/reference/androidx/fragment/app/Fragment#getChildFragmentManager())()`

**This method is deprecated.** Deprecated in Java
`@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/android/content/Context.html` `[getContext](https://developer.android.com/reference/androidx/fragment/app/Fragment#getContext())()`

**This method is deprecated.** Deprecated in Java
`@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/lifecycle/viewmodel/CreationExtras` `@https://developer.android.com/reference/androidx/annotation/CallSuper
[getDefaultViewModelCreationExtras](https://developer.android.com/reference/androidx/fragment/app/Fragment#getDefaultViewModelCreationExtras())()`

**This method is deprecated.** Deprecated in Java
`@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/lifecycle/ViewModelProvider.Factory` `[getDefaultViewModelProviderFactory](https://developer.android.com/reference/androidx/fragment/app/Fragment#getDefaultViewModelProviderFactory())()`

**This method is deprecated.** Deprecated in Java
`@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/java/lang/Object.html` `[getEnterTransition](https://developer.android.com/reference/androidx/fragment/app/Fragment#getEnterTransition())()`

**This method is deprecated.** Deprecated in Java
`@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/java/lang/Object.html` `[getExitTransition](https://developer.android.com/reference/androidx/fragment/app/Fragment#getExitTransition())()`

**This method is deprecated.** Deprecated in Java
`final @https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/androidx/fragment/app/FragmentManager` `[getFragmentManager](https://developer.android.com/reference/androidx/fragment/app/Fragment#getFragmentManager())()`

**This method is deprecated.**

This has been removed in favor of `getParentFragmentManager()` which throws an `https://developer.android.com/reference/java/lang/IllegalStateException.html` if the FragmentManager is null.

<br />

`final @https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/java/lang/Object.html` `[getHost](https://developer.android.com/reference/androidx/fragment/app/Fragment#getHost())()`

**This method is deprecated.** Deprecated in Java
`final int` `[getId](https://developer.android.com/reference/androidx/fragment/app/Fragment#getId())()`

**This method is deprecated.** Deprecated in Java
`final @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/view/LayoutInflater.html` `[getLayoutInflater](https://developer.android.com/reference/androidx/fragment/app/Fragment#getLayoutInflater())()`

**This method is deprecated.** Deprecated in Java
`@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/lifecycle/Lifecycle` `[getLifecycle](https://developer.android.com/reference/androidx/fragment/app/Fragment#getLifecycle())()`

**This method is deprecated.** Deprecated in Java
`@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/loader/app/LoaderManager` `[getLoaderManager](https://developer.android.com/reference/androidx/fragment/app/Fragment#getLoaderManager())()`

**This method is deprecated.**

Use `https://developer.android.com/reference/androidx/loader/app/LoaderManager#getInstance(T)`.

<br />

`final @https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/androidx/fragment/app/Fragment` `[getParentFragment](https://developer.android.com/reference/androidx/fragment/app/Fragment#getParentFragment())()`

**This method is deprecated.** Deprecated in Java
`final @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/fragment/app/FragmentManager` `[getParentFragmentManager](https://developer.android.com/reference/androidx/fragment/app/Fragment#getParentFragmentManager())()`

**This method is deprecated.** Deprecated in Java
`@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/java/lang/Object.html` `[getReenterTransition](https://developer.android.com/reference/androidx/fragment/app/Fragment#getReenterTransition())()`

**This method is deprecated.** Deprecated in Java
`final @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/content/res/Resources.html` `[getResources](https://developer.android.com/reference/androidx/fragment/app/Fragment#getResources())()`

**This method is deprecated.** Deprecated in Java
`final boolean` `[getRetainInstance](https://developer.android.com/reference/androidx/fragment/app/Fragment#getRetainInstance())()`

**This method is deprecated.**

Instead of retaining the Fragment itself, use a non-retained Fragment and keep retained state in a ViewModel attached to that Fragment.

<br />

`@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/java/lang/Object.html` `[getReturnTransition](https://developer.android.com/reference/androidx/fragment/app/Fragment#getReturnTransition())()`

**This method is deprecated.** Deprecated in Java
`final @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/savedstate/SavedStateRegistry` `[getSavedStateRegistry](https://developer.android.com/reference/androidx/fragment/app/Fragment#getSavedStateRegistry())()`

**This method is deprecated.** Deprecated in Java
`@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/java/lang/Object.html` `[getSharedElementEnterTransition](https://developer.android.com/reference/androidx/fragment/app/Fragment#getSharedElementEnterTransition())()`

**This method is deprecated.** Deprecated in Java
`@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/java/lang/Object.html` `[getSharedElementReturnTransition](https://developer.android.com/reference/androidx/fragment/app/Fragment#getSharedElementReturnTransition())()`

**This method is deprecated.** Deprecated in Java
`final @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/lang/String.html` `[getString](https://developer.android.com/reference/androidx/fragment/app/Fragment#getString(int))(@https://developer.android.com/reference/androidx/annotation/StringRes int resId)`

**This method is deprecated.** Deprecated in Java
`final @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/lang/String.html` `[getString](https://developer.android.com/reference/androidx/fragment/app/Fragment#getString(int,java.lang.Object...))(@https://developer.android.com/reference/androidx/annotation/StringRes int resId, @https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html Object[] formatArgs)`

**This method is deprecated.** Deprecated in Java
`final @https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/java/lang/String.html` `[getTag](https://developer.android.com/reference/androidx/fragment/app/Fragment#getTag())()`

**This method is deprecated.** Deprecated in Java
`final @https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/androidx/fragment/app/Fragment` `[getTargetFragment](https://developer.android.com/reference/androidx/fragment/app/Fragment#getTargetFragment())()`

**This method is deprecated.**

Instead of using a target fragment to pass results, use `https://developer.android.com/reference/androidx/fragment/app/FragmentManager#setFragmentResult(java.lang.String,android.os.Bundle)` to deliver results to `https://developer.android.com/reference/androidx/fragment/app/FragmentResultListener` instances registered by other fragments via `https://developer.android.com/reference/androidx/fragment/app/FragmentManager#setFragmentResultListener(java.lang.String,androidx.lifecycle.LifecycleOwner,androidx.fragment.app.FragmentResultListener)`.

<br />

`final int` `[getTargetRequestCode](https://developer.android.com/reference/androidx/fragment/app/Fragment#getTargetRequestCode())()`

**This method is deprecated.**

When using the target fragment replacement of `https://developer.android.com/reference/androidx/fragment/app/FragmentManager#setFragmentResultListener(java.lang.String,androidx.lifecycle.LifecycleOwner,androidx.fragment.app.FragmentResultListener)` and `https://developer.android.com/reference/androidx/fragment/app/FragmentManager#setFragmentResult(java.lang.String,android.os.Bundle)`, consider using `https://developer.android.com/reference/androidx/fragment/app/Fragment#setArguments(android.os.Bundle)` to pass a `requestKey` if you need to support dynamic request keys.

<br />

`final @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/lang/CharSequence.html` `[getText](https://developer.android.com/reference/androidx/fragment/app/Fragment#getText(int))(@https://developer.android.com/reference/androidx/annotation/StringRes int resId)`

**This method is deprecated.** Deprecated in Java
`boolean` `[getUserVisibleHint](https://developer.android.com/reference/androidx/fragment/app/Fragment#getUserVisibleHint())()`

**This method is deprecated.**

Use `https://developer.android.com/reference/androidx/fragment/app/FragmentTransaction#setMaxLifecycle(androidx.fragment.app.Fragment,androidx.lifecycle.Lifecycle.State)` instead.

<br />

`@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/android/view/View.html` `[getView](https://developer.android.com/reference/androidx/fragment/app/Fragment#getView())()`

**This method is deprecated.** Deprecated in Java
`@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/lifecycle/LifecycleOwner` `@https://developer.android.com/reference/androidx/annotation/MainThread
[getViewLifecycleOwner](https://developer.android.com/reference/androidx/fragment/app/Fragment#getViewLifecycleOwner())()`

**This method is deprecated.** Deprecated in Java
`@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/lifecycle/LiveData<https://developer.android.com/reference/androidx/lifecycle/LifecycleOwner>` `[getViewLifecycleOwnerLiveData](https://developer.android.com/reference/androidx/fragment/app/Fragment#getViewLifecycleOwnerLiveData())()`

**This method is deprecated.** Deprecated in Java
`@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/lifecycle/ViewModelStore` `[getViewModelStore](https://developer.android.com/reference/androidx/fragment/app/Fragment#getViewModelStore())()`

**This method is deprecated.** Deprecated in Java
`final int` `[hashCode](https://developer.android.com/reference/androidx/fragment/app/Fragment#hashCode())()`

**This method is deprecated.** Deprecated in Java
`static @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/fragment/app/Fragment` `[instantiate](https://developer.android.com/reference/androidx/fragment/app/Fragment#instantiate(android.content.Context,java.lang.String))(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/content/Context.html context, @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/lang/String.html fname)`

**This method is deprecated.**

Use `https://developer.android.com/reference/androidx/fragment/app/FragmentManager#getFragmentFactory()` and `https://developer.android.com/reference/androidx/fragment/app/FragmentFactory#instantiate(java.lang.ClassLoader,java.lang.String)`

<br />

`static @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/fragment/app/Fragment` `[instantiate](https://developer.android.com/reference/androidx/fragment/app/Fragment#instantiate(android.content.Context,java.lang.String,android.os.Bundle))(
@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/content/Context.html context,
@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/lang/String.html fname,
@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/android/os/Bundle.html args
)`

**This method is deprecated.**

Use `https://developer.android.com/reference/androidx/fragment/app/FragmentManager#getFragmentFactory()` and `https://developer.android.com/reference/androidx/fragment/app/FragmentFactory#instantiate(java.lang.ClassLoader,java.lang.String)`, manually calling `https://developer.android.com/reference/androidx/fragment/app/Fragment#setArguments(android.os.Bundle)` on the returned Fragment.

<br />

`final boolean` `[isAdded](https://developer.android.com/reference/androidx/fragment/app/Fragment#isAdded())()`

**This method is deprecated.** Deprecated in Java
`final boolean` `[isDetached](https://developer.android.com/reference/androidx/fragment/app/Fragment#isDetached())()`

**This method is deprecated.** Deprecated in Java
`final boolean` `[isHidden](https://developer.android.com/reference/androidx/fragment/app/Fragment#isHidden())()`

**This method is deprecated.** Deprecated in Java
`final boolean` `[isInLayout](https://developer.android.com/reference/androidx/fragment/app/Fragment#isInLayout())()`

**This method is deprecated.** Deprecated in Java
`final boolean` `[isRemoving](https://developer.android.com/reference/androidx/fragment/app/Fragment#isRemoving())()`

**This method is deprecated.** Deprecated in Java
`final boolean` `[isResumed](https://developer.android.com/reference/androidx/fragment/app/Fragment#isResumed())()`

**This method is deprecated.** Deprecated in Java
`final boolean` `[isStateSaved](https://developer.android.com/reference/androidx/fragment/app/Fragment#isStateSaved())()`

**This method is deprecated.** Deprecated in Java
`final boolean` `[isVisible](https://developer.android.com/reference/androidx/fragment/app/Fragment#isVisible())()`

**This method is deprecated.** Deprecated in Java
`void` `@https://developer.android.com/reference/androidx/annotation/MainThread
@https://developer.android.com/reference/androidx/annotation/CallSuper
[onActivityCreated](https://developer.android.com/reference/androidx/fragment/app/Fragment#onActivityCreated(android.os.Bundle))(@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/android/os/Bundle.html savedInstanceState)`

**This method is deprecated.**

use `https://developer.android.com/reference/androidx/fragment/app/Fragment#onViewCreated(android.view.View,android.os.Bundle)` for code touching the view created by `https://developer.android.com/reference/androidx/fragment/app/Fragment#onCreateView(android.view.LayoutInflater,android.view.ViewGroup,android.os.Bundle)` and `https://developer.android.com/reference/androidx/fragment/app/Fragment#onCreate(android.os.Bundle)` for other initialization.

<br />

`void` `[onActivityResult](https://developer.android.com/reference/androidx/fragment/app/Fragment#onActivityResult(int,int,android.content.Intent))(int requestCode, int resultCode, @https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/android/content/Intent.html data)`

**This method is deprecated.**

This method has been deprecated in favor of using the Activity Result API which brings increased type safety via an `https://developer.android.com/reference/androidx/activity/result/contract/ActivityResultContract` and the prebuilt contracts for common intents available in `https://developer.android.com/reference/androidx/activity/result/contract/ActivityResultContracts`, provides hooks for testing, and allow receiving results in separate, testable classes independent from your fragment.

<br />

`void` `@https://developer.android.com/reference/androidx/annotation/MainThread
@https://developer.android.com/reference/androidx/annotation/CallSuper
[onAttach](https://developer.android.com/reference/androidx/fragment/app/Fragment#onAttach(android.app.Activity))(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/app/Activity.html activity)`

**This method is deprecated.**

See `https://developer.android.com/reference/androidx/fragment/app/Fragment#onAttach(android.content.Context)`.

<br />

`void` `@https://developer.android.com/reference/androidx/annotation/MainThread
[onAttachFragment](https://developer.android.com/reference/androidx/fragment/app/Fragment#onAttachFragment(androidx.fragment.app.Fragment))(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/fragment/app/Fragment childFragment)`

**This method is deprecated.**

The responsibility for listening for fragments being attached has been moved to FragmentManager.

<br />

`void` `@https://developer.android.com/reference/androidx/annotation/CallSuper
[onConfigurationChanged](https://developer.android.com/reference/androidx/fragment/app/Fragment#onConfigurationChanged(android.content.res.Configuration))(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/content/res/Configuration.html newConfig)`

**This method is deprecated.** Deprecated in Java
`boolean` `@https://developer.android.com/reference/androidx/annotation/MainThread
[onContextItemSelected](https://developer.android.com/reference/androidx/fragment/app/Fragment#onContextItemSelected(android.view.MenuItem))(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/view/MenuItem.html item)`

**This method is deprecated.** Deprecated in Java
`@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/android/view/animation/Animation.html` `@https://developer.android.com/reference/androidx/annotation/MainThread
[onCreateAnimation](https://developer.android.com/reference/androidx/fragment/app/Fragment#onCreateAnimation(int,boolean,int))(int transit, boolean enter, int nextAnim)`

**This method is deprecated.** Deprecated in Java
`@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/android/animation/Animator.html` `@https://developer.android.com/reference/androidx/annotation/MainThread
[onCreateAnimator](https://developer.android.com/reference/androidx/fragment/app/Fragment#onCreateAnimator(int,boolean,int))(int transit, boolean enter, int nextAnim)`

**This method is deprecated.** Deprecated in Java
`void` `@https://developer.android.com/reference/androidx/annotation/MainThread
[onCreateContextMenu](https://developer.android.com/reference/androidx/fragment/app/Fragment#onCreateContextMenu(android.view.ContextMenu,android.view.View,android.view.ContextMenu.ContextMenuInfo))(
@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/view/ContextMenu.html menu,
@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/view/View.html v,
@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/android/view/ContextMenu.ContextMenuInfo.html menuInfo
)`

**This method is deprecated.** Deprecated in Java
`void` `@https://developer.android.com/reference/androidx/annotation/MainThread
[onCreateOptionsMenu](https://developer.android.com/reference/androidx/fragment/app/Fragment#onCreateOptionsMenu(android.view.Menu,android.view.MenuInflater))(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/view/Menu.html menu, @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/view/MenuInflater.html inflater)`

**This method is deprecated.**

`https://developer.android.com/reference/androidx/activity/ComponentActivity` now implements `https://developer.android.com/reference/androidx/core/view/MenuHost`, an interface that allows any component, including your activity itself, to add menu items by calling `https://developer.android.com/reference/androidx/activity/ComponentActivity#addMenuProvider(androidx.core.view.MenuProvider)` without forcing all components through this single method override.

<br />

`@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/android/view/View.html` `@https://developer.android.com/reference/androidx/annotation/MainThread
[onCreateView](https://developer.android.com/reference/androidx/fragment/app/Fragment#onCreateView(android.view.LayoutInflater,android.view.ViewGroup,android.os.Bundle))(
@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/view/LayoutInflater.html inflater,
@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/android/view/ViewGroup.html container,
@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/android/os/Bundle.html savedInstanceState
)`

**This method is deprecated.** Deprecated in Java
`void` `@https://developer.android.com/reference/androidx/annotation/MainThread
[onDestroyOptionsMenu](https://developer.android.com/reference/androidx/fragment/app/Fragment#onDestroyOptionsMenu())()`

**This method is deprecated.**

`https://developer.android.com/reference/androidx/activity/ComponentActivity` now implements `https://developer.android.com/reference/androidx/core/view/MenuHost`, an interface that allows any component, including your activity itself, to add menu items by calling `https://developer.android.com/reference/androidx/core/view/MenuHost#addMenuProvider(androidx.core.view.MenuProvider)` without forcing all components through this single method override.

<br />

`void` `@https://developer.android.com/reference/androidx/annotation/MainThread
@https://developer.android.com/reference/androidx/annotation/CallSuper
[onDestroyView](https://developer.android.com/reference/androidx/fragment/app/Fragment#onDestroyView())()`

**This method is deprecated.** Deprecated in Java
`@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/view/LayoutInflater.html` `[onGetLayoutInflater](https://developer.android.com/reference/androidx/fragment/app/Fragment#onGetLayoutInflater(android.os.Bundle))(@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/android/os/Bundle.html savedInstanceState)`

**This method is deprecated.** Deprecated in Java
`void` `@https://developer.android.com/reference/androidx/annotation/MainThread
[onHiddenChanged](https://developer.android.com/reference/androidx/fragment/app/Fragment#onHiddenChanged(boolean))(boolean hidden)`

**This method is deprecated.** Deprecated in Java
`void` `@https://developer.android.com/reference/androidx/annotation/UiThread
@https://developer.android.com/reference/androidx/annotation/CallSuper
[onInflate](https://developer.android.com/reference/androidx/fragment/app/Fragment#onInflate(android.app.Activity,android.util.AttributeSet,android.os.Bundle))(
@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/app/Activity.html activity,
@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/util/AttributeSet.html attrs,
@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/android/os/Bundle.html savedInstanceState
)`

**This method is deprecated.**

See `https://developer.android.com/reference/androidx/fragment/app/Fragment#onInflate(android.content.Context,android.util.AttributeSet,android.os.Bundle)`.

<br />

`void` `@https://developer.android.com/reference/androidx/annotation/UiThread
@https://developer.android.com/reference/androidx/annotation/CallSuper
[onInflate](https://developer.android.com/reference/androidx/fragment/app/Fragment#onInflate(android.content.Context,android.util.AttributeSet,android.os.Bundle))(
@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/content/Context.html context,
@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/util/AttributeSet.html attrs,
@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/android/os/Bundle.html savedInstanceState
)`

**This method is deprecated.** Deprecated in Java
`void` `@https://developer.android.com/reference/androidx/annotation/MainThread
@https://developer.android.com/reference/androidx/annotation/CallSuper
[onLowMemory](https://developer.android.com/reference/androidx/fragment/app/Fragment#onLowMemory())()`

**This method is deprecated.**
`void` `[onMultiWindowModeChanged](https://developer.android.com/reference/androidx/fragment/app/Fragment#onMultiWindowModeChanged(boolean))(boolean isInMultiWindowMode)`

**This method is deprecated.** Deprecated in Java
`boolean` `@https://developer.android.com/reference/androidx/annotation/MainThread
[onOptionsItemSelected](https://developer.android.com/reference/androidx/fragment/app/Fragment#onOptionsItemSelected(android.view.MenuItem))(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/view/MenuItem.html item)`

**This method is deprecated.**

`https://developer.android.com/reference/androidx/activity/ComponentActivity` now implements `https://developer.android.com/reference/androidx/core/view/MenuHost`, an interface that allows any component, including your activity itself, to add menu items by calling `https://developer.android.com/reference/androidx/core/view/MenuHost#addMenuProvider(androidx.core.view.MenuProvider)` without forcing all components through this single method override.

<br />

`void` `@https://developer.android.com/reference/androidx/annotation/MainThread
[onOptionsMenuClosed](https://developer.android.com/reference/androidx/fragment/app/Fragment#onOptionsMenuClosed(android.view.Menu))(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/view/Menu.html menu)`

**This method is deprecated.**

`https://developer.android.com/reference/androidx/activity/ComponentActivity` now implements `https://developer.android.com/reference/androidx/core/view/MenuHost`, an interface that allows any component, including your activity itself, to add menu items by calling `https://developer.android.com/reference/androidx/core/view/MenuHost#addMenuProvider(androidx.core.view.MenuProvider)` without forcing all components through this single method override.

<br />

`void` `[onPictureInPictureModeChanged](https://developer.android.com/reference/androidx/fragment/app/Fragment#onPictureInPictureModeChanged(boolean))(boolean isInPictureInPictureMode)`

**This method is deprecated.** Deprecated in Java
`void` `@https://developer.android.com/reference/androidx/annotation/MainThread
[onPrepareOptionsMenu](https://developer.android.com/reference/androidx/fragment/app/Fragment#onPrepareOptionsMenu(android.view.Menu))(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/view/Menu.html menu)`

**This method is deprecated.**

`https://developer.android.com/reference/androidx/activity/ComponentActivity` now implements `https://developer.android.com/reference/androidx/core/view/MenuHost`, an interface that allows any component, including your activity itself, to add menu items by calling `https://developer.android.com/reference/androidx/core/view/MenuHost#addMenuProvider(androidx.core.view.MenuProvider)` without forcing all components through this single method override.

<br />

`void` `@https://developer.android.com/reference/androidx/annotation/MainThread
[onPrimaryNavigationFragmentChanged](https://developer.android.com/reference/androidx/fragment/app/Fragment#onPrimaryNavigationFragmentChanged(boolean))(
boolean isPrimaryNavigationFragment
)`

**This method is deprecated.** Deprecated in Java
`void` `[onRequestPermissionsResult](https://developer.android.com/reference/androidx/fragment/app/Fragment#onRequestPermissionsResult(int,java.lang.String[],int[]))(
int requestCode,
@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html String[] permissions,
@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html int[] grantResults
)`

**This method is deprecated.**

This method has been deprecated in favor of using the Activity Result API which brings increased type safety via an `https://developer.android.com/reference/androidx/activity/result/contract/ActivityResultContract` and the prebuilt contracts for common intents available in `https://developer.android.com/reference/androidx/activity/result/contract/ActivityResultContracts`, provides hooks for testing, and allow receiving results in separate, testable classes independent from your fragment.

<br />

`void` `@https://developer.android.com/reference/androidx/annotation/MainThread
[onSaveInstanceState](https://developer.android.com/reference/androidx/fragment/app/Fragment#onSaveInstanceState(android.os.Bundle))(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/os/Bundle.html outState)`

**This method is deprecated.** Deprecated in Java
`void` `@https://developer.android.com/reference/androidx/annotation/MainThread
@https://developer.android.com/reference/androidx/annotation/CallSuper
[onStart](https://developer.android.com/reference/androidx/fragment/app/Fragment#onStart())()`

**This method is deprecated.** Deprecated in Java
`void` `@https://developer.android.com/reference/androidx/annotation/MainThread
[onViewCreated](https://developer.android.com/reference/androidx/fragment/app/Fragment#onViewCreated(android.view.View,android.os.Bundle))(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/view/View.html view, @https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/android/os/Bundle.html savedInstanceState)`

**This method is deprecated.** Deprecated in Java
`void` `@https://developer.android.com/reference/androidx/annotation/MainThread
@https://developer.android.com/reference/androidx/annotation/CallSuper
[onViewStateRestored](https://developer.android.com/reference/androidx/fragment/app/Fragment#onViewStateRestored(android.os.Bundle))(@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/android/os/Bundle.html savedInstanceState)`

**This method is deprecated.** Deprecated in Java
`@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/android/content/Context.html` `[peekAvailableContext](https://developer.android.com/reference/androidx/fragment/app/Fragment#peekAvailableContext())()`

**This method is deprecated.** Deprecated in Java
`void` `[postponeEnterTransition](https://developer.android.com/reference/androidx/fragment/app/Fragment#postponeEnterTransition())()`

**This method is deprecated.** Deprecated in Java
`final void` `[postponeEnterTransition](https://developer.android.com/reference/androidx/fragment/app/Fragment#postponeEnterTransition(long,java.util.concurrent.TimeUnit))(long duration, @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/util/concurrent/TimeUnit.html timeUnit)`

**This method is deprecated.** Deprecated in Java
`final @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/activity/result/ActivityResultLauncher<I>` `@https://developer.android.com/reference/androidx/annotation/MainThread
<I, O> [registerForActivityResult](https://developer.android.com/reference/androidx/fragment/app/Fragment#registerForActivityResult(androidx.activity.result.contract.ActivityResultContract<I,O>,androidx.activity.result.ActivityResultCallback<O>))(
@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/activity/result/contract/ActivityResultContract<I, O> contract,
@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/activity/result/ActivityResultCallback<O> callback
)`

**This method is deprecated.** Deprecated in Java
`final @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/activity/result/ActivityResultLauncher<I>` `@https://developer.android.com/reference/androidx/annotation/MainThread
<I, O> [registerForActivityResult](https://developer.android.com/reference/androidx/fragment/app/Fragment#registerForActivityResult(androidx.activity.result.contract.ActivityResultContract<I,O>,androidx.activity.result.ActivityResultRegistry,androidx.activity.result.ActivityResultCallback<O>))(
@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/activity/result/contract/ActivityResultContract<I, O> contract,
@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/activity/result/ActivityResultRegistry registry,
@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/activity/result/ActivityResultCallback<O> callback
)`

**This method is deprecated.** Deprecated in Java
`void` `[registerForContextMenu](https://developer.android.com/reference/androidx/fragment/app/Fragment#registerForContextMenu(android.view.View))(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/view/View.html view)`

**This method is deprecated.** Deprecated in Java
`void` `[removeOnContextAvailableListener](https://developer.android.com/reference/androidx/fragment/app/Fragment#removeOnContextAvailableListener(androidx.activity.contextaware.OnContextAvailableListener))(
@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/activity/contextaware/OnContextAvailableListener listener
)`

**This method is deprecated.** Deprecated in Java
`final void` `[requestPermissions](https://developer.android.com/reference/androidx/fragment/app/Fragment#requestPermissions(java.lang.String[],int))(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html String[] permissions, int requestCode)`

**This method is deprecated.**

This method has been deprecated in favor of using the Activity Result API which brings increased type safety via an `https://developer.android.com/reference/androidx/activity/result/contract/ActivityResultContract` and the prebuilt contracts for common intents available in `https://developer.android.com/reference/androidx/activity/result/contract/ActivityResultContracts`, provides hooks for testing, and allow receiving results in separate, testable classes independent from your fragment.

<br />

`final @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/fragment/app/FragmentActivity` `[requireActivity](https://developer.android.com/reference/androidx/fragment/app/Fragment#requireActivity())()`

**This method is deprecated.** Deprecated in Java
`final @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/os/Bundle.html` `[requireArguments](https://developer.android.com/reference/androidx/fragment/app/Fragment#requireArguments())()`

**This method is deprecated.** Deprecated in Java
`final @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/content/Context.html` `[requireContext](https://developer.android.com/reference/androidx/fragment/app/Fragment#requireContext())()`

**This method is deprecated.** Deprecated in Java
`final @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/fragment/app/FragmentManager` `[requireFragmentManager](https://developer.android.com/reference/androidx/fragment/app/Fragment#requireFragmentManager())()`

**This method is deprecated.**

This has been renamed to `getParentFragmentManager()` to make it clear that you are accessing the FragmentManager that contains this Fragment and not the FragmentManager associated with child Fragments.

<br />

`final @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/lang/Object.html` `[requireHost](https://developer.android.com/reference/androidx/fragment/app/Fragment#requireHost())()`

**This method is deprecated.** Deprecated in Java
`final @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/fragment/app/Fragment` `[requireParentFragment](https://developer.android.com/reference/androidx/fragment/app/Fragment#requireParentFragment())()`

**This method is deprecated.** Deprecated in Java
`final @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/view/View.html` `[requireView](https://developer.android.com/reference/androidx/fragment/app/Fragment#requireView())()`

**This method is deprecated.** Deprecated in Java
`void` `[setAllowEnterTransitionOverlap](https://developer.android.com/reference/androidx/fragment/app/Fragment#setAllowEnterTransitionOverlap(boolean))(boolean allow)`

**This method is deprecated.** Deprecated in Java
`void` `[setAllowReturnTransitionOverlap](https://developer.android.com/reference/androidx/fragment/app/Fragment#setAllowReturnTransitionOverlap(boolean))(boolean allow)`

**This method is deprecated.** Deprecated in Java
`void` `[setArguments](https://developer.android.com/reference/androidx/fragment/app/Fragment#setArguments(android.os.Bundle))(@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/android/os/Bundle.html args)`

**This method is deprecated.** Deprecated in Java
`void` `[setEnterSharedElementCallback](https://developer.android.com/reference/androidx/fragment/app/Fragment#setEnterSharedElementCallback(androidx.core.app.SharedElementCallback))(@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/androidx/core/app/SharedElementCallback callback)`

**This method is deprecated.** Deprecated in Java
`void` `[setEnterTransition](https://developer.android.com/reference/androidx/fragment/app/Fragment#setEnterTransition(java.lang.Object))(@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/java/lang/Object.html transition)`

**This method is deprecated.** Deprecated in Java
`void` `[setExitSharedElementCallback](https://developer.android.com/reference/androidx/fragment/app/Fragment#setExitSharedElementCallback(androidx.core.app.SharedElementCallback))(@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/androidx/core/app/SharedElementCallback callback)`

**This method is deprecated.** Deprecated in Java
`void` `[setExitTransition](https://developer.android.com/reference/androidx/fragment/app/Fragment#setExitTransition(java.lang.Object))(@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/java/lang/Object.html transition)`

**This method is deprecated.** Deprecated in Java
`void` `[setHasOptionsMenu](https://developer.android.com/reference/androidx/fragment/app/Fragment#setHasOptionsMenu(boolean))(boolean hasMenu)`

**This method is deprecated.**

This method is no longer needed when using a `https://developer.android.com/reference/androidx/core/view/MenuProvider` to provide a `https://developer.android.com/reference/android/view/Menu.html` to your activity, which replaces `https://developer.android.com/reference/androidx/fragment/app/Fragment#onCreateOptionsMenu(android.view.Menu,android.view.MenuInflater)` as the recommended way to provide a consistent, optionally `https://developer.android.com/reference/androidx/lifecycle/Lifecycle`-aware, and modular way to handle menu creation and item selection.

<br />

`void` `[setInitialSavedState](https://developer.android.com/reference/androidx/fragment/app/Fragment#setInitialSavedState(androidx.fragment.app.Fragment.SavedState))(@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/androidx/fragment/app/Fragment.SavedState state)`

**This method is deprecated.** Deprecated in Java
`void` `[setMenuVisibility](https://developer.android.com/reference/androidx/fragment/app/Fragment#setMenuVisibility(boolean))(boolean menuVisible)`

**This method is deprecated.** Deprecated in Java
`void` `[setReenterTransition](https://developer.android.com/reference/androidx/fragment/app/Fragment#setReenterTransition(java.lang.Object))(@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/java/lang/Object.html transition)`

**This method is deprecated.** Deprecated in Java
`void` `[setRetainInstance](https://developer.android.com/reference/androidx/fragment/app/Fragment#setRetainInstance(boolean))(boolean retain)`

**This method is deprecated.**

Instead of retaining the Fragment itself, use a non-retained Fragment and keep retained state in a ViewModel attached to that Fragment.

<br />

`void` `[setReturnTransition](https://developer.android.com/reference/androidx/fragment/app/Fragment#setReturnTransition(java.lang.Object))(@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/java/lang/Object.html transition)`

**This method is deprecated.** Deprecated in Java
`void` `[setSharedElementEnterTransition](https://developer.android.com/reference/androidx/fragment/app/Fragment#setSharedElementEnterTransition(java.lang.Object))(@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/java/lang/Object.html transition)`

**This method is deprecated.** Deprecated in Java
`void` `[setSharedElementReturnTransition](https://developer.android.com/reference/androidx/fragment/app/Fragment#setSharedElementReturnTransition(java.lang.Object))(@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/java/lang/Object.html transition)`

**This method is deprecated.** Deprecated in Java
`void` `[setTargetFragment](https://developer.android.com/reference/androidx/fragment/app/Fragment#setTargetFragment(androidx.fragment.app.Fragment,int))(@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/androidx/fragment/app/Fragment fragment, int requestCode)`

**This method is deprecated.**

Instead of using a target fragment to pass results, the fragment requesting a result should use `https://developer.android.com/reference/androidx/fragment/app/FragmentManager#setFragmentResultListener(java.lang.String,androidx.lifecycle.LifecycleOwner,androidx.fragment.app.FragmentResultListener)` to register a `https://developer.android.com/reference/androidx/fragment/app/FragmentResultListener` with a `
requestKey` using its `https://developer.android.com/reference/androidx/fragment/app/Fragment#getParentFragmentManager()`.

<br />

`void` `[setUserVisibleHint](https://developer.android.com/reference/androidx/fragment/app/Fragment#setUserVisibleHint(boolean))(boolean isVisibleToUser)`

**This method is deprecated.**

If you are manually calling this method, use `https://developer.android.com/reference/androidx/fragment/app/FragmentTransaction#setMaxLifecycle(androidx.fragment.app.Fragment,androidx.lifecycle.Lifecycle.State)` instead.

<br />

`boolean` `[shouldShowRequestPermissionRationale](https://developer.android.com/reference/androidx/fragment/app/Fragment#shouldShowRequestPermissionRationale(java.lang.String))(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/lang/String.html permission)`

**This method is deprecated.** Deprecated in Java
`void` `[startActivity](https://developer.android.com/reference/androidx/fragment/app/Fragment#startActivity(android.content.Intent))(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/content/Intent.html intent)`

**This method is deprecated.** Deprecated in Java
`void` `[startActivity](https://developer.android.com/reference/androidx/fragment/app/Fragment#startActivity(android.content.Intent,android.os.Bundle))(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/content/Intent.html intent, @https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/android/os/Bundle.html options)`

**This method is deprecated.** Deprecated in Java
`void` `[startActivityForResult](https://developer.android.com/reference/androidx/fragment/app/Fragment#startActivityForResult(android.content.Intent,int))(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/content/Intent.html intent, int requestCode)`

**This method is deprecated.**

This method has been deprecated in favor of using the Activity Result API which brings increased type safety via an `https://developer.android.com/reference/androidx/activity/result/contract/ActivityResultContract` and the prebuilt contracts for common intents available in `https://developer.android.com/reference/androidx/activity/result/contract/ActivityResultContracts`, provides hooks for testing, and allow receiving results in separate, testable classes independent from your fragment.

<br />

`void` `[startActivityForResult](https://developer.android.com/reference/androidx/fragment/app/Fragment#startActivityForResult(android.content.Intent,int,android.os.Bundle))(
@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/content/Intent.html intent,
int requestCode,
@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/android/os/Bundle.html options
)`

**This method is deprecated.**

This method has been deprecated in favor of using the Activity Result API which brings increased type safety via an `https://developer.android.com/reference/androidx/activity/result/contract/ActivityResultContract` and the prebuilt contracts for common intents available in `https://developer.android.com/reference/androidx/activity/result/contract/ActivityResultContracts`, provides hooks for testing, and allow receiving results in separate, testable classes independent from your fragment.

<br />

`void` `[startIntentSenderForResult](https://developer.android.com/reference/androidx/fragment/app/Fragment#startIntentSenderForResult(android.content.IntentSender,int,android.content.Intent,int,int,int,android.os.Bundle))(
@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/content/IntentSender.html intent,
int requestCode,
@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/android/content/Intent.html fillInIntent,
int flagsMask,
int flagsValues,
int extraFlags,
@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/android/os/Bundle.html options
)`

**This method is deprecated.**

This method has been deprecated in favor of using the Activity Result API which brings increased type safety via an `https://developer.android.com/reference/androidx/activity/result/contract/ActivityResultContract` and the prebuilt contracts for common intents available in `https://developer.android.com/reference/androidx/activity/result/contract/ActivityResultContracts`, provides hooks for testing, and allow receiving results in separate, testable classes independent from your fragment.

<br />

`void` `[startPostponedEnterTransition](https://developer.android.com/reference/androidx/fragment/app/Fragment#startPostponedEnterTransition())()`

**This method is deprecated.** Deprecated in Java
`@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/lang/String.html` `[toString](https://developer.android.com/reference/androidx/fragment/app/Fragment#toString())()`

**This method is deprecated.** Deprecated in Java
`void` `[unregisterForContextMenu](https://developer.android.com/reference/androidx/fragment/app/Fragment#unregisterForContextMenu(android.view.View))(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/view/View.html view)`

**This method is deprecated.** Deprecated in Java
From [androidx.lifecycle.HasDefaultViewModelProviderFactory](https://developer.android.com/reference/androidx/lifecycle/HasDefaultViewModelProviderFactory) `https://developer.android.com/reference/androidx/lifecycle/viewmodel/CreationExtras` `[getDefaultViewModelCreationExtras](https://developer.android.com/reference/androidx/lifecycle/HasDefaultViewModelProviderFactory#getDefaultViewModelCreationExtras())()`

**This method is deprecated.** Deprecated in Java
`https://developer.android.com/reference/androidx/lifecycle/ViewModelProvider.Factory` `[getDefaultViewModelProviderFactory](https://developer.android.com/reference/androidx/lifecycle/HasDefaultViewModelProviderFactory#getDefaultViewModelProviderFactory())()`

**This method is deprecated.** Deprecated in Java
From [androidx.lifecycle.LifecycleOwner](https://developer.android.com/reference/androidx/lifecycle/LifecycleOwner) `abstract https://developer.android.com/reference/androidx/lifecycle/Lifecycle` `[getLifecycle](https://developer.android.com/reference/androidx/lifecycle/LifecycleOwner#getLifecycle())()`

**This method is deprecated.** Deprecated in Java
From [androidx.savedstate.SavedStateRegistryOwner](https://developer.android.com/reference/androidx/savedstate/SavedStateRegistryOwner) `abstract https://developer.android.com/reference/androidx/savedstate/SavedStateRegistry` `[getSavedStateRegistry](https://developer.android.com/reference/androidx/savedstate/SavedStateRegistryOwner#getSavedStateRegistry())()`

**This method is deprecated.** Deprecated in Java
From [android.view.View.OnCreateContextMenuListener](https://developer.android.com/reference/android/view/View.OnCreateContextMenuListener.html) `abstract void` `[onCreateContextMenu](https://developer.android.com/reference/android/view/View.OnCreateContextMenuListener.html#onCreateContextMenu(android.view.ContextMenu, android.view.View, android.view.ContextMenu.ContextMenuInfo))(
https://developer.android.com/reference/android/view/ContextMenu.html p,
https://developer.android.com/reference/android/view/View.html p1,
https://developer.android.com/reference/android/view/ContextMenu.ContextMenuInfo.html p2
)`

**This method is deprecated.** Deprecated in Java
From [androidx.lifecycle.ViewModelStoreOwner](https://developer.android.com/reference/androidx/lifecycle/ViewModelStoreOwner) `abstract https://developer.android.com/reference/androidx/lifecycle/ViewModelStore` `[getViewModelStore](https://developer.android.com/reference/androidx/lifecycle/ViewModelStoreOwner#getViewModelStore())()`

**This method is deprecated.** Deprecated in Java

## Constants

### EXTRA_BURN_IN_PROTECTION

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/wear#1.1.0) Deprecated in [1.3.0](https://developer.android.com/jetpack/androidx/releases/wear#1.3.0)

```
public static final String EXTRA_BURN_IN_PROTECTION = "com.google.android.wearable.compat.extra.BURN_IN_PROTECTION"
```

> [!CAUTION]
> **This field is deprecated.**   
> Deprecated in Java

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.

### EXTRA_LOWBIT_AMBIENT

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/wear#1.1.0) Deprecated in [1.3.0](https://developer.android.com/jetpack/androidx/releases/wear#1.3.0)

```
public static final String EXTRA_LOWBIT_AMBIENT = "com.google.android.wearable.compat.extra.LOWBIT_AMBIENT"
```

> [!CAUTION]
> **This field is deprecated.**   
> Deprecated in Java

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.

### FRAGMENT_TAG

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/wear#1.1.0) Deprecated in [1.3.0](https://developer.android.com/jetpack/androidx/releases/wear#1.3.0)

```
public static final String FRAGMENT_TAG = "android.support.wearable.ambient.AmbientMode"
```

> [!CAUTION]
> **This field is deprecated.**   
> Deprecated in Java

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

## Public constructors

### AmbientModeSupport

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/wear#1.1.0) Deprecated in [1.3.0](https://developer.android.com/jetpack/androidx/releases/wear#1.3.0)

```
public [AmbientModeSupport](https://developer.android.com/reference/androidx/wear/ambient/AmbientModeSupport#AmbientModeSupport())()
```

> [!CAUTION]
> **This method is deprecated.**   
> Deprecated in Java

Constructor

## Public methods

### attach

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/wear#1.1.0) Deprecated in [1.3.0](https://developer.android.com/jetpack/androidx/releases/wear#1.3.0)

```
public static AmbientModeSupport.AmbientController <T extends FragmentActivity> [attach](https://developer.android.com/reference/androidx/wear/ambient/AmbientModeSupport#attach(T))(T activity)
```

> [!CAUTION]
> **This method is deprecated.**   
> Deprecated in Java

Attach ambient support to the given activity. Calling this method with an Activity implementing the `https://developer.android.com/reference/androidx/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/androidx/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/androidx/wear/ambient/AmbientModeSupport.AmbientCallbackProvider`.

| Parameters |
|---|---|
| `T activity` | the activity to attach ambient support to. |

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

### dump

```
public void [dump](https://developer.android.com/reference/androidx/wear/ambient/AmbientModeSupport#dump(java.lang.String,java.io.FileDescriptor,java.io.PrintWriter,java.lang.String[]))(String prefix, FileDescriptor fd, PrintWriter writer, String[] args)
```

> [!CAUTION]
> **This method is deprecated.**   
> Deprecated in Java

Print the Fragments's state into the given stream.

| Parameters |
|---|---|
| `https://developer.android.com/reference/java/lang/String.html prefix` | Text to print at the front of each line. |
| `https://developer.android.com/reference/java/io/FileDescriptor.html fd` | The raw file descriptor that the dump is being sent to. |
| `https://developer.android.com/reference/java/io/PrintWriter.html writer` | The PrintWriter to which you should dump your state. This will be closed for you after you return. |
| `String[] args` | additional arguments to the dump request. |

### onAttach

```
@CallSuper
public void [onAttach](https://developer.android.com/reference/androidx/wear/ambient/AmbientModeSupport#onAttach(android.content.Context))(Context context)
```

> [!CAUTION]
> **This method is deprecated.**   
> Deprecated in Java

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

### onCreate

```
@CallSuper
public void [onCreate](https://developer.android.com/reference/androidx/wear/ambient/AmbientModeSupport#onCreate(android.os.Bundle))(Bundle savedInstanceState)
```

> [!CAUTION]
> **This method is deprecated.**   
> Deprecated in Java

Called to do initial creation of a fragment. This is called after `https://developer.android.com/reference/androidx/fragment/app/Fragment#onAttach(android.app.Activity)` and before `https://developer.android.com/reference/androidx/fragment/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, add a `https://developer.android.com/reference/androidx/lifecycle/LifecycleObserver` on the activity's Lifecycle, removing it when it receives the `https://developer.android.com/reference/androidx/lifecycle/Lifecycle.State#CREATED` callback.

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

| Parameters |
|---|---|
| `https://developer.android.com/reference/android/os/Bundle.html savedInstanceState` | If the fragment is being re-created from a previous saved state, this is the state. |

### onDestroy

```
@CallSuper
public void [onDestroy](https://developer.android.com/reference/androidx/wear/ambient/AmbientModeSupport#onDestroy())()
```

> [!CAUTION]
> **This method is deprecated.**   
> Deprecated in Java

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

### onDetach

```
@CallSuper
public void [onDetach](https://developer.android.com/reference/androidx/wear/ambient/AmbientModeSupport#onDetach())()
```

> [!CAUTION]
> **This method is deprecated.**   
> Deprecated in Java

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

### onPause

```
@CallSuper
public void [onPause](https://developer.android.com/reference/androidx/wear/ambient/AmbientModeSupport#onPause())()
```

> [!CAUTION]
> **This method is deprecated.**   
> Deprecated in Java

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.

### onResume

```
@CallSuper
public void [onResume](https://developer.android.com/reference/androidx/wear/ambient/AmbientModeSupport#onResume())()
```

> [!CAUTION]
> **This method is deprecated.**   
> Deprecated in Java

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.

### onStop

```
@CallSuper
public void [onStop](https://developer.android.com/reference/androidx/wear/ambient/AmbientModeSupport#onStop())()
```

> [!CAUTION]
> **This method is deprecated.**   
> Deprecated in Java

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.