2

I've written an Andoid app that uses the hardware Volume buttons for another purpose.

It works fine if the app is running and visible, but when I turn the screen off or let it time out, the button clicks don't get into my handlers.

Does anyone know if there is a way to detect these button clicks when the screen is off?

AV695
  • 21
  • 3

1 Answers1

0

The only way to keep detecting things like this when the screen is off is to acquire a WakeLock that will allow the screen to turn off, and still let your app function. However, this drains the battery life quite a bit, and should only be used when absolutely necessary.

In this case, you will need a PARTIAL_WAKE_LOCK.

Raghav Sood
  • 81,899
  • 22
  • 187
  • 195