活动在被销毁时是否保存其意图?

时间:2016-05-23 12:32:12

标签: android android-fragments android-intent android-activity

想象一下,在用户打开另一个活动,然后再打开另一个活动等等之后,以意图启动活动的情况。此刻,由于缺乏RAM,第一个活动被破坏。用户导航回第一个活动后,第一个活动是否可以访问其初始意图?是否存在严格确定的行为?

1 个答案:

答案 0 :(得分:0)

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,就像它从未被销毁一样。