When using ViewPager
with fragments, our onPause
, onResume
methods are not called when moving between tabs. Is there any way we can figure out in the fragment when we're being made visible or being hidden?
Unfortunately I have logic in onResume
, onPause
, like registering with location services, that never get stopped when switching tabs because onPause
never gets called until one exits the whole app.
The ViewPager comes with the OnPageChangeListener
interface. By setting some flags for the previous and currently shown pages, you can emulate this behavior.