From 11cf971514cfd6c23c4a6d23ade4f3c48354ab78 Mon Sep 17 00:00:00 2001 From: zlzw <583819556@qq.com> Date: Mon, 13 Feb 2023 16:25:04 +0800 Subject: [PATCH] =?UTF-8?q?=E7=A7=BB=E9=99=A4=E5=85=A8=E5=B1=80=E5=BC=82?= =?UTF-8?q?=E5=B8=B8=E6=8D=95=E8=8E=B7=E5=90=8E=E6=9D=80=E6=AD=BB=E8=BF=9B?= =?UTF-8?q?=E7=A8=8B=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/java/com/shayu/phonelive/AppContext.java | 8 ++++---- .../main/java/com/shayu/phonelive/NeverCrashUtils.java | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/com/shayu/phonelive/AppContext.java b/app/src/main/java/com/shayu/phonelive/AppContext.java index 4cc9e4c31..af69b040a 100644 --- a/app/src/main/java/com/shayu/phonelive/AppContext.java +++ b/app/src/main/java/com/shayu/phonelive/AppContext.java @@ -278,17 +278,17 @@ public class AppContext extends CommonAppContext { Log.e("ApplicationError", "主线程异常");//此处log只是展示,当debug为true时,主类内部log会打印异常信息 e.printStackTrace(); //闪退后finish所有Activity并且杀死进程 - for (WeakReference activity : activities) { + /* for (WeakReference activity : activities) { if (activity != null && activity.get() != null) { activity.get().finish(); } } - /* Process.killProcess(Process.myPid()); - System.exit(0);*/ + *//* Process.killProcess(Process.myPid()); + System.exit(0);*//* setFirebaseCrashData(); new Handler(Looper.getMainLooper()).postDelayed(() -> { throw new RuntimeException(e); - }, 100); + }, 100);*/ }) .setUncaughtCrashHandler((t, e) -> { Log.e("ApplicationError", "子线程异常");//此处log只是展示,当debug为true时,主类内部log会打印异常信息 diff --git a/app/src/main/java/com/shayu/phonelive/NeverCrashUtils.java b/app/src/main/java/com/shayu/phonelive/NeverCrashUtils.java index f99f3a492..676852fd0 100644 --- a/app/src/main/java/com/shayu/phonelive/NeverCrashUtils.java +++ b/app/src/main/java/com/shayu/phonelive/NeverCrashUtils.java @@ -101,10 +101,10 @@ public class NeverCrashUtils { Log.e(TAG, "未捕获的主线程异常行为", e); } e.printStackTrace(); - Toast.makeText(application, "发生闪退", Toast.LENGTH_SHORT).show(); + Toast.makeText(application, "发生闪退:"+e.getMessage(), Toast.LENGTH_SHORT).show(); FileUtil.saveStringToFile(new File(application.getDir("files", Context.MODE_PRIVATE).getAbsolutePath()), throwableToString(e), "error.log"); getMainCrashHandler().mainException(Looper.getMainLooper().getThread(), e); - return; + // return; } } });