NavController has methods navigate which navigate by default with backstack. How to navigate to the fragment without having backstack?
Please note that, I am not asking about FragmentTransaction
If you have a back stack of:
A -> B
And want to get to a back stack of
A -> C
You can do a 'replace' operation by popping B off the back stack and adding C.
In Navigation, this is done by using app:popUpTo (and optionally app:popUpToInclusive="true" if needed) to the <action> in your XML or by using the equivalent NavOptions API.
<action
android:id="@+id/goToC"
app:destination="@+id/c"
app:popUpTo="@+id/b"
app:popUpToInclusive="true"/>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With