I have a complete app that uses one Activity to rule several fragments. I'd like that, when the screen rotates, the whole state of the Activity (and it's Fragments' stack) to remain the same without having to wire all the SaveInstanceState all by myself if possible. So, I found this other question that provides almost what I need:
<activity android:name=".MyActivity"
android:configChanges="screenSize|orientation"
android:label="@string/app_name">
This does the trick: all state remains the same (scrolls, current fragment, whatever). There's just one single issue with it: It doesn't switch the XML's layout variant (from layout/*
to layout-land/*
or vice-versa).
I am aware of Android Activity's Lifecycle and I have done this kind of things serializing whatever state needed to be kept before, but yet, I need to ask: isn't there a way this easy to make it do exactly the same it already does, but changing the XML variant as if android:configChanges="screenSize|orientation"
wasn't set at all, but at the same time harnessing its benefits? Or do I have to wire all the state logic manually and there's no way around it?