community icon indicating copy to clipboard operation
community copied to clipboard

A way to input foreground service type

Open Fector101 opened this issue 5 months ago • 3 comments

After using the code in the Wiki to start a foreground service properly

In the service file I keep getting this error jnius.jnius.JavaException: JVM exception occurred: Starting FGS without a type callerApp=ProcessRecord{fc07cfb 7444:org.laner.lan_ft:service_Final/u0a305} targetSDK=35 android.app.MissingForegroundServiceTypeException

After reading through this stack answer for kotlin I understand it needs the service type to specify the service element in the XML from android 13+

It'll be great to have a way to specify the service type

Fector101 avatar Jun 01 '25 20:06 Fector101

Let me know if this solves your problem: https://github.com/Android-for-Python/Android-for-Python-Users?tab=readme-ov-file#android-service

ElliotGarbus avatar Jun 01 '25 21:06 ElliotGarbus

Thank you @ElliotGarbus I've learnt a whole lot for the section you provided it said I need to specify foreground:sticky to let the service run regardless of the app open state and that it's running as a service regardless of the notification.

But I tried specifying foreground:sticky only and it didn't work my service lifetime still lasts for roughly 1 minute Also compiled the music player example and it threw the same error I was getting when I tried starting the service notification

Fector101 avatar Jun 04 '25 14:06 Fector101

I'd recommend asking about this issue on the kivy discord.

ElliotGarbus avatar Jun 04 '25 15:06 ElliotGarbus