Add CrashHandler
This commit is contained in:
parent
263548749c
commit
f95108fa67
|
@ -13,8 +13,8 @@ android {
|
||||||
applicationId "me.ash.reader"
|
applicationId "me.ash.reader"
|
||||||
minSdk 26
|
minSdk 26
|
||||||
targetSdk 32
|
targetSdk 32
|
||||||
versionCode 2
|
versionCode 3
|
||||||
versionName "0.6.2"
|
versionName "0.6.5"
|
||||||
|
|
||||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||||
vectorDrawables {
|
vectorDrawables {
|
||||||
|
|
|
@ -11,8 +11,8 @@
|
||||||
"type": "SINGLE",
|
"type": "SINGLE",
|
||||||
"filters": [],
|
"filters": [],
|
||||||
"attributes": [],
|
"attributes": [],
|
||||||
"versionCode": 2,
|
"versionCode": 3,
|
||||||
"versionName": "0.6.2",
|
"versionName": "0.6.5",
|
||||||
"outputFile": "app-release.apk"
|
"outputFile": "app-release.apk"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
|
|
@ -67,6 +67,7 @@ class App : Application(), Configuration.Provider {
|
||||||
|
|
||||||
override fun onCreate() {
|
override fun onCreate() {
|
||||||
super.onCreate()
|
super.onCreate()
|
||||||
|
CrashHandler(this)
|
||||||
applicationScope.launch(dispatcherDefault) {
|
applicationScope.launch(dispatcherDefault) {
|
||||||
accountInit()
|
accountInit()
|
||||||
dataStoreInit()
|
dataStoreInit()
|
||||||
|
|
20
app/src/main/java/me/ash/reader/CrashHandler.kt
Normal file
20
app/src/main/java/me/ash/reader/CrashHandler.kt
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
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 {
|
||||||
|
private val mDefaultHandler = Thread.getDefaultUncaughtExceptionHandler();
|
||||||
|
|
||||||
|
init {
|
||||||
|
Thread.setDefaultUncaughtExceptionHandler(this)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun uncaughtException(p0: Thread, p1: Throwable) {
|
||||||
|
Toast.makeText(context, p1.message, Toast.LENGTH_LONG).show()
|
||||||
|
android.os.Process.killProcess(android.os.Process.myPid());
|
||||||
|
exitProcess(1)
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user