Closed AndreMiras closed 6 years ago
Made an attempt in this branch https://github.com/AndreMiras/EtherollApp/tree/feature/ticket57_roll_notifications_improvements
When stopping the app with the back button, the App.on_stop()
seems to get called and the message broadcasted.
See logcat command and debug output below:
buildozer android adb -- logcat | grep -e python -e service
...
09-09 17:17:15.637 14432 14487 I SendBroadcastPermission: action:restart_roll_pulling_service, mPermissionType:0
...
However I get no logs from the broadcast receiver. Needs further debugging.
There's also a undocumented feature that makes it possible to run the service "sticky" so that the Android OS would restart it itself. See https://github.com/kivy/python-for-android/commit/7ad96b20750300ba5de4bd2448faa2b4bdc0e9e0
To use it buildozer.spec
:
services = service:service/main.py:sticky
However it currently crashes on restart because the intent seems to be null, see line 71: https://github.com/kivy/python-for-android/blob/3534a76/pythonforandroid/bootstraps/sdl2/build/src/main/java/org/kivy/android/PythonService.java#L71
I'm not yet sure why it's being called with null, maybe it's an feature https://stackoverflow.com/questions/8421430/reasons-that-the-passed-intent-would-be-null-in-onstartcommand not yet covered in p4a. I'm also not sure if this sticky/auto-restart was ever tested successfully on p4a.
Addressed with https://github.com/kivy/python-for-android/pull/1374
The roll monitoring and notification service created in ##57 gets killed when the app is killed. We want it to keep running so the user receives roll result notifications even after the app is closed. https://stackoverflow.com/questions/30525784/android-keep-service-running-when-app-is-killed