Android : Android Backstack Management

on Monday, September 8, 2014


I have an Activity A which calls another activity B. Activity B 3 has tabs/fragments (F1,F2,F3). When activity B is called Fragment F1 is launched initially which has an list view. From Fragment F1, on list item click I call a DialogFragment D1. This dialog fragment refreshes the list in the fragment F1. Everything on backstack works fine till the Dialog Fragment is called. The issue is when the Fragment F1 is refreshed and back button is pressed it comes back to same fragment as DialogFragment is called from F1. So the sequence is


A->B->F1->DF(refresh Fragment)->F1


From dialog fragment I suppressed its entry to backstack through below code:



if (fragmentManager.getBackStackEntryCount() > 0) {
fragmentManager.popBackStack();
}


Now the back press sequence from fragment is


F1->F1->B->A


where as I need


F1->B->A.


I have tried many things and read related posts but nothing seem to be working. I am not sure if I am missing some thing . Please advise.


0 comments:

Post a Comment