diff --git a/husky/app/src/main/java/com/keylesspalace/tusky/core/logging/CrashHandler.kt b/husky/app/src/main/java/com/keylesspalace/tusky/core/logging/CrashHandler.kt index e2a1942..d261947 100644 --- a/husky/app/src/main/java/com/keylesspalace/tusky/core/logging/CrashHandler.kt +++ b/husky/app/src/main/java/com/keylesspalace/tusky/core/logging/CrashHandler.kt @@ -43,26 +43,26 @@ class CrashHandler @Inject constructor( private val huskyApp: Application ) : UncaughtExceptionHandler { + private val defaultHandler = Thread.getDefaultUncaughtExceptionHandler() + private var activityCounter = 0 + private var lastActivity: Activity? = null + private val activityCallbacks = object : ActivityCallback() { override fun onActivityCreated(activity: Activity, savedInstanceState: Bundle?) { lastActivity = activity + activityCounter++ Timber.d("onActivityCreated[${activity::class.simpleName}]") } - override fun onActivityResumed(activity: Activity) { - lastActivity = activity - Timber.d("onActivityResumed[${activity::class.simpleName}]") - } - override fun onActivityStopped(activity: Activity) { - lastActivity = null + activityCounter-- + if(activityCounter <= 0) { + lastActivity = null + } Timber.d("onActivityStopped[${activity::class.simpleName}]") } } - private val defaultHandler = Thread.getDefaultUncaughtExceptionHandler() - private var lastActivity: Activity? = null - override fun uncaughtException(thread: Thread, throwable: Throwable) { try { sendLogEmail(throwable.stackTraceToString())