i use a service to get some data from my online database when the app is starts and start admob . i have an error in androis 13 and above:
i call my service in the Main Activity
i search and found that i should add
could you help me by putting this line to manifest the problem is solved?
B4X:
Fatal Exception: java.lang.RuntimeException
android.app.ForegroundServiceStartNotAllowedException: startForegroundService() not allowed due to mAllowStartForeground false: service ir.samware.ludo/.http
anywheresoftware.b4a.keywords.Common$12.run
Caused by android.app.ForegroundServiceStartNotAllowedException
startForegroundService() not allowed due to mAllowStartForeground false: service test.test.test/.http
android.app.ForegroundServiceStartNotAllowedException$1.createFromParcel (ForegroundServiceStartNotAllowedException.java:54)
i call my service in the Main Activity
B4X:
Sub Activity_Create(FirstTime As Boolean)
If FirstTime=True Then
StartService(http)
End If
End Sub
B4X:
ub Service_Create
' Dim MobileAds As MobileAds
' MobileAds.Initialize
CheckForGooglePlayServices
DeviceInfo
End Sub
Sub Service_Start (StartingIntent As Intent)
If analytics.IsGooglePlayServicesAvailable=True And SDKver>=14 Then
Log("GooglePlayServicesAvailable ="&analytics.IsGooglePlayServicesAvailable)
analytics.Initialize
analytics.SendEvent("login", CreateMap ("additional parameter": 100))
End If
Service.StopAutomaticForeground
End Sub
Sub Service_Destroy
End Sub
i search and found that i should add
B4X:
SetServiceAttribute(MyService, "android:foregroundServiceType", "dataSync")