当它被销毁时,活动会保存它的意图吗?
想象一下,一种活动是以意向开始的,然后是用户打开另一个活动,然后是另一个活动,等等。一时之间,由于缺乏内存,第一项活动将被破坏。用户导航到第一个活动后,第一个活动是否可以访问其初始意图?有没有严格的决定行为?当它被销毁时,活动会保存它的意图吗?
从Android source采取了一些意见摘录:
/**
* Information you can retrieve about a particular task that is currently
* "running" in the system. Note that a running task does not mean the
* given task actually has a process it is actively running in; it simply
* means that the user has gone to it and never closed it, but currently
* the system may have killed its process and is only holding on to its
* last state in order to restart it when the user returns.
*/
public static class RunningTaskInfo ...
注意最后一条语句:......只有坚持自己的最后的状态,以便当用户返回
/**
* The original Intent used to launch the task. You can use this
* Intent to re-launch the task (if it is no longer running) or bring
* the current task to the front.
*/
public Intent baseIntent;
重新启动它
从中可以明显看出,Android会坚持原来的Intent来重新启动Activity,就好像它从未被销毁一样。
陈述您找到评论的来源。 – t0mm13b
@ t0mm13b搜索Android源代码非常简单 - 我已经添加了链接。 – adelphus
谢谢。这非常有帮助。但它指的是切换任务,但活动可以在不切换任务的情况下销毁。然而,破坏当前任务中的活动似乎是在后台任务中销毁它的一个子集。谢谢 – Buckstabue
最初的意图将是Manifest中定义的默认意图。 – t0mm13b
是的 - Android应该保持意图数据,以便可以正确地重新创建活动。 – adelphus