我正在使用 ACTION_MEDIA_BUTTON 处理程序执行一个应用程序,但它似乎总是被 MX Player 或 Apollo 拦截,并且我没有得到 Intent
我尝试过在标记中设置 1000 和 2147483647 优先级,并在构造函数之后直接使用 setPriority 设置
当没有 MX Player 或 Apollo 时,应用程序可以运行
我还尝试使用 Google Play 中的耳机拦截器应用程序,我尝试使用自动启动应用程序拒绝 MX Player 的事件 - 没有任何帮助
在 onCreate 中:
IntentFilter filter = new IntentFilter(Intent.ACTION_MEDIA_BUTTON);
filter.addAction(Intent.ACTION_HEADSET_PLUG);
filter.setPriority(1000);
registerReceiver(receiver, filter);
在接收器中
@Override
public void onReceive(Context context, Intent intent) {
if (Intent.ACTION_MEDIA_BUTTON.equals(intent.getAction())) {
// NEVER REACHES HERE WHEN MX PLAYER PRESENT. WORKS IF NOT
明显地
<receiver
android:name="BCreceiver"
android:enabled="true">
<intent-filter android:priority="1000">
<action android:name="android.intent.action.MEDIA_BUTTON" />
<action android:name="android.intent.action.HEADSET_PLUG" />
</intent-filter>
</receiver>
请参阅行“该值必须大于 -1000 且小于 1000。" 从下面的链接中,最高优先级是 999 而不是 1000。
http://developer.android.com/guide/topics/manifest/intent-filter-element.html http://developer.android.com/guide/topics/manifest/intent-filter-element.html
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)