Samsung更新后,任何收到的ACTION_MEDIA_BUTTON Intent extra现在都为空。
Receiver.java:
@Override
public void onReceive(Context context, Intent intent) {
if (!Intent.ACTION_MEDIA_BUTTON.equals(intent.getAction())) {return;}
// This is now coming back null
KeyEvent event = (KeyEvent)intent.getParcelableExtra(Intent.EXTRA_KEY_EVENT);
// ... do something
}
AndroidManifest.xml:
<uses-permission android:name="android.permission.BLUETOOTH" />
<!-- stuff -->
<receiver
android:name=".RemoteControlReceiver"
android:enabled="true"
android:exported="true">
<intent-filter android:priority="999">
<action android:name="android.intent.action.MEDIA_BUTTON" />
</intent-filter>
</receiver>
这已经工作了很长时间。我需要对代码做什么调整?
有任何故障排除建议吗?
或者我的应用是否需要在手机设置中重新授予某种类型的权限?
2条答案
按热度按时间jei2mxaa1#
我在三星手机上遇到了同样的问题。
下面是工作代码:
通知管理器:
cngwdvgl2#
我遇到了同样的问题,它就在那里:
当我把flag改为MUTABLE时,它就开始工作了。