我的Android代码包含Log.e.以编程方式获取logcat时,不会显示这些日志。我的logcat代码是
String command = "logcat MyApp:V";
Process process = Runtime.getRuntime().exec(command);
BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream()));
StringBuilder result = new StringBuilder();
String currentLine;
while ((currentLine = reader.readLine()) != null) {
result.append(currentLine);
result.append("\n");
}
Log.e(TAG, "printLog: " + result.toString());
答案 0 :(得分:0)
不要使用result.toString ..而是使用结果Log.e(TAG, "printLog: " + result);