I tried with FragmentManager like this:
Navigation.findNavController(mView).popBackStack() And tried using FragmentManager.
val fm = activity!!.supportFragmentManager 1.
fm.popBackStack() 2.
fm.popBackStackImmediate() But They didn't work. I mean, It seems like they pop all the fragments.
I also tried applying these attributes in graph_nav.xml:
app:launchSingleTop="true" app:popUpToInclusive="true" I applied them in the A fragment and also B fragment.
I want to go to B fragment from A fragment. And I want to clear all the fragment stack before B fragment and just leave B fragment alone.