diff --git a/AnkiDroid/src/main/java/com/ichi2/anki/workarounds/AppLoadedFromBackupWorkaround.kt b/AnkiDroid/src/main/java/com/ichi2/anki/workarounds/AppLoadedFromBackupWorkaround.kt index 94189cfaaefe..8f5c205eeefd 100644 --- a/AnkiDroid/src/main/java/com/ichi2/anki/workarounds/AppLoadedFromBackupWorkaround.kt +++ b/AnkiDroid/src/main/java/com/ichi2/anki/workarounds/AppLoadedFromBackupWorkaround.kt @@ -48,6 +48,7 @@ object AppLoadedFromBackupWorkaround { if (AnkiDroidApp.isInitialized) { return false } + // TODO: Timber likely does not work on this path - maybe add a check in IntentHandler // #7630: Can be triggered with `adb shell bmgr restore com.ichi2.anki` after AnkiDroid settings are changed. // Application.onCreate() is not called if: @@ -73,7 +74,10 @@ object AppLoadedFromBackupWorkaround { Themes.setTheme(this) // Avoids a SuperNotCalledException activitySuperOnCreate(savedInstanceState) - finish() + // Process.killProcess is a hard kill. I suspect that some Android OSes leave has the app in + // an invalid state after this occurs (meaning Application.onCreate is not called). + // Before killProcess, gracefully kill the app, removing it from the recents list + finishAndRemoveTask() // If we don't kill the process, the backup is not "done" and reopening the app show the same message. Thread {