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

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());
}