G GuyBooth Active Member Licensed User Longtime User Feb 6, 2023 #1 I have an application that runs one service with a partial lock etc to keep it running all the time. I have another service that needs to stay alive until I turn it off. Do I need to apply a partial lock to this service as well to make sure it stays running until I turn it off, given that the other service is holding a partial lock? In fact do I need to apply all the following to every service, even when the first one I run is supposed to run all the time? B4X: Copy Sub Process_Globals Private lock As PhoneWakeState End Sub Sub Service_Create lock.PartialLock Service.StartForeground(nid, CreateNotification("Message")) End Sub Sub Service_Start (StartingIntent As Intent) Service.StopAutomaticForeground End Sub
I have an application that runs one service with a partial lock etc to keep it running all the time. I have another service that needs to stay alive until I turn it off. Do I need to apply a partial lock to this service as well to make sure it stays running until I turn it off, given that the other service is holding a partial lock? In fact do I need to apply all the following to every service, even when the first one I run is supposed to run all the time? B4X: Copy Sub Process_Globals Private lock As PhoneWakeState End Sub Sub Service_Create lock.PartialLock Service.StartForeground(nid, CreateNotification("Message")) End Sub Sub Service_Start (StartingIntent As Intent) Service.StopAutomaticForeground End Sub
Erel B4X founder Staff member Licensed User Longtime User Feb 7, 2023 #2 GuyBooth said: o I need to apply a partial lock to this service as well Click to expand... No. A single one is enough. It is also not needed to make your other services foreground services. Upvote 0
GuyBooth said: o I need to apply a partial lock to this service as well Click to expand... No. A single one is enough. It is also not needed to make your other services foreground services.
G GuyBooth Active Member Licensed User Longtime User Feb 7, 2023 #3 Erel said: No. A single one is enough. It is also not needed to make your other services foreground services. Click to expand... Do I always need the Service.StopAutomaticForeground? And is the Sub Service_Start the correct place to put it? Upvote 0
Erel said: No. A single one is enough. It is also not needed to make your other services foreground services. Click to expand... Do I always need the Service.StopAutomaticForeground? And is the Sub Service_Start the correct place to put it?
JohnC Expert Licensed User Longtime User Feb 8, 2023 #5 I have two questions: 1) Does "Service.AutomaticForegroundMode = Service.AUTOMATIC_FOREGROUND_ALWAYS" work EXACTLY the same as Service.StartForeground(nid, CreateNotification("Message")) in the context of keeping the service alive? 2) To give a service the best chance to staying alive, should either of the above lines be put in the Service_Create or Service_Start? Last edited: Feb 8, 2023 Upvote 0
I have two questions: 1) Does "Service.AutomaticForegroundMode = Service.AUTOMATIC_FOREGROUND_ALWAYS" work EXACTLY the same as Service.StartForeground(nid, CreateNotification("Message")) in the context of keeping the service alive? 2) To give a service the best chance to staying alive, should either of the above lines be put in the Service_Create or Service_Start?