Android Question [Solved] Foreground service for all versions ?


Well-Known Member
Licensed User
Longtime User
I have read and tested but I would like to be sure if i have well understood, please. If a service has to run always and to be sure it runs on all Android versions, I have to :

- start the service as it is with the new AutomaticForegroundMode
- in Service_Start :
1) StopAutomaticForeground
2) Prepare a notification using NB6
3) put the service in foreground mode again using : Service.StartForeground
4) acquire a PartialLock

If the app is swipped, as we don't have Sticky services anymore, I have to restart the service from Starter / Service_TaskRemoved.

Please, is this correct ? Many thanks


B4X founder
Staff member
Licensed User
Longtime User
1) True. Only relevant if the service will be started from the background.
2) You can show regular notifications with Notification object.
3) True. Make sure not to use the starter server for this.
4) Depends on your requirements.

On most devices foreground services are not killed when the app is swiped. You can see it with B4A-Bridge. "kill" it and the icon will still be there.
Upvote 0

Similar Threads