Search code examples
androidservicevolumekeyevent

Is it possible to create a service that listens for Volume key (hardware) presses?


I am trying to create a service that listens Volume key events.

Whenever the volume key presses, the service should send an sms to a number, but I can't detect volume key event.


Solution

  • You can use an OnKeyListener which can detect keyevents (including volume keys). You can find the keycodes here. Good Luck!