机器人类,例如适用于Android的类 [英] Robot class like classes for android

查看:70
本文介绍了机器人类,例如适用于Android的类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


可能重复:

Android API,例如java.awt.Robot

还有其他适用于Android的类,例如java中的Robot类,还是可以在android中使用Robot类?

Are there any other classes for android like Robot class in java, OR can we use Robot class in android ?

推荐答案

否,但是等价于您的仪器在Android上。

No, but an equivalent for you could be Instrumentation on Android.

例如,带有 sendKeyDownUpSync(int键)。

For instance with sendKeyDownUpSync(int key) for sending an up and down key event sync to the currently focused window.

Instrumentation inst = new Instrumentation();
inst.sendKeyDownUpSync(KeyEvent.KEYCODE_MENU);

还有实用程序类 TouchUtils 来模拟触摸事件。尽管需要注意,但Instrumentation类实际上仅用于测试,所以这取决于您要实现的目标。

There is also the utility class TouchUtils to simulate touch events. Although I have to note, that the Instrumentation class is actually only used for testing, so it depends on what you want to achieve anyway.

这篇关于机器人类,例如适用于Android的类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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