#Region Service Attributes
#StartAtBoot: true
#End Region
Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
End Sub
Sub Service_Start (StartingIntent As Intent)
Dim t As Long = FindNextTime(Array As Double(13.5,13.55, 13.6))
Log($"Next time is: $Time{t}"$)
StartServiceAt(Me,t,True)
End Sub
Sub FindNextTime(Times As List) As Long
Times.Sort(True)
For Each st As Double In Times
If SetHours(st) > DateTime.Now Then
Return SetHours(st)
Log("This is SetHours: " & SetHours(st))
End If
Next
Return DateTime.Add(SetHours(Times.Get(0)), 0, 0, 1)
End Sub
Sub SetHours(st As Double) As Long
Dim hours As Int = Floor(st)
Dim minutes As Int = 60 * (st - hours)
Return DateUtils.SetDateAndTime(DateTime.GetYear(DateTime.Now), _
DateTime.GetMonth(DateTime.Now), DateTime.GetDayOfMonth(DateTime.Now), hours, minutes, 0)
End Sub
Sub Service_TaskRemoved
'This event will be raised when the user removes the app from the recent apps list.
End Sub
'Return true to allow the OS default exceptions handler to handle the uncaught exception.
Sub Application_Error (Error As Exception, StackTrace As String) As Boolean
Return True
End Sub
Sub Service_Destroy
End Sub