AndroidMainfest - 应该意图过滤器有多个动作? [英] AndroidMainfest - should an intent-filter have multiple actions?
问题描述
我现在的意向过滤器对我的MainActivity看起来像这样
<意向滤光器>
<作用机器人:名字=android.intent.action.MAIN/>
<类机器人:名字=android.intent.category.LAUNCHER/>
<作用机器人:名字=android.hardware.usb.action.USB_ACCESSORY_ATTACHED/>
&所述; /意图滤光器>
请注意,有2个动作节点。它是否正确?还是说只是每意图过滤器一个动作节点?
此外,什么是默认类别的目的是什么?
<类机器人:名字=android.intent.category.DEFAULT/>
这是正确的?
块引用>它可以是,尽管在这种情况下,我怀疑这是不是你想要的。
本
<意向滤光器>
将匹配:
的
意图
与主
动作和LAUNCHER
类别,或的
意图
与USB_ACCESSORY_ATTACHED
和LAUNCHER
类别前者是常见的。不过,我倒是怀疑
USB_ACCESSORY_ATTACHED
将与LAUNCHER
类使用。我甚至不能确定它是用来用的活动的,因为文档有点糊涂这一点。My current intent-filter for my MainActivity looks like this
<intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> <action android:name="android.hardware.usb.action.USB_ACCESSORY_ATTACHED" /> </intent-filter>
Notice that there are 2 action nodes. Is this correct? Or should there only be one action node per intent-filter?
Also, what is the purpose of the DEFAULT category?
<category android:name="android.intent.category.DEFAULT" />
解决方案Is this correct?
It can be, though in this case I suspect it is not what you want.
This
<intent-filter>
will match:
an
Intent
with theMAIN
action and theLAUNCHER
category, oran
Intent
with theUSB_ACCESSORY_ATTACHED
and theLAUNCHER
categoryThe former is common. However, I rather doubt that
USB_ACCESSORY_ATTACHED
will be used with theLAUNCHER
category. I am not even sure it is used with activities, as the documentation is a bit muddled on this point.这篇关于AndroidMainfest - 应该意图过滤器有多个动作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!