码迷,mamicode.com
首页 > 移动开发 > 详细

Android 捕获 crash

时间:2017-08-17 12:43:32      阅读:225      评论:0      收藏:0      [点我收藏+]

标签:cas   dex   ack   private   pass   new t   else   been   contex   

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

标签:cas   dex   ack   private   pass   new t   else   been   contex   

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!