Android Question Scheduled service check

dennmtr

Member
Licensed User
How to check if service is scheduled to run when is paused?

For Example if i run the code below the service will start even is scheduled to run another time. i want to prevent that

B4X:
If IsPaused(SomeService) Then 'append sth like... And IsNotScheduledToRun(SomeService)

    StartService(SomeService)

End If
 
Last edited:

DonManfred

Expert
Licensed User
Longtime User
Upvote 0

Brian Dean

Well-Known Member
Licensed User
Longtime User
I think that @DonManfred did understand your question, but maybe you did not understand his answer. Here is what I think you want to know ...

At some point in time you issued a StartServideAt for some service. At some later time you discover that you want the service to run at a different time, and you want to know how to prevent the service running at the originally planned time. In other words, you want to cancel the currently scheduled event and replace it with another.

You cancel the currently scheduled event with a CancelScheduledService(serviceName) statement, and then issue your new StartService instruction. Here is a link that seems to be answering the same question.

By the way, CancelScheduledService will cancel all the pending StartService events, so if you are planning multiple events then you will have to save them in a list and issue fresh StartEventAt commands.
 
Last edited:
Upvote 0

dennmtr

Member
Licensed User
I think that @DonManfred did understand your question, but maybe you did not understand his answer. Here is what I think you want to know ...

At some point in time you issued a StartServideAt for some service. At some later time you discover that you want the service to run at a different time, and you want to know how to prevent the service running at the originally planned time. In other words, you want to cancel the currently scheduled event and replace it with another.

You cancel the currently scheduled event with a CancelScheduledService(serviceName) statement, and then issue your new StartService instruction. Here is a link that seems to be answering the same question.

By the way, CancelScheduledService will cancel all the pending StartService events, so if you are planning multiple events then you will have to save them in a list and issue fresh StartEventAt commands.

Did i said i want to cancel the scheduled service? I definitely know what CancelScheduledService do. Expect that the Scheduled start of services are ignored if the service is active. If the service is scheduled to run in 5 hours i dont want to cancel the scheduled service and i dont want to start it ether now. I ll maybe define a process global variable with the scheduled time or correct my logic
 
Last edited:
Upvote 0
Top