Android Question Starting Scheduled service's

Jmu5667

Well-Known Member
Licensed User
Longtime User
Morning All

When the phone is fast asleep, and a scheduled service is started, how long is the service allowed to run before it is killed by the OS.

Is it good practice to use 'service.startforeground' in a scheduled 'service_create' to keep it alive ?

Reason I am asking I have a few services that are scheduled and one of the is for GPS positioning, and another is for Bluetooth serial comms, the two are not linked in any way.

Regards

John.
 

Peter Simpson

Expert
Licensed User
Longtime User
service.startforeground will keep it alive but with a Icon at the top of the screen, even though that's simple enough to hide. Have you tried running the service as Sticky Service and using StartServiceAt(Null, xxx, True) in the service itself?

This solution works perfectly fine for me...
 
Upvote 0

Jmu5667

Well-Known Member
Licensed User
Longtime User
service.startforeground will keep it alive but with a Icon at the top of the screen, even though that's simple enough to hide. Have you tried running the service as Sticky Service and using StartServiceAt(Null, xxx, True) in the service itself?
This solution works perfectly fine for me...

Hi Peter

The icon display is fine. Service is Stickyand yes I do use StartServiceAt("", xxx, True) not StartServiceAt(Null, xxx, True). So it is best practice to use service.startforeground ?

Regards

John.
 
Upvote 0

Jmu5667

Well-Known Member
Licensed User
Longtime User
Mmmm... after some time working on this today, I have noticed that sometime my service will pause for maybe 1-2 mins before resuming, is hooking a service to the notification object dependent on the time that is allocated to the notification object by the OS. I have reverted back to using a partial lock to do some further tests. I suspect the former is true..(as far as I can see anyways)...maybe Lord @Erel can verify this.
 
Upvote 0
Top