Moving mouse pointer on Android screen programmatically

情到浓时终转凉″ 提交于 2019-12-18 16:38:48

问题


I am developing an Android application where I would like to move the "mouse" pointer/cursor on an Android tablet. I know this is possible because when I connect a mouse (USB or BT) to an Android tablet (Honeycomb+), a cursor appears and I can interact with the tablet using the mouse only. I would like to control that mouse from Java on the Tablet.
I already have a second device that can communicate the tablet and which can stream pointer coordinates to it.
And no I can't use bluetooth. The second device that I'm using has WiFi but no ability to drive BlueTooth. My thought is that there must be a way to move the mouse pointer.


回答1:


It is possible to control the mouse pointer in Android programmatically via the AccessibilityService API.

Here is an example app in the play store: EVA Facial Mouse app

Here is a github repository for controlling the mouse pointer via WiFi (API level 21): chetbox/android-mouse-cursor

I have forked and updated the latter repo to API level 27: Ra-Na/android-mouse-cursor




回答2:


I would like to control that mouse from Java on the Tablet.

This is not possible, except via firmware or specialized instrumentation code. Ordinary SDK applications cannot inject input events this way.



来源:https://stackoverflow.com/questions/7695258/moving-mouse-pointer-on-android-screen-programmatically

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!