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 ?
Sorry really can't understand how to start service in certain time cause of ticks.
If I want to start every 3 minute ok - it is DateTime.Now + 3 *DateTime.TicksPerMinute . But how to start every day in 20:00 for example ?
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))
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?
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)