Adb shell from application

498 views Asked by At

I want to ask if there is a way to execute swipe command inside the application

adb shell input touchscreen swipe 200 200 500 200

I want to swipe through button onclick

1

There are 1 answers

0
Don Chakkappan On

just input touchscreen swipe 200 200 500 200 is enough if you are executing a command from your phone .

Call the method below as 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;
}