I've encountered a really hard to diagnose issue in an Android app. getUserVisibleHint() returns false on the currently selected fragment in a ViewPager when it should return true (because it is visible and selected).
I've characterized the instances I see this behavior as follows:
- Fragment is selected and currently displayed in a
ViewPager - ViewPager is managed by a
FragmentStatePagerAdapter - Fragment was previously selected, its state was saved and later restored by the
PagerAdapter- minimum of 3 tabs in the viewpager
- user navigates to tab 3, then to tab 1 then back to tab 3.
- App uses Support Library version 24.0.0 or greater