Android Activity launchMode

  1. "standard" (the default mode)
    Default. The system creates a new instance of the activity in the task from which it was started and routes the intent to it. The activity can be instantiated multiple times, each instance can belong to different tasks, and one task can have multiple instances.

每一次都會(huì)重新創(chuàng)建一個(gè)實(shí)例

  1. "singleTop"
    If an instance of the activity already exists at the top of the current task, the system routes the intent to that instance through a call to its onNewIntent()
    method, rather than creating a new instance of the activity. The activity can be instantiated multiple times, each instance can belong to different tasks, and one task can have multiple instances (but only if the activity at the top of the back stack is not an existing instance of the activity).For example, suppose a task's back stack consists of root activity A with activities B, C, and D on top (the stack is A-B-C-D; D is on top). An intent arrives for an activity of type D. If D has the default "standard" launch mode, a new instance of the class is launched and the stack becomes A-B-C-D-D. However, if D's launch mode is "singleTop", the existing instance of D receives the intent through onNewIntent(), because it's at the top of the stack—the stack remains A-B-C-D. However, if an intent arrives for an activity of type B, then a new instance of B is added to the stack, even if its launch mode is "singleTop".

簡(jiǎn)單來說就是: 處于堆棧的棧頂,并且不會(huì)重新實(shí)例化新的對(duì)象

  1. "singleTask"
    The system creates a new task and instantiates the activity at the root of the new task. However, if an instance of the activity already exists in a separate task, the system routes the intent to the existing instance through a call to its onNewIntent() method, rather than creating a new instance. Only one instance of the activity can exist at a time.

不會(huì)重新實(shí)例化對(duì)象

  1. "singleInstance"
    Same as "singleTask", except that the system doesn't launch any other activities into the task holding the instance. The activity is always the single and only member of its task; any activities started by this one open in a separate task.

類似于"singleTask",區(qū)別在于系統(tǒng)不會(huì)啟動(dòng)任何的activities放到這個(gè)任務(wù)堆棧中去處理這個(gè)實(shí)例.并且在這個(gè)被設(shè)置成"singleInstance"的Activity任務(wù)棧中只有他一個(gè).由它啟動(dòng)的Activity都會(huì)被push到一個(gè)新的堆棧中.

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
  • 序言:七十年代末,一起剝皮案震驚了整個(gè)濱河市企巢,隨后出現(xiàn)的幾起案子苗缩,更是在濱河造成了極大的恐慌,老刑警劉巖,帶你破解...
    沈念sama閱讀 212,718評(píng)論 6 492
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件女仰,死亡現(xiàn)場(chǎng)離奇詭異御毅,居然都是意外死亡,警方通過查閱死者的電腦和手機(jī)羽杰,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 90,683評(píng)論 3 385
  • 文/潘曉璐 我一進(jìn)店門渡紫,熙熙樓的掌柜王于貴愁眉苦臉地迎上來,“玉大人考赛,你說我怎么就攤上這事腻惠。” “怎么了欲虚?”我有些...
    開封第一講書人閱讀 158,207評(píng)論 0 348
  • 文/不壞的土叔 我叫張陵集灌,是天一觀的道長(zhǎng)。 經(jīng)常有香客問我复哆,道長(zhǎng)欣喧,這世上最難降的妖魔是什么? 我笑而不...
    開封第一講書人閱讀 56,755評(píng)論 1 284
  • 正文 為了忘掉前任梯找,我火速辦了婚禮唆阿,結(jié)果婚禮上,老公的妹妹穿的比我還像新娘锈锤。我一直安慰自己驯鳖,他們只是感情好闲询,可當(dāng)我...
    茶點(diǎn)故事閱讀 65,862評(píng)論 6 386
  • 文/花漫 我一把揭開白布。 她就那樣靜靜地躺著浅辙,像睡著了一般扭弧。 火紅的嫁衣襯著肌膚如雪。 梳的紋絲不亂的頭發(fā)上记舆,一...
    開封第一講書人閱讀 50,050評(píng)論 1 291
  • 那天鸽捻,我揣著相機(jī)與錄音,去河邊找鬼泽腮。 笑死御蒲,一個(gè)胖子當(dāng)著我的面吹牛,可吹牛的內(nèi)容都是我干的诊赊。 我是一名探鬼主播厚满,決...
    沈念sama閱讀 39,136評(píng)論 3 410
  • 文/蒼蘭香墨 我猛地睜開眼,長(zhǎng)吁一口氣:“原來是場(chǎng)噩夢(mèng)啊……” “哼碧磅!你這毒婦竟也來了痰滋?” 一聲冷哼從身側(cè)響起,我...
    開封第一講書人閱讀 37,882評(píng)論 0 268
  • 序言:老撾萬榮一對(duì)情侶失蹤续崖,失蹤者是張志新(化名)和其女友劉穎敲街,沒想到半個(gè)月后,有當(dāng)?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體严望,經(jīng)...
    沈念sama閱讀 44,330評(píng)論 1 303
  • 正文 獨(dú)居荒郊野嶺守林人離奇死亡多艇,尸身上長(zhǎng)有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點(diǎn)故事閱讀 36,651評(píng)論 2 327
  • 正文 我和宋清朗相戀三年,在試婚紗的時(shí)候發(fā)現(xiàn)自己被綠了像吻。 大學(xué)時(shí)的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片峻黍。...
    茶點(diǎn)故事閱讀 38,789評(píng)論 1 341
  • 序言:一個(gè)原本活蹦亂跳的男人離奇死亡,死狀恐怖拨匆,靈堂內(nèi)的尸體忽然破棺而出姆涩,到底是詐尸還是另有隱情,我是刑警寧澤惭每,帶...
    沈念sama閱讀 34,477評(píng)論 4 333
  • 正文 年R本政府宣布骨饿,位于F島的核電站,受9級(jí)特大地震影響台腥,放射性物質(zhì)發(fā)生泄漏宏赘。R本人自食惡果不足惜,卻給世界環(huán)境...
    茶點(diǎn)故事閱讀 40,135評(píng)論 3 317
  • 文/蒙蒙 一黎侈、第九天 我趴在偏房一處隱蔽的房頂上張望察署。 院中可真熱鬧,春花似錦峻汉、人聲如沸贴汪。這莊子的主人今日做“春日...
    開封第一講書人閱讀 30,864評(píng)論 0 21
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽扳埂。三九已至业簿,卻和暖如春,著一層夾襖步出監(jiān)牢的瞬間聂喇,已是汗流浹背辖源。 一陣腳步聲響...
    開封第一講書人閱讀 32,099評(píng)論 1 267
  • 我被黑心中介騙來泰國(guó)打工蔚携, 沒想到剛下飛機(jī)就差點(diǎn)兒被人妖公主榨干…… 1. 我叫王不留希太,地道東北人。 一個(gè)月前我還...
    沈念sama閱讀 46,598評(píng)論 2 362
  • 正文 我出身青樓酝蜒,卻偏偏與公主長(zhǎng)得像誊辉,于是被迫代替她去往敵國(guó)和親。 傳聞我的和親對(duì)象是個(gè)殘疾皇子亡脑,可洞房花燭夜當(dāng)晚...
    茶點(diǎn)故事閱讀 43,697評(píng)論 2 351

推薦閱讀更多精彩內(nèi)容

  • **2014真題Directions:Read the following text. Choose the be...
    又是夜半驚坐起閱讀 9,442評(píng)論 0 23
  • D6周樂清#周檢視# 0820--0826 百日目標(biāo)檢視 1.提高普通話2.提高交流表達(dá)3.提高溝通匯報(bào) 第一部分...
    oldmien閱讀 204評(píng)論 0 0
  • 最近霉咨,昆明發(fā)生了一場(chǎng)悲劇蛙紫。 28歲的姑娘劉潔,帶未婚夫去醫(yī)院看望生病的外婆途戒。 在住院部樓下遇到一名醉漢坑傅,只因不小心...
    簡(jiǎn)明估閱讀 338評(píng)論 2 1
  • 練完琴時(shí),已經(jīng)是九點(diǎn)多了喷斋,得去趕十點(diǎn)的末班車了唁毒。 才出到廣場(chǎng),一陣熟悉的旋律傳來星爪,順著聲音找去浆西,一個(gè)穿著藍(lán)色格子衫...
    攝氏386度閱讀 283評(píng)論 0 2