ankidroid / ankidroid/Anki-Android

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

Abierto
#18,286 15 comentarios 0 reacciones 0 asignados Ver en GitHub
API Keep Open Needs Triage Priority-High
Lenguaje dominante
Kotlin
Estrellas
11.8k
Forks
2.9k
Merge medio
2 d 3 h
PR fusionados (30 d)
171

Descripción

### 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))

Guía de contribución

Abrir la guía de contribución

Evaluación

Este issue todavía no se ha evaluado.

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.