为什么一个快捷方式到次要活动打开的主要活动,同时在后台? [英] Why does a shortcut to a secondary activity opens the main activity while in the background?

查看:168
本文介绍了为什么一个快捷方式到次要活动打开的主要活动,同时在后台?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的应用程序有几个活动,其中之一在自己的权利有生命的,所以我在清单通过做一个快捷方式:

My app has several activities, one of which has life in its own right, so I made a shortcut to it in the manifest via:

        <intent-filter>
            <action android:name="android.intent.action.CREATE_SHORTCUT" />
            <category android:name="android.intent.category.DEFAULT" />
        </intent-filter>

现在我有它在小工具区。当我点击我把我的发射,因为我想快捷这个次要活动现在打开。

Now I have it in the Widgets zone. This secondary activity now opens when I click the shortcut that I put in my launcher, as I wanted.

不过,也有一些是因为我想不工作:如果主应用程序在后台运行(例如,通过首页按钮),点击二次活动快捷键弹出窗口的主要应用,而不是次要活动。

However, there is something that does not work as I want: if the main app is working in the background (say, via the home button), clicking the secondary activity shortcut pop-ups the main app, not the secondary activity.

这是为什么?这是自然的行为吗?有没有一种方法总是打开次要活动,甚至并排着主要的应用程序?

Why is that? Is this the natural behavior? Is there a way to open the secondary activity always, even side by side with the main app?

谢谢!

升。

推荐答案

通过冲浪其他的东西,我发现这个解决方案。
只需添加

By surfing other stuff I found the solution of this. Just add

 android:launchMode="singleInstance"

在二级&LT;活性GT; 在清单。这里的解释是:
http://developer.android.com/guide/topics/manifest/activity-element.html#lmode

in the secondary <activity> in the manifest. Here is the explanation: http://developer.android.com/guide/topics/manifest/activity-element.html#lmode

这篇关于为什么一个快捷方式到次要活动打开的主要活动,同时在后台?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆