简体   繁体   English

以编程方式获取logcat时不显示我的代码登录

[英]Logs in my code do not display when getting logcat programmatically

My android code contains Log.e. 我的Android代码包含Log.e。 When getting logcat programmatically, those logs are not displayed. 以编程方式获取logcat时,不会显示这些日志。 My code for logcat is 我的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());

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM