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

こ雲淡風輕ζ 提交于 2020-12-15 06:17:26

问题


        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 ?


回答1:


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);


来源:https://stackoverflow.com/questions/64844158/where-to-lookup-for-the-meaning-adb-screencap-commands-exit-codes-or-how-to-g

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!