onRestoreInstanceState不叫当屏幕唤醒? [英] onRestoreInstanceState not called when screen wake up?

查看:199
本文介绍了onRestoreInstanceState不叫当屏幕唤醒?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经写了所有必要的code保存我的活动状态(用的EditText小部件一个简单的形式),并在电话中旋转恢复它和它的伟大工程。

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.

我的问题是开/关变动管理屏幕:去关时的onSaveInstanceState被调用,一切顺利。 在屏幕上,onRestoreInstanceState不叫,既不的onCreate,只有onResume。

My problem is on managing screen on/off changes: when going off, onSaveInstanceState is called and everything goes well. On screen on, onRestoreInstanceState is not called, neither onCreate, only onResume.

我缺少的东西?

推荐答案

该onRestoreInstanceState方法只称为如果活动过程中被杀死(由于内存限制或其他原因),然后在重新成为可见的恢复。在手机旋转,该活动被杀害和恢复的不同方位,以便它会奏效。但在屏幕上的开/关不会是这种情况。该活动并没有被破坏所以没有必要恢复

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

这篇关于onRestoreInstanceState不叫当屏幕唤醒?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆