onRestoreInstanceState not called when screen wake up?

前端 未结 3 1982
悲哀的现实
悲哀的现实 2020-12-21 09:51

I\'ve wrote all the needed code to save my Activity state (a simple form with EditText widgets) and restore it on phone rotation and it works great.

My problem is on

相关标签:
3条回答
  • 2020-12-21 10:04

    Its also called while zoom pressing (for example on Tablet).

    0 讨论(0)
  • 2020-12-21 10:15

    onRestoreInstanceState is called to save the state of the activity before being killed. When the screen goes off, the activity is put in a pause state - because the keyguard is an activity that come in front of your activity. to catch the screen off/on cycle, to have to override onPause / onResume methods, as stated in http://developer.android.com/reference/android/app/Activity.html#ActivityLifecycle

    0 讨论(0)
  • 2020-12-21 10:19

    The onRestoreInstanceState method is called only if the activity process is killed(due to memory constraints or some other reasons) and then restored when it becomes visible again. On the phone rotation, the activity is killed and restored with different orientation so it will work. But on screen on/off it wouldn't be the case. The activity has not been destroyed so no need for restore

    0 讨论(0)
提交回复
热议问题