Android Question Clarifications about foreground services

FrankBerra

Active Member
Licensed User
Longtime User
Hello forum!

I am trying to understand how to deal with foreground services since something it is not working randomly in my app.
I have an app with few services and when i need to do something when the app is in background i execute each service with something like this:
B4X:
....
Service.StartForeground(100, n)

My questions are:
- should i use Service.StartForeground(100, n) in EACH service or can i start in foreground just ONE service to allow all the others to run? (on official documentation it refers just to a single one: "It has a foreground service" - https://developer.android.com/about/versions/oreo/background but what about B4A?)
- if i must start in foreground EACH service (with the same ID tho display just one notification) what happens if i stop a foreground service with the same ID from a different service with Service.StopForeground(100) when the first one hasn't finished yet?

Thanks in advance!
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…