Android辅助功能执行触摸操作 [英] Android Accessibility perform touch action

查看:700
本文介绍了Android辅助功能执行触摸操作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道是否可以使用屏幕上的位置的Android无障碍服务来执行触摸操作,例如:

I am wondering if it is possible to perform touch action with Android accessibility service on screen at position, e.g.:

Bundle arguments = new Bundle();
arguments.putInt(/*coord X*/, /*X value*/);
arguments.putInt(/*coord Y*/, /*Y value*/);
node.performAction(/*touch action*/, arguments);

或者,如果可能的话,再次记录用户点击某个视图/位置时的操作。

Or, again if possible, record an action when user taps on a certain view / position.

基本上,当弹出时,我必须通过软键盘执行操作(外部应用程序没有 Submit按钮来执行ACTION_CLICK),但是注入事件不是由于安全政策而被允许。任何的想法?谢谢!

Basically, I have to perform action over soft keyboard, when it pops up (external app does not have "Submit" button to perform ACTION_CLICK on it), but injecting events is not permitted due to security policies. Any idea? Thanks!

推荐答案

您不能按屏幕上的位置执行任何操作,只能在节点上执行操作,但是可以通过使用 getBoundsInScreen 递归检查节点在屏幕上的位置来找到坐标上的哪个节点。

You can not perform any action by position on the screen, you can only do on the nodes, but you can find which node is on your coordinates by recursively checking nodes position-on-the-screen with getBoundsInScreen.

它如果它是OpenGL游戏,将无法正常工作,并且您将无法仅在该位置上找到的节点上单击精确位置。

It wouldn't work if it is OpenGL game, and you won't be able to perform the click on the precise location only on the node you found on that location.

这篇关于Android辅助功能执行触摸操作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆