Android Question Automatic foreground services


Well-Known Member
Licensed User

I have read the tutorial about the automatic foreground services -

I have a service running and I have the code:

Sub Service_Destroy
    StartServiceAt(Me, DateTime.Now + 5 * 1000, False) 'will start after 5 seconds.
End Sub

As you have noticed I put that code in Service_Destroy.

I was hoping to keep this service running 24/7 and never have it stop running.

The issue I have is, about 1 minute after the app is closed (not showing on the screen) this service is killed and Service_Destroy is called.

This then starts the service again 5 seconds later since my code is telling it to start again. However a notification is then shown in the system notification tray.

Is there a way in running the service again without this notification showing, but keep the service running?
Or, is there a way in changing the text of the notification rather than just the app title?


Well-Known Member
Licensed User
So I need to use:

Service.AutomaticForegroundMode = Service.AUTOMATIC_FOREGROUND_NEVER

And in in Service_Start I need to use:
Service.StartForeground(nid, CreateNotification("..."))

Without using the Service.StartForeground then it will kill the service after approx. 1 minute ?

Is there a way in not showing the notification ?

I also noticed you have the following code in the same service:
StartServiceAt(Me, DateTime.Now + 30 * DateTime.TicksPerMinute, True)

Is that just in case the service is killed so it can start again ?
Upvote 0