Notification in certain time

Johnmcenroy

Active Member
Licensed User
Longtime User
I have SQL database , there I have a column Remind with row Time.
So also there is a service that reads SQL database's time and show notification.
How is the best way to show this notification in certain time ? How I understand service must check time every 1-5 minutes and if this time same as in DB - show notification. Is this correct ?

Thanks
 

barx

Well-Known Member
Licensed User
Longtime User
You start the service on the first (earliest) time, Then when the service starts check for next time and schedule again.
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
Because you are scheduling for a time in the past causing the service to be started again and again.
You should use this code to calculate the next schedule:
B4X:
Dim four As Long
Dim now As Long = DateTime.Now
four = DateUtils.SetDateAndTime(DateTime.GetYear(now), DateTime.GetMonth(now), _
   DateTime.GetDayOfMonth(now),16, 0, 0)
If four < now Then
   'skip to tomorrow
   Dim p As Period
   p.Days = 1
   four = DateUtils.AddPeriod(four, p)
End If
Log(DateUtils.TicksToString(four))
 
Upvote 0

Johan Schoeman

Expert
Licensed User
Longtime User
Please help. I have used a combination of Simple_Alarm and WheelView to create an alarm clock. It works perfectly but once I have scheduled the alarm and "closed" the app I want the app to come "alive" when alarm starts sounding so that I can shut the alarm or select for eg "snooze" that will silent the alam for 5 or 10 or 15 minutes (user selecteable). How do I make the app come "alive" again so that I can interface with it?
 
Upvote 0

bsnqt

Active Member
Licensed User
Longtime User
Hi Erel, sorry for this simple question, but I cannot figure it out how to do.
I am ok with StartServiceAt, now my Service is started and running. Now I want to stop it at a given time (at that time I will schedule it to start again and so on). How can I stop a Service at a given time (I don't want to use a timer, I want to use the same solution as StartServiceAt)

Thank you.
 
Upvote 0
Top