Marcos Alves Well-Known Member Licensed User Longtime User Jan 12, 2018 #1 Hello, I have a doubt. I'm scheduling a service to start every 30 seconds, but I don't need the service running between the intervals... then, I use the code... Code: Copy Sub Service_Start (StartingIntent As Intent) do everything... StartServiceAt("",DateTime.Now + 30000,True) StopService("") End Sub Of course that if I check between the intervals if the service is running (using IsPaused(service)) then I'll have true (for pause). But how can I know if the service is scheduled? And if I start again, even if scheduled, I'll have two scheduled instances or the system will respect the last call and cancel any scheduled time for the service?
Hello, I have a doubt. I'm scheduling a service to start every 30 seconds, but I don't need the service running between the intervals... then, I use the code... Code: Copy Sub Service_Start (StartingIntent As Intent) do everything... StartServiceAt("",DateTime.Now + 30000,True) StopService("") End Sub Of course that if I check between the intervals if the service is running (using IsPaused(service)) then I'll have true (for pause). But how can I know if the service is scheduled? And if I start again, even if scheduled, I'll have two scheduled instances or the system will respect the last call and cancel any scheduled time for the service?
Peter Simpson Expert Licensed User Longtime User Jan 12, 2018 #2 Just print a log of the time every time the service stats, what is your target SDK level? Read this https://www.b4x.com/android/forum/threads/starting-a-service-every-15-minutes.87602/page-1 Last edited: Jan 12, 2018 Upvote 0
Just print a log of the time every time the service stats, what is your target SDK level? Read this https://www.b4x.com/android/forum/threads/starting-a-service-every-15-minutes.87602/page-1
Marcos Alves Well-Known Member Licensed User Longtime User Jan 13, 2018 #3 sdk level android-27. Does make difference? Upvote 0
Marcos Alves Well-Known Member Licensed User Longtime User Jan 13, 2018 #4 I done a workaround: always before startservice I use CancelScheduledService. Then I know that there is no risk to have two instances running. I think that this approach will always work, doesn't it? Last edited: Jan 20, 2020 Upvote 0
I done a workaround: always before startservice I use CancelScheduledService. Then I know that there is no risk to have two instances running. I think that this approach will always work, doesn't it?
Peter Simpson Expert Licensed User Longtime User Jan 13, 2018 #5 That will work just fine just run it for 30 minutes with logs on every restart so you can see exactly if it's still firing up, but it should be. Upvote 0
That will work just fine just run it for 30 minutes with logs on every restart so you can see exactly if it's still firing up, but it should be.
Marcos Alves Well-Known Member Licensed User Longtime User Jan 13, 2018 #6 ok, thanks @Peter Simpson Upvote 0