Sub Service_Start (StartingIntent As Intent)
Log("shedule.service_start()")
Log("i´m started. So i´ll do my job NOW and reshedule me for the next time")
' DownloadQuote 'RESTART THE NOTIFICATION SEVERAL TIMES
Dim n As Notification
n.Initialize
n.Icon = "icon"
n.AutoCancel = True
n.SetInfo(Application.LabelName, "Quote of the day", Main)
n.Notify(1)
Dim t As Long
t = FindNextTime(Array As Double(17+6/60, 17+7/60, 17+8/60))
Log($"Next time is: $Time{t}"$)
StartServiceAt(Me,t,True)
StopService("")
End Sub
Sub DownloadQuote
Dim j As HttpJob
j.Initialize("", Me) 'name is empty as it is no longer needed
j.Download("http://quotesondesign.com/wp-json/posts?filter[orderby]=rand")
Wait For (j) JobDone(j As HttpJob)
If j.Success Then
'The result is a json string. We parse it and log the fields.
Dim jp As JSONParser
jp.Initialize(j.GetString)
Dim quotes As List = jp.NextArray
For Each quot As Map In quotes
Log("Title: " & quot.Get("title"))
Log("Content: " & quot.Get("content"))
Next
End If
j.Release
End Sub