【发布时间】:2014-06-01 03:43:12
【问题描述】:
在我的应用程序中,我想设置未捕获的异常处理程序,以便在发生不可预见的崩溃时进行处理。 (我想做一些事情,比如关闭套接字、清除通知……等等)
Thread.currentThread().setDefaultUncaughtExceptionHandler(sDefaultThreadHandler);
在哪里
private static UncaughtExceptionHandler sDefaultThreadHandler = new UncaughtExceptionHandler() {
@Override
public void uncaughtException(Thread thread, Throwable ex) {
// i want ACRA to log here, then clear notifications, close out connections, cancel asynctasks...etc.
// DO NOT REMOVE or else your app will hang when there is a crash.
android.os.Process.killProcess(android.os.Process.myPid());
System.exit(10);
}
};
问题是,我希望 ACRA 在进程退出之前也进行报告。我该如何做到这一点?
【问题讨论】:
标签: android exception-handling crash acra