Android应用在&QUOT表现不同;近期应用和QUOT;从SEND意图启动时列出 [英] Android app behaves differently in "recent apps" list when launched from SEND Intent
问题描述
我有一些文本数据进行操作的简单的Android应用程序。该应用程序被调用方法有两种:1)从发射发射应用程序,并手动输入文本数据,或2)使用SEND意图与它分享一些文本
在通过发射装置发射,一切行为与我期望的那样。当通过共享功能推出,随后使用应用程序切换器/最近使用的应用按钮,应用程序显示为Android系统,如果我从中切换出来消失。我想它出现在该列表像任何其他应用程序,当来自切离坚持。所以,问题是:为什么我的应用程序从不同的意图启动时不同的表现?我敢肯定有我不理解有关意图,活动和任务的一些基本的东西,但我不能确定,甚至找。
下面是清单的相关部分。
<应用
机器人:allowBackup =真
机器人:图标=@绘制/ ic_launcher
机器人:标签=@字符串/ APP_NAME
机器人:主题=@风格/ AppTheme>
<活动
机器人:名字=com.example.stub2.Main
机器人:标签=@字符串/ APP_NAME>
&所述;意图滤光器>
<作用机器人:名字=android.intent.action.MAIN/>
<类机器人:名字=android.intent.category.LAUNCHER/>
&所述; /意图滤光器>
&所述;意图滤光器>
<作用机器人:名字=android.intent.action.SEND/>
<类机器人:名字=android.intent.category.DEFAULT/>
<数据机器人:mime类型=text / plain的/>
&所述; /意图滤光器>
< /活性GT;
< /用途>
例如用户调用你的活动主
与 ACTION_SEND
一些文本 ABC
一起。还有一次,他叫主
文本 ZZZ
。然后,你将有主
的两个实例在最近列表中,用不同的意图。
的修改的
您可以 ACTION_SEND
像 AdapterActivity
,则文本转发给<$ C的适配器活动报名$ C>主。通过这种方式,您的应用程序(主
活动)将在最近用过仅列出当用户从启动开始吧。
&LT;活动
机器人:名字=AdapterActivity
机器人:excludeFromRecents =真/&GT;
有更多的活动标签这里。
I have a simple Android application that operates on some text data. The app is invoked two ways: 1) launching the app from the launcher and entering the text data manually, or 2) using the SEND intent to share some text with it.
When launched through the launcher, everything behaves as I expect. When launched through the Share feature and subsequently using the app switcher/recent apps button, the application appears as "Android System" and disappears if I switch away from it. I'd like it to appear in that list like any other app and persist when switched away from. So the question is: why does my app behave differently when launched from the different intents? I'm sure there's some fundamental thing I'm not understanding about Intents, Activities and Tasks, but I can't determine where even to look.
Here's the relevant section of the manifest.
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="com.example.stub2.Main"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.SEND" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="text/plain" />
</intent-filter>
</activity>
</application>
For example the user calls your activity Main
with ACTION_SEND
along with some text abc
. Another time, he calls Main
with text zzz
. Then you will have 2 instances of Main
in recent list, with different intents.
Edit
You can register ACTION_SEND
with an "adapter" activity like AdapterActivity
, then forward the text to Main
. By this way, your app (Main
activity) will be only listed in recent apps if the user starts it from the launcher.
<activity
android:name="AdapterActivity"
android:excludeFromRecents="true" />
There are more activity tags here.
这篇关于Android应用在&QUOT表现不同;近期应用和QUOT;从SEND意图启动时列出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!