ReadYou/app/src/main/java/me/ash/reader/CrashHandler.kt

20 lines
579 B
Kotlin
Raw Normal View History

2022-04-07 09:05:10 +02:00
package me.ash.reader
import android.content.Context
import android.widget.Toast
import java.lang.Thread.UncaughtExceptionHandler
import kotlin.system.exitProcess
class CrashHandler(private val context: Context) : UncaughtExceptionHandler {
init {
Thread.setDefaultUncaughtExceptionHandler(this)
}
override fun uncaughtException(p0: Thread, p1: Throwable) {
Toast.makeText(context, p1.message, Toast.LENGTH_LONG).show()
2022-04-08 16:45:18 +02:00
p1.printStackTrace()
2022-04-07 09:05:10 +02:00
android.os.Process.killProcess(android.os.Process.myPid());
exitProcess(1)
}
}