I am trying to find a way to check if one of the buttons is pressed while the Android screen is locked. I would like to be able to pause and resume audio playback when a button is pressed without making the user unlock the screen.

Does anyone know how to detect if a button is pressed while the Android screen is locked?