【发布时间】:2014-11-13 10:08:05
【问题描述】:
假设我有一个可以处理从其他应用发送图像的活动,其定义类似于您在此处看到的:
<activity
android:name="..."
android:configChanges="keyboardHidden"
android:label="..."
android:screenOrientation="portrait" >
<intent-filter android:label="new collection" >
<action android:name="android.intent.action.SEND_MULTIPLE" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="image/*" />
</intent-filter>
<intent-filter android:label="new collection" >
<action android:name="android.intent.action.SEND" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="image/*" />
</intent-filter>
</activity>
一切都很好,但是如果我想添加相同的意图过滤器(处理将图像发送到应用程序),但这次使用不同的标签,我可以在代码中检查哪个?
例如,我可以为“添加到现有集合”添加一个意图过滤器。
我已经搜索了我可以自己设置的属性,这不会影响操作系统解析意图的方式,但我失败了。
我该如何正确地做到这一点? 我真的必须创建一个新活动吗?
【问题讨论】:
-
在清单中添加别名:
-
@pskink 你能举个例子来说明你的意思吗?另外,我应该在代码中添加什么以区分操作(“添加到现有集合”、“新集合”)?
-
添加带有attrs的activity-alias:name、targetActivity和label,同时复制intent-filter,在你的Activity中使用getIntent().getComponent()
-
@pskink 这看起来像是在工作。请把它作为答案。另外,顺便说一句,必须在活动标签之后添加新的“活动别名”标签,您可以将任何您想要的名称添加到它的名称中。 “标签”不是必需的,但它很有用。关于这项技术,我需要了解什么重要的事情吗?
标签: android android-intent android-manifest