I'm using BottomNavigationView to navigate between two Fragments, on of these fragments has its own ViewPager with TabLayout as below:
This is what i'm trying to do:
MainActivity
|--- HomeFragment
| |--- POPULAR
| |--- LATEST
| |--- TOP RATED
| |--- UPCOMING
|--- FavoritesFragment
it works fine while swiping the ViewPager, the problem occures when i'm in LATEST or TOP RATED and navigates the BottomNavigationView to FavoritesFragment
and return back to HomeFragment, the ViewPager starts over from POPULAR not the fragment i was in before navigation.
How can i avoid this tricky navigation problem?
And what is the best solution to keep track of navigation in such situation?

addToBackStack
Fragment Transactions
I am obviously unaware of a best solution. A case like this involves fragment lifecycles as well which further complicate things. If you want a very specific navigation behaviour - specially the ability to resume from any previous UI state - I would suggest using a log file to keep track of lifecycle and navigation changes. This has often paid off for me in the long run