I created a new project in Android Studio that uses fragments and tabs to select a fragment. So Android Studio created a project for me that uses a ViewPager to select the different fragments.
Unfortunately, ViewPager will create off-screen fragments and even trigger onResume() in the off-screen fragment !
This is a problem, since code in onResume() in fragment 2 depends on what a user does in fragment 1.
I've tried setting mViewPager.setOffscreenPageLimit(0);
but this doesn't seem to have any effect, the neighboring fragment is still called with onResume() before it's actually shown.
QUESTION
What callback is triggered in a Fragment when it's actually shown? Otherwise, how can I set it up so that I can adjust the UI in fragment 2 depending on what the user did in Fragment 1 ?