specific - Android: Remove ALL FragmentTransactions from the back stack




return to previous fragment on back press (2)

I add a bunch of FragmentTransactions to the back stack in one Tab, and I want to clear them ALL from the back stack when the user selects a different Tab. I can't find a method to clear stuff off the back stack, only methods to pop them off, and these don't even return the Fragment to you so you can close them. Any ideas?

https://code.i-harness.com


If you add many Fragments to the backstack and want to remove them all you can do this: popBackStack(null, FragmentManager.POP_BACK_STACK_INCLUSIVE)


Just remove them from the backstack using the popBackStack() methods.

Each fragment you pop is exactly the same as if the user had pressed the BACK button, and you don't do any special cleanup when the BACK button is pressed, right?





android-fragments