I\'m doing an application using ACTION_MEDIA_BUTTON handler, but it appears it is always intercepted by MX Player or Apollo and I get no Intent
I\'ve tried both 1000
To capture headset button one should register receiver in media too in onCreate in Activity
AudioManager manager = (AudioManager) getSystemService(AUDIO_SERVICE);
manager.registerMediaButtonEventReceiver(new ComponentName(getPackageName(), BCreceiver.class.getName()));
Refer to the line "The value must be greater than -1000 and less than 1000." from below link, highest priority is 999 not 1000.
http://developer.android.com/guide/topics/manifest/intent-filter-element.html
First of all, you shouldn't register the receiver in code if it's already mentioned in the manifest. Then, the name of the receiver is invalid, it should either be a full class name, or the shorthand, which will be appended to the application package name. In case if BCreceiver
is in the main package, the attribute value should be ".BCreceiver"
. Last mention is that you shouldn't really change the priority, there is no such thing as intercepting a broadcast in Android (as far as I know), so all BroadcastReceivers
subscribed to an action will receive the broadcast when it's fired. Try these fixes and update your question.
Even though this a little old question, I am adding my findings, so that it will help new visitors.
To receive Intent.ACTION_MEDIA_BUTTON broadcast registering intent from code is not required. Documentation says intent has to be registered in the manifest. Could not get it working from registering from code.
Use registerMediaButtonEventReceiver
Setting priority in manifest android:priority="<int value>"
works. I used 2147483647 and was even able to override the stock player. I read winamp is using the highest priority.
Hope this helps.