in an activity:
Configuration config = ContextThemeWrapper.getResources().getConfiguration();
- override
onSaveInstanceState(Bundle b)
- override
onRestoreInstanceState(Bundle b)
Note: bundle serilization is done on the main thread. Deserilise large items may block and risks an ANR
Only do this if you must as there is lots of resource updating done by the framework for you.
- override
onConfigurationChanged(Configuration newConfig)
and check device orientatino
- https://github.com/codepath/android_guides/wiki/Handling-Configuration-Changes
- https://developer.android.com/guide/topics/resources/runtime-changes
- https://www.androiddesignpatterns.com/2013/04/retaining-objects-across-config-changes.html - a bit outdated.
- http://developer.android.com/guide/topics/resources/runtime-changes.html
- http://developer.android.com/training/basics/activity-lifecycle/recreating.html
- http://www.vogella.com/tutorials/AndroidLifeCycle/article.html#configurationchange
- http://www.androiddesignpatterns.com/2013/04/retaining-objects-across-config-changes.html
- http://www.intertech.com/Blog/saving-and-retrieving-android-instance-state-part-1/
- http://sunil-android.blogspot.com/2013/03/save-and-restore-instance-state.html
- https://medium.com/google-developers/activity-revival-and-the-case-of-the-rotating-device-167e34f9a30d#.nq3b23lxg