我想询问是否有办法在应用程序中执行滑动命令
adb shell input touchscreen swipe 200 200 500 200
我想通过按钮点击
答案 0 :(得分:-1)
input touchscreen swipe 200 200 500 200
即可。
将以下方法称为exec("input touchscreen swipe 200 200 500 200");
/**
* Execute a command in a shell
*
* @param command
* command to execute
* @return the return of the command
*/
public String exec(String command) {
String retour = "";
try {
Runtime runtime = Runtime.getRuntime();
Process p = runtime.exec(command);
java.io.BufferedReader standardIn = new java.io.BufferedReader(
new java.io.InputStreamReader(p.getInputStream()));
java.io.BufferedReader errorIn = new java.io.BufferedReader(
new java.io.InputStreamReader(p.getErrorStream()));
String line = "";
while ((line = standardIn.readLine()) != null) {
retour += line + "\n";
}
while ((line = errorIn.readLine()) != null) {
retour += line + "\n";
}
} catch (java.io.IOException e) {
e.printStackTrace();
}
return retour;
}