以编程方式获取logcat时,不显示我的代码中的日志

时间:2017-12-27 08:11:56

标签: android logcat android-logcat

我的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());

1 个答案:

答案 0 :(得分:0)

不要使用result.toString ..而是使用结果Log.e(TAG, "printLog: " + result);