Hello everyone.
Here I make my first contribution, a persistent android service for kivy.
This service runs the new p4a service (it is a service that runs another service). This service will continue to run even after the application has closed.
In addition, notifications can also be sent, which when touched will open the application.
Instructions:
Add the following line to the file "AndroidManifest.tmpl.xml":
<service android:name=".Servicio"></service>
Add the java file to the "buildozer.spec" file:
android.add_src = Servicio.java
(Changes to be made to the java file):
Line 9: import your.package.name.ServiceYourServiceName; //The package name of your app + ServiceYourServiceName
Line 89: ServiceYourServiceName service = new ServiceYourServiceName(); //Here you place the class name of your service.
Here you must change the name of the class by the name of the class of your service. Example: ServiceS1
Note: you can repeat this line with the name of your other services (if you have more services). Be sure to call the function "service.start (context," ");" For each service you place.
In python:
How to start the service:
from jnius import autoclass
activity = autoclass("org.kivy.android.PythonActivity").mActivity
service = s()
service.start(activity)
Congratulations, you already have your service running.
How to send notifications from python:
from jnius import autoclass
from plyer.platforms.android import activity
servicio = s()
servicio.notificar(activity, "title", "text", "info", "ticker")
Congratulations, you will have a notification, that when the touch starts your application.
I hope you find it useful.
I know that many things can be improved, but that is what I have achieved. If anyone wants to contribute, he can do it. :)
Thanks :)