Dim myURL As String = "http://www.mysite.com"
Din szUsr As String = "myself"
Din szPwd As String = "password"
Dim j As HttpJob
j.Initialize("MyJob",Me)
Dim generator As JSONGenerator
generator.Initialize(CreateMap("Usr": szUsr, "Pwd": szPwd))
j.PostString(myURL, generator.ToString)
Could I retrieve "myself" and "password" into sub JobDone if Job.Success = FALSE?
Sub JobDone(Job As HttpJob)
Dim bRel As Boolean = True
If ( Job.JobName == "MyJob" ) Then
bRel = False ' managed by Wait For
Else
' ... managing others jobs ...
End If
If ( bRel ) Then
Job.Release
End If
End Sub
No. Using wait for you do not need the sub at all.
The code should be in the sub where you are using the wait for.
B4X:
If ( bRel ) Then
Job.Release
End If
End Sub
The job must be ALWAYS released.
B4X:
Dim myURL As String = "http://www.mysite.com"
Din szUsr As String = "myself"
Din szPwd As String = "password"
Dim j As HttpJob
j.Initialize("MyJob",Me)
dim m as map = CreateMap("Usr": szUsr, "Pwd": szPwd)
Dim generator As JSONGenerator
generator.Initialize(m)
j.PostString(myURL, generator.ToString)
Wait For (j) JobDone(j As HttpJob)
If j.Success Then
Log(j.GetString)
else
log("User used: "&szUsr)
log("PW used: "&szPwd)
log(j.errormessage)
End If
j.Release
Dim m As String = ""
Dim j As HttpJob
Log(m)
j.Initialize("", Me)
j.PostString("http://gpstracker.nowyouseeme.net/appmovil/index.php"&$"?IMEI=${public_data.imei}&bateria=10&longi=${public_data.longitude}&lat=${public_data.lattitude}&altitud=${public_data.altitud}&orientacion=N"$ ,m)
Wait For (j) JobDone(j As HttpJob)
If j.Success Then
Log(j.GetString)
End If
j.Release
B4a code 2
B4X:
Dim m As String = $"?IMEI=${public_data.imei}&bateria=10&longi=${public_data.longitude}&lat=${public_data.lattitude}&altitud=${public_data.altitud}&orientacion=N"$
Dim j As HttpJob
Log(m)
j.Initialize("", Me)
j.PostString("http://gpstracker.nowyouseeme.net/appmovil/index.php",m)
Wait For (j) JobDone(j As HttpJob)
If j.Success Then
Log(j.GetString)
End If
j.Release