Detect Hardware Volume Button Clicks When Screen Is Off

Go To StackoverFlow.com

1

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?

2012-04-04 21:13
by AV695


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.

2012-07-01 17:19
by Raghav Sood
i tried this, but it doesnt detect the buttons :( , any workaround - Rat-a-tat-a-tat Ratatouille 2014-02-25 12:32
this doent work please add some cod - amodkanthe 2015-04-27 18:56
Ads