Why onRestoreInstanceState() never gets called
Well, if onRestart()
is called, the value of the instance variables would be maintained by the application stack itself and thus you do not need to restore them.
onCreate()
method is only called when your Activity
's onStop()
is called and the process is killed.
Please refer the Activity
life cycle Android Activity Life Cycle for a clear understanding.
You may want to check whether the onStop()
method is called and if your process is killed. I do no think that your process gets killed by the scenario which you have described.
the onRestoreInstanceState()
method is very tricky. I do not know when exactly it is called but I saw it was called once while changing from Potrait to Landscape.
I have asked similiar question earlier on here
Here's some steps to test out onRestoreInstanceState()
:
- Press home screen
- Kill the app through adb
- Launch your app again
From doc:
The system calls onRestoreInstanceState() only if there is a saved state to restore.