所以我开始创建一个非常简单的应用程序,并阅读了如何在应用程序中设置手势。
我想知道是否有办法为android设备设置全局手势?
如果应用程序在后台运行(根本不在屏幕上)并且用户在屏幕上执行一些手势。我可以控制吗?我可以根据该手势启动某些内容或激活某些内容吗?
如果可以的话,请给我一些详细信息。我对此有点陌生。
谢谢。
最佳答案
全局接收触摸手势的唯一方法是使用 AccessibilityService
和 FLAG_REQUEST_TOUCH_EXPLORATION_MODE标志已启用。当这样的 AccessibilityService 处于 Activity 状态时,将进入“触摸探索模式”。结果是(引自上面的链接)
In this mode a single finger moving on the screen behaves as a mouse pointer hovering over the user interface. The system will also detect certain gestures performed on the touch screen and notify this service.
系统检测到的手势列在 AccessibilityService documentation 中。请考虑这对系统的总体使用有很大影响。
此外,用户必须通过辅助功能系统设置手动启用 AccessibilityService
。
关于android - Android 中的全局触摸手势?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27312790/