If activity is forcefully closed by Android system due to screen orientation change, then how to save UI states?
Save all your UI stats in onSaveInstanceState().
Save all your UI states using onRetainNonConfigurationInstance function.
Save all your UI states in onPause.
Android will save & restore UI states automatically, so programmer don't need to worry.
Generally orientation changes will cause android to kill and recreate the activity. But all the UI states will be saved and restored by android automatically. But to do this programmer has to supply id for each view. Other than this programmer don't need to take any extra effort.
Note : Android will save and restore only UI states, not transient states (any variable values).
Back To Top