android 一个Activity 设置了process 和affinity,主屏task划除问题
巴扎黑
巴扎黑 2017-04-17 12:03:28
0
1
581

这是我一个主应用下得一个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栈的时候会发生当移除任意一个时,另一个进程也被关闭的情况,请问这是什么原因

巴扎黑
巴扎黑

全部回覆(1)
小葫芦

以下引用自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 如果你不想出現2個task那麼請移除你的

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

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

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

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

熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板
關於我們 免責聲明 Sitemap
PHP中文網:公益線上PHP培訓,幫助PHP學習者快速成長!