Android Question Converted to API 34

so27

Active Member
Licensed User
Longtime User
Hello everyone,

I use a notification with buttons in my app. When this button is clicked, my app opens. This has worked without any problems until now. Since the changeover to API 34, this log appears:

B4X:
java.lang.RuntimeException: android.app.MissingForegroundServiceTypeException: Starting FGS without a type  callerApp=ProcessRecord{777a85a 7054:XY.XX.APPNAME/u0a190} targetSDK=34

I always started my window with in the service:
B4X:
Startactivity(NAME)

It must also be possible with the new API to open an app from the notification. With SetWhenLook, I have always been able to open my app successfully before the lock screen.
 

jkhazraji

Active Member
Licensed User
Longtime User
Adding the foregroundServiceType attribute to your service declaration may help:
XML:
<service
android:name=".YourService"
android:foregroundServiceType="mediaPlayback" />
 
Upvote 1

Erel

B4X founder
Staff member
Licensed User
Longtime User
There are new strict restrictions on the usage of foreground services. The first question - what are you using a foreground service for?

I always started my window with in the service:
This requires the "draw over apps" permission since Android 10.
 
Upvote 0

so27

Active Member
Licensed User
Longtime User
Thank you very much, that was exactly the problem. Everything is running smoothly again.
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…