I’ve looked for how to not reload whole activity when rotating screen in android app. Finally, I figured out that using only
android:configChanges="orientation"
in activity definition in AndroidManifest is really enough. When I rotate the phone, the activity doesn’t reload, all my views are perfectly adjusted to landscape orientation, nothing goes wrong, neither onSaveInstanceState nor onRestoreInstanceState, which is used in some guides to programmatical rotation, is fired.
But if it is that simple, why all tutorials and guides I found present so complicated solution?
I.e.
Saving some data on orientation change in Android
By my experiments, everything is automatically correctly re-rendered, but isn’t there some hidden problem with my simple solution I don’t know about? Is it really that easy and correct?
Thank you
This is fine if you don’t need to change any resources when the configuration changes. But say you have landscape resources defined, then you’ll now need to handle swapping the UI resources yourself. But if the Activity needs no resources changed, it really is that simple.
Also, be warned if you target SDK 13 or above in your manifest you must include the screenSize value for rotation changes, such as:-
If you’re targeting SDK 12 or below, it’s fine as you’ve got it.