creating and calling services

fanfalveto

Active Member
Licensed User
Longtime User
I want to make a calendar with alarm.
For one alarm to sound within x time no problem, but if I put an alarm for x time and this calls the service and put another alarm for x + y time and this calls the service? the second overrides the first? Must i create separate services for each alarm? can create unlimited services in run time? or should I create a limited number of services for each alarm you want to include in the program?
Thank you.
 

mc73

Well-Known Member
Licensed User
Longtime User
Why use many services? You can have just one service, starting at the very first alarm, then reschedule it to restart at the next alarm.
 
Upvote 0

fanfalveto

Active Member
Licensed User
Longtime User
Ok, with this
B4X:
StartServiceAt(alarma, DateTime.Now+elapsedtotal,True)
i start service since 5 minutes for example (elapsedtotal= 5 minutes) .thats ok.
but if i put again another alarm in 10 minutes (elapsedtotal=10 minutes) i call again to starserviceat(......) then sound at 5 minutes and 10 minutes?
 
Upvote 0

mc73

Well-Known Member
Licensed User
Longtime User
It's a matter of how your code handles the upcoming events.
Suppose you have a list of events. Then, when your service starts to perform the 'alarm', you can take this alarm out of your list. Then take the next one, and find the time interval between the current executed alarm and that one. This way, execute a startServiceAt again, using this interval.
 
Upvote 0
Top