[英]Adb shell from application
請問有沒有辦法在應用程序內部執行swipe命令
adb shell input touchscreen swipe 200 200 500 200
我想通過點擊按鈕滑動
如果您從手機執行命令,只需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;
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.