日本综合一区二区|亚洲中文天堂综合|日韩欧美自拍一区|男女精品天堂一区|欧美自拍第6页亚洲成人精品一区|亚洲黄色天堂一区二区成人|超碰91偷拍第一页|日韩av夜夜嗨中文字幕|久久蜜综合视频官网|精美人妻一区二区三区

RELATEED CONSULTING
相關(guān)咨詢
選擇下列產(chǎn)品馬上在線溝通
服務(wù)時(shí)間:8:30-17:00
你可能遇到了下面的問題
關(guān)閉右側(cè)工具欄

新聞中心

這里有您想知道的互聯(lián)網(wǎng)營(yíng)銷解決方案
Android應(yīng)用程序組件Activity的"singleTask"(12)

注意,這里我們?cè)O(shè)置Mainactivity的taskAffinity屬性值為"shy.luo.task.main.activity",

成都創(chuàng)新互聯(lián)是一家集網(wǎng)站建設(shè),沾益企業(yè)網(wǎng)站建設(shè),沾益品牌網(wǎng)站建設(shè),網(wǎng)站定制,沾益網(wǎng)站建設(shè)報(bào)價(jià),網(wǎng)絡(luò)營(yíng)銷,網(wǎng)絡(luò)優(yōu)化,沾益網(wǎng)站推廣為一體的創(chuàng)新建站企業(yè),幫助傳統(tǒng)企業(yè)提升企業(yè)形象加強(qiáng)企業(yè)競(jìng)爭(zhēng)力??沙浞譂M足這一群體相比中小企業(yè)更為豐富、高端、多元的互聯(lián)網(wǎng)需求。同時(shí)我們時(shí)刻保持專業(yè)、時(shí)尚、前沿,時(shí)刻以成就客戶成長(zhǎng)自我,堅(jiān)持不斷學(xué)習(xí)、思考、沉淀、凈化自己,讓我們?yōu)楦嗟钠髽I(yè)打造出實(shí)用型網(wǎng)站。

設(shè)置 SubActivity的taskAffinity屬性值為"shy.luo.task.sub.activity"。

重新編譯一下程序,在模擬器上把這 個(gè)應(yīng)用程序再次跑起來,

用“adb shell dumpsys activity”命令再來查看一下系統(tǒng)運(yùn)行的的任務(wù),就會(huì)看到:

 
 
 
  1. [html] view plaincopyRunning activities (most recent first): 
  2.  
  3. TaskRecord{4069c020 #4 A shy.luo.task.sub.activity} 
  4.  
  5. Run #2: HistoryRecord{40725040 shy.luo.task/.SubActivity} 
  6.  
  7. TaskRecord{40695220 #3 A shy.luo.task.main.activity} 
  8.  
  9. Run #1: HistoryRecord{406b26b8 shy.luo.task/.MainActivity} 
  10.  
  11. TaskRecord{40599c90 #2 A com.Android.launcher} 
  12.  
  13. Run #0: HistoryRecord{40646628 com.android.launcher/com.android.launcher2.Launcher} 

這里就可以看到,SubActivity和MainActivity就分別運(yùn)行在不同的任務(wù)中了。

至此,我們總結(jié)一下,設(shè)置了"singleTask"啟動(dòng)模式的Activity的特點(diǎn):

1. 設(shè)置了"singleTask"啟動(dòng)模式的Activity,它在啟動(dòng)的時(shí)候,會(huì)先在系統(tǒng)中查找屬性值affinity等于它的屬性值 taskAffinity的任務(wù)存在;如果存在這樣的任務(wù),它就會(huì)在這個(gè)任務(wù)中啟動(dòng),否則就會(huì)在新任務(wù)中啟動(dòng)。因此,如果我們想要設(shè)置 了"singleTask"啟動(dòng)模式的Activity在新的任務(wù)中啟動(dòng),就要為它設(shè)置一個(gè)獨(dú)立的taskAffinity屬性值。

2. 如果設(shè)置了"singleTask"啟動(dòng)模式的Activity不是在新的任務(wù)中啟動(dòng)時(shí),它會(huì)在已有的任務(wù)中查看是否已經(jīng)存在相應(yīng)的Activity實(shí) 例,如果存在,就會(huì)把位于這個(gè)Activity實(shí)例上面的Activity全部結(jié)束掉,即最終這個(gè)Activity實(shí)例會(huì)位于任務(wù)的堆棧頂端中。

看來,要解開Activity的"singleTask"之謎,還是要自力更生啊,不過,如果我們仔細(xì)閱讀官方文檔,在http://developer.android.com/guide/topics/manifest/activity-element.html中,有這樣的描述:

As shown in the table above, standard is the default mode and is appropriate for most types of activities. SingleTop is also a common and useful launch mode for many types of activities. The other modes — singleTask and singleInstance —are not appropriate for most applications, since they result in an interaction model that is likely to be unfamiliar to users and is very different from most other applications.

Regardless of the launch mode that you choose, make sure to test the usability of the activity during launch and when navigating back to it from other activities and tasks using the BACK key.

這樣看,官方文檔也沒有坑我們呢,它告誡我們:make sure to test the usability of the activity during launch。


網(wǎng)站名稱:Android應(yīng)用程序組件Activity的"singleTask"(12)
文章位置:http://www.dlmjj.cn/article/dhhpdij.html