java - Android Volume Button Listener when Screen Off -


i have activity listening volume button events using onkeydown(), not able see these events when screen off.

is there way can still listen volume button presses when screen off?

no, not possible because broadcast receiver not work when screen light off because after screen off volume button lock , volume level not change.

alternative way this:

but can achieve using run media player 0 sound in background infinite times keep volume button active or can use wake lock achieve this.

but don't suggest method of long time because totally drain battery fast. can use these alternative method short period of time otherwise mobile battery down fastly.


Comments

Popular posts from this blog

monitor web browser programmatically in Android? -

Shrink a YouTube video to responsive width -

wpf - PdfWriter.GetInstance throws System.NullReferenceException -