Skip to content

Commit bbf5db4

Browse files
committed
service.rsr auto-start section 3
1 parent dc778b3 commit bbf5db4

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

doc/source/services.rst

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,3 +215,24 @@ Then need create ``MyBroadcastReceiver.java``, code::
215215
}
216216
}
217217
}
218+
219+
This code start ``service.py`` from ``buildozer.spec`` when get signal ``ACTION_BOOT_COMPLETED``::
220+
221+
services = Test:./service.py:foreground
222+
223+
For example ``service.py``::
224+
225+
import os
226+
from time import sleep
227+
228+
from jnius import cast
229+
from jnius import autoclass
230+
231+
PythonService = autoclass('org.kivy.android.PythonService')
232+
CurrentActivityService = cast("android.app.Service", PythonService.mService)
233+
234+
while True:
235+
print("python service running.....", CurrentActivityService.getPackageName(), os.getpid())
236+
sleep(10)
237+
238+

0 commit comments

Comments
 (0)