Search code examples
androidandroid-studioadblookupexit-code

Where to lookup for the meaning "adb screencap" command's exit codes or how to get the meaning programatically?


        Process p = Runtime.getRuntime().exec("screencap -p /storage/sdcard0/test3332.png");
        p.waitFor();
        String error = "error: " +  p.exitValue();

p.exitValue() is equal to 11

How to get the "meaning" or message from this exit code?

If this should be available in the command's manual, then where to find this manual? Can someone post a link or a reference ?


Solution

  • The error message can be retrieved in this way:

    int ch;
    StringBuilder sb = new StringBuilder();
    while((ch = p.getErrorStream().read()) != -1) {
        sb.append((char)ch);
    }
    String errorString = sb.toString();
    Log.d("TAG", "Error is: " + errorString);