Robot class like classes for android [duplicate]

一笑奈何 提交于 2019-12-23 19:45:40

问题


Possible Duplicate:
Android API like java.awt.Robot

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


回答1:


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

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);

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.




回答2:


If it's for testing you can look up Robotium, http://code.google.com/p/robotium/. It's Selenium for Android.



来源:https://stackoverflow.com/questions/14580465/robot-class-like-classes-for-android

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