Skip to content

Commit 4aa449c

Browse files
BrayanDSOmikehardy
authored andcommitted
fix: sync worker not initialized crash
(cherry picked from commit 54d4db1)
1 parent 997043a commit 4aa449c

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

AnkiDroid/src/main/java/com/ichi2/anki/IntentHandler.kt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import androidx.annotation.VisibleForTesting
2626
import androidx.core.app.TaskStackBuilder
2727
import androidx.core.content.FileProvider
2828
import androidx.core.content.IntentCompat
29+
import androidx.work.WorkManager
2930
import com.ichi2.anki.common.annotations.NeedsTest
3031
import com.ichi2.anki.common.utils.trimToLength
3132
import com.ichi2.anki.dialogs.DialogHandler.Companion.storeMessage
@@ -78,7 +79,10 @@ class IntentHandler : AbstractIntentHandler() {
7879
val launchType = getLaunchType(intent)
7980
// TODO block the UI with some kind of ProgressDialog instead of cancelling the sync work
8081
if (requiresCollectionAccess(launchType)) {
81-
SyncWorker.cancel(this)
82+
// # 18899
83+
if (WorkManager.isInitialized()) {
84+
SyncWorker.cancel(this)
85+
}
8286
}
8387
when (launchType) {
8488
LaunchType.FILE_IMPORT ->

0 commit comments

Comments
 (0)