简单的问题 - 我可以注册一个吗BroadcastReceiver
多个 Intent 操作?这是我正在考虑的:
<receiver android:name=".myReceiver">
<intent-filter android:priority="1000000">
<action android:name="android.intent.action.MEDIA_BUTTON" />
<action android:name="android.intent.action.ACTION_HEADSET_PLUG" />
</intent-filter>
</receiver>
So in myReceiver
class' onReceive
,我可以检查一下吗intent.getAction()
对彼此而言ACTION_MEDIA_BUTTON and ACTION_HEADSET_PLUG
?
我想你可以有多个 s,每个都有其动作元素。
<receiver android:name=".myReceiver">
<intent-filter android:priority="1000000">
<action android:name="android.intent.action.ACTION_HEADSET_PLUG" />
</intent-filter>
<intent-filter android:priority="1000000">
<action android:name="android.intent.action.MEDIA_BUTTON" />
</intent-filter>
</receiver>
然后在接收者的onReceive中检查Intent的action。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)