Catching key presses when android phone is in deep sleep mode Catching key presses when android phone is in deep sleep mode android android

Catching key presses when android phone is in deep sleep mode


In my experience, an app can't receive media button broadcasts when the device is asleep, even if it is a foreground service (the media button doesn't wake it up). Holding a partial wake lock prevents it sleeping so the button press is detected. I suspect your music playing app is holding a wake lock which is why it works. I would like to be proved wrong and not need the wake lock though...


I found an open source app that actually wakes phone from sleep by pressing the volume button. https://github.com/praslnx8/volume_Screen_Lock

This app uses Service to play media.

While playing media the volume button action will always sent to the respective reciever even if the phone screen is locked...