如题,项目中,有可能需要我们同时用到全局异常捕获和bugly统计。但是bugly已经集成了全局异常捕获了,如何使两个异常捕获都生效?
只需要在bugly声明之前,先声明我们自定义的全局异常捕获即可。
代码如下图:
/**
* bugly init
*/
private void initBugly() {
//设置全部异常捕获
try {
MyCatchException handler = MyCatchException.getInstance();
Thread.setDefaultUncaughtExceptionHandler(handler);
LogUtil.d("init----设置全局自定义异常捕获成功");
} catch (Exception e) {
LogUtil.d("init----设置全局自定义异常捕获错误: " + e.getMessage());
}
Beta.autoInit = true;
Beta.autoCheckUpgrade = true;
Beta.upgradeCheckPeriod = 60 * 1000 * 60;
Beta.initDelay = 6 * 1000;
Beta.largeIconId = R.mipmap.ic_logo_64;
Beta.smallIconId = R.mipmap.ic_logo_64;
Beta.defaultBannerId = R.mipmap.ic_logo_64;
Beta.storageDir = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS);
Beta.showInterruptedStrategy = true;
Bugly.init(getApplicationContext(), Constant.CONSTANT_BUGLY_ID, false);
}
that's all----------------------------------------------------------------
网友评论