python-for-android icon indicating copy to clipboard operation
python-for-android copied to clipboard

add set type start service (START_STICKY/START_NOT_STICKY/START_RED…

Open dvjdjvu opened this issue 3 years ago • 2 comments

I added choice type start service START_STICKY, START_NOT_STICKY and START_REDELIVER_INTENT. Default use now and before START_NOT_STICKY, but when you close app, service close too.

And I used this code for restart service.

PythonService = autoclass('org.kivy.android.PythonService')
PythonService.mService.setAutoRestartService(True)

Now you can use

PythonService.mService.setTypeStartSticky()
PythonService.mService.setTypeStartNotSticky()
PythonService.mService.setTypeStartRedeliverIntent()

With setTypeStartNotSticky, service doesnt close when app swipping or close.

dvjdjvu avatar Feb 17 '23 13:02 dvjdjvu

Hello @misl6, can you look this? I create 2-nd pull request.

dvjdjvu avatar Mar 07 '23 21:03 dvjdjvu

FYI the proposed change is overridden by https://github.com/kivy/python-for-android/blob/develop/pythonforandroid/bootstraps/common/build/templates/Service.tmpl.java#L9-L14 (which also provides service persistence control from buildozer.spec :foreground:sticky).

RobertFlatt avatar Mar 12 '23 02:03 RobertFlatt