0

I am a android developer.I make a music player application.Now I want to handle play and pause event by headset.this is my code for register receiver:

IntentFilter iF = new IntentFilter(Intent.ACTION_MEDIA_BUTTON);
    iF.setPriority(10000);
    registerReceiver(mButtonReceiver, iF);

and then get action in receiver class. but not working. please help me!!

Ahmad Azarnia
  • 129
  • 1
  • 1
  • 11
  • 1
    A Receiver for the media buttons needs to be registered with `AudioManager`, instead of the usual way of registering Receivers. Check the [developer page](http://developer.android.com/training/managing-audio/volume-playback.html#PlaybackControls) for an example, and [my answer here](http://stackoverflow.com/a/25158635) for corrections. – Mike M. Oct 11 '15 at 09:36
  • 1
    Thanks for your answer,solved problem. – Ahmad Azarnia Oct 11 '15 at 09:48

0 Answers0