【Android 捕获 crash】一卷旌收千骑虏,万全身出百重围。这篇文章主要讲述Android 捕获 crash相关的知识,希望能为你提供帮助。
private void initializeCrashHandlers() {
// This crash handler can take care of anything, but you MUST close the process at the end if you are
// not throwing an exception back to the default thread exception handler. To do this, we first get the
// original thread handler and pass the exception to the previous thread handler (the only way this has
// been found to work so far).
final Thread.UncaughtExceptionHandler originalDefaultUncaughtExceptionHandler =
Thread.getDefaultUncaughtExceptionHandler();
final Thread.UncaughtExceptionHandler scThreadExceptionHandler = new Thread.UncaughtExceptionHandler() {
@Override
public void uncaughtException(Thread thread, Throwable ex) {
// take care of anything else here...
for (Crashable crashable : mCrashables) {
crashable.onApplicationCrash(AppContext.get(), thread, ex);
}
originalDefaultUncaughtExceptionHandler.uncaughtException(thread, ex);
}
};
// Set an uncaught exception handler to take care of cases where you want to do stuff before app crashes
// This is also compatible with HockeyApp.
Thread.setDefaultUncaughtExceptionHandler(scThreadExceptionHandler);
ExceptionReportingProvider.initialize(GracefulExceptionHandler.getInstance(), new ExceptionReporter());
}
推荐阅读
- Android基础Service全解析----看不见的Activity
- Mac下Android studio 之NDK配置教程
- Android逆向之旅---破解"穿靴子的猫"游戏的收费功能
- Android利用RecognizerIntent识别语音并简单实现打电话动作
- Hbuilder开发app实战-识岁03-文件上传
- Android清单文件具体解释 ---- 应用程序权限声明
- 使用Android Studio 哪些文件可以直接被版本控制软件忽略
- android 网络框架 源码分析
- dapper参数不定时用这种方法动态参数