4

I am building a Panic Alert App on Android for which I want a service to run in background and is acquiring Partial-Wake-Lock to run even when screen is off. I want this service to listen for volume key(or combination of power & volume key) press for 3secs or more to start the service sending panic messages.

Is it possible to listen key events by binding my service to any other system service? Or, is there any other way to achieve my goal?

Piyush Yadav
  • 41
  • 1
  • 3

1 Answers1

0

For listening to power button press, you register listeners for SCREEN_ON and SCREEN_OFF events.

Android does not document any such way of services listening to volume buttons, but you might want to look at this: Listen to volume buttons in background service?

Community
  • 1
  • 1
shiladitya
  • 2,290
  • 1
  • 23
  • 36