fragmentstatepageradapter
FragmentStatePagerAdapter is deprecated from API 27
Switch to ViewPager2 and use FragmentStateAdapter instead. From there you can use onPause and onResume callbacks to determine which fragment is currently visible for the user. onResume is called when a fragment became visible and onPause when it stops to be visible. -> read more Based on the comments of Eric and Reejesh. Old answer … Read more
What is the difference between FragmentPagerAdapter and FragmentStatePagerAdapter?
Like the docs say, think about it this way. If you were to do an application like a book reader, you will not want to load all the fragments into memory at once. You would like to load and destroy Fragments as the user reads. In this case you will use FragmentStatePagerAdapter. If you are … Read more