天天看點

背景運作 程式

項目要求

應用啟動時,有A B C 三個ACTIVITY 進到A B C任何一個activity 按下home鍵,程式在背景運作,當恢複應用的時候,應用顯示之前被按下home鍵的那個頁面。

可以查到官方文檔:

 moveTaskToBack(true);

官方給出的說明是:

Move the task containing this activity to the back of the activity stack. The activity's order within the task is unchanged.

Parameters:
nonRoot If false then this only works if the activity is the root of a task; if true it will work for any activity in a task.
Returns:
If the task was moved (or it was already at the back) true is returned, else false.

 也就是說 将包含actvity的任務放到 activity的棧頂,但是在棧任務裡面的順序不會改變

參數說明:

  當值為false的時候,隻在目前的activity是棧任務的根才起作用,當值為ture的時候,棧任務裡面的任何一個activity都起作用。

傳回

    如果任務呗移動的(或者已經在棧頂了),傳回ture,否則傳回false。

繼續閱讀