ankidroid / ankidroid/Anki-Android

ContentProvider returns null unless app manually launched — request for background-initializable entry point

Open
#18,286 15 comments 0 reactions 0 assignees View on GitHub
API Keep Open Needs Triage Priority-High
Dominant language
Kotlin
Stars
11.8k
Forks
2.9k
Avg merge
2d 3h
Merged PRs (30d)
171

Description

### Checked for duplicates?

- [x] This issue is not a duplicate

### Does it also happen in the desktop version?

- [ ] This bug does not occur in the latest version of Anki Desktop

### What are the steps to reproduce this bug?

- Install AnkiDroid but do not open it.
- From another app, use ContentResolver.query() on content://com.ichi2.anki.api/deck.
- Observe that the query returns null.
- Now open AnkiDroid once and return to the other app.
- Repeat the query — it now succeeds.

Reproduced with Pleco as well.

### Expected behaviour

The contentProvider can be made available independently from the UI lifecycle, possibly with a silent Intent, so that API queries should succeed even if AnkiDroid hasn’t been manually opened, assuming permissions are met.

### Debug info

```text
AnkiDroid Version = 2.20.1 (e32a82c33646807ea19623c9c88be38965bc07e6)

Backend Version = 0.1.48-anki24.11 (24.11 c47638ca36f99dd4f3b81ae82d964aec66e392e0)

Android Version = 15 (SDK 35)

ProductFlavor = play

Manufacturer = HONOR

Model = PGT-AN10

Hardware = qcom

Webview User Agent = Mozilla/5.0 (Linux; Android 15; PGT-AN10 Build/HONORPGT-AN10; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/135.0.7049.111 Mobile Safari/537.36

ACRA UUID = 8f9e47ec-8911-4c6c-88cd-4a5b699726a6

FSRS = 1.4.3 (Enabled: false)

Crash Reports Enabled = true
```

### (Optional) Anything else you want to share?

Maybe consider exposing a headless BroadcastReceiver or lightweight Service (e.g. com.ichi2.anki.WarmupReceiver) that can be used to start the app process without invoking the UI — allowing external apps to "warm up" the AnkiDroid process in the background before sending API requests?

### Research

- [x] I have checked the [manual](https://ankidroid.org/docs/manual.html) and the [FAQ](https://github.com/ankidroid/Anki-Android/wiki/FAQ) and could not find a solution to my issue
- [x] (Optional) I have confirmed the issue is not resolved in the latest alpha release ([instructions](https://docs.ankidroid.org/manual.html#betaTesting))

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.