# FragmentManager

Added in[API level 11](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  
Deprecated in[API level 28](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  
Summary:[Nested Classes](https://developer.android.com/reference/android/app/FragmentManager#nestedclasses)\|[Constants](https://developer.android.com/reference/android/app/FragmentManager#constants)\|[Ctors](https://developer.android.com/reference/android/app/FragmentManager#pubctors)\|[Methods](https://developer.android.com/reference/android/app/FragmentManager#pubmethods)\|[Inherited Methods](https://developer.android.com/reference/android/app/FragmentManager#inhmethods)  

# FragmentManager

*** ** * ** ***

[Kotlin](https://developer.android.com/reference/kotlin/android/app/FragmentManager "View this page in Kotlin")\|Java

`
public


abstract
class
FragmentManager
`  
`

extends `[Object](https://developer.android.com/reference/java/lang/Object)`


``


`

|---|-----------------------------|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object) ||
| ↳ | android.app.FragmentManager |

<br />

*** ** * ** ***

<br />

**This class was deprecated in API level 28.**   
Use the[Support Library](https://developer.android.com/tools/extras/support-library)[FragmentManager](https://developer.android.com/reference/androidx/fragment/app/FragmentManager.html)for consistent behavior across all devices and access to[Lifecycle](https://developer.android.com/topic/libraries/architecture/lifecycle).

Interface for interacting with[Fragment](https://developer.android.com/reference/android/app/Fragment)objects inside of an[Activity](https://developer.android.com/reference/android/app/Activity)  

### Developer Guides

For more information about using fragments, read the[Fragments](https://developer.android.com/guide/components/fragments)developer guide.
While the FragmentManager API was introduced in[Build.VERSION_CODES.HONEYCOMB](https://developer.android.com/reference/android/os/Build.VERSION_CODES#HONEYCOMB), a version of the API at is also available for use on older platforms through[FragmentActivity](https://developer.android.com/reference/androidx/fragment/app/FragmentActivity.html). See the blog post[Fragments For All](http://android-developers.blogspot.com/2011/03/fragments-for-all.html)for more details.

<br />

## Summary

|                                                                                                                                                                                                                     ### Nested classes                                                                                                                                                                                                                      ||
|--------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| ` interface` | [FragmentManager.BackStackEntry](https://developer.android.com/reference/android/app/FragmentManager.BackStackEntry) *This interface was deprecated in API level 28. Use the[Support Library](https://developer.android.com/tools/extras/support-library)[FragmentManager.BackStackEntry](https://developer.android.com/reference/androidx/fragment/app/FragmentManager.BackStackEntry.html)*                                                 |
| ` class`     | [FragmentManager.FragmentLifecycleCallbacks](https://developer.android.com/reference/android/app/FragmentManager.FragmentLifecycleCallbacks) *This class was deprecated in API level 28. Use the[Support Library](https://developer.android.com/tools/extras/support-library)[FragmentManager.FragmentLifecycleCallbacks](https://developer.android.com/reference/androidx/fragment/app/FragmentManager.FragmentLifecycleCallbacks.html)*     |
| ` interface` | [FragmentManager.OnBackStackChangedListener](https://developer.android.com/reference/android/app/FragmentManager.OnBackStackChangedListener) *This interface was deprecated in API level 28. Use the[Support Library](https://developer.android.com/tools/extras/support-library)[FragmentManager.OnBackStackChangedListener](https://developer.android.com/reference/androidx/fragment/app/FragmentManager.OnBackStackChangedListener.html)* |

|                                                                                                                                                                                                                                                                                                 ### Constants                                                                                                                                                                                                                                                                                                  ||
|-------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `int` | [POP_BACK_STACK_INCLUSIVE](https://developer.android.com/reference/android/app/FragmentManager#POP_BACK_STACK_INCLUSIVE) Flag for[popBackStack(java.lang.String, int)](https://developer.android.com/reference/android/app/FragmentManager#popBackStack(java.lang.String,%20int))and[popBackStack(int, int)](https://developer.android.com/reference/android/app/FragmentManager#popBackStack(int,%20int)): If set, and the name or ID of a back stack entry has been supplied, then all matching entries will be consumed until one that doesn't match is found or the bottom of the stack is reached. |

|                                               ### Public constructors                                               ||
|------------------------------------------------------------------------------------------------------------------|---|
| ` `[FragmentManager](https://developer.android.com/reference/android/app/FragmentManager#FragmentManager())`() ` |

|                                                                                                                                                                                                                                                                                                                                                                                                      ### Public methods                                                                                                                                                                                                                                                                                                                                                                                                       ||
|----------------------------------------------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| ` abstract void`                                                                                                                                         | ` `[addOnBackStackChangedListener](https://developer.android.com/reference/android/app/FragmentManager#addOnBackStackChangedListener(android.app.FragmentManager.OnBackStackChangedListener))`(`[FragmentManager.OnBackStackChangedListener](https://developer.android.com/reference/android/app/FragmentManager.OnBackStackChangedListener)` listener) ` Add a new listener for changes to the fragment back stack.                                                                                                                                                                                                                                                |
| ` abstract `[FragmentTransaction](https://developer.android.com/reference/android/app/FragmentTransaction)                                               | ` `[beginTransaction](https://developer.android.com/reference/android/app/FragmentManager#beginTransaction())`() ` Start a series of edit operations on the Fragments associated with this FragmentManager.                                                                                                                                                                                                                                                                                                                                                                                                                                                         |
| ` abstract void`                                                                                                                                         | ` `[dump](https://developer.android.com/reference/android/app/FragmentManager#dump(java.lang.String,%20java.io.FileDescriptor,%20java.io.PrintWriter,%20java.lang.String[]))`(`[String](https://developer.android.com/reference/java/lang/String)` prefix, `[FileDescriptor](https://developer.android.com/reference/java/io/FileDescriptor)` fd, `[PrintWriter](https://developer.android.com/reference/java/io/PrintWriter)` writer, `[String[]](https://developer.android.com/reference/java/lang/String)` args) ` Print the FragmentManager's state into the given stream.                                                                                      |
| ` static void`                                                                                                                                           | ` `[enableDebugLogging](https://developer.android.com/reference/android/app/FragmentManager#enableDebugLogging(boolean))`(boolean enabled) ` Control whether the framework's internal fragment manager debugging logs are turned on.                                                                                                                                                                                                                                                                                                                                                                                                                                |
| ` abstract boolean`                                                                                                                                      | ` `[executePendingTransactions](https://developer.android.com/reference/android/app/FragmentManager#executePendingTransactions())`() ` After a[FragmentTransaction](https://developer.android.com/reference/android/app/FragmentTransaction)is committed with[FragmentTransaction.commit()](https://developer.android.com/reference/android/app/FragmentTransaction#commit()), it is scheduled to be executed asynchronously on the process's main thread.                                                                                                                                                                                                          |
| ` abstract `[Fragment](https://developer.android.com/reference/android/app/Fragment)                                                                     | ` `[findFragmentById](https://developer.android.com/reference/android/app/FragmentManager#findFragmentById(int))`(int id) ` Finds a fragment that was identified by the given id either when inflated from XML or as the container ID when added in a transaction.                                                                                                                                                                                                                                                                                                                                                                                                  |
| ` abstract `[Fragment](https://developer.android.com/reference/android/app/Fragment)                                                                     | ` `[findFragmentByTag](https://developer.android.com/reference/android/app/FragmentManager#findFragmentByTag(java.lang.String))`(`[String](https://developer.android.com/reference/java/lang/String)` tag) ` Finds a fragment that was identified by the given tag either when inflated from XML or as supplied when added in a transaction.                                                                                                                                                                                                                                                                                                                        |
| ` abstract `[FragmentManager.BackStackEntry](https://developer.android.com/reference/android/app/FragmentManager.BackStackEntry)                         | ` `[getBackStackEntryAt](https://developer.android.com/reference/android/app/FragmentManager#getBackStackEntryAt(int))`(int index) ` Return the BackStackEntry at index<var translate="no">index</var>in the back stack; where the item on the bottom of the stack has index 0.                                                                                                                                                                                                                                                                                                                                                                                     |
| ` abstract int`                                                                                                                                          | ` `[getBackStackEntryCount](https://developer.android.com/reference/android/app/FragmentManager#getBackStackEntryCount())`() ` Return the number of entries currently in the back stack.                                                                                                                                                                                                                                                                                                                                                                                                                                                                            |
| ` abstract `[Fragment](https://developer.android.com/reference/android/app/Fragment)                                                                     | ` `[getFragment](https://developer.android.com/reference/android/app/FragmentManager#getFragment(android.os.Bundle,%20java.lang.String))`(`[Bundle](https://developer.android.com/reference/android/os/Bundle)` bundle, `[String](https://developer.android.com/reference/java/lang/String)` key) ` Retrieve the current Fragment instance for a reference previously placed with[putFragment(android.os.Bundle, java.lang.String, android.app.Fragment)](https://developer.android.com/reference/android/app/FragmentManager#putFragment(android.os.Bundle,%20java.lang.String,%20android.app.Fragment)).                                                          |
| ` abstract `[List](https://developer.android.com/reference/java/util/List)`<`[Fragment](https://developer.android.com/reference/android/app/Fragment)`>` | ` `[getFragments](https://developer.android.com/reference/android/app/FragmentManager#getFragments())`() ` Get a list of all fragments that are currently added to the FragmentManager.                                                                                                                                                                                                                                                                                                                                                                                                                                                                             |
| ` abstract `[Fragment](https://developer.android.com/reference/android/app/Fragment)                                                                     | ` `[getPrimaryNavigationFragment](https://developer.android.com/reference/android/app/FragmentManager#getPrimaryNavigationFragment())`() ` Return the currently active primary navigation fragment for this FragmentManager.                                                                                                                                                                                                                                                                                                                                                                                                                                        |
| ` void`                                                                                                                                                  | ` `[invalidateOptionsMenu](https://developer.android.com/reference/android/app/FragmentManager#invalidateOptionsMenu())`() ` Invalidate the attached activity's options menu as necessary.                                                                                                                                                                                                                                                                                                                                                                                                                                                                          |
| ` abstract boolean`                                                                                                                                      | ` `[isDestroyed](https://developer.android.com/reference/android/app/FragmentManager#isDestroyed())`() ` Returns true if the final[Activity.onDestroy()](https://developer.android.com/reference/android/app/Activity#onDestroy())call has been made on the FragmentManager's Activity, so this instance is now dead.                                                                                                                                                                                                                                                                                                                                               |
| ` abstract boolean`                                                                                                                                      | ` `[isStateSaved](https://developer.android.com/reference/android/app/FragmentManager#isStateSaved())`() ` Returns`true`if the FragmentManager's state has already been saved by its host.                                                                                                                                                                                                                                                                                                                                                                                                                                                                          |
| ` abstract void`                                                                                                                                         | ` `[popBackStack](https://developer.android.com/reference/android/app/FragmentManager#popBackStack())`() ` Pop the top state off the back stack.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    |
| ` abstract void`                                                                                                                                         | ` `[popBackStack](https://developer.android.com/reference/android/app/FragmentManager#popBackStack(int,%20int))`(int id, int flags) ` Pop all back stack states up to the one with the given identifier.                                                                                                                                                                                                                                                                                                                                                                                                                                                            |
| ` abstract void`                                                                                                                                         | ` `[popBackStack](https://developer.android.com/reference/android/app/FragmentManager#popBackStack(java.lang.String,%20int))`(`[String](https://developer.android.com/reference/java/lang/String)` name, int flags) ` Pop the last fragment transition from the manager's fragment back stack.                                                                                                                                                                                                                                                                                                                                                                      |
| ` abstract boolean`                                                                                                                                      | ` `[popBackStackImmediate](https://developer.android.com/reference/android/app/FragmentManager#popBackStackImmediate())`() ` Like[popBackStack()](https://developer.android.com/reference/android/app/FragmentManager#popBackStack()), but performs the operation immediately inside of the call.                                                                                                                                                                                                                                                                                                                                                                   |
| ` abstract boolean`                                                                                                                                      | ` `[popBackStackImmediate](https://developer.android.com/reference/android/app/FragmentManager#popBackStackImmediate(int,%20int))`(int id, int flags) ` Like[popBackStack(int, int)](https://developer.android.com/reference/android/app/FragmentManager#popBackStack(int,%20int)), but performs the operation immediately inside of the call.                                                                                                                                                                                                                                                                                                                      |
| ` abstract boolean`                                                                                                                                      | ` `[popBackStackImmediate](https://developer.android.com/reference/android/app/FragmentManager#popBackStackImmediate(java.lang.String,%20int))`(`[String](https://developer.android.com/reference/java/lang/String)` name, int flags) ` Like[popBackStack(java.lang.String, int)](https://developer.android.com/reference/android/app/FragmentManager#popBackStack(java.lang.String,%20int)), but performs the operation immediately inside of the call.                                                                                                                                                                                                            |
| ` abstract void`                                                                                                                                         | ` `[putFragment](https://developer.android.com/reference/android/app/FragmentManager#putFragment(android.os.Bundle,%20java.lang.String,%20android.app.Fragment))`(`[Bundle](https://developer.android.com/reference/android/os/Bundle)` bundle, `[String](https://developer.android.com/reference/java/lang/String)` key, `[Fragment](https://developer.android.com/reference/android/app/Fragment)` fragment) ` Put a reference to a fragment in a Bundle.                                                                                                                                                                                                         |
| ` abstract void`                                                                                                                                         | ` `[registerFragmentLifecycleCallbacks](https://developer.android.com/reference/android/app/FragmentManager#registerFragmentLifecycleCallbacks(android.app.FragmentManager.FragmentLifecycleCallbacks,%20boolean))`(`[FragmentManager.FragmentLifecycleCallbacks](https://developer.android.com/reference/android/app/FragmentManager.FragmentLifecycleCallbacks)` cb, boolean recursive) ` Registers a[FragmentLifecycleCallbacks](https://developer.android.com/reference/android/app/FragmentManager.FragmentLifecycleCallbacks)to listen to fragment lifecycle events happening in this FragmentManager.                                                        |
| ` abstract void`                                                                                                                                         | ` `[removeOnBackStackChangedListener](https://developer.android.com/reference/android/app/FragmentManager#removeOnBackStackChangedListener(android.app.FragmentManager.OnBackStackChangedListener))`(`[FragmentManager.OnBackStackChangedListener](https://developer.android.com/reference/android/app/FragmentManager.OnBackStackChangedListener)` listener) ` Remove a listener that was previously added with[addOnBackStackChangedListener(android.app.FragmentManager.OnBackStackChangedListener)](https://developer.android.com/reference/android/app/FragmentManager#addOnBackStackChangedListener(android.app.FragmentManager.OnBackStackChangedListener)). |
| ` abstract `[Fragment.SavedState](https://developer.android.com/reference/android/app/Fragment.SavedState)                                               | ` `[saveFragmentInstanceState](https://developer.android.com/reference/android/app/FragmentManager#saveFragmentInstanceState(android.app.Fragment))`(`[Fragment](https://developer.android.com/reference/android/app/Fragment)` f) ` Save the current instance state of the given Fragment.                                                                                                                                                                                                                                                                                                                                                                         |
| ` abstract void`                                                                                                                                         | ` `[unregisterFragmentLifecycleCallbacks](https://developer.android.com/reference/android/app/FragmentManager#unregisterFragmentLifecycleCallbacks(android.app.FragmentManager.FragmentLifecycleCallbacks))`(`[FragmentManager.FragmentLifecycleCallbacks](https://developer.android.com/reference/android/app/FragmentManager.FragmentLifecycleCallbacks)` cb) ` Unregisters a previously registered[FragmentLifecycleCallbacks](https://developer.android.com/reference/android/app/FragmentManager.FragmentLifecycleCallbacks).                                                                                                                                  |

| ### Inherited methods |
|-----------------------|---|
| From class` `[java.lang.Object](https://developer.android.com/reference/java/lang/Object)` ` |--------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | ` `[Object](https://developer.android.com/reference/java/lang/Object)          | ` `[clone](https://developer.android.com/reference/java/lang/Object#clone())`() ` Creates and returns a copy of this object.                                                                                                                                                      | | ` boolean`                                                                     | ` `[equals](https://developer.android.com/reference/java/lang/Object#equals(java.lang.Object))`(`[Object](https://developer.android.com/reference/java/lang/Object)` obj) ` Indicates whether some other object is "equal to" this one.                                           | | ` void`                                                                        | ` `[finalize](https://developer.android.com/reference/java/lang/Object#finalize())`() ` Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.                                                          | | ` final `[Class](https://developer.android.com/reference/java/lang/Class)`<?>` | ` `[getClass](https://developer.android.com/reference/java/lang/Object#getClass())`() ` Returns the runtime class of this`Object`.                                                                                                                                                | | ` int`                                                                         | ` `[hashCode](https://developer.android.com/reference/java/lang/Object#hashCode())`() ` Returns a hash code value for the object.                                                                                                                                                 | | ` final void`                                                                  | ` `[notify](https://developer.android.com/reference/java/lang/Object#notify())`() ` Wakes up a single thread that is waiting on this object's monitor.                                                                                                                            | | ` final void`                                                                  | ` `[notifyAll](https://developer.android.com/reference/java/lang/Object#notifyAll())`() ` Wakes up all threads that are waiting on this object's monitor.                                                                                                                         | | ` `[String](https://developer.android.com/reference/java/lang/String)          | ` `[toString](https://developer.android.com/reference/java/lang/Object#toString())`() ` Returns a string representation of the object.                                                                                                                                            | | ` final void`                                                                  | ` `[wait](https://developer.android.com/reference/java/lang/Object#wait(long,%20int))`(long timeoutMillis, int nanos) ` Causes the current thread to wait until it is awakened, typically by being*notified* or*interrupted*, or until a certain amount of real time has elapsed. | | ` final void`                                                                  | ` `[wait](https://developer.android.com/reference/java/lang/Object#wait(long))`(long timeoutMillis) ` Causes the current thread to wait until it is awakened, typically by being*notified* or*interrupted*, or until a certain amount of real time has elapsed.                   | | ` final void`                                                                  | ` `[wait](https://developer.android.com/reference/java/lang/Object#wait())`() ` Causes the current thread to wait until it is awakened, typically by being*notified* or*interrupted*.                                                                                             | ||

## Constants

### POP_BACK_STACK_INCLUSIVE

Added in[API level 11](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public static final int POP_BACK_STACK_INCLUSIVE
```

Flag for[popBackStack(java.lang.String, int)](https://developer.android.com/reference/android/app/FragmentManager#popBackStack(java.lang.String,%20int))and[popBackStack(int, int)](https://developer.android.com/reference/android/app/FragmentManager#popBackStack(int,%20int)): If set, and the name or ID of a back stack entry has been supplied, then all matching entries will be consumed until one that doesn't match is found or the bottom of the stack is reached. Otherwise, all entries up to but not including that entry will be removed.

<br />

Constant Value: 1 (0x00000001)

## Public constructors

### FragmentManager

```
public FragmentManager ()
```

<br />

<br />

## Public methods

### addOnBackStackChangedListener

Added in[API level 11](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public abstract void addOnBackStackChangedListener (FragmentManager.OnBackStackChangedListener listener)
```

Add a new listener for changes to the fragment back stack.

<br />

|                           Parameters                            ||
|------------|-----------------------------------------------------|
| `listener` | `FragmentManager.OnBackStackChangedListener` <br /> |

### beginTransaction

Added in[API level 11](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public abstract FragmentTransaction beginTransaction ()
```

Start a series of edit operations on the Fragments associated with this FragmentManager.

Note: A fragment transaction can only be created/committed prior to an activity saving its state. If you try to commit a transaction after[Activity.onSaveInstanceState()](https://developer.android.com/reference/android/app/Activity#onSaveInstanceState(android.os.Bundle))(and prior to a following[Activity.onStart](https://developer.android.com/reference/android/app/Activity#onStart())or[Activity.onResume()](https://developer.android.com/reference/android/app/Activity#onResume()), you will get an error. This is because the framework takes care of saving your current fragments in the state, and if changes are made after the state is saved then they will be lost.

<br />

<br />

|                                                Returns                                                 ||
|------------------------------------------------------------------------------------------------|--------|
| [FragmentTransaction](https://developer.android.com/reference/android/app/FragmentTransaction) | <br /> |

### dump

Added in[API level 11](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

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

Print the FragmentManager'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`: A PrintWriter to which the dump is to be set. <br />              |
| `args`   | `String`: Additional arguments to the dump request. <br />                       |

### enableDebugLogging

Added in[API level 11](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public static void enableDebugLogging (boolean enabled)
```

Control whether the framework's internal fragment manager debugging logs are turned on. If enabled, you will see output in logcat as the framework performs fragment operations.

<br />

|         Parameters          ||
|-----------|------------------|
| `enabled` | `boolean` <br /> |

### executePendingTransactions

Added in[API level 11](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public abstract boolean executePendingTransactions ()
```

After a[FragmentTransaction](https://developer.android.com/reference/android/app/FragmentTransaction)is committed with[FragmentTransaction.commit()](https://developer.android.com/reference/android/app/FragmentTransaction#commit()), it is scheduled to be executed asynchronously on the process's main thread. If you want to immediately executing any such pending operations, you can call this function (only from the main thread) to do so. Note that all callbacks and other related behavior will be done from within this call, so be careful about where this is called from.

This also forces the start of any postponed Transactions where[Fragment.postponeEnterTransition()](https://developer.android.com/reference/android/app/Fragment#postponeEnterTransition())has been called.

<br />

|                                        Returns                                        ||
|-----------|----------------------------------------------------------------------------|
| `boolean` | Returns true if there were any pending transactions to be executed. <br /> |

### findFragmentById

Added in[API level 11](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public abstract Fragment findFragmentById (int id)
```

Finds a fragment that was identified by the given id either when inflated from XML or as the container ID when added in a transaction. This first searches through fragments that are currently added to the manager's activity; if no such fragment is found, then all fragments currently on the back stack associated with this ID are searched.

<br />

|     Parameters     ||
|------|--------------|
| `id` | `int` <br /> |

|                                                          Returns                                                          ||
|--------------------------------------------------------------------------|-------------------------------------------------|
| [Fragment](https://developer.android.com/reference/android/app/Fragment) | The fragment if found or null otherwise. <br /> |

### findFragmentByTag

Added in[API level 11](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public abstract Fragment findFragmentByTag (String tag)
```

Finds a fragment that was identified by the given tag either when inflated from XML or as supplied when added in a transaction. This first searches through fragments that are currently added to the manager's activity; if no such fragment is found, then all fragments currently on the back stack are searched.

<br />

|       Parameters       ||
|-------|-----------------|
| `tag` | `String` <br /> |

|                                                          Returns                                                          ||
|--------------------------------------------------------------------------|-------------------------------------------------|
| [Fragment](https://developer.android.com/reference/android/app/Fragment) | The fragment if found or null otherwise. <br /> |

### getBackStackEntryAt

Added in[API level 11](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public abstract FragmentManager.BackStackEntry getBackStackEntryAt (int index)
```

Return the BackStackEntry at index<var translate="no">index</var>in the back stack; where the item on the bottom of the stack has index 0.

<br />

|      Parameters       ||
|---------|--------------|
| `index` | `int` <br /> |

|                                                           Returns                                                            ||
|----------------------------------------------------------------------------------------------------------------------|--------|
| [FragmentManager.BackStackEntry](https://developer.android.com/reference/android/app/FragmentManager.BackStackEntry) | <br /> |

### getBackStackEntryCount

Added in[API level 11](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public abstract int getBackStackEntryCount ()
```

Return the number of entries currently in the back stack.

<br />

|    Returns    ||
|-------|--------|
| `int` | <br /> |

### getFragment

Added in[API level 11](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public abstract Fragment getFragment (Bundle bundle, 
                String key)
```

Retrieve the current Fragment instance for a reference previously placed with[putFragment(android.os.Bundle, java.lang.String, android.app.Fragment)](https://developer.android.com/reference/android/app/FragmentManager#putFragment(android.os.Bundle,%20java.lang.String,%20android.app.Fragment)).

<br />

|                                      Parameters                                      ||
|----------|----------------------------------------------------------------------------|
| `bundle` | `Bundle`: The bundle from which to retrieve the fragment reference. <br /> |
| `key`    | `String`: The name of the entry in the bundle. <br />                      |

|                                                                               Returns                                                                               ||
|--------------------------------------------------------------------------|-------------------------------------------------------------------------------------------|
| [Fragment](https://developer.android.com/reference/android/app/Fragment) | Returns the current Fragment instance that is associated with the given reference. <br /> |

### getFragments

Added in[API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  
Deprecated in[API level 28](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public abstract List<Fragment> getFragments ()
```

Get a list of all fragments that are currently added to the FragmentManager. This may include those that are hidden as well as those that are shown. This will not include any fragments only in the back stack, or fragments that are detached or removed.

The order of the fragments in the list is the order in which they were added or attached.

<br />

|                                                                                                       Returns                                                                                                       ||
|----------------------------------------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------|
| [List](https://developer.android.com/reference/java/util/List)`<`[Fragment](https://developer.android.com/reference/android/app/Fragment)`>` | A list of all fragments that are added to the FragmentManager. <br /> |

### getPrimaryNavigationFragment

Added in[API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  
Deprecated in[API level 28](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public abstract Fragment getPrimaryNavigationFragment ()
```

Return the currently active primary navigation fragment for this FragmentManager.

The primary navigation fragment's[child FragmentManager](https://developer.android.com/reference/android/app/Fragment#getChildFragmentManager())will be called first to process delegated navigation actions such as[popBackStack()](https://developer.android.com/reference/android/app/FragmentManager#popBackStack())if no ID or transaction name is provided to pop to.

<br />

<br />

|                                                                   Returns                                                                   ||
|--------------------------------------------------------------------------|-------------------------------------------------------------------|
| [Fragment](https://developer.android.com/reference/android/app/Fragment) | the fragment designated as the primary navigation fragment <br /> |

### invalidateOptionsMenu

Added in[API level 14](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  
Deprecated in[API level 28](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public void invalidateOptionsMenu ()
```

Invalidate the attached activity's options menu as necessary. This may end up being deferred until we move to the resumed state.

<br />

### isDestroyed

Added in[API level 17](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  
Deprecated in[API level 28](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public abstract boolean isDestroyed ()
```

Returns true if the final[Activity.onDestroy()](https://developer.android.com/reference/android/app/Activity#onDestroy())call has been made on the FragmentManager's Activity, so this instance is now dead.

<br />

|      Returns      ||
|-----------|--------|
| `boolean` | <br /> |

### isStateSaved

Added in[API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  
Deprecated in[API level 28](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public abstract boolean isStateSaved ()
```

Returns`true`if the FragmentManager's state has already been saved by its host. Any operations that would change saved state should not be performed if this method returns true. For example, any popBackStack() method, such as[popBackStackImmediate()](https://developer.android.com/reference/android/app/FragmentManager#popBackStackImmediate())or any FragmentTransaction using[FragmentTransaction.commit()](https://developer.android.com/reference/android/app/FragmentTransaction#commit())instead of[FragmentTransaction.commitAllowingStateLoss()](https://developer.android.com/reference/android/app/FragmentTransaction#commitAllowingStateLoss())will change the state and will result in an error.

<br />

|                                          Returns                                          ||
|-----------|--------------------------------------------------------------------------------|
| `boolean` | true if this FragmentManager's state has already been saved by its host <br /> |

### popBackStack

Added in[API level 11](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public abstract void popBackStack ()
```

Pop the top state off the back stack. This function is asynchronous -- it enqueues the request to pop, but the action will not be performed until the application returns to its event loop.

<br />

### popBackStack

Added in[API level 11](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public abstract void popBackStack (int id, 
                int flags)
```

Pop all back stack states up to the one with the given identifier. This function is asynchronous -- it enqueues the request to pop, but the action will not be performed until the application returns to its event loop.

<br />

|                                                                                                                                                                                                                              Parameters                                                                                                                                                                                                                              ||
|---------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `id`    | `int`: Identifier of the stated to be popped. If no identifier exists, false is returned. The identifier is the number returned by[FragmentTransaction.commit()](https://developer.android.com/reference/android/app/FragmentTransaction#commit()). The[POP_BACK_STACK_INCLUSIVE](https://developer.android.com/reference/android/app/FragmentManager#POP_BACK_STACK_INCLUSIVE)flag can be used to control whether the named state itself is popped. <br /> |
| `flags` | `int`: Either 0 or[POP_BACK_STACK_INCLUSIVE](https://developer.android.com/reference/android/app/FragmentManager#POP_BACK_STACK_INCLUSIVE). <br />                                                                                                                                                                                                                                                                                                          |

### popBackStack

Added in[API level 11](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public abstract void popBackStack (String name, 
                int flags)
```

Pop the last fragment transition from the manager's fragment back stack. If there is nothing to pop, false is returned. This function is asynchronous -- it enqueues the request to pop, but the action will not be performed until the application returns to its event loop.

<br />

|                                                                                                                                                                                         Parameters                                                                                                                                                                                          ||
|---------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `name`  | `String`: If non-null, this is the name of a previous back state to look for; if found, all states up to that state will be popped. The[POP_BACK_STACK_INCLUSIVE](https://developer.android.com/reference/android/app/FragmentManager#POP_BACK_STACK_INCLUSIVE)flag can be used to control whether the named state itself is popped. If null, only the top state is popped. <br /> |
| `flags` | `int`: Either 0 or[POP_BACK_STACK_INCLUSIVE](https://developer.android.com/reference/android/app/FragmentManager#POP_BACK_STACK_INCLUSIVE). <br />                                                                                                                                                                                                                                 |

### popBackStackImmediate

Added in[API level 11](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public abstract boolean popBackStackImmediate ()
```

Like[popBackStack()](https://developer.android.com/reference/android/app/FragmentManager#popBackStack()), but performs the operation immediately inside of the call. This is like calling[executePendingTransactions()](https://developer.android.com/reference/android/app/FragmentManager#executePendingTransactions())afterwards without forcing the start of postponed Transactions.

<br />

|                                  Returns                                  ||
|-----------|----------------------------------------------------------------|
| `boolean` | Returns true if there was something popped, else false. <br /> |

### popBackStackImmediate

Added in[API level 11](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public abstract boolean popBackStackImmediate (int id, 
                int flags)
```

Like[popBackStack(int, int)](https://developer.android.com/reference/android/app/FragmentManager#popBackStack(int,%20int)), but performs the operation immediately inside of the call. This is like calling[executePendingTransactions()](https://developer.android.com/reference/android/app/FragmentManager#executePendingTransactions())afterwards without forcing the start of postponed Transactions.

<br />

|      Parameters       ||
|---------|--------------|
| `id`    | `int` <br /> |
| `flags` | `int` <br /> |

|                                  Returns                                  ||
|-----------|----------------------------------------------------------------|
| `boolean` | Returns true if there was something popped, else false. <br /> |

### popBackStackImmediate

Added in[API level 11](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public abstract boolean popBackStackImmediate (String name, 
                int flags)
```

Like[popBackStack(java.lang.String, int)](https://developer.android.com/reference/android/app/FragmentManager#popBackStack(java.lang.String,%20int)), but performs the operation immediately inside of the call. This is like calling[executePendingTransactions()](https://developer.android.com/reference/android/app/FragmentManager#executePendingTransactions())afterwards without forcing the start of postponed Transactions.

<br />

|        Parameters        ||
|---------|-----------------|
| `name`  | `String` <br /> |
| `flags` | `int` <br />    |

|                                  Returns                                  ||
|-----------|----------------------------------------------------------------|
| `boolean` | Returns true if there was something popped, else false. <br /> |

### putFragment

Added in[API level 11](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public abstract void putFragment (Bundle bundle, 
                String key, 
                Fragment fragment)
```

Put a reference to a fragment in a Bundle. This Bundle can be persisted as saved state, and when later restoring[getFragment(android.os.Bundle, java.lang.String)](https://developer.android.com/reference/android/app/FragmentManager#getFragment(android.os.Bundle,%20java.lang.String))will return the current instance of the same fragment.

<br />

|                                   Parameters                                    ||
|------------|---------------------------------------------------------------------|
| `bundle`   | `Bundle`: The bundle in which to put the fragment reference. <br /> |
| `key`      | `String`: The name of the entry in the bundle. <br />               |
| `fragment` | `Fragment`: The Fragment whose reference is to be stored. <br />    |

### registerFragmentLifecycleCallbacks

Added in[API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  
Deprecated in[API level 28](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public abstract void registerFragmentLifecycleCallbacks (FragmentManager.FragmentLifecycleCallbacks cb, 
                boolean recursive)
```

Registers a[FragmentLifecycleCallbacks](https://developer.android.com/reference/android/app/FragmentManager.FragmentLifecycleCallbacks)to listen to fragment lifecycle events happening in this FragmentManager. All registered callbacks will be automatically unregistered when this FragmentManager is destroyed.

<br />

|                                                 Parameters                                                 ||
|-------------|-----------------------------------------------------------------------------------------------|
| `cb`        | `FragmentManager.FragmentLifecycleCallbacks`: Callbacks to register <br />                    |
| `recursive` | `boolean`: true to automatically register this callback for all child FragmentManagers <br /> |

### removeOnBackStackChangedListener

Added in[API level 11](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public abstract void removeOnBackStackChangedListener (FragmentManager.OnBackStackChangedListener listener)
```

Remove a listener that was previously added with[addOnBackStackChangedListener(android.app.FragmentManager.OnBackStackChangedListener)](https://developer.android.com/reference/android/app/FragmentManager#addOnBackStackChangedListener(android.app.FragmentManager.OnBackStackChangedListener)).

<br />

|                           Parameters                            ||
|------------|-----------------------------------------------------|
| `listener` | `FragmentManager.OnBackStackChangedListener` <br /> |

### saveFragmentInstanceState

Added in[API level 13](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  
Deprecated in[API level 28](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public abstract Fragment.SavedState saveFragmentInstanceState (Fragment f)
```

Save the current instance state of the given Fragment. This can be used later when creating a new instance of the Fragment and adding it to the fragment manager, to have it create itself to match the current state returned here. Note that there are limits on how this can be used:

- The Fragment must currently be attached to the FragmentManager.
- A new Fragment created using this saved state must be the same class type as the Fragment it was created from.
- The saved state can not contain dependencies on other fragments -- that is it can't use[putFragment(android.os.Bundle, java.lang.String, android.app.Fragment)](https://developer.android.com/reference/android/app/FragmentManager#putFragment(android.os.Bundle,%20java.lang.String,%20android.app.Fragment))to store a fragment reference because that reference may not be valid when this saved state is later used. Likewise the Fragment's target and result code are not included in this state.

<br />

<br />

|                            Parameters                            ||
|-----|-------------------------------------------------------------|
| `f` | `Fragment`: The Fragment whose state is to be saved. <br /> |

|                                                                                                 Returns                                                                                                  ||
|------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------|
| [Fragment.SavedState](https://developer.android.com/reference/android/app/Fragment.SavedState) | The generated state. This will be null if there was no interesting state created by the fragment. <br /> |

### unregisterFragmentLifecycleCallbacks

Added in[API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  
Deprecated in[API level 28](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public abstract void unregisterFragmentLifecycleCallbacks (FragmentManager.FragmentLifecycleCallbacks cb)
```

Unregisters a previously registered[FragmentLifecycleCallbacks](https://developer.android.com/reference/android/app/FragmentManager.FragmentLifecycleCallbacks). If the callback was not previously registered this call has no effect. All registered callbacks will be automatically unregistered when this FragmentManager is destroyed.

<br />

|                                     Parameters                                     ||
|------|------------------------------------------------------------------------------|
| `cb` | `FragmentManager.FragmentLifecycleCallbacks`: Callbacks to unregister <br /> |