#Region Module Attributes
#StartAtBoot: False
#End Region
'Service module
Sub Process_Globals
Dim hc As HttpClient
End Sub
Sub Service_Create
hc.Initialize("hc")
End Sub
Sub Service_Start'(StartingIntent As Intent)
Dim Request1 As HttpRequest
Request1.InitializeGet("http://sdo.gsfc.nasa.gov/assets/img/latest/latest_1024_HMII.jpg")
hc.Execute(Request1, 0)
Dim Request2 As HttpRequest
Request2.InitializeGet("http://sdo.gsfc.nasa.gov/assets/img/latest/latest_1024_0304.jpg")
hc.Execute(Request2, 1)
End Sub
Sub Service_Destroy
End Sub
Sub hc_ResponseSuccess (Response As HttpResponse, TaskId As Int)
Response.GetAsynchronously("ImageResponse", File.OpenOutput(File.DirInternal, TaskId, False), True, TaskId)
End Sub
Sub hc_ResponseError (Response As HttpResponse, Reason As String, StatusCode As Int, TaskId As Int)
If StatusCode = -1 Then Reason = "Phone is offline"
ToastMessageShow(Reason ,False)
If Response <> Null Then Response.Release
ProgressDialogHide
End Sub
Sub ImageResponse_StreamFinish (Success As Boolean, TaskId As Int)
If Success = False Then
ToastMessageShow(LastException.Message, False)
Return
End If
CallSub2(sunspots,"DownloadComplete", TaskId)
End Sub