【问题标题】:Adb shell from application来自应用程序的 adb shell
【发布时间】:2015-06-25 09:05:41
【问题描述】:

我想问一下有没有办法在应用里面执行swipe命令

adb shell input touchscreen swipe 200 200 500 200

我想在点击按钮上滑动

【问题讨论】:

    标签: android shell adb touchscreen


    【解决方案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;
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2023-04-06
      • 1970-01-01
      • 2011-01-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多