Android Question Android API 33 - services/receiver vs http


Licensed User
Longtime User
I had a problem for which there was no solution:

Somehow I managed to get a service to run in the "foreground" under Android 13 (API 33). What's interesting is that this service doesn't stop, even if I stop the application and the "start at boot" works. Of course it has the message that the running service is in the background, but the user can turn it off, so it is not confusing.
And with the timed receiver I can call this service and the http request works in the background.

Maybe I misunderstood something, but I took it to mean that foreground services can't really be used anymore, because they don't run in the "fixed" foreground anymore.

This is the code for my service:

#Region  Service Attributes
    #StartAtBoot: True
#End Region

Sub Process_Globals
    'These global variables will be declared once when the application starts.
    'These variables can be accessed from all modules.
End Sub

Sub Service_Create

    Dim notification As Notification

    Log("=== Service Create")

    notification.Icon = "icon"
    notification.Light = False
    notification.Vibrate = False
    notification.Sound = False
    'notification.OnGoingEvent = True
    'notification.AutoCancel = False

    notification.SetInfo(Application.LabelName, "Service running", Main)

    Service.AutomaticForegroundMode = Service.AUTOMATIC_FOREGROUND_ALWAYS
    Service.AutomaticForegroundNotification = notification

End Sub

Sub Service_Start (StartingIntent As Intent)
    Log("=== Service Start")

    'Service.StopAutomaticForeground 'Call this when the background task completes (if there is one)
End Sub

Sub Service_Destroy
    Log("=== Service Destroy")
End Sub

Sub getData
    Log("=== Service getData")
   Private getGustoData As getHttpDataGusto

    getGustoData.startFromService = True
End Sub

I'm testing it now, but is it possible to use API 33 to use service ?


Licensed User
Longtime User
I'm testing it now, but is it possible to use API 33 to use service ?

As of API 31, your app can only start a foreground service if the app is in the foreground itself. There are exceptions to the rule and they are listed here:
Note that receiving the ACTION_BOOT_COMPLETED, ACTION_LOCKED_BOOT_COMPLETED intent actions (related to start on boot) allows an app to start the foreground service even though the app is not in the foreground.

API 33 introduces an additional POST_NOTIFICATION manifest entry if you want your app to have the ability to SHOW the notifications. It does not keep the app from starting the foreground service in itself. For usage, see
Upvote 1