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

问题描述 投票:0回答:1

我的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());
android logcat android-logcat
1个回答
0
投票

不要使用result.toString ..而是使用结果qazxsw poi

© www.soinside.com 2019 - 2024. All rights reserved.