在启动不同的任务新的Android活动 [英] Starting a new Android Activity in different task
问题描述
这是一个有点令人费解的故事:
This is a bit of a convoluted story:
我有一个活动A
。结果活动A
使用意图打开浏览器做一些验证。结果
当这样做时,网页重定向到URL。 活动B
设置与意图过滤器是BROWSABLE和URL是这样的浏览器启动活动B
而不是打开一个网页。结果
I have an Activity A
.
Activity A
uses an intent to open a browser to do some authentication.
When this is done, the web page redirects to a URL. Activity B
is set with an intent filter to be BROWSABLE, and the URL is such that the browser starts Activity B
rather than opening a web page.
活动B
因此,开放的,但作为一个镀铬的'孩子'。在最近的应用程序窗口,我可以看到我原来的活动A,那么我可以看到活动B
铬之下。
Activity B
is therefore open, but as a 'child' of Chrome. In the recent apps window, I can see my original Activity A, then I can see Activity B
under Chrome.
我活动B推出任何活动似乎停留铬的孩子。我一直在使用的意图标志 FLAG_ACTIVITY_NEW_TASK
尝试,但似乎并没有改变任何东西。
Any Activity I launch in Activity B seems to stay a child of Chrome. I have tried using the intent flag FLAG_ACTIVITY_NEW_TASK
but this doesn't seem to change anything.
我想从启动活动B不Chrome会出现一个活动,但在自己的新任务。理想情况下,我会想回到那个任务活动A
是的,但如果这是不可能的一个新的就足够了。
I would like to launch an Activity from Activity B that does not appear under Chrome, but under its own new task. Ideally, I would want to go back to the task that Activity A
is in, but if this isn't possible a new one would suffice.
推荐答案
我意识到,这可以通过使用singleTask启动模式这里描述来完成:的http://www.intridea.com/blog/2011/6/16/android-understanding-activity-launchmode
I've realised that this can be accomplished by using the singleTask launch mode as described here: http://www.intridea.com/blog/2011/6/16/android-understanding-activity-launchmode
从本质上讲,我结合A和B为一体的活动,并将其设置为单个任务。当Chrome浏览器重定向到它,它恢复到原来的任务,而不是创建一个新的作为它的孩子。
Essentially, I combined A and B into one activity, and set it to be a single task. When Chrome redirects to it, it returns to the original task rather than creating a new one as its child.
这篇关于在启动不同的任务新的Android活动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!