Reputation: 25
I have some trouble with popping the back stack when using the navigation library.
I have the following flow
Secondary Graph FragSecondA -> FragSecondB
Main Graph FragMainA -> FragMainB -> FragMainC -> SecondaryGraph
I'd like to clear FragMainA, FragMainB, FragMainC from the back stack once I reach FragSecondA.
I tried using setting app:popUpTo="@id/fragment_main_c" app:popUpToInclusive="true"
on the action that leads to the Secondary Graph. Using the code I mentioned will only pop FragMainC from the back stack leaving me to navigate back to FragMainB. I tried setting app:clearTask=true
which gets me the desired result, however this method as deprecated.
Does anyone have any suggestions as to how I might fix this issue without having to use the deprecated method?
Upvotes: 1
Views: 92
Reputation: 8670
try below it should work.
edit your action_fragMainC_to_secondaryGraph
<action
android:id="@+id/action_fragMainC_to_secondaryGraph"
app:destination="@id/secondary_nav_graph"
app:popUpTo="@+id/main_nav_graph" />
Upvotes: 1