'Service module
Sub Process_Globals
Dim myHttpRequest As HttpRequest
Dim myHttpClient As HttpClient
Dim FileName As String
End Sub
Sub Service_Create
myHttpClient.InitializeAcceptAll("myHttpClient")
End Sub
Sub Service_Start (StartingIntent As Intent)
Dim TaskId = 123
myHttpRequest.InitializeGet(Url)
myHttpClient.Execute(EQHttpRequest, TaskId)
End Sub
Sub myHttpClient_ResponseSuccess (Response As HttpResponse, TaskId As Int)
Response.GetAsynchronously("ImageResponse", _
File.OpenOutput(File.DirInternal, FileName, False), True, TaskId)
End Sub
Sub ImageResponse_StreamFinish (Success As Boolean, TaskId As Int)
If Success = False Then
Msgbox(LastException.Message, "Error")
Return
End If
Dim FilePath As String
FilePath = File.DirInternal & "/" & FileName
CallSub2(myActiviti, "AddToList", FilePaht)
'if you need to to download next file, start the service again
StartServiceAt("", DateTime.Now + 30 * 1000, True)
End Sub
Sub myHttpClient_ResponseError (Response As HttpResponse, Reason As String, StatusCode As Int, TaskId As Int)
Log("ERROR HTTP REQUEST")
End Su