by following @Erel Update on this Post https://www.b4x.com/android/forum/threads/background-location-tracking.99873/#post-993226
targeting Sdkversion = 34, if you have a foregroundservice that do media play back in the background you will need to add this to your manifest in order to migrate to targetsdk 34
Starting service Code
here is a list of foreground service types.
developer.android.com
in short
this code may not be useful on the next B4a Release, have a great day.
targeting Sdkversion = 34, if you have a foregroundservice that do media play back in the background you will need to add this to your manifest in order to migrate to targetsdk 34
B4X:
' sdk 34
SetServiceAttribute(Your_Service_Name, android:foregroundServiceType, "mediaPlayback")
AddPermission(android.permission.FOREGROUND_SERVICE_MEDIA_PLAYBACK)
Starting service Code
B4X:
Private Sub StartForegroundService(Service As Object)
Dim p As Phone
If p.SdkVersion <= 26 Then
StartService(Service)
Return
End If
Dim ctxt As JavaObject
ctxt.InitializeContext
Dim intent As JavaObject
intent.InitializeNewInstance("android.content.Intent", Array(ctxt, Service))
ctxt.RunMethod("startForegroundService", Array(intent))
End Sub
here is a list of foreground service types.
Foreground service types | Background work | Android Developers
This document outlines the specific foreground service types required for apps targeting Android 14 (API level 34) and higher, detailing their manifest declarations, associated permissions, runtime prerequisites, and intended use cases.
in short
B4X:
[camera=64, connectedDevice=16, dataSync=1, location=8, mediaPlayback=2, mediaProjection=32, microphone=128, phoneCall=4]
this code may not be useful on the next B4a Release, have a great day.