Skip to content

Instantly share code, notes, and snippets.

@atultiwari
Created May 17, 2016 11:55
Show Gist options
  • Save atultiwari/abe89be3a97705c3219d4c428886798a to your computer and use it in GitHub Desktop.
Save atultiwari/abe89be3a97705c3219d4c428886798a to your computer and use it in GitHub Desktop.
public Fragment getVisibleFragment(){
FragmentManager fragmentManager = MainActivity.this.getSupportFragmentManager();
List<Fragment> fragments = fragmentManager.getFragments();
if(fragments != null){
for(Fragment fragment : fragments){
if(fragment != null && fragment.isVisible())
return fragment;
}
}
return null;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment