private static void changeFragment(Fragment f, boolean init) {
FragmentTransaction ft = fm.beginTransaction();
ft.replace(R.id.info_content, f,f.getClass().getName());
if(!init){
ft.addToBackStack(null);
}
ft.commit();
}
when I want to get the stack cout by call fm.getBackStackEntryCount(), it returns zero?
It might be too late to answer this question. Hope this answer will help someone anyway.
You should getBackStackEntryCount() method in onResume().
It will be this:
@Override
protected void onResume() {
super.onResume();
Log.i(TAG, "onResume: " + fragmentManager.getBackStackEntryCount());
for (int entry = 0; entry < fragmentManager.getBackStackEntryCount(); entry++) {
Log.i(TAG, "Found fragment: " + fragmentManager.getBackStackEntryAt(entry).getId());
}
}
Good luck!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With