MonkeyDevice是 用来控制 Android设备 或模拟器, 发送 UI事件 方法 检索信息 安装和 删除应用程序, 并可以运行应用程序

通常 不必使用newdevice = MonkeyDevice()来 创建 MonkeyDevice 一个 实例 相反的经常 使用 MonkeyRunner.waitForConnection ()来创建 一个新的MonkeyDevice对象

MonkeyDevice的常用方法:

Summary

Constants
string DOWN Use this with the type argument ofpress() ortouch() to send a DOWN event.
string UP Use this with the type argument ofpress() ortouch() to send an UP event.
string DOWN_AND_UP Use this with the type argument ofpress() ortouch() to send a DOWN event immediately followed by an UP event.
Methods
void broadcastIntent ( string uri, string action, string data, string mimetype, iterable categories dictionary extras, component component, iterable flags) Broadcasts an Intent to this device, as if the Intent were coming from an application.
void drag ( tuple start, tuple end, float duration, integer steps) Simulates a drag gesture (touch, hold, and move) on this device's screen.
object getProperty ( string key) Given the name of a system environment variable, returns its value for this device. The available variable names are listed in the detailed description of this method.
object getSystemProperty ( string key) . The API equivalent of adb shell getprop <key>. This is provided for use by platform developers.
void installPackage ( string path) Installs the Android application or test package contained in packageFile onto this device. If the application or test package is already installed, it is replaced.
dictionary instrument ( string className, dictionary args) Runs the specified component under Android instrumentation, and returns the results in a dictionary whose exact format is dictated by the component being run. The component must already be present on this device.
void press ( string name, dictionary type) Sends the key event specified by type to the key specified by keycode.
void reboot ( string into) Reboots this device into the bootloader specified by bootloadType.
void removePackage ( string package) Deletes the specified package from this device, including its data and cache.
object shell ( string cmd) Executes an adb shell command and returns the result, if any.
void startActivity ( string uri, string action, string data, string mimetype, iterable categories dictionary extras, component component, flags) Starts an Activity on this device by sending an Intent constructed from the supplied arguments.
MonkeyImage takeSnapshot() Captures the entire screen buffer of this device, yielding a MonkeyImageobject containing a screen capture of the current display.
void touch ( integer x, integer y, integer type) Sends a touch event specified by type to the screen location specified by x and y.
void type ( string message) Sends the characters contained in message to this device, as if they had been typed on the device's keyboard. This is equivalent to calling press() for each keycode in message using the key event type DOWN_AND_UP.
void wake () Wakes the screen of this device.

http://www.devdiv.com/android/docs/guide/developing/tools/MonkeyDevice.html

/**
* @author 张兴业
* 邮箱:[email protected]
* qq:363302850
*
*/

更多相关文章

  1. Androi与html中的JavaScript之间方法相互调用
  2. Android中如何修改系统时间(应用程序获得系统权限)
  3. 【Android】(转)android模拟器命令详解
  4. 【Android】Android中Button的OnClickListener实现方法
  5. Android webview中定制js的alert,confirm和prompt对话框的方法 (
  6. Android 性能优化的一些方法(转)

随机推荐

  1. Android基础_页面布局_TableLayout(表格
  2. Android之AsyncTask异步任务详解总结
  3. 20180502_从零开始的android持久库room其
  4. Android 推送通知指南
  5. Android(安卓)控件框架
  6. ELIPS Studio 3 Beta 6支持iPhone和Andro
  7. android SDK安装出现Failed to fetch URL
  8. 【Android(安卓)界面效果34】Android里Se
  9. Android获得手机所有应用(非系统)、正在运
  10. Android源码学习--SystemServer进程