android - 任务、后退按钮和 onSaveInstanceState 方法

标签 android android-activity task

您好,在 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/

相关文章:

Android 将 TextView 保持在 ImageView 内的固定位置

java - 我的视频下载程序无法运行

android - 由于 Lint 和木材,Gradle clean 失败

android - 查看其他 Android 应用产生的网络流量

android - 应用程序在 android 中启动

c# - 使用委托(delegate)处理错误

c# - 结束任务以防止失控的最佳方式是什么

java - Android:如何关闭从类返回到 Activity 的游标

java - 使用 2 个 Java 类显示 1 个 XML 文件的信息

c# - 如何在任务中传递多个参数