version:1.2.2

fix:
update:增加报错
This commit is contained in:
tt committed 2023-12-21 10:19:22 +08:00
1 parent b117888f87
commit 86986c8d58
4 files changed
+33 -9

No files matched your search

@@ -1,6 +1,8 @@
package com.uiuipad.os.base;
import android.app.Application;
import android.os.Handler;
import android.os.Looper;
import android.util.Log;
import com.tencent.bugly.crashreport.CrashReport;
@@ -43,5 +45,34 @@ public class BaseApplication extends Application {
CrashReport.initCrashReport(getApplicationContext(), "55d55ba689", false);
CrashReport.setDeviceId(this, Utils.getSerial(this));
xcrash.XCrash.init(this);
catchException();
}
private void catchException() {
Thread.setDefaultUncaughtExceptionHandler(
new Thread.UncaughtExceptionHandler() {
@Override
public void uncaughtException(Thread t, Throwable e) {
Log.e("捕获异常子线程:", Thread.currentThread().getName() +
"在:" + e.getStackTrace()[0].getClassName());
}
}
);
//下面是新增方法!
new Handler(Looper.getMainLooper()).post(new Runnable() {
@Override
public void run() {
while (true) {
try {
Looper.loop(); //会先执行这个方法,然后在执行下面的异常捕获方法!
} catch (Exception e) {
Log.e("捕获异常主线程:", Thread.currentThread().getName() +
"在:" + e.getStackTrace()[0].getClassName());
e.printStackTrace();
}
}
}
});
}
}