现在,我想在Android 4.1上读取系统日志。但只能获取应用程序本身的日志。我的代码如下:
Process logcatProc = Runtime.getRuntime().exec(new String[] { "logcat","ActivityManager:V","*:S" });
reader = new BufferedReader(new InputStreamReader(logcatProc.getInputStream()));
String line;
while ((line = reader.readLine()) != null) {
Log.e("log",line);
}
看起来 IT 可以在 Android 4.0 或之前的版本上运行。有人试过吗?还是我需要 root 权限?