如果检测到手势,如何发送 KeyEvent

发布于 2024-12-21 07:25:42 字数 112 浏览 3 评论 0原文

我想要一个手势方向键,但是如果检测到手势,如何发送 e 键事件?例如,我检测到向下的手势,现在我想发送键事件KEYCODE_DPAD_DOWN

我怎样才能做到这一点?

I want a gesture D-Pad, but how can I send an e keyevent if I detect a gesture? For example, I detect the gesture down, and now I want to send the keyevent KEYCODE_DPAD_DOWN.

How can i do that?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(1

缺⑴份安定 2024-12-28 07:25:42

如果您只想将按键事件发送到您的应用程序,最简单的方法是将其注入到根视图中:

KeyEvent event = new KeyEvent(...)
someView.getRootView().dispatchKeyEvent(event);

如果您想将其发送到另一个应用程序/窗口,那么您不能(您需要特殊的权限,这需要您需要使用系统证书对您的应用程序进行签名,AFAIK)

If you want to send the key event only to your application, the easiest is to just inject it in the root view:

KeyEvent event = new KeyEvent(...)
someView.getRootView().dispatchKeyEvent(event);

If you want to send it to another application/window, then you cannot (you would need a special permission, which requires you to have your application signed with the system certificate, AFAIK)

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