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

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

巴扎黑
巴扎黑

reply all(1)
小葫芦

The following quote is from 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 of its task, but other activities ( 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 its task . It's the only activity in the task.

If you don’t want 2 tasks to appear, please remove your android:launchMode="singleInstance"

About the situation where removing one will also close the other:
All tasks are opened from the main application. If you close the main application, all tasks should be closed at the same time
In another case, closing the activity task will also close the process. The process you set should be android:process="com.test.webivew", which will close the process. Check whether the process of your application is also set to com.test.webivew

Final reminder: Unless you clearly know the functions of android:launchMode="singleInstance" and android:taskAffinity="com.lydiabox.webView", please do not use these two parameters. Also read the content of the link above carefully

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template