In Android, I'm trying to detect when the user presses the volume button, even if the screen is turned off.
I've tried many approaches already suggested on stackoverflow, like using ContentObserver, WAKE_LOCKs and android.media.VOLUME_CHANGED_ACTION, but I was not able to get any of them to work.
I'm able to detect these events when the application is not in the foreground, however if the screen is off, then the event is not detected.
I tried an application (QuickClick) which supposedly enables this screen-off volume button detection, but couldn't find a way to detect the event.
I'd like something that doesn't require root permission, as stated on other answers.
Is there any code that will allow me to detect a volume button press when the screen is off?