Sub Service_Start (StartingIntent As Intent)
'Service.StopAutomaticForeground 'Starter service can start in the foreground state in some edge cases.
StartServiceAt(Me, NextTimeInstance(05, 30) ,True)
End Sub
Sub NextTimeInstance (Hours As Int, Minutes As Int) As Long
Dim today As Long = DateTime.Now
today = DateUtils.SetDateAndTime(DateTime.GetYear(today), DateTime.GetMonth(today), _
DateTime.GetDayOfMonth(today), Hours, Minutes, 0)
If today < DateTime.Now Then
Dim p As Period
p.Days = 1
Dim tomorrow As Long = DateUtils.AddPeriod(today, p)
Return tomorrow
Else
Return today
End If
End Sub