gpt4 book ai didi

android - 广播接收器最高优先级不工作

转载 作者:塔克拉玛干 更新时间:2023-11-02 19:13:37 25 4
gpt4 key购买 nike

我正在使用 ACTION_MEDIA_BUTTON 处理程序做一个应用程序,但它似乎总是被 MX Player 或 Apollo 拦截,我没有得到任何 Intent

我已经尝试在标记中设置 1000 和 2147483647 优先级,并在构造函数之后直接使用 setPriority

应用程序在没有 MX Player 或 Apollo 的情况下工作

我也尝试过使用 google play 中的 Headset Interceptor 应用程序,我尝试使用 Autostarts 应用程序拒绝 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

在 list 中

<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

关于android - 广播接收器最高优先级不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18734440/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com