# FragmentManager

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

# FragmentManager

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

`
public


abstract
class
FragmentManager
`  
`

extends Object


``


`

|---|----------------------------------------|
| java.lang.Object                          ||
| ↳ | android.support.v4.app.FragmentManager |

<br />

*** ** * ** ***

Static library support version of the framework's[FragmentManager](https://developer.android.com/reference/android/app/FragmentManager.html). Used to write apps that run on platforms prior to Android 3.0. When running on Android 3.0 or above, this implementation is still used; it does not try to switch to the framework's implementation. See the framework[FragmentManager](https://developer.android.com/reference/android/support/v4/app/FragmentManager)documentation for a class overview.

Your activity must derive from[FragmentActivity](https://developer.android.com/reference/android/support/v4/app/FragmentActivity)to use this. From such an activity, you can acquire the[FragmentManager](https://developer.android.com/reference/android/support/v4/app/FragmentManager)by calling[getSupportFragmentManager()](https://developer.android.com/reference/android/support/v4/app/FragmentActivity#getSupportFragmentManager()).

## Summary

|                                                                                                                                                                                ### Nested classes                                                                                                                                                                                ||
|--------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| ` interface` | [FragmentManager.BackStackEntry](https://developer.android.com/reference/android/support/v4/app/FragmentManager.BackStackEntry) Representation of an entry on the fragment back stack, as created with[FragmentTransaction.addToBackStack()](https://developer.android.com/reference/android/support/v4/app/FragmentTransaction#addToBackStack(java.lang.String)). |
| ` class`     | [FragmentManager.FragmentLifecycleCallbacks](https://developer.android.com/reference/android/support/v4/app/FragmentManager.FragmentLifecycleCallbacks) Callback interface for listening to fragment state changes that happen within a given FragmentManager.                                                                                                     |
| ` interface` | [FragmentManager.OnBackStackChangedListener](https://developer.android.com/reference/android/support/v4/app/FragmentManager.OnBackStackChangedListener) Interface to watch for changes to the back stack.                                                                                                                                                          |

|                                                                                                                                                                                                                                                                                                           ### Constants                                                                                                                                                                                                                                                                                                           ||
|-------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `int` | [POP_BACK_STACK_INCLUSIVE](https://developer.android.com/reference/android/support/v4/app/FragmentManager#POP_BACK_STACK_INCLUSIVE) Flag for[popBackStack(String, int)](https://developer.android.com/reference/android/support/v4/app/FragmentManager#popBackStack(java.lang.String, int))and[popBackStack(int, int)](https://developer.android.com/reference/android/support/v4/app/FragmentManager#popBackStack(int, int)): 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/support/v4/app/FragmentManager#FragmentManager())`() ` |

|                                                                                                                                                                                                                                                                                                                                                                                                             ### Public methods                                                                                                                                                                                                                                                                                                                                                                                                              ||
|---------------------------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| ` abstract void`                                                                                                                            | ` `[addOnBackStackChangedListener](https://developer.android.com/reference/android/support/v4/app/FragmentManager#addOnBackStackChangedListener(android.support.v4.app.FragmentManager.OnBackStackChangedListener))`(`[FragmentManager.OnBackStackChangedListener](https://developer.android.com/reference/android/support/v4/app/FragmentManager.OnBackStackChangedListener)` listener) ` Add a new listener for changes to the fragment back stack.                                                                                                                                                                                                                                          |
| ` abstract `[FragmentTransaction](https://developer.android.com/reference/android/support/v4/app/FragmentTransaction)                       | ` `[beginTransaction](https://developer.android.com/reference/android/support/v4/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/support/v4/app/FragmentManager#dump(java.lang.String, java.io.FileDescriptor, java.io.PrintWriter, java.lang.String[]))`(String prefix, FileDescriptor fd, PrintWriter writer, String[] args) ` Print the FragmentManager's state into the given stream.                                                                                                                                                                                                                                                                                                                                                                             |
| ` static void`                                                                                                                              | ` `[enableDebugLogging](https://developer.android.com/reference/android/support/v4/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/support/v4/app/FragmentManager#executePendingTransactions())`() ` After a[FragmentTransaction](https://developer.android.com/reference/android/support/v4/app/FragmentTransaction)is committed with[FragmentTransaction.commit()](https://developer.android.com/reference/android/support/v4/app/FragmentTransaction#commit()), it is scheduled to be executed asynchronously on the process's main thread.                                                                                                                                                                                                    |
| ` abstract `[Fragment](https://developer.android.com/reference/android/support/v4/app/Fragment)                                             | ` `[findFragmentById](https://developer.android.com/reference/android/support/v4/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/support/v4/app/Fragment)                                             | ` `[findFragmentByTag](https://developer.android.com/reference/android/support/v4/app/FragmentManager#findFragmentByTag(java.lang.String))`(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/support/v4/app/FragmentManager.BackStackEntry) | ` `[getBackStackEntryAt](https://developer.android.com/reference/android/support/v4/app/FragmentManager#getBackStackEntryAt(int))`(int index) ` Return the BackStackEntry at index<var translate="no">index</var>in the back stack; entries start index 0 being the bottom of the stack.                                                                                                                                                                                                                                                                                                                                                                                                       |
| ` abstract int`                                                                                                                             | ` `[getBackStackEntryCount](https://developer.android.com/reference/android/support/v4/app/FragmentManager#getBackStackEntryCount())`() ` Return the number of entries currently in the back stack.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            |
| ` abstract `[Fragment](https://developer.android.com/reference/android/support/v4/app/Fragment)                                             | ` `[getFragment](https://developer.android.com/reference/android/support/v4/app/FragmentManager#getFragment(android.os.Bundle, java.lang.String))`(`[Bundle](https://developer.android.com/reference/android/os/Bundle.html)` bundle, String key) ` Retrieve the current Fragment instance for a reference previously placed with[putFragment(Bundle, String, Fragment)](https://developer.android.com/reference/android/support/v4/app/FragmentManager#putFragment(android.os.Bundle, java.lang.String, android.support.v4.app.Fragment)).                                                                                                                                                    |
| ` abstract List<`[Fragment](https://developer.android.com/reference/android/support/v4/app/Fragment)`>`                                     | ` `[getFragments](https://developer.android.com/reference/android/support/v4/app/FragmentManager#getFragments())`() ` Get a list of all fragments that are currently added to the FragmentManager.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             |
| ` abstract `[Fragment](https://developer.android.com/reference/android/support/v4/app/Fragment)                                             | ` `[getPrimaryNavigationFragment](https://developer.android.com/reference/android/support/v4/app/FragmentManager#getPrimaryNavigationFragment())`() ` Return the currently active primary navigation fragment for this FragmentManager.                                                                                                                                                                                                                                                                                                                                                                                                                                                        |
| ` abstract boolean`                                                                                                                         | ` `[isDestroyed](https://developer.android.com/reference/android/support/v4/app/FragmentManager#isDestroyed())`() ` Returns true if the final[Activity.onDestroy()](https://developer.android.com/reference/android/app/Activity.html#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/support/v4/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/support/v4/app/FragmentManager#popBackStack())`() ` Pop the top state off the back stack.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    |
| ` abstract void`                                                                                                                            | ` `[popBackStack](https://developer.android.com/reference/android/support/v4/app/FragmentManager#popBackStack(int, int))`(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/support/v4/app/FragmentManager#popBackStack(java.lang.String, int))`(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/support/v4/app/FragmentManager#popBackStackImmediate())`() ` Like[popBackStack()](https://developer.android.com/reference/android/support/v4/app/FragmentManager#popBackStack()), but performs the operation immediately inside of the call.                                                                                                                                                                                                                                                                                                                                                                        |
| ` abstract boolean`                                                                                                                         | ` `[popBackStackImmediate](https://developer.android.com/reference/android/support/v4/app/FragmentManager#popBackStackImmediate(int, int))`(int id, int flags) ` Like[popBackStack(int, int)](https://developer.android.com/reference/android/support/v4/app/FragmentManager#popBackStack(int, int)), but performs the operation immediately inside of the call.                                                                                                                                                                                                                                                                                                                               |
| ` abstract boolean`                                                                                                                         | ` `[popBackStackImmediate](https://developer.android.com/reference/android/support/v4/app/FragmentManager#popBackStackImmediate(java.lang.String, int))`(String name, int flags) ` Like[popBackStack(String, int)](https://developer.android.com/reference/android/support/v4/app/FragmentManager#popBackStack(java.lang.String, int)), but performs the operation immediately inside of the call.                                                                                                                                                                                                                                                                                             |
| ` abstract void`                                                                                                                            | ` `[putFragment](https://developer.android.com/reference/android/support/v4/app/FragmentManager#putFragment(android.os.Bundle, java.lang.String, android.support.v4.app.Fragment))`(`[Bundle](https://developer.android.com/reference/android/os/Bundle.html)` bundle, String key, `[Fragment](https://developer.android.com/reference/android/support/v4/app/Fragment)` fragment) ` Put a reference to a fragment in a Bundle.                                                                                                                                                                                                                                                                |
| ` abstract void`                                                                                                                            | ` `[registerFragmentLifecycleCallbacks](https://developer.android.com/reference/android/support/v4/app/FragmentManager#registerFragmentLifecycleCallbacks(android.support.v4.app.FragmentManager.FragmentLifecycleCallbacks, boolean))`(`[FragmentManager.FragmentLifecycleCallbacks](https://developer.android.com/reference/android/support/v4/app/FragmentManager.FragmentLifecycleCallbacks)` cb, boolean recursive) ` Registers a[FragmentManager.FragmentLifecycleCallbacks](https://developer.android.com/reference/android/support/v4/app/FragmentManager.FragmentLifecycleCallbacks)to listen to fragment lifecycle events happening in this FragmentManager.                         |
| ` abstract void`                                                                                                                            | ` `[removeOnBackStackChangedListener](https://developer.android.com/reference/android/support/v4/app/FragmentManager#removeOnBackStackChangedListener(android.support.v4.app.FragmentManager.OnBackStackChangedListener))`(`[FragmentManager.OnBackStackChangedListener](https://developer.android.com/reference/android/support/v4/app/FragmentManager.OnBackStackChangedListener)` listener) ` Remove a listener that was previously added with[addOnBackStackChangedListener(OnBackStackChangedListener)](https://developer.android.com/reference/android/support/v4/app/FragmentManager#addOnBackStackChangedListener(android.support.v4.app.FragmentManager.OnBackStackChangedListener)). |
| ` abstract `[Fragment.SavedState](https://developer.android.com/reference/android/support/v4/app/Fragment.SavedState)                       | ` `[saveFragmentInstanceState](https://developer.android.com/reference/android/support/v4/app/FragmentManager#saveFragmentInstanceState(android.support.v4.app.Fragment))`(`[Fragment](https://developer.android.com/reference/android/support/v4/app/Fragment)` f) ` Save the current instance state of the given Fragment.                                                                                                                                                                                                                                                                                                                                                                   |
| ` abstract void`                                                                                                                            | ` `[unregisterFragmentLifecycleCallbacks](https://developer.android.com/reference/android/support/v4/app/FragmentManager#unregisterFragmentLifecycleCallbacks(android.support.v4.app.FragmentManager.FragmentLifecycleCallbacks))`(`[FragmentManager.FragmentLifecycleCallbacks](https://developer.android.com/reference/android/support/v4/app/FragmentManager.FragmentLifecycleCallbacks)` cb) ` Unregisters a previously registered[FragmentManager.FragmentLifecycleCallbacks](https://developer.android.com/reference/android/support/v4/app/FragmentManager.FragmentLifecycleCallbacks).                                                                                                 |

| ### Inherited methods |
|-----------------------|---|
| [![](https://developer.android.com/static/assets/images/styles/disclosure_down.png)](https://developer.android.com/reference/android/support/v4/app/FragmentManager#)From class` java.lang.Object ` |-------------------|-------------------------------| | ` Object`         | ` clone() `                   | | ` boolean`        | ` equals(Object arg0) `       | | ` void`           | ` finalize() `                | | ` final Class<?>` | ` getClass() `                | | ` int`            | ` hashCode() `                | | ` final void`     | ` notify() `                  | | ` final void`     | ` notifyAll() `               | | ` String`         | ` toString() `                | | ` final void`     | ` wait(long arg0, int arg1) ` | | ` final void`     | ` wait(long arg0) `           | | ` final void`     | ` wait() `                    | ||

## Constants

### POP_BACK_STACK_INCLUSIVE

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

```
int POP_BACK_STACK_INCLUSIVE
```

Flag for[popBackStack(String, int)](https://developer.android.com/reference/android/support/v4/app/FragmentManager#popBackStack(java.lang.String, int))and[popBackStack(int, int)](https://developer.android.com/reference/android/support/v4/app/FragmentManager#popBackStack(int, int)): 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

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

```
FragmentManager ()
```

<br />

<br />

## Public methods

### addOnBackStackChangedListener

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

```
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[version 22.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
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[FragmentActivity.onSaveInstanceState()](https://developer.android.com/reference/android/support/v4/app/FragmentActivity#onSaveInstanceState(android.os.Bundle))(and prior to a following[FragmentActivity.onStart](https://developer.android.com/reference/android/support/v4/app/FragmentActivity#onStart())or[FragmentActivity.onResume()](https://developer.android.com/reference/android/support/v4/app/FragmentActivity#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/support/v4/app/FragmentTransaction) | <br /> |

### dump

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

```
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[version 22.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
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[version 22.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
boolean executePendingTransactions ()
```

After a[FragmentTransaction](https://developer.android.com/reference/android/support/v4/app/FragmentTransaction)is committed with[FragmentTransaction.commit()](https://developer.android.com/reference/android/support/v4/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.

If you are committing a single transaction that does not modify the fragment back stack, strongly consider using[commitNow()](https://developer.android.com/reference/android/support/v4/app/FragmentTransaction#commitNow())instead. This can help avoid unwanted side effects when other code in your app has pending committed transactions that expect different timing.

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

<br />

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

### findFragmentById

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

```
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/support/v4/app/Fragment) | The fragment if found or null otherwise. <br /> |

### findFragmentByTag

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

```
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/support/v4/app/Fragment) | The fragment if found or null otherwise. <br /> |

### getBackStackEntryAt

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

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

Return the BackStackEntry at index<var translate="no">index</var>in the back stack; entries start index 0 being the bottom of the stack.

<br />

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

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

### getBackStackEntryCount

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

```
int getBackStackEntryCount ()
```

Return the number of entries currently in the back stack.

<br />

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

### getFragment

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

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

Retrieve the current Fragment instance for a reference previously placed with[putFragment(Bundle, String, Fragment)](https://developer.android.com/reference/android/support/v4/app/FragmentManager#putFragment(android.os.Bundle, java.lang.String, android.support.v4.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/support/v4/app/Fragment) | Returns the current Fragment instance that is associated with the given reference. <br /> |

### getFragments

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

```
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<`[Fragment](https://developer.android.com/reference/android/support/v4/app/Fragment)`>` | A list of all fragments that are added to the FragmentManager. <br /> |

### getPrimaryNavigationFragment

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

```
Fragment getPrimaryNavigationFragment ()
```

Return the currently active primary navigation fragment for this FragmentManager. The primary navigation fragment is set by fragment transactions using[setPrimaryNavigationFragment(Fragment)](https://developer.android.com/reference/android/support/v4/app/FragmentTransaction#setPrimaryNavigationFragment(android.support.v4.app.Fragment)).

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

<br />

<br />

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

### isDestroyed

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

```
boolean isDestroyed ()
```

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

<br />

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

### isStateSaved

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

```
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/support/v4/app/FragmentManager#popBackStackImmediate())or any FragmentTransaction using[commit()](https://developer.android.com/reference/android/support/v4/app/FragmentTransaction#commit())instead of[commitAllowingStateLoss()](https://developer.android.com/reference/android/support/v4/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[version 22.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
void popBackStack ()
```

Pop the top state off the back stack. Returns true if there was one to pop, else false. 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[version 22.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
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/support/v4/app/FragmentTransaction#commit()). The[POP_BACK_STACK_INCLUSIVE](https://developer.android.com/reference/android/support/v4/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/support/v4/app/FragmentManager#POP_BACK_STACK_INCLUSIVE). <br />                                                                                                                                                                                                                                                                                                                     |

### popBackStack

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

```
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/support/v4/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/support/v4/app/FragmentManager#POP_BACK_STACK_INCLUSIVE). <br />                                                                                                                                                                                                                                 |

### popBackStackImmediate

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

```
boolean popBackStackImmediate ()
```

Like[popBackStack()](https://developer.android.com/reference/android/support/v4/app/FragmentManager#popBackStack()), but performs the operation immediately inside of the call. This is like calling[executePendingTransactions()](https://developer.android.com/reference/android/support/v4/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[version 22.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

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

Like[popBackStack(int, int)](https://developer.android.com/reference/android/support/v4/app/FragmentManager#popBackStack(int, int)), but performs the operation immediately inside of the call. This is like calling[executePendingTransactions()](https://developer.android.com/reference/android/support/v4/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[version 22.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

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

Like[popBackStack(String, int)](https://developer.android.com/reference/android/support/v4/app/FragmentManager#popBackStack(java.lang.String, int)), but performs the operation immediately inside of the call. This is like calling[executePendingTransactions()](https://developer.android.com/reference/android/support/v4/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[version 22.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
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(Bundle, String)](https://developer.android.com/reference/android/support/v4/app/FragmentManager#getFragment(android.os.Bundle, java.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[version 25.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

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

Registers a[FragmentManager.FragmentLifecycleCallbacks](https://developer.android.com/reference/android/support/v4/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[version 22.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

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

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

<br />

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

### saveFragmentInstanceState

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

```
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(Bundle, String, Fragment)](https://developer.android.com/reference/android/support/v4/app/FragmentManager#putFragment(android.os.Bundle, java.lang.String, android.support.v4.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/support/v4/app/Fragment.SavedState) | The generated state. This will be null if there was no interesting state created by the fragment. <br /> |

### unregisterFragmentLifecycleCallbacks

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

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

Unregisters a previously registered[FragmentManager.FragmentLifecycleCallbacks](https://developer.android.com/reference/android/support/v4/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 /> |

-

  ## Annotations

  - [NotificationCompat.Action.SemanticAction](https://developer.android.com/reference/android/support/v4/app/NotificationCompat.Action.SemanticAction)
-

  ## Interfaces

  - [ActionBarDrawerToggle.Delegate](https://developer.android.com/reference/android/support/v4/app/ActionBarDrawerToggle.Delegate)
  - [ActionBarDrawerToggle.DelegateProvider](https://developer.android.com/reference/android/support/v4/app/ActionBarDrawerToggle.DelegateProvider)
  - [ActivityCompat.OnRequestPermissionsResultCallback](https://developer.android.com/reference/android/support/v4/app/ActivityCompat.OnRequestPermissionsResultCallback)
  - [ActivityCompat.PermissionCompatDelegate](https://developer.android.com/reference/android/support/v4/app/ActivityCompat.PermissionCompatDelegate)
  - [FragmentManager.BackStackEntry](https://developer.android.com/reference/android/support/v4/app/FragmentManager.BackStackEntry)
  - [FragmentManager.OnBackStackChangedListener](https://developer.android.com/reference/android/support/v4/app/FragmentManager.OnBackStackChangedListener)
  - [LoaderManager.LoaderCallbacks](https://developer.android.com/reference/android/support/v4/app/LoaderManager.LoaderCallbacks)
  - [NotificationCompat.Action.Extender](https://developer.android.com/reference/android/support/v4/app/NotificationCompat.Action.Extender)
  - [NotificationCompat.Extender](https://developer.android.com/reference/android/support/v4/app/NotificationCompat.Extender)
  - [SharedElementCallback.OnSharedElementsReadyListener](https://developer.android.com/reference/android/support/v4/app/SharedElementCallback.OnSharedElementsReadyListener)
  - [TaskStackBuilder.SupportParentable](https://developer.android.com/reference/android/support/v4/app/TaskStackBuilder.SupportParentable)
-

  ## Classes

  - [ActionBarDrawerToggle](https://developer.android.com/reference/android/support/v4/app/ActionBarDrawerToggle)
  - [ActivityCompat](https://developer.android.com/reference/android/support/v4/app/ActivityCompat)
  - [ActivityManagerCompat](https://developer.android.com/reference/android/support/v4/app/ActivityManagerCompat)
  - [ActivityOptionsCompat](https://developer.android.com/reference/android/support/v4/app/ActivityOptionsCompat)
  - [AlarmManagerCompat](https://developer.android.com/reference/android/support/v4/app/AlarmManagerCompat)
  - [AppLaunchChecker](https://developer.android.com/reference/android/support/v4/app/AppLaunchChecker)
  - [AppOpsManagerCompat](https://developer.android.com/reference/android/support/v4/app/AppOpsManagerCompat)
  - [BundleCompat](https://developer.android.com/reference/android/support/v4/app/BundleCompat)
  - [DialogFragment](https://developer.android.com/reference/android/support/v4/app/DialogFragment)
  - [Fragment](https://developer.android.com/reference/android/support/v4/app/Fragment)
  - [Fragment.SavedState](https://developer.android.com/reference/android/support/v4/app/Fragment.SavedState)
  - [FragmentActivity](https://developer.android.com/reference/android/support/v4/app/FragmentActivity)
  - [FragmentContainer](https://developer.android.com/reference/android/support/v4/app/FragmentContainer)
  - [FragmentController](https://developer.android.com/reference/android/support/v4/app/FragmentController)
  - [FragmentHostCallback](https://developer.android.com/reference/android/support/v4/app/FragmentHostCallback)
  - [FragmentManager](https://developer.android.com/reference/android/support/v4/app/FragmentManager)
  - [FragmentManager.FragmentLifecycleCallbacks](https://developer.android.com/reference/android/support/v4/app/FragmentManager.FragmentLifecycleCallbacks)
  - [FragmentManagerNonConfig](https://developer.android.com/reference/android/support/v4/app/FragmentManagerNonConfig)
  - [FragmentPagerAdapter](https://developer.android.com/reference/android/support/v4/app/FragmentPagerAdapter)
  - [FragmentStatePagerAdapter](https://developer.android.com/reference/android/support/v4/app/FragmentStatePagerAdapter)
  - [FragmentTabHost](https://developer.android.com/reference/android/support/v4/app/FragmentTabHost)
  - [FragmentTransaction](https://developer.android.com/reference/android/support/v4/app/FragmentTransaction)
  - [FrameMetricsAggregator](https://developer.android.com/reference/android/support/v4/app/FrameMetricsAggregator)
  - [JobIntentService](https://developer.android.com/reference/android/support/v4/app/JobIntentService)
  - [ListFragment](https://developer.android.com/reference/android/support/v4/app/ListFragment)
  - [LoaderManager](https://developer.android.com/reference/android/support/v4/app/LoaderManager)
  - [NavUtils](https://developer.android.com/reference/android/support/v4/app/NavUtils)
  - [NotificationCompat](https://developer.android.com/reference/android/support/v4/app/NotificationCompat)
  - [NotificationCompat.Action](https://developer.android.com/reference/android/support/v4/app/NotificationCompat.Action)
  - [NotificationCompat.Action.Builder](https://developer.android.com/reference/android/support/v4/app/NotificationCompat.Action.Builder)
  - [NotificationCompat.Action.WearableExtender](https://developer.android.com/reference/android/support/v4/app/NotificationCompat.Action.WearableExtender)
  - [NotificationCompat.BigPictureStyle](https://developer.android.com/reference/android/support/v4/app/NotificationCompat.BigPictureStyle)
  - [NotificationCompat.BigTextStyle](https://developer.android.com/reference/android/support/v4/app/NotificationCompat.BigTextStyle)
  - [NotificationCompat.Builder](https://developer.android.com/reference/android/support/v4/app/NotificationCompat.Builder)
  - [NotificationCompat.CarExtender](https://developer.android.com/reference/android/support/v4/app/NotificationCompat.CarExtender)
  - [NotificationCompat.CarExtender.UnreadConversation](https://developer.android.com/reference/android/support/v4/app/NotificationCompat.CarExtender.UnreadConversation)
  - [NotificationCompat.CarExtender.UnreadConversation.Builder](https://developer.android.com/reference/android/support/v4/app/NotificationCompat.CarExtender.UnreadConversation.Builder)
  - [NotificationCompat.DecoratedCustomViewStyle](https://developer.android.com/reference/android/support/v4/app/NotificationCompat.DecoratedCustomViewStyle)
  - [NotificationCompat.InboxStyle](https://developer.android.com/reference/android/support/v4/app/NotificationCompat.InboxStyle)
  - [NotificationCompat.MessagingStyle](https://developer.android.com/reference/android/support/v4/app/NotificationCompat.MessagingStyle)
  - [NotificationCompat.MessagingStyle.Message](https://developer.android.com/reference/android/support/v4/app/NotificationCompat.MessagingStyle.Message)
  - [NotificationCompat.Style](https://developer.android.com/reference/android/support/v4/app/NotificationCompat.Style)
  - [NotificationCompat.WearableExtender](https://developer.android.com/reference/android/support/v4/app/NotificationCompat.WearableExtender)
  - [NotificationCompatExtras](https://developer.android.com/reference/android/support/v4/app/NotificationCompatExtras)
  - [NotificationCompatSideChannelService](https://developer.android.com/reference/android/support/v4/app/NotificationCompatSideChannelService)
  - [NotificationManagerCompat](https://developer.android.com/reference/android/support/v4/app/NotificationManagerCompat)
  - [RemoteInput](https://developer.android.com/reference/android/support/v4/app/RemoteInput)
  - [RemoteInput.Builder](https://developer.android.com/reference/android/support/v4/app/RemoteInput.Builder)
  - [ServiceCompat](https://developer.android.com/reference/android/support/v4/app/ServiceCompat)
  - [ShareCompat](https://developer.android.com/reference/android/support/v4/app/ShareCompat)
  - [ShareCompat.IntentBuilder](https://developer.android.com/reference/android/support/v4/app/ShareCompat.IntentBuilder)
  - [ShareCompat.IntentReader](https://developer.android.com/reference/android/support/v4/app/ShareCompat.IntentReader)
  - [SharedElementCallback](https://developer.android.com/reference/android/support/v4/app/SharedElementCallback)
  - [TaskStackBuilder](https://developer.android.com/reference/android/support/v4/app/TaskStackBuilder)
-

  ## Exceptions

  - [Fragment.InstantiationException](https://developer.android.com/reference/android/support/v4/app/Fragment.InstantiationException)