General: I have my app consisting of the activity and several fragments. I am using the Navigation Graph to move through the various fragments. I have the ability to rotate the device and therefore have different layouts.
Problem: I know from fragment A I go to fragment B and I rotate the phone, I go back to fragment A
First partial solution:
From the documentation I took what could have been the solution, which however turned out to be only a partial solution. in fact I read that to prevent problems during rotation I could use the following parameters:
android:configChanges="orientation|screenSize|screenLayout|keyboardHidden"
This would seem to solve the rotation problem but it creates a new one: landscape layouts are not updated to the size they should have. How can I completely remedy the problem? It doesn't matter if you need to get your hands dirty in the code or just add another parameter in the manifest, I would like to understand what is wrong
Example: bottom navigation -> TabA (entrypoint); TabB, TabC.
I click on Tab B -> then clicking inside I will go to fragment B1 (from corrent tab B). So I rotate phone and I will go again to Tab B instead fragment B1
When the phone rotate, the activity is recreated, so I suppose that you activity is starting again from the entry point fragment. You can use ViewModel to persist the actual fragment reference and inflate it again on OnResume method of the Activity who hold the fragments.