Open barrydisign opened 3 years ago
Unfortunately, currently it is not possible to run able as a service, I have not tried it yet.
Hi, I am facing the same issue. @barrydisign did you find a work around? I need it in a service to get streamed data via ble.
It is how the service is defined in the main app.
self.mActivity = autoclass(u'org.kivy.android.PythonActivity').mActivity argument = '' service.start(self.mActivity, argument)
and the complete log :
File "/home/jejmule/ISSULab/.buildozer/android/app/service.py", line 71, in
jnius.jnius.JavaException: JVM exception occurred: Attempt to invoke virtual method 'android.content.pm.PackageManager android.content.Context.getPackageManager()' on a null object reference
Sorry no fix or work around. We just altered the switch off time on the tablet so as to never sleep and not require a background service.
Thank you for comment didi you use the wakelock option in the buildozer.spec file to keep the app alive?
# (bool) Indicate whether the screen should stay on
# Don't forget to add the WAKE_LOCK permission if you set this to True
#android.wakelock = False
I look into the code and the issue is coming from the BLE class defined in BLE.java.
on line 19 : import org.kivy.android.PythonActivity;
then in the constructor on line 40 the context is obtain from it
mContext = (Context) PythonActivity.mActivity;
able crashes on line 43 when calling mContext.getPackageManager()
Since the context is obtain from the PythonActivity and not the PythonService as a consequence the context is a null object and we obtain the following error :
jnius.jnius.JavaException: JVM exception occurred: Attempt to invoke virtual method 'android.content.pm.PackageManager android.content.Context.getPackageManager()' on a null object reference
I will try to modify the BLE.java to work from service and not activity to check if my guess is correct....
The ability to be used from a service context is added in 1.0.8.
Also, require_bluetooth_enabled
and require_runtime_permissions
decorators
are added to prepare adapter and permissions before service is started.
Usage example: https://herethere.me/able/examples.html#android-services
Future work should be done to add scan filters #25. Without filters, scan stops when a device screen goes off.
We have created a Kivy application which spawns a service and we wish to run able within this. We tried running some existing working code but get
Is this at all possible? Many thanks