My question is how can I use the button
on my headphones in my app?
I just want a very simple example that displays a Toast
when button
is clicked. Also I would appreciate a detailed explanation.
Thanks in advance.
(I use lollipop 5.1)
My question is how can I use the button
on my headphones in my app?
I just want a very simple example that displays a Toast
when button
is clicked. Also I would appreciate a detailed explanation.
Thanks in advance.
(I use lollipop 5.1)
There's a simpler way which doesn't require any BroadcastReceiver to be registered if you only want to listen for headset button callbacks while your app (particular activity) is running, simply override Activity onKeyDown method:
For more extended implementation use ACTION_MEDIA_BUTTON intent.