1.
Save Your Activity State
1.1
To save additional state information for your activity, you must implement onSaveInstanceState()
and add key-value pairs to the Bundle
object.
2.
Restore Your Activity State
2.1
onCreate(),
you must check whether the state Bundle
is null before you attempt to read it.
2.2
The system calls onRestoreInstanceState()
only if there is a saved state to restore, so you do not need to check whether the Bundle
is null
To learn more about recreating your activity due to a restart event at runtime (such as when the screen rotates), read Handling Runtime Changes.