'Activity module
Sub Process_Globals
Dim webresponse As String
End Sub
Sub Activity_Create(FirstTime As Boolean)
Dim job1, job2, job3 As HttpJob
job1.Initialize("Job1", Me)
'Send a GET request
job1.Download2("http://www.b4x.com/print.php", _
Array As String("first key", "first value :)", "second key", "value 2"))
'Send a POST request
job2.Initialize("Job2", Me)
job2.PostString("http://www.b4x.com/print.php", "first key=first value&key2=value2")
'Send a GET request
job3.Initialize("Job3", Me)
job3.Download("http://www.b4x.com/android/forum/data/avatars/m/0/1.jpg?1374051458")
DoEvents 'Take out = empty webresponse / Leave in = Msgbox below doesn't show
Msgbox(webresponse,"DEBUG MESSAGE") 'NEED TO ACCESS WEBRESPONSE VARIABLE (JobDone needs to have run)
End Sub
Sub JobDone (Job As HttpJob)
Log("JobName = " & Job.JobName & ", Success = " & Job.Success)
If Job.Success = True Then
Select Job.JobName
Case "Job1", "Job2"
'print the result to the logs
Log(Job.GetString)
webresponse = Job.GetString 'FILL VARIABLE
Case "Job3"
'show the downloaded image
Activity.SetBackgroundImage(Job.GetBitmap)
End Select
Else
Log("Error: " & Job.ErrorMessage)
ToastMessageShow("Error: " & Job.ErrorMessage, True)
End If
Job.Release
End Sub