So I am starting to create a very simple app and I read on how to setup gestures within the app.
I want to know if there is a way to set global gesture for the android device?
If the app is running in the background (not on the screen at all) and user does some gesture on the screen. can I control that? Can I launch something or activate something based on that gesture?
Please give me some info in detail if you can. I am kinda new to this.
Thank you.
The only way to globally receive touch gestures is by using an AccessibilityService
with the FLAG_REQUEST_TOUCH_EXPLORATION_MODE flag enabled. When such an AccessibilityService
is active, "touch exploration mode" will be entered. The result is that (cited from the link above)
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.
The gestures which are detected by the system are listed in the AccessibilityService documentation. Please consider that this has a high impact on using the system in general.
Additionally, the AccessibilityService
would have to be manually enabled by the user via the accessibility system settings.