I’m interested to know which methods are overridden, when an Android device is rotated (i.e. when configuration changes)?
onSaveInstanceState(...), onConfigurationChanged(...), onRestoreInstanceState(...) – something similar to this?
It will be also interesting for me to listen about the whole process connected with changing a configuration. Thanks.
When you rotate the device your Activity will re-create and all the variables will be re-initialized. So, in that case if you want to some values to remain same on Rotation also you can store their state using the
onSaveInstanceState()and you can restore inonCreate()again by checking Bundle is not null.Where as
onConfigurationChanged()will be called when you rotate the Device(Note that this will only be called if you have selected configurations you would like to handle with theconfigChangesattribute in your manifest). From the parameter you will get the new device configuration.If you don’t want your Activity to get re-created on rotation of Device then you have to add this line to your activity tag in the
AndroidManifestfile.