是否可以创建一个监听音量键(硬件)按下的服务?
我正在尝试创建一个监听音量键事件的服务。
每当按下音量键时,服务应该向某个号码发送短信,但我无法检测到音量键事件。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以使用 OnKeyListener 来检测按键事件(包括音量键) )。您可以在此处找到键码。祝你好运!
You can use an OnKeyListener which can detect keyevents (including volume keys). You can find the keycodes here. Good Luck!
据我了解,您无法直接在服务中监听按键(查看此问题)。
顺便说一句,除了编写恶意软件之外,我很难想出一个做你想做的事情的理由。
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.