How to use the monkeyrunner API to make Java applications?
•
Java
The Android SDK has an API for sending commands to a mobile phone named monkeyrunner It seems to be a python API Is it possible to use it in Java applications?
Solution
Well, I've been trying to do this. Here's what I found (thanks to Google and members on the Internet for some help)
This is a java program that uses monkeyrunner to print the device name
import com.android.monkeyrunner.MonkeyDevice;
import com.android.monkeyrunner.adb.AdbBackend;
public class Monk {
public static void main(String[] args) {
// TODO code application logic here
Monk monk=new Monk();
monk.demo();
}
public void demo()
{
AdbBackend ab = new AdbBackend();
MonkeyDevice device = ab.waitForConnection();
//Print Device Name
System.out.println(device.getProperty("build.model"));
device.dispose();
}
}
For the above code, I need to include the following jar jarrunner, ddmlib, Jython, guavalib, sdklib
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码
