I am turning to you today with a very specific problem.
The MainActivity is an AppCompatActivity
it has a ViewPager in it's layout with a FragmentStatePagerAdapter
one of those Fragments has a ViewPager2 in it's layout with a FragmentStateAdapter
problem is, when I rotate the device, the up navigation of the nested Fragment is gone and it always prompts to exit the app (a prompt which I've added in the MainActivity of course).
problem is that when I turn the screen off and back on, then I cannot use the nested ViewPager anymore. It does not react to changes until I completely restart the app.
Does anyone have an idea on what the problem is and how to fix it?
Thanks!!!
Edit: After some investigation I am now convinced that the problem is, that the adapter will be recreated on rotation and therefore the child fragments will also be recreated. I verified this with logging... but how can I prevent that? And yes, I've tried "retainInstance" which doesn't change anything.
I think what I should do is somehow create the innermost fragments in the scope of the activity and avoid recreation of the adapter on rotation, but I have exactly no idea on how to do that.