2

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.

Chris
  • 8,030
  • 4
  • 37
  • 56
ASP
  • 1,974
  • 3
  • 18
  • 30

2 Answers2

2

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

keyser
  • 18,829
  • 16
  • 59
  • 101
0

As far as I understand, you can not listen for key presses directly in a service (see this question).

On an unrelated note, it is hard for me to think of a reason to do what you want aside from writing malware.

Community
  • 1
  • 1
Tad
  • 4,668
  • 34
  • 35