F FrankBerra Active Member Licensed User Longtime User Nov 28, 2019 #1 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: Code: .... 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!
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: Code: .... 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!
Erel B4X founder Staff member Licensed User Longtime User Nov 28, 2019 #2 A single foreground service is enough. The app will run in the foreground state so other services will not be killed. Upvote 0
A single foreground service is enough. The app will run in the foreground state so other services will not be killed.