首页 > 移动平台 > 详细

Android 捕获 crash

时间:2017-08-17 11:44:00      阅读:266      评论:0      收藏:0      [点我收藏+]
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 捕获 crash

原文:http://www.cnblogs.com/longhorn/p/7380483.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!