blob: 0c5fde33492c80fd7d76b18adb6b829b1d794497 [file] [log] [blame]
<html devsite="true">
<head>
<title>FragmentManager</title>
{% setvar book_path %}/reference/androidx/_book.yaml{% endsetvar %}
{% include "_shared/_reference-head-tags.html" %}
</head>
<body>
<h1>FragmentManager</h1>
<p>
<pre>public abstract class FragmentManager implements <a href="/reference/androidx/fragment/app/FragmentResultOwner.html">FragmentResultOwner</a></pre>
</p>
<hr>
<p>Static library support version of the framework's android.app.FragmentManager. 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 <code><a href="/reference/androidx/fragment/app/FragmentManager.html">FragmentManager</a></code> documentation for a class overview. </p>
<p>Your activity must derive from <code><a href="/reference/androidx/fragment/app/FragmentActivity.html">FragmentActivity</a></code> to use this. From such an activity, you can acquire the <code><a href="/reference/androidx/fragment/app/FragmentManager.html">FragmentManager</a></code> by calling <code><a href="/reference/androidx/fragment/app/FragmentActivity.html#getSupportFragmentManager()">FragmentActivity#getSupportFragmentManager</a></code>.</p>
<h2>Summary</h2>
<div class="devsite-table-wrapper">
<table class="responsive">
<thead>
<tr>
<th colspan="2"><h3>Nested types</h3></th>
</tr>
</thead>
<tbody>
<tr>
<td width="40%"><code><a href="/reference/androidx/fragment/app/FragmentManager.BackStackEntry.html">FragmentManager.BackStackEntry</a></code></td>
<td>
<p>Representation of an entry on the fragment back stack, as created with <code><a href="/reference/androidx/fragment/app/FragmentTransaction.html#addToBackStack(java.lang.String)">FragmentTransaction.addToBackStack()</a></code>.</p>
</td>
</tr>
<tr>
<td width="40%"><code><a href="/reference/androidx/fragment/app/FragmentManager.FragmentLifecycleCallbacks.html">FragmentManager.FragmentLifecycleCallbacks</a></code></td>
<td>
<p>Callback interface for listening to fragment state changes that happen within a given FragmentManager.</p>
</td>
</tr>
<tr>
<td width="40%"><code><a href="/reference/androidx/fragment/app/FragmentManager.OnBackStackChangedListener.html">FragmentManager.OnBackStackChangedListener</a></code></td>
<td>
<p>Interface to watch for changes to the back stack.</p>
</td>
</tr>
</tbody>
</table>
</div>
<div class="devsite-table-wrapper">
<table class="responsive">
<thead>
<tr>
<th colspan="2"><h3>Constants</h3></th>
</tr>
</thead>
<tbody>
<tr>
<td width="40%"><code>static&nbsp;final int</code></td>
<td>
<div><code><a href="/reference/androidx/fragment/app/FragmentManager.html#POP_BACK_STACK_INCLUSIVE()">POP_BACK_STACK_INCLUSIVE</a></code></div>
<p>Flag for <code><a href="/reference/androidx/fragment/app/FragmentManager.html#popBackStack(java.lang.String,int)">popBackStack</a></code> and <code><a href="/reference/androidx/fragment/app/FragmentManager.html#popBackStack(int,int)">popBackStack</a></code>: 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.</p>
</td>
</tr>
</tbody>
</table>
</div>
<div class="devsite-table-wrapper">
<table class="responsive">
<thead>
<tr>
<th colspan="2"><h3>Public constructors</h3></th>
</tr>
</thead>
<tbody>
<tr>
<td>
<div><code><a href="/reference/androidx/fragment/app/FragmentManager.html#FragmentManager()">FragmentManager</a>()</code></div>
</td>
</tr>
</tbody>
</table>
</div>
<div class="devsite-table-wrapper">
<table class="responsive">
<thead>
<tr>
<th colspan="2"><h3>Public methods</h3></th>
</tr>
</thead>
<tbody>
<tr>
<td width="40%"><code>void</code></td>
<td>
<div><code><a href="/reference/androidx/fragment/app/FragmentManager.html#addFragmentOnAttachListener(androidx.fragment.app.FragmentOnAttachListener)">addFragmentOnAttachListener</a>(@<a href="/reference/androidx/annotation/NonNull.html">NonNull</a> <a href="/reference/androidx/fragment/app/FragmentOnAttachListener.html">FragmentOnAttachListener</a>&nbsp;listener)</code></div>
<p>Add a <code><a href="/reference/androidx/fragment/app/FragmentOnAttachListener.html">FragmentOnAttachListener</a></code> that should receive a call to <code><a href="/reference/androidx/fragment/app/FragmentOnAttachListener.html#onAttachFragment(androidx.fragment.app.FragmentManager,androidx.fragment.app.Fragment)">FragmentOnAttachListener#onAttachFragment(FragmentManager, Fragment)</a></code> when a new Fragment is attached to this FragmentManager.</p>
</td>
</tr>
<tr>
<td width="40%"><code>void</code></td>
<td>
<div><code><a href="/reference/androidx/fragment/app/FragmentManager.html#addOnBackStackChangedListener(androidx.fragment.app.FragmentManager.OnBackStackChangedListener)">addOnBackStackChangedListener</a>(<br>&nbsp;&nbsp;&nbsp;&nbsp;@<a href="/reference/androidx/annotation/NonNull.html">NonNull</a> <a href="/reference/androidx/fragment/app/FragmentManager.OnBackStackChangedListener.html">FragmentManager.OnBackStackChangedListener</a>&nbsp;listener<br>)</code></div>
<p>Add a new listener for changes to the fragment back stack.</p>
</td>
</tr>
<tr>
<td width="40%"><code>@<a href="/reference/androidx/annotation/NonNull.html">NonNull</a> <a href="/reference/androidx/fragment/app/FragmentTransaction.html">FragmentTransaction</a></code></td>
<td>
<div><code><a href="/reference/androidx/fragment/app/FragmentManager.html#beginTransaction()">beginTransaction</a>()</code></div>
<p>Start a series of edit operations on the Fragments associated with this FragmentManager.</p>
</td>
</tr>
<tr>
<td width="40%"><code>final void</code></td>
<td>
<div><code><a href="/reference/androidx/fragment/app/FragmentManager.html#clearFragmentResult(java.lang.String)">clearFragmentResult</a>(@<a href="/reference/androidx/annotation/NonNull.html">NonNull</a> <a href="https://developer.android.com/reference/java/lang/String.html">String</a>&nbsp;requestKey)</code></div>
<p>Clears the stored result for the given requestKey.</p>
</td>
</tr>
<tr>
<td width="40%"><code>final void</code></td>
<td>
<div><code><a href="/reference/androidx/fragment/app/FragmentManager.html#clearFragmentResultListener(java.lang.String)">clearFragmentResultListener</a>(@<a href="/reference/androidx/annotation/NonNull.html">NonNull</a> <a href="https://developer.android.com/reference/java/lang/String.html">String</a>&nbsp;requestKey)</code></div>
<p>Clears the stored <code><a href="/reference/androidx/fragment/app/FragmentResultListener.html">FragmentResultListener</a></code> for the given requestKey.</p>
</td>
</tr>
<tr>
<td width="40%"><code>void</code></td>
<td>
<div><code><a href="/reference/androidx/fragment/app/FragmentManager.html#dump(java.lang.String,java.io.FileDescriptor,java.io.PrintWriter,java.lang.String[])">dump</a>(<br>&nbsp;&nbsp;&nbsp;&nbsp;@<a href="/reference/androidx/annotation/NonNull.html">NonNull</a> <a href="https://developer.android.com/reference/java/lang/String.html">String</a>&nbsp;prefix,<br>&nbsp;&nbsp;&nbsp;&nbsp;@<a href="/reference/androidx/annotation/Nullable.html">Nullable</a> <a href="https://developer.android.com/reference/java/io/FileDescriptor.html">FileDescriptor</a>&nbsp;fd,<br>&nbsp;&nbsp;&nbsp;&nbsp;@<a href="/reference/androidx/annotation/NonNull.html">NonNull</a> <a href="https://developer.android.com/reference/java/io/PrintWriter.html">PrintWriter</a>&nbsp;writer,<br>&nbsp;&nbsp;&nbsp;&nbsp;@<a href="/reference/androidx/annotation/Nullable.html">Nullable</a> String[]&nbsp;args<br>)</code></div>
<p>Print the FragmentManager's state into the given stream.</p>
</td>
</tr>
<tr>
<td width="40%"><code>static void</code></td>
<td>
<div><code><span><del><a href="/reference/androidx/fragment/app/FragmentManager.html#enableDebugLogging(boolean)">enableDebugLogging</a></del></span>(boolean&nbsp;enabled)</code></div>
<p><strong>This method is deprecated.</strong>
<p>FragmentManager now respects Log#isLoggable(String, int) for debug logging, allowing you to use <code>adb shell setprop log.tag.FragmentManager VERBOSE</code>.</p>
</p>
</td>
</tr>
<tr>
<td width="40%"><code>static @<a href="/reference/androidx/fragment/app/FragmentStateManagerControl.html">FragmentStateManagerControl</a> void</code></td>
<td>
<div><code><a href="/reference/androidx/fragment/app/FragmentManager.html#enableNewStateManager(boolean)">enableNewStateManager</a>(boolean&nbsp;enabled)</code></div>
<p>Control whether FragmentManager uses the new state manager that is responsible for: </p>
</td>
</tr>
<tr>
<td width="40%"><code>boolean</code></td>
<td>
<div><code><a href="/reference/androidx/fragment/app/FragmentManager.html#executePendingTransactions()">executePendingTransactions</a>()</code></div>
<p>After a <code><a href="/reference/androidx/fragment/app/FragmentTransaction.html">FragmentTransaction</a></code> is committed with <code><a href="/reference/androidx/fragment/app/FragmentTransaction.html#commit()">FragmentTransaction.commit()</a></code>, it is scheduled to be executed asynchronously on the process's main thread.</p>
</td>
</tr>
<tr>
<td width="40%"><code>static @<a href="/reference/androidx/annotation/NonNull.html">NonNull</a> F</code></td>
<td>
<div><code>&lt;F&nbsp;extends&nbsp;<a href="/reference/androidx/fragment/app/Fragment.html">Fragment</a>&gt; <a href="/reference/androidx/fragment/app/FragmentManager.html#findFragment(android.view.View)">findFragment</a>(@<a href="/reference/androidx/annotation/NonNull.html">NonNull</a> View&nbsp;view)</code></div>
<p>Find a <code><a href="/reference/androidx/fragment/app/Fragment.html">Fragment</a></code> associated with the given View.</p>
</td>
</tr>
<tr>
<td width="40%"><code>@<a href="/reference/androidx/annotation/Nullable.html">Nullable</a> <a href="/reference/androidx/fragment/app/Fragment.html">Fragment</a></code></td>
<td>
<div><code><a href="/reference/androidx/fragment/app/FragmentManager.html#findFragmentById(int)">findFragmentById</a>(int&nbsp;id)</code></div>
<p>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.</p>
</td>
</tr>
<tr>
<td width="40%"><code>@<a href="/reference/androidx/annotation/Nullable.html">Nullable</a> <a href="/reference/androidx/fragment/app/Fragment.html">Fragment</a></code></td>
<td>
<div><code><a href="/reference/androidx/fragment/app/FragmentManager.html#findFragmentByTag(java.lang.String)">findFragmentByTag</a>(@<a href="/reference/androidx/annotation/Nullable.html">Nullable</a> <a href="https://developer.android.com/reference/java/lang/String.html">String</a>&nbsp;tag)</code></div>
<p>Finds a fragment that was identified by the given tag either when inflated from XML or as supplied when added in a transaction.</p>
</td>
</tr>
<tr>
<td width="40%"><code>@<a href="/reference/androidx/annotation/NonNull.html">NonNull</a> <a href="/reference/androidx/fragment/app/FragmentManager.BackStackEntry.html">FragmentManager.BackStackEntry</a></code></td>
<td>
<div><code><a href="/reference/androidx/fragment/app/FragmentManager.html#getBackStackEntryAt(int)">getBackStackEntryAt</a>(int&nbsp;index)</code></div>
<p>Return the BackStackEntry at index index in the back stack; entries start index 0 being the bottom of the stack.</p>
</td>
</tr>
<tr>
<td width="40%"><code>int</code></td>
<td>
<div><code><a href="/reference/androidx/fragment/app/FragmentManager.html#getBackStackEntryCount()">getBackStackEntryCount</a>()</code></div>
<p>Return the number of entries currently in the back stack.</p>
</td>
</tr>
<tr>
<td width="40%"><code>@<a href="/reference/androidx/annotation/Nullable.html">Nullable</a> <a href="/reference/androidx/fragment/app/Fragment.html">Fragment</a></code></td>
<td>
<div><code><a href="/reference/androidx/fragment/app/FragmentManager.html#getFragment(android.os.Bundle,java.lang.String)">getFragment</a>(@<a href="/reference/androidx/annotation/NonNull.html">NonNull</a> Bundle&nbsp;bundle,&nbsp;@<a href="/reference/androidx/annotation/NonNull.html">NonNull</a> <a href="https://developer.android.com/reference/java/lang/String.html">String</a>&nbsp;key)</code></div>
<p>Retrieve the current Fragment instance for a reference previously placed with <code><a href="/reference/androidx/fragment/app/FragmentManager.html#putFragment(android.os.Bundle,java.lang.String,androidx.fragment.app.Fragment)">putFragment</a></code>.</p>
</td>
</tr>
<tr>
<td width="40%"><code>@<a href="/reference/androidx/annotation/NonNull.html">NonNull</a> <a href="/reference/androidx/fragment/app/FragmentFactory.html">FragmentFactory</a></code></td>
<td>
<div><code><a href="/reference/androidx/fragment/app/FragmentManager.html#getFragmentFactory()">getFragmentFactory</a>()</code></div>
<p>Gets the current <code><a href="/reference/androidx/fragment/app/FragmentFactory.html">FragmentFactory</a></code> used to instantiate new Fragment instances.</p>
</td>
</tr>
<tr>
<td width="40%"><code>@<a href="/reference/androidx/annotation/NonNull.html">NonNull</a> <a href="https://developer.android.com/reference/java/util/List.html">List</a>&lt;<a href="/reference/androidx/fragment/app/Fragment.html">Fragment</a>&gt;</code></td>
<td>
<div><code><a href="/reference/androidx/fragment/app/FragmentManager.html#getFragments()">getFragments</a>()</code></div>
<p>Get a list of all fragments that are currently added to the FragmentManager.</p>
</td>
</tr>
<tr>
<td width="40%"><code>@<a href="/reference/androidx/annotation/Nullable.html">Nullable</a> <a href="/reference/androidx/fragment/app/Fragment.html">Fragment</a></code></td>
<td>
<div><code><a href="/reference/androidx/fragment/app/FragmentManager.html#getPrimaryNavigationFragment()">getPrimaryNavigationFragment</a>()</code></div>
<p>Return the currently active primary navigation fragment for this FragmentManager.</p>
</td>
</tr>
<tr>
<td width="40%"><code>boolean</code></td>
<td>
<div><code><a href="/reference/androidx/fragment/app/FragmentManager.html#isDestroyed()">isDestroyed</a>()</code></div>
<p>Returns true if the final Activity.onDestroy() call has been made on the FragmentManager's Activity, so this instance is now dead.</p>
</td>
</tr>
<tr>
<td width="40%"><code>boolean</code></td>
<td>
<div><code><a href="/reference/androidx/fragment/app/FragmentManager.html#isStateSaved()">isStateSaved</a>()</code></div>
<p>Returns <code>true</code> if the FragmentManager's state has already been saved by its host.</p>
</td>
</tr>
<tr>
<td width="40%"><code>void</code></td>
<td>
<div><code><a href="/reference/androidx/fragment/app/FragmentManager.html#popBackStack()">popBackStack</a>()</code></div>
<p>Pop the top state off the back stack.</p>
</td>
</tr>
<tr>
<td width="40%"><code>void</code></td>
<td>
<div><code><a href="/reference/androidx/fragment/app/FragmentManager.html#popBackStack(java.lang.String,int)">popBackStack</a>(@<a href="/reference/androidx/annotation/Nullable.html">Nullable</a> <a href="https://developer.android.com/reference/java/lang/String.html">String</a>&nbsp;name,&nbsp;int&nbsp;flags)</code></div>
<p>Pop the last fragment transition from the manager's fragment back stack.</p>
</td>
</tr>
<tr>
<td width="40%"><code>void</code></td>
<td>
<div><code><a href="/reference/androidx/fragment/app/FragmentManager.html#popBackStack(int,int)">popBackStack</a>(int&nbsp;id,&nbsp;int&nbsp;flags)</code></div>
<p>Pop all back stack states up to the one with the given identifier.</p>
</td>
</tr>
<tr>
<td width="40%"><code>boolean</code></td>
<td>
<div><code><a href="/reference/androidx/fragment/app/FragmentManager.html#popBackStackImmediate()">popBackStackImmediate</a>()</code></div>
<p>Like <code><a href="/reference/androidx/fragment/app/FragmentManager.html#popBackStack()">popBackStack</a></code>, but performs the operation immediately inside of the call.</p>
</td>
</tr>
<tr>
<td width="40%"><code>boolean</code></td>
<td>
<div><code><a href="/reference/androidx/fragment/app/FragmentManager.html#popBackStackImmediate(java.lang.String,int)">popBackStackImmediate</a>(@<a href="/reference/androidx/annotation/Nullable.html">Nullable</a> <a href="https://developer.android.com/reference/java/lang/String.html">String</a>&nbsp;name,&nbsp;int&nbsp;flags)</code></div>
<p>Like <code><a href="/reference/androidx/fragment/app/FragmentManager.html#popBackStack(java.lang.String,int)">popBackStack</a></code>, but performs the operation immediately inside of the call.</p>
</td>
</tr>
<tr>
<td width="40%"><code>boolean</code></td>
<td>
<div><code><a href="/reference/androidx/fragment/app/FragmentManager.html#popBackStackImmediate(int,int)">popBackStackImmediate</a>(int&nbsp;id,&nbsp;int&nbsp;flags)</code></div>
<p>Like <code><a href="/reference/androidx/fragment/app/FragmentManager.html#popBackStack(int,int)">popBackStack</a></code>, but performs the operation immediately inside of the call.</p>
</td>
</tr>
<tr>
<td width="40%"><code>void</code></td>
<td>
<div><code><a href="/reference/androidx/fragment/app/FragmentManager.html#putFragment(android.os.Bundle,java.lang.String,androidx.fragment.app.Fragment)">putFragment</a>(<br>&nbsp;&nbsp;&nbsp;&nbsp;@<a href="/reference/androidx/annotation/NonNull.html">NonNull</a> Bundle&nbsp;bundle,<br>&nbsp;&nbsp;&nbsp;&nbsp;@<a href="/reference/androidx/annotation/NonNull.html">NonNull</a> <a href="https://developer.android.com/reference/java/lang/String.html">String</a>&nbsp;key,<br>&nbsp;&nbsp;&nbsp;&nbsp;@<a href="/reference/androidx/annotation/NonNull.html">NonNull</a> <a href="/reference/androidx/fragment/app/Fragment.html">Fragment</a>&nbsp;fragment<br>)</code></div>
<p>Put a reference to a fragment in a Bundle.</p>
</td>
</tr>
<tr>
<td width="40%"><code>void</code></td>
<td>
<div><code><a href="/reference/androidx/fragment/app/FragmentManager.html#registerFragmentLifecycleCallbacks(androidx.fragment.app.FragmentManager.FragmentLifecycleCallbacks,boolean)">registerFragmentLifecycleCallbacks</a>(<br>&nbsp;&nbsp;&nbsp;&nbsp;@<a href="/reference/androidx/annotation/NonNull.html">NonNull</a> <a href="/reference/androidx/fragment/app/FragmentManager.FragmentLifecycleCallbacks.html">FragmentManager.FragmentLifecycleCallbacks</a>&nbsp;cb,<br>&nbsp;&nbsp;&nbsp;&nbsp;boolean&nbsp;recursive<br>)</code></div>
<p>Registers a <code><a href="/reference/androidx/fragment/app/FragmentManager.FragmentLifecycleCallbacks.html">FragmentLifecycleCallbacks</a></code> to listen to fragment lifecycle events happening in this FragmentManager.</p>
</td>
</tr>
<tr>
<td width="40%"><code>void</code></td>
<td>
<div><code><a href="/reference/androidx/fragment/app/FragmentManager.html#removeFragmentOnAttachListener(androidx.fragment.app.FragmentOnAttachListener)">removeFragmentOnAttachListener</a>(<br>&nbsp;&nbsp;&nbsp;&nbsp;@<a href="/reference/androidx/annotation/NonNull.html">NonNull</a> <a href="/reference/androidx/fragment/app/FragmentOnAttachListener.html">FragmentOnAttachListener</a>&nbsp;listener<br>)</code></div>
<p>Remove a <code><a href="/reference/androidx/fragment/app/FragmentOnAttachListener.html">FragmentOnAttachListener</a></code> that was previously added via <code><a href="/reference/androidx/fragment/app/FragmentManager.html#addFragmentOnAttachListener(androidx.fragment.app.FragmentOnAttachListener)">addFragmentOnAttachListener</a></code>.</p>
</td>
</tr>
<tr>
<td width="40%"><code>void</code></td>
<td>
<div><code><a href="/reference/androidx/fragment/app/FragmentManager.html#removeOnBackStackChangedListener(androidx.fragment.app.FragmentManager.OnBackStackChangedListener)">removeOnBackStackChangedListener</a>(<br>&nbsp;&nbsp;&nbsp;&nbsp;@<a href="/reference/androidx/annotation/NonNull.html">NonNull</a> <a href="/reference/androidx/fragment/app/FragmentManager.OnBackStackChangedListener.html">FragmentManager.OnBackStackChangedListener</a>&nbsp;listener<br>)</code></div>
<p>Remove a listener that was previously added with <code><a href="/reference/androidx/fragment/app/FragmentManager.html#addOnBackStackChangedListener(androidx.fragment.app.FragmentManager.OnBackStackChangedListener)">addOnBackStackChangedListener</a></code>.</p>
</td>
</tr>
<tr>
<td width="40%"><code>@<a href="/reference/androidx/annotation/Nullable.html">Nullable</a> <a href="/reference/androidx/fragment/app/Fragment.SavedState.html">Fragment.SavedState</a></code></td>
<td>
<div><code><a href="/reference/androidx/fragment/app/FragmentManager.html#saveFragmentInstanceState(androidx.fragment.app.Fragment)">saveFragmentInstanceState</a>(@<a href="/reference/androidx/annotation/NonNull.html">NonNull</a> <a href="/reference/androidx/fragment/app/Fragment.html">Fragment</a>&nbsp;fragment)</code></div>
<p>Save the current instance state of the given Fragment.</p>
</td>
</tr>
<tr>
<td width="40%"><code>void</code></td>
<td>
<div><code><a href="/reference/androidx/fragment/app/FragmentManager.html#setFragmentFactory(androidx.fragment.app.FragmentFactory)">setFragmentFactory</a>(@<a href="/reference/androidx/annotation/NonNull.html">NonNull</a> <a href="/reference/androidx/fragment/app/FragmentFactory.html">FragmentFactory</a>&nbsp;fragmentFactory)</code></div>
<p>Set a <code><a href="/reference/androidx/fragment/app/FragmentFactory.html">FragmentFactory</a></code> for this FragmentManager that will be used to create new Fragment instances from this point onward.</p>
</td>
</tr>
<tr>
<td width="40%"><code>final void</code></td>
<td>
<div><code><a href="/reference/androidx/fragment/app/FragmentManager.html#setFragmentResult(java.lang.String,android.os.Bundle)">setFragmentResult</a>(@<a href="/reference/androidx/annotation/NonNull.html">NonNull</a> <a href="https://developer.android.com/reference/java/lang/String.html">String</a>&nbsp;requestKey,&nbsp;@<a href="/reference/androidx/annotation/NonNull.html">NonNull</a> Bundle&nbsp;result)</code></div>
<p>Sets the given result for the requestKey.</p>
</td>
</tr>
<tr>
<td width="40%"><code>final void</code></td>
<td>
<div><code><a href="/reference/androidx/fragment/app/FragmentManager.html#setFragmentResultListener(java.lang.String,androidx.lifecycle.LifecycleOwner,androidx.fragment.app.FragmentResultListener)">setFragmentResultListener</a>(<br>&nbsp;&nbsp;&nbsp;&nbsp;@<a href="/reference/androidx/annotation/NonNull.html">NonNull</a> <a href="https://developer.android.com/reference/java/lang/String.html">String</a>&nbsp;requestKey,<br>&nbsp;&nbsp;&nbsp;&nbsp;@<a href="/reference/androidx/annotation/NonNull.html">NonNull</a> LifecycleOwner&nbsp;lifecycleOwner,<br>&nbsp;&nbsp;&nbsp;&nbsp;@<a href="/reference/androidx/annotation/NonNull.html">NonNull</a> <a href="/reference/androidx/fragment/app/FragmentResultListener.html">FragmentResultListener</a>&nbsp;listener<br>)</code></div>
<p>Sets the <code><a href="/reference/androidx/fragment/app/FragmentResultListener.html">FragmentResultListener</a></code> for a given requestKey.</p>
</td>
</tr>
<tr>
<td width="40%"><code>@<a href="/reference/androidx/annotation/NonNull.html">NonNull</a> <a href="https://developer.android.com/reference/java/lang/String.html">String</a></code></td>
<td>
<div><code><a href="/reference/androidx/fragment/app/FragmentManager.html#toString()">toString</a>()</code></div>
</td>
</tr>
<tr>
<td width="40%"><code>void</code></td>
<td>
<div><code><a href="/reference/androidx/fragment/app/FragmentManager.html#unregisterFragmentLifecycleCallbacks(androidx.fragment.app.FragmentManager.FragmentLifecycleCallbacks)">unregisterFragmentLifecycleCallbacks</a>(<br>&nbsp;&nbsp;&nbsp;&nbsp;@<a href="/reference/androidx/annotation/NonNull.html">NonNull</a> <a href="/reference/androidx/fragment/app/FragmentManager.FragmentLifecycleCallbacks.html">FragmentManager.FragmentLifecycleCallbacks</a>&nbsp;cb<br>)</code></div>
<p>Unregisters a previously registered <code><a href="/reference/androidx/fragment/app/FragmentManager.FragmentLifecycleCallbacks.html">FragmentLifecycleCallbacks</a></code>.</p>
</td>
</tr>
</tbody>
</table>
</div>
<h2>Constants</h2>
<div><a name="getPOP_BACK_STACK_INCLUSIVE()"></a><a name="setPOP_BACK_STACK_INCLUSIVE()"></a><a name="getPOP_BACK_STACK_INCLUSIVE--"></a><a name="setPOP_BACK_STACK_INCLUSIVE--"></a>
<h3 class="api-name" id="POP_BACK_STACK_INCLUSIVE()">POP_BACK_STACK_INCLUSIVE</h3>
<pre class="api-signature no-pretty-print">public&nbsp;static&nbsp;final&nbsp;int&nbsp;<a href="/reference/androidx/fragment/app/FragmentManager.html#POP_BACK_STACK_INCLUSIVE()">POP_BACK_STACK_INCLUSIVE</a></pre>
<p>Flag for <code><a href="/reference/androidx/fragment/app/FragmentManager.html#popBackStack(java.lang.String,int)">popBackStack</a></code> and <code><a href="/reference/androidx/fragment/app/FragmentManager.html#popBackStack(int,int)">popBackStack</a></code>: 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.</p>
</div>
<h2>Public constructors</h2>
<div><a name="FragmentManager--"></a><a name="fragmentmanager"></a>
<h3 class="api-name" id="FragmentManager()">FragmentManager</h3>
<pre class="api-signature no-pretty-print">public&nbsp;<a href="/reference/androidx/fragment/app/FragmentManager.html#FragmentManager()">FragmentManager</a>()</pre>
</div>
<h2>Public methods</h2>
<div><a name="addFragmentOnAttachListener-androidx.fragment.app.FragmentOnAttachListener-"></a><a name="addfragmentonattachlistener"></a>
<h3 class="api-name" id="addFragmentOnAttachListener(androidx.fragment.app.FragmentOnAttachListener)">addFragmentOnAttachListener</h3>
<pre class="api-signature no-pretty-print">public&nbsp;void&nbsp;<a href="/reference/androidx/fragment/app/FragmentManager.html#addFragmentOnAttachListener(androidx.fragment.app.FragmentOnAttachListener)">addFragmentOnAttachListener</a>(@<a href="/reference/androidx/annotation/NonNull.html">NonNull</a> <a href="/reference/androidx/fragment/app/FragmentOnAttachListener.html">FragmentOnAttachListener</a>&nbsp;listener)</pre>
<p>Add a <code><a href="/reference/androidx/fragment/app/FragmentOnAttachListener.html">FragmentOnAttachListener</a></code> that should receive a call to <code><a href="/reference/androidx/fragment/app/FragmentOnAttachListener.html#onAttachFragment(androidx.fragment.app.FragmentManager,androidx.fragment.app.Fragment)">FragmentOnAttachListener#onAttachFragment(FragmentManager, Fragment)</a></code> when a new Fragment is attached to this FragmentManager.</p>
<div class="devsite-table-wrapper">
<table class="responsive">
<thead>
<tr>
<th colspan="2">Parameters</th>
</tr>
</thead>
<tbody>
<tr>
<td width="40%"><code>@<a href="/reference/androidx/annotation/NonNull.html">NonNull</a> <a href="/reference/androidx/fragment/app/FragmentOnAttachListener.html">FragmentOnAttachListener</a>&nbsp;listener</code></td>
<td>
<p>Listener to add</p>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<div><a name="addOnBackStackChangedListener-androidx.fragment.app.FragmentManager.OnBackStackChangedListener-"></a><a name="addonbackstackchangedlistener"></a>
<h3 class="api-name" id="addOnBackStackChangedListener(androidx.fragment.app.FragmentManager.OnBackStackChangedListener)">addOnBackStackChangedListener</h3>
<pre class="api-signature no-pretty-print">public&nbsp;void&nbsp;<a href="/reference/androidx/fragment/app/FragmentManager.html#addOnBackStackChangedListener(androidx.fragment.app.FragmentManager.OnBackStackChangedListener)">addOnBackStackChangedListener</a>(<br>&nbsp;&nbsp;&nbsp;&nbsp;@<a href="/reference/androidx/annotation/NonNull.html">NonNull</a> <a href="/reference/androidx/fragment/app/FragmentManager.OnBackStackChangedListener.html">FragmentManager.OnBackStackChangedListener</a>&nbsp;listener<br>)</pre>
<p>Add a new listener for changes to the fragment back stack.</p>
</div>
<div><a name="beginTransaction--"></a><a name="begintransaction"></a>
<h3 class="api-name" id="beginTransaction()">beginTransaction</h3>
<pre class="api-signature no-pretty-print">public&nbsp;@<a href="/reference/androidx/annotation/NonNull.html">NonNull</a> <a href="/reference/androidx/fragment/app/FragmentTransaction.html">FragmentTransaction</a>&nbsp;<a href="/reference/androidx/fragment/app/FragmentManager.html#beginTransaction()">beginTransaction</a>()</pre>
<p>Start a series of edit operations on the Fragments associated with this FragmentManager. </p>
<p>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() (and prior to a following <code><a href="/reference/androidx/fragment/app/FragmentActivity.html#onStart()">FragmentActivity.onStart</a></code> or <code><a href="/reference/androidx/fragment/app/FragmentActivity.html#onResume()">FragmentActivity.onResume()</a></code>, 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.</p>
</div>
<div><a name="clearFragmentResult-java.lang.String-"></a><a name="clearfragmentresult"></a>
<h3 class="api-name" id="clearFragmentResult(java.lang.String)">clearFragmentResult</h3>
<pre class="api-signature no-pretty-print">public&nbsp;final&nbsp;void&nbsp;<a href="/reference/androidx/fragment/app/FragmentManager.html#clearFragmentResult(java.lang.String)">clearFragmentResult</a>(@<a href="/reference/androidx/annotation/NonNull.html">NonNull</a> <a href="https://developer.android.com/reference/java/lang/String.html">String</a>&nbsp;requestKey)</pre>
<p>Clears the stored result for the given requestKey. This clears any result that was previously set via <code><a href="/reference/androidx/fragment/app/FragmentResultOwner.html#setFragmentResult(java.lang.String,android.os.Bundle)">setFragmentResult</a></code> that hasn't yet been delivered to a <code><a href="/reference/androidx/fragment/app/FragmentResultListener.html">FragmentResultListener</a></code>.</p>
<div class="devsite-table-wrapper">
<table class="responsive">
<thead>
<tr>
<th colspan="2">Parameters</th>
</tr>
</thead>
<tbody>
<tr>
<td width="40%"><code>@<a href="/reference/androidx/annotation/NonNull.html">NonNull</a> <a href="https://developer.android.com/reference/java/lang/String.html">String</a>&nbsp;requestKey</code></td>
<td>
<p>key used to identify the result</p>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<div><a name="clearFragmentResultListener-java.lang.String-"></a><a name="clearfragmentresultlistener"></a>
<h3 class="api-name" id="clearFragmentResultListener(java.lang.String)">clearFragmentResultListener</h3>
<pre class="api-signature no-pretty-print">public&nbsp;final&nbsp;void&nbsp;<a href="/reference/androidx/fragment/app/FragmentManager.html#clearFragmentResultListener(java.lang.String)">clearFragmentResultListener</a>(@<a href="/reference/androidx/annotation/NonNull.html">NonNull</a> <a href="https://developer.android.com/reference/java/lang/String.html">String</a>&nbsp;requestKey)</pre>
<p>Clears the stored <code><a href="/reference/androidx/fragment/app/FragmentResultListener.html">FragmentResultListener</a></code> for the given requestKey. This clears any <code><a href="/reference/androidx/fragment/app/FragmentResultListener.html">FragmentResultListener</a></code> that was previously set via <code><a href="/reference/androidx/fragment/app/FragmentResultOwner.html#setFragmentResultListener(java.lang.String,androidx.lifecycle.LifecycleOwner,androidx.fragment.app.FragmentResultListener)">setFragmentResultListener</a></code>.</p>
<div class="devsite-table-wrapper">
<table class="responsive">
<thead>
<tr>
<th colspan="2">Parameters</th>
</tr>
</thead>
<tbody>
<tr>
<td width="40%"><code>@<a href="/reference/androidx/annotation/NonNull.html">NonNull</a> <a href="https://developer.android.com/reference/java/lang/String.html">String</a>&nbsp;requestKey</code></td>
<td>
<p>key used to identify the result</p>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<div><a name="dump(java.lang.String, java.io.FileDescriptor, java.io.PrintWriter, java.lang.String[])"></a><a name="dump-java.lang.String-java.io.FileDescriptor-java.io.PrintWriter-java.lang.String[]-"></a><a name="dump"></a>
<h3 class="api-name" id="dump(java.lang.String,java.io.FileDescriptor,java.io.PrintWriter,java.lang.String[])">dump</h3>
<pre class="api-signature no-pretty-print">public&nbsp;void&nbsp;<a href="/reference/androidx/fragment/app/FragmentManager.html#dump(java.lang.String,java.io.FileDescriptor,java.io.PrintWriter,java.lang.String[])">dump</a>(<br>&nbsp;&nbsp;&nbsp;&nbsp;@<a href="/reference/androidx/annotation/NonNull.html">NonNull</a> <a href="https://developer.android.com/reference/java/lang/String.html">String</a>&nbsp;prefix,<br>&nbsp;&nbsp;&nbsp;&nbsp;@<a href="/reference/androidx/annotation/Nullable.html">Nullable</a> <a href="https://developer.android.com/reference/java/io/FileDescriptor.html">FileDescriptor</a>&nbsp;fd,<br>&nbsp;&nbsp;&nbsp;&nbsp;@<a href="/reference/androidx/annotation/NonNull.html">NonNull</a> <a href="https://developer.android.com/reference/java/io/PrintWriter.html">PrintWriter</a>&nbsp;writer,<br>&nbsp;&nbsp;&nbsp;&nbsp;@<a href="/reference/androidx/annotation/Nullable.html">Nullable</a> String[]&nbsp;args<br>)</pre>
<p>Print the FragmentManager's state into the given stream.</p>
<div class="devsite-table-wrapper">
<table class="responsive">
<thead>
<tr>
<th colspan="2">Parameters</th>
</tr>
</thead>
<tbody>
<tr>
<td width="40%"><code>@<a href="/reference/androidx/annotation/NonNull.html">NonNull</a> <a href="https://developer.android.com/reference/java/lang/String.html">String</a>&nbsp;prefix</code></td>
<td>
<p>Text to print at the front of each line.</p>
</td>
</tr>
<tr>
<td width="40%"><code>@<a href="/reference/androidx/annotation/Nullable.html">Nullable</a> <a href="https://developer.android.com/reference/java/io/FileDescriptor.html">FileDescriptor</a>&nbsp;fd</code></td>
<td>
<p>The raw file descriptor that the dump is being sent to.</p>
</td>
</tr>
<tr>
<td width="40%"><code>@<a href="/reference/androidx/annotation/NonNull.html">NonNull</a> <a href="https://developer.android.com/reference/java/io/PrintWriter.html">PrintWriter</a>&nbsp;writer</code></td>
<td>
<p>A PrintWriter to which the dump is to be set.</p>
</td>
</tr>
<tr>
<td width="40%"><code>@<a href="/reference/androidx/annotation/Nullable.html">Nullable</a> String[]&nbsp;args</code></td>
<td>
<p>Additional arguments to the dump request.</p>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<div><a name="enableDebugLogging-boolean-"></a><a name="enabledebuglogging"></a>
<h3 class="api-name" id="enableDebugLogging(boolean)">enableDebugLogging</h3>
<pre class="api-signature no-pretty-print">public&nbsp;static&nbsp;void&nbsp;<span><del><a href="/reference/androidx/fragment/app/FragmentManager.html#enableDebugLogging(boolean)">enableDebugLogging</a></del></span>(boolean&nbsp;enabled)</pre>
<aside class="caution"><strong>This method is deprecated.</strong><br>
<p>FragmentManager now respects Log#isLoggable(String, int) for debug logging, allowing you to use <code>adb shell setprop log.tag.FragmentManager VERBOSE</code>.</p>
</aside>
<p>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.</p>
<div class="devsite-table-wrapper">
<table class="responsive">
<thead>
<tr>
<th colspan="2">See also</th>
</tr>
</thead>
<tbody>
<tr>
<td width="40%"><code><a href="/reference/android/util/Log.html#isLoggable(String, int)">Log</a></code></td>
<td></td>
</tr>
</tbody>
</table>
</div>
</div>
<div><a name="enableNewStateManager-boolean-"></a><a name="enablenewstatemanager"></a>
<h3 class="api-name" id="enableNewStateManager(boolean)">enableNewStateManager</h3>
<pre class="api-signature no-pretty-print">@<a href="/reference/androidx/fragment/app/FragmentStateManagerControl.html">FragmentStateManagerControl</a><br>public&nbsp;static&nbsp;void&nbsp;<a href="/reference/androidx/fragment/app/FragmentManager.html#enableNewStateManager(boolean)">enableNewStateManager</a>(boolean&nbsp;enabled)</pre>
<p>Control whether FragmentManager uses the new state manager that is responsible for: </p>
<ul>
<li>Moving Fragments through their lifecycle methods</li>
<li>Running animations and transitions</li>
<li>Handling postponed transactions</li>
</ul>
This must only be changed <b>before</b> any fragment transactions are done (i.e., in your <code>Application</code> class or prior to <code>super.onCreate()</code> in every activity with the same value for all activities). Changing it after that point is <b>not</b> supported and can result in fragments not moving to their expected state.
<p> This is <b>enabled</b> by default. Disabling it should only be used in cases where you are debugging a potential regression and as part of <a href="https://issuetracker.google.com/issues/new?component=460964">filing an issue</a> to verify and fix the regression.</p>
<div class="devsite-table-wrapper">
<table class="responsive">
<thead>
<tr>
<th colspan="2">Parameters</th>
</tr>
</thead>
<tbody>
<tr>
<td width="40%"><code>boolean&nbsp;enabled</code></td>
<td>
<p>Whether the new state manager should be enabled.</p>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<div><a name="executePendingTransactions--"></a><a name="executependingtransactions"></a>
<h3 class="api-name" id="executePendingTransactions()">executePendingTransactions</h3>
<pre class="api-signature no-pretty-print">public&nbsp;boolean&nbsp;<a href="/reference/androidx/fragment/app/FragmentManager.html#executePendingTransactions()">executePendingTransactions</a>()</pre>
<p>After a <code><a href="/reference/androidx/fragment/app/FragmentTransaction.html">FragmentTransaction</a></code> is committed with <code><a href="/reference/androidx/fragment/app/FragmentTransaction.html#commit()">FragmentTransaction.commit()</a></code>, 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. </p>
<p>If you are committing a single transaction that does not modify the fragment back stack, strongly consider using <code><a href="/reference/androidx/fragment/app/FragmentTransaction.html#commitNow()">FragmentTransaction#commitNow()</a></code> instead. This can help avoid unwanted side effects when other code in your app has pending committed transactions that expect different timing.</p>
<p> This also forces the start of any postponed Transactions where <code><a href="/reference/androidx/fragment/app/Fragment.html#postponeEnterTransition()">Fragment#postponeEnterTransition()</a></code> has been called.</p>
<div class="devsite-table-wrapper">
<table class="responsive">
<thead>
<tr>
<th colspan="2">Returns</th>
</tr>
</thead>
<tbody>
<tr>
<td width="40%"><code>boolean</code></td>
<td>
<p>Returns true if there were any pending transactions to be executed.</p>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<div><a name="findFragment-android.view.View-"></a><a name="findfragment"></a>
<h3 class="api-name" id="findFragment(android.view.View)">findFragment</h3>
<pre class="api-signature no-pretty-print">public&nbsp;static&nbsp;@<a href="/reference/androidx/annotation/NonNull.html">NonNull</a> F&nbsp;&lt;F&nbsp;extends&nbsp;<a href="/reference/androidx/fragment/app/Fragment.html">Fragment</a>&gt; <a href="/reference/androidx/fragment/app/FragmentManager.html#findFragment(android.view.View)">findFragment</a>(@<a href="/reference/androidx/annotation/NonNull.html">NonNull</a> View&nbsp;view)</pre>
<p>Find a <code><a href="/reference/androidx/fragment/app/Fragment.html">Fragment</a></code> associated with the given View. This method will locate the <code><a href="/reference/androidx/fragment/app/Fragment.html">Fragment</a></code> associated with this view. This is automatically populated for the View returned by <code><a href="/reference/androidx/fragment/app/Fragment.html#onCreateView(android.view.LayoutInflater,android.view.ViewGroup,android.os.Bundle)">Fragment#onCreateView</a></code> and its children.</p>
<div class="devsite-table-wrapper">
<table class="responsive">
<thead>
<tr>
<th colspan="2">Parameters</th>
</tr>
</thead>
<tbody>
<tr>
<td width="40%"><code>@<a href="/reference/androidx/annotation/NonNull.html">NonNull</a> View&nbsp;view</code></td>
<td>
<p>the view to search from</p>
</td>
</tr>
</tbody>
</table>
</div>
<div class="devsite-table-wrapper">
<table class="responsive">
<thead>
<tr>
<th colspan="2">Returns</th>
</tr>
</thead>
<tbody>
<tr>
<td width="40%"><code>@<a href="/reference/androidx/annotation/NonNull.html">NonNull</a> F</code></td>
<td>
<p>the locally scoped <code><a href="/reference/androidx/fragment/app/Fragment.html">Fragment</a></code> to the given view</p>
</td>
</tr>
</tbody>
</table>
</div>
<div class="devsite-table-wrapper">
<table class="responsive">
<thead>
<tr>
<th colspan="2">Throws</th>
</tr>
</thead>
<tbody>
<tr>
<td width="40%"><code>java.lang.IllegalStateException</code></td>
<td>
<p>if the given view does not correspond with a <code><a href="/reference/androidx/fragment/app/Fragment.html">Fragment</a></code>.</p>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<div><a name="findFragmentById-int-"></a><a name="findfragmentbyid"></a>
<h3 class="api-name" id="findFragmentById(int)">findFragmentById</h3>
<pre class="api-signature no-pretty-print">public&nbsp;@<a href="/reference/androidx/annotation/Nullable.html">Nullable</a> <a href="/reference/androidx/fragment/app/Fragment.html">Fragment</a>&nbsp;<a href="/reference/androidx/fragment/app/FragmentManager.html#findFragmentById(int)">findFragmentById</a>(int&nbsp;id)</pre>
<p>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.</p>
<div class="devsite-table-wrapper">
<table class="responsive">
<thead>
<tr>
<th colspan="2">Returns</th>
</tr>
</thead>
<tbody>
<tr>
<td width="40%"><code>@<a href="/reference/androidx/annotation/Nullable.html">Nullable</a> <a href="/reference/androidx/fragment/app/Fragment.html">Fragment</a></code></td>
<td>
<p>The fragment if found or null otherwise.</p>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<div><a name="findFragmentByTag-java.lang.String-"></a><a name="findfragmentbytag"></a>
<h3 class="api-name" id="findFragmentByTag(java.lang.String)">findFragmentByTag</h3>
<pre class="api-signature no-pretty-print">public&nbsp;@<a href="/reference/androidx/annotation/Nullable.html">Nullable</a> <a href="/reference/androidx/fragment/app/Fragment.html">Fragment</a>&nbsp;<a href="/reference/androidx/fragment/app/FragmentManager.html#findFragmentByTag(java.lang.String)">findFragmentByTag</a>(@<a href="/reference/androidx/annotation/Nullable.html">Nullable</a> <a href="https://developer.android.com/reference/java/lang/String.html">String</a>&nbsp;tag)</pre>
<p>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. </p>
<p> If provided a <code>null</code> tag, this method returns null.</p>
<div class="devsite-table-wrapper">
<table class="responsive">
<thead>
<tr>
<th colspan="2">Parameters</th>
</tr>
</thead>
<tbody>
<tr>
<td width="40%"><code>@<a href="/reference/androidx/annotation/Nullable.html">Nullable</a> <a href="https://developer.android.com/reference/java/lang/String.html">String</a>&nbsp;tag</code></td>
<td>
<p>the tag used to search for the fragment</p>
</td>
</tr>
</tbody>
</table>
</div>
<div class="devsite-table-wrapper">
<table class="responsive">
<thead>
<tr>
<th colspan="2">Returns</th>
</tr>
</thead>
<tbody>
<tr>
<td width="40%"><code>@<a href="/reference/androidx/annotation/Nullable.html">Nullable</a> <a href="/reference/androidx/fragment/app/Fragment.html">Fragment</a></code></td>
<td>
<p>The fragment if found or null otherwise.</p>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<div><a name="getBackStackEntryAt-int-"></a><a name="getbackstackentryat"></a>
<h3 class="api-name" id="getBackStackEntryAt(int)">getBackStackEntryAt</h3>
<pre class="api-signature no-pretty-print">public&nbsp;@<a href="/reference/androidx/annotation/NonNull.html">NonNull</a> <a href="/reference/androidx/fragment/app/FragmentManager.BackStackEntry.html">FragmentManager.BackStackEntry</a>&nbsp;<a href="/reference/androidx/fragment/app/FragmentManager.html#getBackStackEntryAt(int)">getBackStackEntryAt</a>(int&nbsp;index)</pre>
<p>Return the BackStackEntry at index index in the back stack; entries start index 0 being the bottom of the stack.</p>
</div>
<div><a name="getBackStackEntryCount--"></a><a name="getbackstackentrycount"></a>
<h3 class="api-name" id="getBackStackEntryCount()">getBackStackEntryCount</h3>
<pre class="api-signature no-pretty-print">public&nbsp;int&nbsp;<a href="/reference/androidx/fragment/app/FragmentManager.html#getBackStackEntryCount()">getBackStackEntryCount</a>()</pre>
<p>Return the number of entries currently in the back stack.</p>
</div>
<div><a name="getFragment(android.os.Bundle, java.lang.String)"></a><a name="getFragment-android.os.Bundle-java.lang.String-"></a><a name="getfragment"></a>
<h3 class="api-name" id="getFragment(android.os.Bundle,java.lang.String)">getFragment</h3>
<pre class="api-signature no-pretty-print">public&nbsp;@<a href="/reference/androidx/annotation/Nullable.html">Nullable</a> <a href="/reference/androidx/fragment/app/Fragment.html">Fragment</a>&nbsp;<a href="/reference/androidx/fragment/app/FragmentManager.html#getFragment(android.os.Bundle,java.lang.String)">getFragment</a>(@<a href="/reference/androidx/annotation/NonNull.html">NonNull</a> Bundle&nbsp;bundle,&nbsp;@<a href="/reference/androidx/annotation/NonNull.html">NonNull</a> <a href="https://developer.android.com/reference/java/lang/String.html">String</a>&nbsp;key)</pre>
<p>Retrieve the current Fragment instance for a reference previously placed with <code><a href="/reference/androidx/fragment/app/FragmentManager.html#putFragment(android.os.Bundle,java.lang.String,androidx.fragment.app.Fragment)">putFragment</a></code>.</p>
<div class="devsite-table-wrapper">
<table class="responsive">
<thead>
<tr>
<th colspan="2">Parameters</th>
</tr>
</thead>
<tbody>
<tr>
<td width="40%"><code>@<a href="/reference/androidx/annotation/NonNull.html">NonNull</a> Bundle&nbsp;bundle</code></td>
<td>
<p>The bundle from which to retrieve the fragment reference.</p>
</td>
</tr>
<tr>
<td width="40%"><code>@<a href="/reference/androidx/annotation/NonNull.html">NonNull</a> <a href="https://developer.android.com/reference/java/lang/String.html">String</a>&nbsp;key</code></td>
<td>
<p>The name of the entry in the bundle.</p>
</td>
</tr>
</tbody>
</table>
</div>
<div class="devsite-table-wrapper">
<table class="responsive">
<thead>
<tr>
<th colspan="2">Returns</th>
</tr>
</thead>
<tbody>
<tr>
<td width="40%"><code>@<a href="/reference/androidx/annotation/Nullable.html">Nullable</a> <a href="/reference/androidx/fragment/app/Fragment.html">Fragment</a></code></td>
<td>
<p>Returns the current Fragment instance that is associated with the given reference.</p>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<div><a name="getFragmentFactory--"></a><a name="getfragmentfactory"></a>
<h3 class="api-name" id="getFragmentFactory()">getFragmentFactory</h3>
<pre class="api-signature no-pretty-print">public&nbsp;@<a href="/reference/androidx/annotation/NonNull.html">NonNull</a> <a href="/reference/androidx/fragment/app/FragmentFactory.html">FragmentFactory</a>&nbsp;<a href="/reference/androidx/fragment/app/FragmentManager.html#getFragmentFactory()">getFragmentFactory</a>()</pre>
<p>Gets the current <code><a href="/reference/androidx/fragment/app/FragmentFactory.html">FragmentFactory</a></code> used to instantiate new Fragment instances. </p>
<p> If no factory has been explicitly set on this FragmentManager via <code><a href="/reference/androidx/fragment/app/FragmentManager.html#setFragmentFactory(androidx.fragment.app.FragmentFactory)">setFragmentFactory</a></code>, the FragmentFactory of the <code><a href="/reference/androidx/fragment/app/Fragment.html#getParentFragmentManager()">parent FragmentManager</a></code> will be returned.</p>
<div class="devsite-table-wrapper">
<table class="responsive">
<thead>
<tr>
<th colspan="2">Returns</th>
</tr>
</thead>
<tbody>
<tr>
<td width="40%"><code>@<a href="/reference/androidx/annotation/NonNull.html">NonNull</a> <a href="/reference/androidx/fragment/app/FragmentFactory.html">FragmentFactory</a></code></td>
<td>
<p>the current FragmentFactory</p>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<div><a name="getFragments--"></a><a name="getfragments"></a>
<h3 class="api-name" id="getFragments()">getFragments</h3>
<pre class="api-signature no-pretty-print">public&nbsp;@<a href="/reference/androidx/annotation/NonNull.html">NonNull</a> <a href="https://developer.android.com/reference/java/util/List.html">List</a>&lt;<a href="/reference/androidx/fragment/app/Fragment.html">Fragment</a>&gt;&nbsp;<a href="/reference/androidx/fragment/app/FragmentManager.html#getFragments()">getFragments</a>()</pre>
<p>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. </p>
<p> The order of the fragments in the list is the order in which they were added or attached.</p>
<div class="devsite-table-wrapper">
<table class="responsive">
<thead>
<tr>
<th colspan="2">Returns</th>
</tr>
</thead>
<tbody>
<tr>
<td width="40%"><code>@<a href="/reference/androidx/annotation/NonNull.html">NonNull</a> <a href="https://developer.android.com/reference/java/util/List.html">List</a>&lt;<a href="/reference/androidx/fragment/app/Fragment.html">Fragment</a>&gt;</code></td>
<td>
<p>A list of all fragments that are added to the FragmentManager.</p>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<div><a name="getPrimaryNavigationFragment--"></a><a name="getprimarynavigationfragment"></a>
<h3 class="api-name" id="getPrimaryNavigationFragment()">getPrimaryNavigationFragment</h3>
<pre class="api-signature no-pretty-print">public&nbsp;@<a href="/reference/androidx/annotation/Nullable.html">Nullable</a> <a href="/reference/androidx/fragment/app/Fragment.html">Fragment</a>&nbsp;<a href="/reference/androidx/fragment/app/FragmentManager.html#getPrimaryNavigationFragment()">getPrimaryNavigationFragment</a>()</pre>
<p>Return the currently active primary navigation fragment for this FragmentManager. The primary navigation fragment is set by fragment transactions using <code><a href="/reference/androidx/fragment/app/FragmentTransaction.html#setPrimaryNavigationFragment(androidx.fragment.app.Fragment)">FragmentTransaction#setPrimaryNavigationFragment(Fragment)</a></code>. </p>
<p>The primary navigation fragment's <code><a href="/reference/androidx/fragment/app/Fragment.html#getChildFragmentManager()">child FragmentManager</a></code> will be called first to process delegated navigation actions such as <code><a href="/reference/androidx/fragment/app/FragmentManager.html#popBackStack()">popBackStack</a></code> if no ID or transaction name is provided to pop to.</p>
<div class="devsite-table-wrapper">
<table class="responsive">
<thead>
<tr>
<th colspan="2">Returns</th>
</tr>
</thead>
<tbody>
<tr>
<td width="40%"><code>@<a href="/reference/androidx/annotation/Nullable.html">Nullable</a> <a href="/reference/androidx/fragment/app/Fragment.html">Fragment</a></code></td>
<td>
<p>the fragment designated as the primary navigation fragment</p>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<div><a name="isDestroyed--"></a><a name="isdestroyed"></a>
<h3 class="api-name" id="isDestroyed()">isDestroyed</h3>
<pre class="api-signature no-pretty-print">public&nbsp;boolean&nbsp;<a href="/reference/androidx/fragment/app/FragmentManager.html#isDestroyed()">isDestroyed</a>()</pre>
<p>Returns true if the final Activity.onDestroy() call has been made on the FragmentManager's Activity, so this instance is now dead.</p>
</div>
<div><a name="isStateSaved--"></a><a name="isstatesaved"></a>
<h3 class="api-name" id="isStateSaved()">isStateSaved</h3>
<pre class="api-signature no-pretty-print">public&nbsp;boolean&nbsp;<a href="/reference/androidx/fragment/app/FragmentManager.html#isStateSaved()">isStateSaved</a>()</pre>
<p>Returns <code>true</code> 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 <code><a href="/reference/androidx/fragment/app/FragmentManager.html#popBackStackImmediate()">popBackStackImmediate</a></code> or any FragmentTransaction using <code><a href="/reference/androidx/fragment/app/FragmentTransaction.html#commit()">FragmentTransaction#commit()</a></code> instead of <code><a href="/reference/androidx/fragment/app/FragmentTransaction.html#commitAllowingStateLoss()">FragmentTransaction#commitAllowingStateLoss()</a></code> will change the state and will result in an error.</p>
<div class="devsite-table-wrapper">
<table class="responsive">
<thead>
<tr>
<th colspan="2">Returns</th>
</tr>
</thead>
<tbody>
<tr>
<td width="40%"><code>boolean</code></td>
<td>
<p>true if this FragmentManager's state has already been saved by its host</p>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<div><a name="popBackStack--"></a><a name="popbackstack"></a>
<h3 class="api-name" id="popBackStack()">popBackStack</h3>
<pre class="api-signature no-pretty-print">public&nbsp;void&nbsp;<a href="/reference/androidx/fragment/app/FragmentManager.html#popBackStack()">popBackStack</a>()</pre>
<p>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.</p>
</div>
<div><a name="popBackStack(java.lang.String, int)"></a><a name="popBackStack-java.lang.String-int-"></a><a name="popbackstack"></a>
<h3 class="api-name" id="popBackStack(java.lang.String,int)">popBackStack</h3>
<pre class="api-signature no-pretty-print">public&nbsp;void&nbsp;<a href="/reference/androidx/fragment/app/FragmentManager.html#popBackStack(java.lang.String,int)">popBackStack</a>(@<a href="/reference/androidx/annotation/Nullable.html">Nullable</a> <a href="https://developer.android.com/reference/java/lang/String.html">String</a>&nbsp;name,&nbsp;int&nbsp;flags)</pre>
<p>Pop the last fragment transition from the manager's fragment 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.</p>
<div class="devsite-table-wrapper">
<table class="responsive">
<thead>
<tr>
<th colspan="2">Parameters</th>
</tr>
</thead>
<tbody>
<tr>
<td width="40%"><code>@<a href="/reference/androidx/annotation/Nullable.html">Nullable</a> <a href="https://developer.android.com/reference/java/lang/String.html">String</a>&nbsp;name</code></td>
<td>
<p>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 <code><a href="/reference/androidx/fragment/app/FragmentManager.html#POP_BACK_STACK_INCLUSIVE()">POP_BACK_STACK_INCLUSIVE</a></code> flag can be used to control whether the named state itself is popped. If null, only the top state is popped.</p>
</td>
</tr>
<tr>
<td width="40%"><code>int&nbsp;flags</code></td>
<td>
<p>Either 0 or <code><a href="/reference/androidx/fragment/app/FragmentManager.html#POP_BACK_STACK_INCLUSIVE()">POP_BACK_STACK_INCLUSIVE</a></code>.</p>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<div><a name="popBackStack(int, int)"></a><a name="popBackStack-int-int-"></a><a name="popbackstack"></a>
<h3 class="api-name" id="popBackStack(int,int)">popBackStack</h3>
<pre class="api-signature no-pretty-print">public&nbsp;void&nbsp;<a href="/reference/androidx/fragment/app/FragmentManager.html#popBackStack(int,int)">popBackStack</a>(int&nbsp;id,&nbsp;int&nbsp;flags)</pre>
<p>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.</p>
<div class="devsite-table-wrapper">
<table class="responsive">
<thead>
<tr>
<th colspan="2">Parameters</th>
</tr>
</thead>
<tbody>
<tr>
<td width="40%"><code>int&nbsp;id</code></td>
<td>
<p>Identifier of the stated to be popped. If no identifier exists, false is returned. The identifier is the number returned by <code><a href="/reference/androidx/fragment/app/FragmentTransaction.html#commit()">FragmentTransaction.commit()</a></code>. The <code><a href="/reference/androidx/fragment/app/FragmentManager.html#POP_BACK_STACK_INCLUSIVE()">POP_BACK_STACK_INCLUSIVE</a></code> flag can be used to control whether the named state itself is popped.</p>
</td>
</tr>
<tr>
<td width="40%"><code>int&nbsp;flags</code></td>
<td>
<p>Either 0 or <code><a href="/reference/androidx/fragment/app/FragmentManager.html#POP_BACK_STACK_INCLUSIVE()">POP_BACK_STACK_INCLUSIVE</a></code>.</p>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<div><a name="popBackStackImmediate--"></a><a name="popbackstackimmediate"></a>
<h3 class="api-name" id="popBackStackImmediate()">popBackStackImmediate</h3>
<pre class="api-signature no-pretty-print">public&nbsp;boolean&nbsp;<a href="/reference/androidx/fragment/app/FragmentManager.html#popBackStackImmediate()">popBackStackImmediate</a>()</pre>
<p>Like <code><a href="/reference/androidx/fragment/app/FragmentManager.html#popBackStack()">popBackStack</a></code>, but performs the operation immediately inside of the call. This is like calling <code><a href="/reference/androidx/fragment/app/FragmentManager.html#executePendingTransactions()">executePendingTransactions</a></code> afterwards without forcing the start of postponed Transactions.</p>
<div class="devsite-table-wrapper">
<table class="responsive">
<thead>
<tr>
<th colspan="2">Returns</th>
</tr>
</thead>
<tbody>
<tr>
<td width="40%"><code>boolean</code></td>
<td>
<p>Returns true if there was something popped, else false.</p>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<div><a name="popBackStackImmediate(java.lang.String, int)"></a><a name="popBackStackImmediate-java.lang.String-int-"></a><a name="popbackstackimmediate"></a>
<h3 class="api-name" id="popBackStackImmediate(java.lang.String,int)">popBackStackImmediate</h3>
<pre class="api-signature no-pretty-print">public&nbsp;boolean&nbsp;<a href="/reference/androidx/fragment/app/FragmentManager.html#popBackStackImmediate(java.lang.String,int)">popBackStackImmediate</a>(@<a href="/reference/androidx/annotation/Nullable.html">Nullable</a> <a href="https://developer.android.com/reference/java/lang/String.html">String</a>&nbsp;name,&nbsp;int&nbsp;flags)</pre>
<p>Like <code><a href="/reference/androidx/fragment/app/FragmentManager.html#popBackStack(java.lang.String,int)">popBackStack</a></code>, but performs the operation immediately inside of the call. This is like calling <code><a href="/reference/androidx/fragment/app/FragmentManager.html#executePendingTransactions()">executePendingTransactions</a></code> afterwards without forcing the start of postponed Transactions.</p>
<div class="devsite-table-wrapper">
<table class="responsive">
<thead>
<tr>
<th colspan="2">Returns</th>
</tr>
</thead>
<tbody>
<tr>
<td width="40%"><code>boolean</code></td>
<td>
<p>Returns true if there was something popped, else false.</p>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<div><a name="popBackStackImmediate(int, int)"></a><a name="popBackStackImmediate-int-int-"></a><a name="popbackstackimmediate"></a>
<h3 class="api-name" id="popBackStackImmediate(int,int)">popBackStackImmediate</h3>
<pre class="api-signature no-pretty-print">public&nbsp;boolean&nbsp;<a href="/reference/androidx/fragment/app/FragmentManager.html#popBackStackImmediate(int,int)">popBackStackImmediate</a>(int&nbsp;id,&nbsp;int&nbsp;flags)</pre>
<p>Like <code><a href="/reference/androidx/fragment/app/FragmentManager.html#popBackStack(int,int)">popBackStack</a></code>, but performs the operation immediately inside of the call. This is like calling <code><a href="/reference/androidx/fragment/app/FragmentManager.html#executePendingTransactions()">executePendingTransactions</a></code> afterwards without forcing the start of postponed Transactions.</p>
<div class="devsite-table-wrapper">
<table class="responsive">
<thead>
<tr>
<th colspan="2">Returns</th>
</tr>
</thead>
<tbody>
<tr>
<td width="40%"><code>boolean</code></td>
<td>
<p>Returns true if there was something popped, else false.</p>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<div><a name="putFragment(android.os.Bundle, java.lang.String, androidx.fragment.app.Fragment)"></a><a name="putFragment-android.os.Bundle-java.lang.String-androidx.fragment.app.Fragment-"></a><a name="putfragment"></a>
<h3 class="api-name" id="putFragment(android.os.Bundle,java.lang.String,androidx.fragment.app.Fragment)">putFragment</h3>
<pre class="api-signature no-pretty-print">public&nbsp;void&nbsp;<a href="/reference/androidx/fragment/app/FragmentManager.html#putFragment(android.os.Bundle,java.lang.String,androidx.fragment.app.Fragment)">putFragment</a>(<br>&nbsp;&nbsp;&nbsp;&nbsp;@<a href="/reference/androidx/annotation/NonNull.html">NonNull</a> Bundle&nbsp;bundle,<br>&nbsp;&nbsp;&nbsp;&nbsp;@<a href="/reference/androidx/annotation/NonNull.html">NonNull</a> <a href="https://developer.android.com/reference/java/lang/String.html">String</a>&nbsp;key,<br>&nbsp;&nbsp;&nbsp;&nbsp;@<a href="/reference/androidx/annotation/NonNull.html">NonNull</a> <a href="/reference/androidx/fragment/app/Fragment.html">Fragment</a>&nbsp;fragment<br>)</pre>
<p>Put a reference to a fragment in a Bundle. This Bundle can be persisted as saved state, and when later restoring <code><a href="/reference/androidx/fragment/app/FragmentManager.html#getFragment(android.os.Bundle,java.lang.String)">getFragment</a></code> will return the current instance of the same fragment.</p>
<div class="devsite-table-wrapper">
<table class="responsive">
<thead>
<tr>
<th colspan="2">Parameters</th>
</tr>
</thead>
<tbody>
<tr>
<td width="40%"><code>@<a href="/reference/androidx/annotation/NonNull.html">NonNull</a> Bundle&nbsp;bundle</code></td>
<td>
<p>The bundle in which to put the fragment reference.</p>
</td>
</tr>
<tr>
<td width="40%"><code>@<a href="/reference/androidx/annotation/NonNull.html">NonNull</a> <a href="https://developer.android.com/reference/java/lang/String.html">String</a>&nbsp;key</code></td>
<td>
<p>The name of the entry in the bundle.</p>
</td>
</tr>
<tr>
<td width="40%"><code>@<a href="/reference/androidx/annotation/NonNull.html">NonNull</a> <a href="/reference/androidx/fragment/app/Fragment.html">Fragment</a>&nbsp;fragment</code></td>
<td>
<p>The Fragment whose reference is to be stored.</p>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<div><a name="registerFragmentLifecycleCallbacks(androidx.fragment.app.FragmentManager.FragmentLifecycleCallbacks, boolean)"></a><a name="registerFragmentLifecycleCallbacks-androidx.fragment.app.FragmentManager.FragmentLifecycleCallbacks-boolean-"></a><a name="registerfragmentlifecyclecallbacks"></a>
<h3 class="api-name" id="registerFragmentLifecycleCallbacks(androidx.fragment.app.FragmentManager.FragmentLifecycleCallbacks,boolean)">registerFragmentLifecycleCallbacks</h3>
<pre class="api-signature no-pretty-print">public&nbsp;void&nbsp;<a href="/reference/androidx/fragment/app/FragmentManager.html#registerFragmentLifecycleCallbacks(androidx.fragment.app.FragmentManager.FragmentLifecycleCallbacks,boolean)">registerFragmentLifecycleCallbacks</a>(<br>&nbsp;&nbsp;&nbsp;&nbsp;@<a href="/reference/androidx/annotation/NonNull.html">NonNull</a> <a href="/reference/androidx/fragment/app/FragmentManager.FragmentLifecycleCallbacks.html">FragmentManager.FragmentLifecycleCallbacks</a>&nbsp;cb,<br>&nbsp;&nbsp;&nbsp;&nbsp;boolean&nbsp;recursive<br>)</pre>
<p>Registers a <code><a href="/reference/androidx/fragment/app/FragmentManager.FragmentLifecycleCallbacks.html">FragmentLifecycleCallbacks</a></code> to listen to fragment lifecycle events happening in this FragmentManager. All registered callbacks will be automatically unregistered when this FragmentManager is destroyed.</p>
<div class="devsite-table-wrapper">
<table class="responsive">
<thead>
<tr>
<th colspan="2">Parameters</th>
</tr>
</thead>
<tbody>
<tr>
<td width="40%"><code>@<a href="/reference/androidx/annotation/NonNull.html">NonNull</a> <a href="/reference/androidx/fragment/app/FragmentManager.FragmentLifecycleCallbacks.html">FragmentManager.FragmentLifecycleCallbacks</a>&nbsp;cb</code></td>
<td>
<p>Callbacks to register</p>
</td>
</tr>
<tr>
<td width="40%"><code>boolean&nbsp;recursive</code></td>
<td>
<p>true to automatically register this callback for all child FragmentManagers</p>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<div><a name="removeFragmentOnAttachListener-androidx.fragment.app.FragmentOnAttachListener-"></a><a name="removefragmentonattachlistener"></a>
<h3 class="api-name" id="removeFragmentOnAttachListener(androidx.fragment.app.FragmentOnAttachListener)">removeFragmentOnAttachListener</h3>
<pre class="api-signature no-pretty-print">public&nbsp;void&nbsp;<a href="/reference/androidx/fragment/app/FragmentManager.html#removeFragmentOnAttachListener(androidx.fragment.app.FragmentOnAttachListener)">removeFragmentOnAttachListener</a>(<br>&nbsp;&nbsp;&nbsp;&nbsp;@<a href="/reference/androidx/annotation/NonNull.html">NonNull</a> <a href="/reference/androidx/fragment/app/FragmentOnAttachListener.html">FragmentOnAttachListener</a>&nbsp;listener<br>)</pre>
<p>Remove a <code><a href="/reference/androidx/fragment/app/FragmentOnAttachListener.html">FragmentOnAttachListener</a></code> that was previously added via <code><a href="/reference/androidx/fragment/app/FragmentManager.html#addFragmentOnAttachListener(androidx.fragment.app.FragmentOnAttachListener)">addFragmentOnAttachListener</a></code>. It will no longer get called when a new Fragment is attached.</p>
<div class="devsite-table-wrapper">
<table class="responsive">
<thead>
<tr>
<th colspan="2">Parameters</th>
</tr>
</thead>
<tbody>
<tr>
<td width="40%"><code>@<a href="/reference/androidx/annotation/NonNull.html">NonNull</a> <a href="/reference/androidx/fragment/app/FragmentOnAttachListener.html">FragmentOnAttachListener</a>&nbsp;listener</code></td>
<td>
<p>Listener to remove</p>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<div><a name="removeOnBackStackChangedListener-androidx.fragment.app.FragmentManager.OnBackStackChangedListener-"></a><a name="removeonbackstackchangedlistener"></a>
<h3 class="api-name" id="removeOnBackStackChangedListener(androidx.fragment.app.FragmentManager.OnBackStackChangedListener)">removeOnBackStackChangedListener</h3>
<pre class="api-signature no-pretty-print">public&nbsp;void&nbsp;<a href="/reference/androidx/fragment/app/FragmentManager.html#removeOnBackStackChangedListener(androidx.fragment.app.FragmentManager.OnBackStackChangedListener)">removeOnBackStackChangedListener</a>(<br>&nbsp;&nbsp;&nbsp;&nbsp;@<a href="/reference/androidx/annotation/NonNull.html">NonNull</a> <a href="/reference/androidx/fragment/app/FragmentManager.OnBackStackChangedListener.html">FragmentManager.OnBackStackChangedListener</a>&nbsp;listener<br>)</pre>
<p>Remove a listener that was previously added with <code><a href="/reference/androidx/fragment/app/FragmentManager.html#addOnBackStackChangedListener(androidx.fragment.app.FragmentManager.OnBackStackChangedListener)">addOnBackStackChangedListener</a></code>.</p>
</div>
<div><a name="saveFragmentInstanceState-androidx.fragment.app.Fragment-"></a><a name="savefragmentinstancestate"></a>
<h3 class="api-name" id="saveFragmentInstanceState(androidx.fragment.app.Fragment)">saveFragmentInstanceState</h3>
<pre class="api-signature no-pretty-print">public&nbsp;@<a href="/reference/androidx/annotation/Nullable.html">Nullable</a> <a href="/reference/androidx/fragment/app/Fragment.SavedState.html">Fragment.SavedState</a>&nbsp;<a href="/reference/androidx/fragment/app/FragmentManager.html#saveFragmentInstanceState(androidx.fragment.app.Fragment)">saveFragmentInstanceState</a>(@<a href="/reference/androidx/annotation/NonNull.html">NonNull</a> <a href="/reference/androidx/fragment/app/Fragment.html">Fragment</a>&nbsp;fragment)</pre>
<p>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: </p>
<ul>
<li>The Fragment must currently be attached to the FragmentManager. </li>
<li>A new Fragment created using this saved state must be the same class type as the Fragment it was created from. </li>
<li>The saved state can not contain dependencies on other fragments -- that is it can't use <code><a href="/reference/androidx/fragment/app/FragmentManager.html#putFragment(android.os.Bundle,java.lang.String,androidx.fragment.app.Fragment)">putFragment</a></code> 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. </li>
</ul>
<div class="devsite-table-wrapper">
<table class="responsive">
<thead>
<tr>
<th colspan="2">Parameters</th>
</tr>
</thead>
<tbody>
<tr>
<td width="40%"><code>@<a href="/reference/androidx/annotation/NonNull.html">NonNull</a> <a href="/reference/androidx/fragment/app/Fragment.html">Fragment</a>&nbsp;fragment</code></td>
<td>
<p>The Fragment whose state is to be saved.</p>
</td>
</tr>
</tbody>
</table>
</div>
<div class="devsite-table-wrapper">
<table class="responsive">
<thead>
<tr>
<th colspan="2">Returns</th>
</tr>
</thead>
<tbody>
<tr>
<td width="40%"><code>@<a href="/reference/androidx/annotation/Nullable.html">Nullable</a> <a href="/reference/androidx/fragment/app/Fragment.SavedState.html">Fragment.SavedState</a></code></td>
<td>
<p>The generated state. This will be null if there was no interesting state created by the fragment.</p>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<div><a name="setFragmentFactory-androidx.fragment.app.FragmentFactory-"></a><a name="setfragmentfactory"></a>
<h3 class="api-name" id="setFragmentFactory(androidx.fragment.app.FragmentFactory)">setFragmentFactory</h3>
<pre class="api-signature no-pretty-print">public&nbsp;void&nbsp;<a href="/reference/androidx/fragment/app/FragmentManager.html#setFragmentFactory(androidx.fragment.app.FragmentFactory)">setFragmentFactory</a>(@<a href="/reference/androidx/annotation/NonNull.html">NonNull</a> <a href="/reference/androidx/fragment/app/FragmentFactory.html">FragmentFactory</a>&nbsp;fragmentFactory)</pre>
<p>Set a <code><a href="/reference/androidx/fragment/app/FragmentFactory.html">FragmentFactory</a></code> for this FragmentManager that will be used to create new Fragment instances from this point onward. </p>
<p> The <code><a href="/reference/androidx/fragment/app/Fragment.html#getChildFragmentManager()">child FragmentManager</a></code> of all Fragments in this FragmentManager will also use this factory if one is not explicitly set.</p>
<div class="devsite-table-wrapper">
<table class="responsive">
<thead>
<tr>
<th colspan="2">Parameters</th>
</tr>
</thead>
<tbody>
<tr>
<td width="40%"><code>@<a href="/reference/androidx/annotation/NonNull.html">NonNull</a> <a href="/reference/androidx/fragment/app/FragmentFactory.html">FragmentFactory</a>&nbsp;fragmentFactory</code></td>
<td>
<p>the factory to use to create new Fragment instances</p>
</td>
</tr>
</tbody>
</table>
</div>
<div class="devsite-table-wrapper">
<table class="responsive">
<thead>
<tr>
<th colspan="2">See also</th>
</tr>
</thead>
<tbody>
<tr>
<td width="40%"><code><a href="/reference/androidx/fragment/app/FragmentManager.html#getFragmentFactory()">getFragmentFactory</a></code></td>
<td></td>
</tr>
</tbody>
</table>
</div>
</div>
<div><a name="setFragmentResult(java.lang.String, android.os.Bundle)"></a><a name="setFragmentResult-java.lang.String-android.os.Bundle-"></a><a name="setfragmentresult"></a>
<h3 class="api-name" id="setFragmentResult(java.lang.String,android.os.Bundle)">setFragmentResult</h3>
<pre class="api-signature no-pretty-print">public&nbsp;final&nbsp;void&nbsp;<a href="/reference/androidx/fragment/app/FragmentManager.html#setFragmentResult(java.lang.String,android.os.Bundle)">setFragmentResult</a>(@<a href="/reference/androidx/annotation/NonNull.html">NonNull</a> <a href="https://developer.android.com/reference/java/lang/String.html">String</a>&nbsp;requestKey,&nbsp;@<a href="/reference/androidx/annotation/NonNull.html">NonNull</a> Bundle&nbsp;result)</pre>
<p>Sets the given result for the requestKey. This result will be delivered to a <code><a href="/reference/androidx/fragment/app/FragmentResultListener.html">FragmentResultListener</a></code> that is called given to <code><a href="/reference/androidx/fragment/app/FragmentResultOwner.html#setFragmentResultListener(java.lang.String,androidx.lifecycle.LifecycleOwner,androidx.fragment.app.FragmentResultListener)">setFragmentResultListener</a></code> with the same requestKey. If no <code><a href="/reference/androidx/fragment/app/FragmentResultListener.html">FragmentResultListener</a></code> with the same key is set or the Lifecycle associated with the listener is not at least STARTED, the result is stored until one becomes available, or <code><a href="/reference/androidx/fragment/app/FragmentResultOwner.html#clearFragmentResult(java.lang.String)">clearFragmentResult</a></code> is called with the same requestKey.</p>
<div class="devsite-table-wrapper">
<table class="responsive">
<thead>
<tr>
<th colspan="2">Parameters</th>
</tr>
</thead>
<tbody>
<tr>
<td width="40%"><code>@<a href="/reference/androidx/annotation/NonNull.html">NonNull</a> <a href="https://developer.android.com/reference/java/lang/String.html">String</a>&nbsp;requestKey</code></td>
<td>
<p>key used to identify the result</p>
</td>
</tr>
<tr>
<td width="40%"><code>@<a href="/reference/androidx/annotation/NonNull.html">NonNull</a> Bundle&nbsp;result</code></td>
<td>
<p>the result to be passed to another fragment</p>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<div><a name="setFragmentResultListener(java.lang.String, androidx.lifecycle.LifecycleOwner, androidx.fragment.app.FragmentResultListener)"></a><a name="setFragmentResultListener-java.lang.String-androidx.lifecycle.LifecycleOwner-androidx.fragment.app.FragmentResultListener-"></a><a name="setfragmentresultlistener"></a>
<h3 class="api-name" id="setFragmentResultListener(java.lang.String,androidx.lifecycle.LifecycleOwner,androidx.fragment.app.FragmentResultListener)">setFragmentResultListener</h3>
<pre class="api-signature no-pretty-print">public&nbsp;final&nbsp;void&nbsp;<a href="/reference/androidx/fragment/app/FragmentManager.html#setFragmentResultListener(java.lang.String,androidx.lifecycle.LifecycleOwner,androidx.fragment.app.FragmentResultListener)">setFragmentResultListener</a>(<br>&nbsp;&nbsp;&nbsp;&nbsp;@<a href="/reference/androidx/annotation/NonNull.html">NonNull</a> <a href="https://developer.android.com/reference/java/lang/String.html">String</a>&nbsp;requestKey,<br>&nbsp;&nbsp;&nbsp;&nbsp;@<a href="/reference/androidx/annotation/NonNull.html">NonNull</a> LifecycleOwner&nbsp;lifecycleOwner,<br>&nbsp;&nbsp;&nbsp;&nbsp;@<a href="/reference/androidx/annotation/NonNull.html">NonNull</a> <a href="/reference/androidx/fragment/app/FragmentResultListener.html">FragmentResultListener</a>&nbsp;listener<br>)</pre>
<p>Sets the <code><a href="/reference/androidx/fragment/app/FragmentResultListener.html">FragmentResultListener</a></code> for a given requestKey. Once the given LifecycleOwner is at least in the STARTED state, any results set by <code><a href="/reference/androidx/fragment/app/FragmentResultOwner.html#setFragmentResult(java.lang.String,android.os.Bundle)">setFragmentResult</a></code> using the same requestKey will be delivered to the <code><a href="/reference/androidx/fragment/app/FragmentResultListener.html#onFragmentResult(java.lang.String,android.os.Bundle)">callback</a></code>. The callback will remain active until the LifecycleOwner reaches the DESTROYED state or <code><a href="/reference/androidx/fragment/app/FragmentResultOwner.html#clearFragmentResultListener(java.lang.String)">clearFragmentResultListener</a></code> is called with the same requestKey.</p>
<div class="devsite-table-wrapper">
<table class="responsive">
<thead>
<tr>
<th colspan="2">Parameters</th>
</tr>
</thead>
<tbody>
<tr>
<td width="40%"><code>@<a href="/reference/androidx/annotation/NonNull.html">NonNull</a> <a href="https://developer.android.com/reference/java/lang/String.html">String</a>&nbsp;requestKey</code></td>
<td>
<p>requestKey used to identify the result</p>
</td>
</tr>
<tr>
<td width="40%"><code>@<a href="/reference/androidx/annotation/NonNull.html">NonNull</a> LifecycleOwner&nbsp;lifecycleOwner</code></td>
<td>
<p>lifecycleOwner for handling the result</p>
</td>
</tr>
<tr>
<td width="40%"><code>@<a href="/reference/androidx/annotation/NonNull.html">NonNull</a> <a href="/reference/androidx/fragment/app/FragmentResultListener.html">FragmentResultListener</a>&nbsp;listener</code></td>
<td>
<p>listener for result changes</p>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<div><a name="toString--"></a><a name="tostring"></a>
<h3 class="api-name" id="toString()">toString</h3>
<pre class="api-signature no-pretty-print">public&nbsp;@<a href="/reference/androidx/annotation/NonNull.html">NonNull</a> <a href="https://developer.android.com/reference/java/lang/String.html">String</a>&nbsp;<a href="/reference/androidx/fragment/app/FragmentManager.html#toString()">toString</a>()</pre>
</div>
<div><a name="unregisterFragmentLifecycleCallbacks-androidx.fragment.app.FragmentManager.FragmentLifecycleCallbacks-"></a><a name="unregisterfragmentlifecyclecallbacks"></a>
<h3 class="api-name" id="unregisterFragmentLifecycleCallbacks(androidx.fragment.app.FragmentManager.FragmentLifecycleCallbacks)">unregisterFragmentLifecycleCallbacks</h3>
<pre class="api-signature no-pretty-print">public&nbsp;void&nbsp;<a href="/reference/androidx/fragment/app/FragmentManager.html#unregisterFragmentLifecycleCallbacks(androidx.fragment.app.FragmentManager.FragmentLifecycleCallbacks)">unregisterFragmentLifecycleCallbacks</a>(<br>&nbsp;&nbsp;&nbsp;&nbsp;@<a href="/reference/androidx/annotation/NonNull.html">NonNull</a> <a href="/reference/androidx/fragment/app/FragmentManager.FragmentLifecycleCallbacks.html">FragmentManager.FragmentLifecycleCallbacks</a>&nbsp;cb<br>)</pre>
<p>Unregisters a previously registered <code><a href="/reference/androidx/fragment/app/FragmentManager.FragmentLifecycleCallbacks.html">FragmentLifecycleCallbacks</a></code>. If the callback was not previously registered this call has no effect. All registered callbacks will be automatically unregistered when this FragmentManager is destroyed.</p>
<div class="devsite-table-wrapper">
<table class="responsive">
<thead>
<tr>
<th colspan="2">Parameters</th>
</tr>
</thead>
<tbody>
<tr>
<td width="40%"><code>@<a href="/reference/androidx/annotation/NonNull.html">NonNull</a> <a href="/reference/androidx/fragment/app/FragmentManager.FragmentLifecycleCallbacks.html">FragmentManager.FragmentLifecycleCallbacks</a>&nbsp;cb</code></td>
<td>
<p>Callbacks to unregister</p>
</td>
</tr>
</tbody>
</table>
</div>
</div>
</body>
</html>