Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to clear Fragment backstack in android

hi how to clear fragment back stack am using below logic it's not working...

for(int i = 0; i < mFragmentManager.getBackStackEntryCount(); ++i) {                  mFragmentManager.popBackStack(); } 

help me..

like image 523
venu Avatar asked Jun 14 '13 11:06

venu


People also ask

How do I delete all fragments in Backstack?

Explanation: MainFragment -> Fragment A -> Fragment B (this is added to backstack) -> Fragment C -> MainFragment (clear backstack ).

How do you delete Backstacks on Android?

Use finishAffinity() to clear all backstack with existing one. Suppose, Activities A, B and C are in stack, and finishAffinity(); is called in Activity C, - Activity B will be finished / removing from stack. - Activity A will be finished / removing from stack. - Activity C will finished / removing from stack.

What is the use of addToBackStack in Android?

addToBackStack. Add this transaction to the back stack. This means that the transaction will be remembered after it is committed, and will reverse its operation when later popped off the stack.


1 Answers

Try this

mFragmentManager.popBackStack(null, FragmentManager.POP_BACK_STACK_INCLUSIVE);  
like image 172
dracula Avatar answered Oct 06 '22 12:10

dracula