2

想象一下,一種活動是以意向開始的,然後是用戶打開另一個活動,然後是另一個活動,等等。一時之間,由於缺乏內存,第一項活動將被破壞。用戶導航到第一個活動後,第一個活動是否可以訪問其初始意圖?有沒有嚴格的決定行爲?當它被銷燬時,活動會保存它的意圖嗎?

+0

最初的意圖將是Manifest中定義的默認意圖。 – t0mm13b

+0

是的 - Android應該保持意圖數據,以便可以正確地重新創建活動。 – adelphus

回答

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,就好像它從未被銷燬一樣。

+0

陳述您找到評論的來源。 – t0mm13b

+0

@ t0mm13b搜索Android源代碼非常簡單 - 我已經添加了鏈接。 – adelphus

+0

謝謝。這非常有幫助。但它指的是切換任務,但活動可以在不切換任務的情況下銷燬。然而,破壞當前任務中的活動似乎是在後臺任務中銷燬它的一個子集。謝謝 – Buckstabue

相關問題