UncaughtExceptionHandler 在catch之后线程会自动结束,需要重新开启一个线程
mHandlerThread = HandlerThread("test",Process.THREAD_PRIORITY_BACKGROUND)
mHandlerThread.uncaughtExceptionHandler = object : Thread.UncaughtExceptionHandler {
override fun uncaughtException(t: Thread, e: Throwable) {
if (e is SQLException) {
mHandlerThread = HandlerThread("test",Process.THREAD_PRIORITY_BACKGROUND)
mHandlerThread.uncaughtExceptionHandler = this
mHandlerThread.start()
} else {
throw e
}
}
}