I have been trying to determine why the onPause()
and the onResume()
methods were not fired when the user switches the the tab to be displayed when using a ViewPager and sectionsPageAdapter.
I assumed that when the user changes the tab being displayed, the onPause()
or the onDestroy()
methods would be called. Then, if the user returns to the tab, the onResume()
method would be called, but it seems it is not the functionality...
is there any way to determine when the user switces a tab and to know to which tab it has been switched? Something like onFragmentBeingDisplayed()
or similar.
Thanks!
EDIT: Answer from Suraj Vaishnav
By editing the constructor from the FragmentPageAdapter
like this super(fm, FragmentPagerAdapter.BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT);
I could use the desired behaviour on the app