Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to remove Fragments from backstack

There is an Activity with 5 fragments (wizard).

StartFrag  -(start)-> Frag1 -(next)-> Frag2 -(next)-> SubmitFrag
-(submit)-> SuccessFrag.

After Taping SubmitMore button on Success fragment, I want to remove Frag1, Frag2 and SubmitFrag from backstage and return to StartFrag. How to do that?

like image 405
hhs Avatar asked May 01 '26 11:05

hhs


1 Answers

You could try this

FragmentManager fm = getFragmentManager(); 
int count = fm.getBackStackEntryCount();
for(int i = 0; i < count; ++i) {    
fm.popBackStack();
}
like image 88
funkomatic Avatar answered May 04 '26 12:05

funkomatic



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!