My question about the OnResume()
method which is part of the Activity's lifecycle.
I know that after the OnStart()
method the OnResume()
will be called and also if the application goes in background and then comes on front again OnResume()
will be executed, but is there any case that some OS system might call this method when the device is rotating or something like that or maybe when they put the device on sleep and then open it again?
I've tested it on some devices to rotate the screen while the application is running and it looks like the OnResume()
is not executing but obviously I can't test all the devices out there.
If the Activity
does not declare that it wants to handle configuration changes by itself (for example, setting android:configChanges="orientation|screenSize|screenLayout|keyboardHidden"
in the manifest), then a device orientation change will cause the following:
onPause()
is calledonStop()
is calledonDestroy()
is called (the Activity
instance is now dead)Activity
is instantiatedonCreate()
is called on the new instanceonStart()
is called on the new instanceonResume()
is called on the new instanceAlso, some devices will cause the Activity
to go through the onPause(), onResume()
cycle when the lock screen is shown/unlocked. There are also some devices go through the orientation change cycle when the lock screen is shown/unlocked, even though the device orientation is not changed.