如果 App 进程被终止,bundle 如何发送到 onCreate?
How is bundle sent to onCreate if App process killed?
在 Activity 生命周期图中,有一个从 'onStop' 到 'App process killed' 再到 'onCreate' 的箭头。一直很纳闷,现在我就fragments做一个小的说说;如果整个应用程序进程被销毁,onCreate 如何从 onStop 接收包?系统是否跟踪已终止的应用程序及其 activity 包?我认为它会这样做,因为那时被杀死的应用程序分配给它的内存为零。
此外,从管理 Activity 生命周期页面的最后一段>开始 Activity,“系统在调用 onPause() 和 onStop() 之后调用 onDestroy()在所有情况下,除了一种情况:...'而且这种情况并未说明内存不足。这让我认为箭头永远不应该从 onStop 转到 onCreate 因为 'Apps with higher priority need memory'。这是错字吗还是我读错了?我假设我读错了,因为“一般来说,activity 的生命周期中的运动看起来像这样:”图表中的 'Killable?' 列。
其中一个一定是 activity 生命周期图表中的箭头或 "The system calls onDestroy() after it has already called onPause() and onStop() in all situations except one:..." 语句中的错误。希望我是在断章取义。
onCreate很有可能在onStop()之后调用。您使用 onSaveInstanceState() 传递包,它在 activity 或片段暂停或停止时随时调用。假设您有一个 activity 并按主页。 OnStop 和 onSaveInstanceState 都被调用。在 onSaveInstanceState 中,您保存包以保存应用程序的状态。该应用程序随后被终止,因为它在后台运行的时间太长。然后,当您打开应用程序备份时,来自 onSaveInstanceState 的包会在重新创建时传递给 SavedInstanceState 参数中的 oncreate。更多内容参见官方文档 https://developer.android.com/training/basics/activity-lifecycle/recreating.html
How is it possible for onCreate to receive the bundle from onStop if the whole app process is destroyed?
它没有 "receive the bundle from onStop",因为 onStop()
与 Bundle
无关。传递给 onCreate()
和 onRestoreInstanceState()
的 Bundle
包含由 onSaveInstanceState()
放入较早的 Bundle
中的数据。 Bundle
的内容跨流程边界传递到核心 OS 流程,该流程管理未完成的活动及其任务的状态。该内容会在相关时传回您的应用程序的新流程。
Does the system keep track of killed apps and their activity bundles?
OS 跟踪未完成的任务。有一段时间(自上次使用后约 30 分钟),它会跟踪任务活动的实例状态 Bundle
。
The system calls onDestroy() after it has already called onPause() and onStop() in all situations except one
不调用onDestroy()
的情况不止一种。由于内存不足而终止进程可能会也可能不会导致调用 onDestroy()
,具体取决于系统 RAM 需求的紧迫性。
在 Activity 生命周期图中,有一个从 'onStop' 到 'App process killed' 再到 'onCreate' 的箭头。一直很纳闷,现在我就fragments做一个小的说说;如果整个应用程序进程被销毁,onCreate 如何从 onStop 接收包?系统是否跟踪已终止的应用程序及其 activity 包?我认为它会这样做,因为那时被杀死的应用程序分配给它的内存为零。
此外,从管理 Activity 生命周期页面的最后一段>开始 Activity,“系统在调用 onPause() 和 onStop() 之后调用 onDestroy()在所有情况下,除了一种情况:...'而且这种情况并未说明内存不足。这让我认为箭头永远不应该从 onStop 转到 onCreate 因为 'Apps with higher priority need memory'。这是错字吗还是我读错了?我假设我读错了,因为“一般来说,activity 的生命周期中的运动看起来像这样:”图表中的 'Killable?' 列。
其中一个一定是 activity 生命周期图表中的箭头或 "The system calls onDestroy() after it has already called onPause() and onStop() in all situations except one:..." 语句中的错误。希望我是在断章取义。
onCreate很有可能在onStop()之后调用。您使用 onSaveInstanceState() 传递包,它在 activity 或片段暂停或停止时随时调用。假设您有一个 activity 并按主页。 OnStop 和 onSaveInstanceState 都被调用。在 onSaveInstanceState 中,您保存包以保存应用程序的状态。该应用程序随后被终止,因为它在后台运行的时间太长。然后,当您打开应用程序备份时,来自 onSaveInstanceState 的包会在重新创建时传递给 SavedInstanceState 参数中的 oncreate。更多内容参见官方文档 https://developer.android.com/training/basics/activity-lifecycle/recreating.html
How is it possible for onCreate to receive the bundle from onStop if the whole app process is destroyed?
它没有 "receive the bundle from onStop",因为 onStop()
与 Bundle
无关。传递给 onCreate()
和 onRestoreInstanceState()
的 Bundle
包含由 onSaveInstanceState()
放入较早的 Bundle
中的数据。 Bundle
的内容跨流程边界传递到核心 OS 流程,该流程管理未完成的活动及其任务的状态。该内容会在相关时传回您的应用程序的新流程。
Does the system keep track of killed apps and their activity bundles?
OS 跟踪未完成的任务。有一段时间(自上次使用后约 30 分钟),它会跟踪任务活动的实例状态 Bundle
。
The system calls onDestroy() after it has already called onPause() and onStop() in all situations except one
不调用onDestroy()
的情况不止一种。由于内存不足而终止进程可能会也可能不会导致调用 onDestroy()
,具体取决于系统 RAM 需求的紧迫性。