kivy / kivy/python-for-android
Support for Worker/WorkManager
- Dominant language
- Python
- Stars
- 8.9k
- Forks
- 2k
- Avg merge
- 12h 20m
- Merged PRs (30d)
- 9
Description
Services in Android start to being agressively stopped with doze mode and Android 10. So if you want to execute something into the background, there is many solution, but the most state of the art is to use [Worker/WorkManager](https://developer.android.com/topic/libraries/architecture/workmanager) . (another approach would be AlarmManager)
It requires androidx (#2020)
The first step is to add the dependencies in the `build.gradle`:
```
dependencies {
implementation 'androidx.work:work-runtime:2.2.0'
implementation 'androidx.annotation:annotation:1.1.0'
}
```
Now, if you want to execute Python in a Worker, we have the same issue to start Python from Java as Service.
The plan would be to create a PythonRunner java class with a native entrypoint implemented in C to start Python, then update our PythonService to use it, and we can also provide a PythonWorker as well that use it.
Contributor guide
Research direction
Start by reading the Android WorkManager documentation and linked issue #2020, then inspect the existing PythonService entry point. The proposed work mentions a PythonRunner Java class with a native C entrypoint and a PythonWorker using it; done means background Python execution works through Worker/WorkManager without breaking the existing service path.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- android, c, java, python
- Domain
- mobile
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100