是否可以在一个< intent-filter>中注册两个动作.活动 [英] Is it possible to register two actions within one <intent-filter> for Activity
问题描述
我想注册我的启动器活动,因此可以通过单击图标并使用自定义方案打开链接来启动它.我设法使其正常工作,但我怀疑这是正确的方法.这是清单的相关部分:
I wanted to register my launcher activity so it could be started by both clicking on icon and opening link with a custom scheme. I managed to make it work but am questioning is this correct way. This is the relevant part of my manifest:
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.MULTIWINDOW_LAUNCHER" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="my.sheme" />
</intent-filter>
这确实有效,但是我想知道我是否应该在相同的Intent过滤器下注册这两个动作.我尝试仅将标签从第二个过滤器移至第一个过滤器,但是安装后我的活动不显示图标.可以这样做吗?我只是犯了一些小语法错误(或破坏了声明规则的某些未记录顺序),或者我的想法完全错误,并且有更深层的原因导致此方法不起作用?
This does work but I was wondering should I register both actions under same intent filter. I tried just moving tags from second filter to the first one but then my activity doesn't show icon on install. Is it possible to do it this way and I just made some small syntax error(or broke some undocumented order of declaration rule) or is my thinking completely wrong on this and there are deeper reasons why this doesn't work?
注意:我确实设置了android:exported ="true",但android.intent.action.MAIN即使没有它也可以工作,因为如果您使用action.MAIN,它仍然会被导出
NOTE:I do set android:exported="true"but android.intent.action.MAIN works even without it because it becomes exported anyway if you use action.MAIN