Fix: crash handler (#666)

* Fix: crash handler

* spotless fix
This commit is contained in:
Yogesh Choudhary Paliyal
2023-08-12 19:18:02 +05:30
committed by GitHub
parent fa252b2366
commit 1a3d346087

View File

@@ -7,7 +7,6 @@ import androidx.hilt.work.HiltWorkerFactory
import androidx.work.Configuration
import com.google.android.material.color.DynamicColors
import javax.inject.Inject
import kotlin.system.exitProcess
abstract class CommonMyApplication : Application(), Configuration.Provider {
@@ -18,12 +17,13 @@ abstract class CommonMyApplication : Application(), Configuration.Provider {
override fun onCreate() {
super.onCreate()
Thread.setDefaultUncaughtExceptionHandler { _, throwable ->
Log.d("MyApplication", "crashed ")
val previewExceptionHandler = Thread.getDefaultUncaughtExceptionHandler()
Thread.setDefaultUncaughtExceptionHandler { thread, throwable ->
val intent = getCrashActivityIntent(throwable)
intent.flags = Intent.FLAG_ACTIVITY_NEW_TASK
startActivity(intent)
exitProcess(1)
previewExceptionHandler?.uncaughtException(thread, throwable)
}
DynamicColors.applyToActivitiesIfAvailable(this)