首頁  >  問答  >  主體

android 一个Activity 设置了process 和affinity,主屏task划除问题

这是我一个主应用下得一个Activity设置:

  <activity
            android:name=".activity.WebViewActivity"
            android:launchMode="singleInstance"
            android:process="com.test.webivew"
            android:configChanges="orientation|screenSize"
            android:taskAffinity="com.lydiabox.webView"

我打开主应用,然后打开这个Activity,我按home回到主界面,看最近打开应用,这是会出现两个任务栈,在移除主应用task栈或者这个activity Task栈的时候会发生当移除任意一个时,另一个进程也被关闭的情况,请问这是什么原因

巴扎黑巴扎黑2721 天前586

全部回覆(1)我來回復

  • 高洛峰

    高洛峰2017-04-17 12:05:28

    以下引用自http://developer.android.com/guide/topics/manifest/activity-element.html

    The "singleTask" and "singleInstance" modes also differ from each other in only one respect: A "singleTask" activity allows other activities to be part of its task. It's always at the root other task, ivities necessarily "standard" and "singleTop" activities) can be launched into that task. A "singleInstance" activity, on the other hand, permits no other activities to be part of itsask< . It's the only activity in the task. 如果你不想出現2個task那麼請移除你的

    android:launchMode="singleInstance"關於移除一個另一個也會關閉的情況:

    所有的task都是從主應用程式開啟的,你關閉主應用,所有的應該會同時關閉了

    另一個情況,關閉這個activity task也會關閉的情況,應為你設定的process為
    ,會關閉這個進程,你查看下是不是你application的process也設置為com.test.webivew
    android:process="com.test.webivew"最後提醒以下,除非你明確知道

    的作用,否則請不要使用這兩個參數。同時認真閱讀上面連結的內容android:launchMode="singleInstance"

    回覆
    0
  • 取消回覆