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
android.support.v4.app.FragmentManager has a method called getFragments() which does exactly what you need, but it was never accessible. Suddenly, though, it is, but I'm not sure if that's intended because it's still marked as hidden.
/**
* Get a list of all fragments that have been added to the fragment manager.
*
* @return The list of all fragments or null if none.
* @hide
*/
public abstract List getFragments();
The regular android.app.FragmentManager doesn't have this method at all, but if really needed, you can access the same object by getting the field mActive via reflection (be careful there: starting with API 26, its type is a SparseArray instead of List). Use at own risk :)