您好,在 Tasks and Back Stack 上阅读这些 Material 后,我只是有点困惑。 , 安卓开发者指南:
它说:
When Activity A starts Activity B, Activity A is stopped, but the system retains its state (such as scroll position and text entered into forms). If the user presses the Back button while in Activity B, Activity A resumes with its state restored.
虽然在 the APIs reference for onSaveInstanceState() method ,它说:
One example of when onPause() and onStop() is called and not this method is when a user navigates back from activity B to activity A: there is no need to call onSaveInstanceState(Bundle) on B because that particular instance will never be restored, so the system avoids calling it.
以上两种情况对我来说似乎是一样的(“按 Back
按钮到 Activity A”和“从 Activity B 导航回 Activity A”)。但我不明白为什么前者说 Activity A 恢复到之前的状态,而后者说 Activity B 的特定实例永远不会恢复。有什么解释吗?
提前致谢!
最佳答案
我觉得第一个是说A会被拯救,所以它可以恢复,第二个是说B不会被拯救,因为它不能被恢复。
关于android - 任务、后退按钮和 onSaveInstanceState 方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9755221/