I haven\'t found a simple way to get all currently active (visible, currently in Resumed state) Fragments in an Activity. Is it possible without custom bookkeeping in my Act
we can use some irregular-but-legal method
ArrayList<Fragment> getActiveFragments() {
Fragment f;
final ArrayList<Fragment> fragments = new ArrayList<>();
int i = 0;
try {
while ((f = getFragmentManager().getFragment(new Intent().putExtra("anyvalue", i++).getExtras(), "anyvalue")) != null) {
fragments.add(f);
}
} catch (IllegalStateException ex) {
}
return fragments;
}