'How to navigate previous fragment without restarting it with NavController?
My app flow A fragment to B fragment :
A -> B(findNavController().navigate(R.id.action_AFragment_to_BFragment))
When I press back arrow from B fragment :
A fragment not resume from resume state but it was restarted(findNavController().popBackStack())
here is my code:
<navigation xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/nav_graph"
app:startDestination="@id/AFragment">
<fragment
android:id="@+id/AFragment"
android:name=".AFragment"
android:label="@string/a_fragment_label"
tools:layout="@layout/fragment_a">
<action
android:id="@+id/action_AFragment_to_BFragment"
app:popUpToSaveState="true"
app:destination="@id/BFragment" />
</fragment>
<fragment
android:id="@+id/BFragment"
android:name=".BFragment"
android:label="@string/b_fragment_label"
tools:layout="@layout/fragment_b">
<action
android:id="@+id/action_BFragment_to_AFragment"
app:popUpToSaveState="true"
app:destination="@id/AFragment"
app:popUpTo="@+id/AFragment"
app:popUpToInclusive="false"/>
</fragment>
</navigation>
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
