Skip to content

Instantly share code, notes, and snippets.

@msomu
Created April 21, 2015 10:31
Show Gist options
  • Select an option

  • Save msomu/8a7dc67e63731f8d2843 to your computer and use it in GitHub Desktop.

Select an option

Save msomu/8a7dc67e63731f8d2843 to your computer and use it in GitHub Desktop.
This is used to find the number of fragments that are on the current activity
@Override
public void onBackPressed() {
//for testing purpose
//returns the number of fragments on the Activity
int count = fragmentManager.getBackStackEntryCount();
//displays the fragments that are present on the activity with their names
for (int i=count-1;i>=0;i--){
String name = fragmentManager.getBackStackEntryAt(i).getName();
Config.l("Count :"+i+" name :"+name);
}
super.onBackPressed();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment