Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get a list of backstack fragment entries in android?

I'm working on an application in which tabs are implemented using FragmentActivity. Since, tabs are required throughout the application, fragments are used extensively to make the application compatible on all the versions of android.

As a consequence, I'm facing a problem in visualizing as to what fragments are present on the backstack. I'm sure there is a way to retrieve the list of fragments present on the backstack. Thanks.

like image 404
Harshal Kshatriya Avatar asked Aug 18 '12 02:08

Harshal Kshatriya


1 Answers

The FragmentManager has methods:

getBackStackEntryCount()

getBackStackEntryAt (int index)

FragmentManager fm = getFragmentManager();  for(int entry = 0; entry<fm.getBackStackEntryCount(); entry++){    Log.i(TAG, "Found fragment: " + fm.getBackStackEntryAt(entry).getId()); } 
like image 69
Error 454 Avatar answered Sep 22 '22 01:09

Error 454