The correct behavior I'd like to have is:
Fragment A -> Fragment B -> Fragment C -> Fragment A
What I currently do:
popBackStack()
still here
everything goes well. popBackStack()
but the BackStackEntryCount will still contain the
entry for B.I really need the backStackEntryCount
to be the same as the fragments contained in the manager.
Anyone know what I am doing wrong?
My code:
Fragment fragment1 = fragmentManager.findFragmentByTag("NavigationFragment_");
if (fragment1 != null) {
fragmentManager.beginTransaction()
.setTransition(TRANSIT_FRAGMENT_FADE)
.remove(fragment1)
.commit();
}
fragmentManager.beginTransaction()
.addToBackStack(backstack)
.setTransition(TRANSIT_FRAGMENT_OPEN)
//.remove(getFragmentManager().findFragmentByTag(NavigationFragment_.class.getSimpleName()))
.add(R.id.fragmentContainer, fragment, fragment.getClass().getSimpleName())
.commit();
I have been searching for a solution for a while without results, so please do not mark this a duplicate.
Thanks in advance.
If you come here because you call popBackStack() but getBackStackEntryCount() doesn't seem to update, then you might want to try popBackStackImmediate() instead.
popBackStack() is asynchronous -- it enqueues the request to pop, but the action will not be performed until the application returns to its event loop.
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