From 94f8ee7f3bc3da664f774cb418dced5b97162856 Mon Sep 17 00:00:00 2001 From: zlzw <583819556@qq.com> Date: Mon, 27 Feb 2023 16:33:40 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4=E6=97=A5=E5=BF=97=E6=A0=BC?= =?UTF-8?q?=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/java/com/shayu/phonelive/AppContext.java | 2 +- app/src/main/java/com/shayu/phonelive/utils/LogUtils.java | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/com/shayu/phonelive/AppContext.java b/app/src/main/java/com/shayu/phonelive/AppContext.java index af69b040a..081ff74cb 100644 --- a/app/src/main/java/com/shayu/phonelive/AppContext.java +++ b/app/src/main/java/com/shayu/phonelive/AppContext.java @@ -122,11 +122,11 @@ public class AppContext extends CommonAppContext { @Override public void onCreate() { super.onCreate(); - //注册全局异常捕获 if (!isMainProcess()) { return; } CrashSaveBean.getInstance().setStartTime(System.currentTimeMillis()); + //注册全局异常捕获 registerError(); registerFirebaseCrash(); LogUtils.start(this); diff --git a/app/src/main/java/com/shayu/phonelive/utils/LogUtils.java b/app/src/main/java/com/shayu/phonelive/utils/LogUtils.java index 87c8f3124..b2dc80e1c 100644 --- a/app/src/main/java/com/shayu/phonelive/utils/LogUtils.java +++ b/app/src/main/java/com/shayu/phonelive/utils/LogUtils.java @@ -31,7 +31,7 @@ public class LogUtils { String[] exec = new String[]{"logcat", "-c"}; Runtime.getRuntime().exec(exec).waitFor(); - exec = new String[]{"logcat", "-v", "UTC", "-D"}; + exec = new String[]{"logcat", "-v", "color", "UTC-8"}; Process process = Runtime.getRuntime().exec(exec); BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(process.getInputStream())); @@ -55,6 +55,7 @@ public class LogUtils { writer = new PrintWriter(os); while ((line = bufferedReader.readLine()) != null) { writer.append(line).write("\n"); + writer.flush(); } writer.flush(); writer.close();