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..
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..
The best option I ever seen is here.
Answer above is almost correct, but you need a guard around the fragment back list as it can be empty:
one way is to tag the
backstack
and when you want to clear itwhere the
"myfancyname"
should match the string you used withaddToBackStack
. E.g.the
backstack
's name and the fragment's tag name can be the same but there are no constrains on this regardFrom the documentation
if you don't want to use a name for your backstack you can pass use a first parameter
Try this
This is a bit late but I just had this problem myself. You can do:
Pretty self explanatory; you just get the first entry, get its id, and then pop everything up to and including the entry with that id.