我试图将数据保存在我的活动中并进行恢复。 我将数据保存在onSaveInstanceState()
上,然后尝试恢复onRestoreInstanceState()
中的数据。为什么onRestoreInstanceState()永远不会被调用
我设置了断点,方法onSaveInstanceState()
被调用。但onRestoreInstanceState()
或onCreate()
从来没有。
这里是我的步骤:
- 开始我
Activity
。 - 按手机上的'Home'按钮。打电话给
onSaveInstanceState()
。 - 单击启动器中的图标并再次启动我的
Activity
。
此时,只有onRestart()
被调用。但不是onRestoreInstanceState()
或onCreate()
。
有谁知道为什么吗?
http://stackoverflow.com/questions/4967435/onrestoreinstancestate-not-called-when-screen-wake-up - 有一个答案是什么onRestoreInstanceState是。 – jellyfish 2011-05-13 14:37:10
你的回答不完全准确,或者至少不清楚,因为在onStop()之后要么调用onRestart(),要么调用onDestroy()。如果onDestroy()被调用,那么你回到onCreate() – LuxuryMode 2012-01-11 19:28:18
谢谢。 onRestore ...在方向改变时似乎被调用。简化的东西对我来说没有结束(+: – Everyone 2012-11-09 18:08:38