Reputation: 1974
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.
Upvotes: 2
Views: 1744
Reputation: 4784
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.
Upvotes: 0
Reputation: 19189
You can use an OnKeyListener which can detect keyevents (including volume keys). You can find the keycodes here. Good Luck!
Upvotes: 2