1

I want to make an mp3 player for android. This is my first app and I have no idea how to get anything related to the button on the headphones. Thank you in advance

  • Try reading [this](https://developer.android.com/guide/topics/media-apps/mediabuttons). It seems similar to handling any other KeyEvent, except the keys you're looking for indicate that play/pause/next has been pressed. – Andrew Nov 28 '22 at 01:40
  • KeyEvent works only if activity is opened, isn't it? – Prosheeptal Nov 28 '22 at 06:09
  • If you're referring to using media controls even if the app is closed, I think [this article](https://developer.android.com/guide/topics/media/media-controls) goes into that problem. – Andrew Nov 28 '22 at 07:01
  • I just need to skip song, if i punch button on my headset – Prosheeptal Nov 28 '22 at 07:23
  • You won't be implementing any direct response to buttons on an external device. Android itself will take care of how pressing pause/play/next on your headphones will result in a signal being fed into your app. So you just need to worry about programming how your app responds to receiving a pause/play/next event as per the articles I linked. – Andrew Nov 28 '22 at 07:32

0 Answers0