是否可以创建一个监听音量键(硬件)按下的服务?

发布于 2024-12-20 08:22:03 字数 72 浏览 5 评论 0原文

我正在尝试创建一个监听音量键事件的服务。

每当按下音量键时,服务应该向某个号码发送短信,但我无法检测到音量键事件。

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

尐偏执 2024-12-27 08:22:03

您可以使用 OnKeyListener 来检测按键事件(包括音量键) )。您可以在此处找到键码。祝你好运!

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

悲念泪 2024-12-27 08:22:03

据我了解,您无法直接在服务中监听按键(查看此问题)。

顺便说一句,除了编写恶意软件之外,我很难想出一个做你想做的事情的理由。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文