0

在 Android 中,我创建了一个实现 UncaughtExceptionHandler 的类,并将其设置为默认处理程序。在大多数情况下它运行良好,但在特殊情况下我无法找到日志打印。

在这种特殊情况下,我看到 Application 类再次运行 oncreate ,并且 pre Activity oncreate ,当前 Activity 错过了。似乎发生了崩溃,但在我的 CrashHandler 中没有抓住它。是否有一些崩溃可以避免这种情况?

@Override
    public void uncaughtException(Thread thread, Throwable ex) {
        // in special case, we can't found log printed here.
        LogUtil.e(TAG, "uncaughtException" + ex.getMessage());
        // handleException(ex) is we used to print log.
        if (!handleException(ex) && mDefaultHandler != null) {
            LogUtil.e(TAG, "uncaughtException user don't handle");
            mDefaultHandler.uncaughtException(thread, ex);
        }
    }
4

0 回答 0