Skip to content

fix: remove app from recents if in an invalid state#20415

Merged
BrayanDSO merged 2 commits intoankidroid:mainfrom
david-allison:19050
Mar 12, 2026
Merged

fix: remove app from recents if in an invalid state#20415
BrayanDSO merged 2 commits intoankidroid:mainfrom
david-allison:19050

Conversation

@david-allison
Copy link
Member

@david-allison david-allison commented Mar 7, 2026

Purpose / Description

I suspect this fixes the app being in an invalid state, causing "android backup in progress, please try again" to appear until the device is restarted.

Process.killProcess() is a hard kill.

I suspect some Android internals keep a reference to the process (users are reporting AnkiDroid being broken in the task list when the backup toast shows)

If the app is in an invalid state within Android, it is feasible that Application.onCreate() is skipped, perpetually causing the "android backup in progress, please try again" toast.

Fixes

Approach

Use finishAndRemoveTask: https://developer.android.com/reference/android/app/Activity#finishAndRemoveTask()

How Has This Been Tested?

After manual testing, the app no longer appears in Recents.

Index: AnkiDroid/src/main/java/com/ichi2/anki/AnkiDroidApp.kt
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/AnkiDroid/src/main/java/com/ichi2/anki/AnkiDroidApp.kt b/AnkiDroid/src/main/java/com/ichi2/anki/AnkiDroidApp.kt
--- a/AnkiDroid/src/main/java/com/ichi2/anki/AnkiDroidApp.kt	(revision 0d08afc531cfaba74f76b6e2c44eefbc5edfd31d)
+++ b/AnkiDroid/src/main/java/com/ichi2/anki/AnkiDroidApp.kt	(date 1772881617915)
@@ -126,7 +126,8 @@
                 return
             }
         }
-        instance = this
+        // instance = this
+        return
 
         // Get preferences
         val preferences = this.sharedPrefs()

Learning (optional, can help others)

Seen on many devices, including a Samsung A35

Checklist

  • You have a descriptive commit message with a short title (first line, max 50 chars).
  • You have commented your code, particularly in hard-to-understand areas
  • You have performed a self-review of your own code
  • UI changes: include screenshots of all affected screens (in particular showing any new or changed strings)
  • UI Changes: You have tested your change using the Google Accessibility Scanner

After manual testing, the app no longer appears in Recents.

I suspect this fixes: "android backup in progress, please try again"

`Process.killProcess()` is a hard kill.

I suspect some Android internals keep a reference to the process
 (users are reporting AnkiDroid being broken in the task list when
 the backup toast shows)

If the app is in an invalid state within Android, it is feasible
 that Application.onCreate() is skipped, perpetually causing the
 "android backup in progress, please try again" toast.

`finishAndRemoveTask` should stop this from occurring.

Fixes 19050 - seen on a Samsung A35
@david-allison david-allison added the Review High Priority Request for high priority review label Mar 7, 2026
@lukstbit lukstbit added Needs Second Approval Has one approval, one more approval to merge and removed Needs Review labels Mar 7, 2026
@BrayanDSO BrayanDSO added this pull request to the merge queue Mar 12, 2026
@BrayanDSO BrayanDSO added Pending Merge Things with approval that are waiting future merge (e.g. targets a future release, CI wait, etc) and removed Needs Second Approval Has one approval, one more approval to merge labels Mar 12, 2026
Merged via the queue into ankidroid:main with commit 19a4d83 Mar 12, 2026
17 of 21 checks passed
@github-actions github-actions bot removed Pending Merge Things with approval that are waiting future merge (e.g. targets a future release, CI wait, etc) Review High Priority Request for high priority review labels Mar 12, 2026
@github-actions github-actions bot added this to the 2.24 release milestone Mar 12, 2026
@david-allison david-allison deleted the 19050 branch March 12, 2026 10:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

User report: "android backup in progress, please try again"

3 participants