How can I detect if a buton, on a pair of headphones, was pressed while running an Android app? Music applications use to this button to stop, play, pause music, etc.
D
Use the ACTION_MEDIA_BUTTON and ACTION_AUDIO_BECOMING_NOISY. Refer this doc: Developer Android
ACTION_MEDIA_BUTTON
ACTION_AUDIO_BECOMING_NOISY