移除全局异常捕获后杀死进程功能

This commit is contained in:
zlzw 2023-02-13 16:25:04 +08:00
parent 3d5ac05d36
commit 11cf971514
2 changed files with 6 additions and 6 deletions

View File

@ -278,17 +278,17 @@ public class AppContext extends CommonAppContext {
Log.e("ApplicationError", "主线程异常");//此处log只是展示当debug为true时主类内部log会打印异常信息
e.printStackTrace();
//闪退后finish所有Activity并且杀死进程
for (WeakReference<Activity> activity : activities) {
/* for (WeakReference<Activity> 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会打印异常信息

View File

@ -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;
}
}
});