有谁知道如何使用Java以编程方式获取android设备系统日志?这将类似于Dalvik调试监视器下部面板上的可用内容.
提前致谢.
解决方法:
未经“ adb shell logcat”测试,但我已使用它通过adb获取其他内容:
public static String[] getAdbLogCat() {
try {
Process p = Runtime.getRuntime().exec("/path/to/adb shell logcat");
InputStream is = p.getInputStream();
InputStreamReader isr = new InputStreamReader(is);
BufferedReader br = new BufferedReader(isr);
final StringBuffer output = new StringBuffer();
String line;
ArrayList arrList = new ArrayList();
while ((line = br.readLine()) != null) {
System.out.println(line);
}
return (String[])arrList.toArray(new String[0]);
} catch (IOException e) {
System.err.println(e);
e.printStackTrace();
return new String[]{};
}
}
标签:logging,java,android
来源: https://codeday.me/bug/20191209/2097042.html