I have an app with several Fragments
which interact to each other. Sometimes I have to add a Fragment
, sometimes I replace it.
Is there a way to listen to FragmentTransactions completed, so I can keep track of every time a Fragment is added/shown/replaced?
I've tried fragmentManager.addOnBackStackChangedListener()
but unsuccessfully.
I thought of doing something on the onResume()
of all of them, but if the app goes to background and foreground I should not do anything to my UI. Only when I interact between them.
Any help/strategy is appreciated.
EDIT: The reason is that I have an overlay that will be shown in the current Fragment. If the user navigates to any other Fragment, I need this overlay to disappear.