Hello,
I'm having a problem since I have to execute several HttpJobs according to several states.
Some are executed, others not.
I call some subroutines, program enters them but JobDone is not always invoked.
In this case, job1 is executed, while jobt not.
The sequence is job1 (always), jobt in some cases.
I receive the log message Readfile but not the one from JobDOne.
Any idea?
Thank you
I'm having a problem since I have to execute several HttpJobs according to several states.
Some are executed, others not.
I call some subroutines, program enters them but JobDone is not always invoked.
In this case, job1 is executed, while jobt not.
The sequence is job1 (always), jobt in some cases.
I receive the log message Readfile but not the one from JobDOne.
B4X:
Sub getToken
Dim jobt As HttpJob
jobt.Initialize("jobt", Me)
jobt.Download(server & "token.php")
Log ("Jobt su getToken")
End Sub
Sub ReadFile
Dim job1 As HttpJob
job1.Initialize("job1", Me)
job1.Download(server&"xxxx.txt")
Log ("Job1 su ReadFile")
End Sub
B4X:
Sub JobDone (Job As HttpJob)
Dim qResult As String
Log("JobName = " & Job.JobName & ", Success = " & Job.Success)
If Job.Success = True Then
Select Job.JobName
Case "job1"
tmr.Enabled = False
Dim os As OutputStream
os = File.OpenOutput(File.DirDefaultExternal, "xxx.txt", False)
File.Copy2(Job.GetInputStream, os)
os.Close
Job.Release
Log ("job1 executed on JobDone")
tmr.Enabled = True
Case "jobt"
tmr.Enabled = False
token = Job.GetString
Job.Release
Log ("jobt executed on JobDone")
tmr.Enabled = True
Case "job3"
tmr.Enabled = False
Dim os As OutputStream
os = File.OpenOutput(File.DirDefaultExternal, "local.txt", False)
File.Copy2(Job.GetInputStream, os)
os.Close
Job.Release
Log ("job3 executed on JobDone ")
tmr.Enabled = True
checkCustom
Case "job4"
tmr.Enabled = False
Dim out As OutputStream = File.OpenOutput(File.DirDefaultExternal, "ext.jpg", False)
File.Copy2(Job.GetInputStream, out)
out.Close
bann = "ext.jpg"
Log ("job4 executed on JobDone - image downloaded")
End Select
Else
ToastMessageShow("Error: " & Job.ErrorMessage, True)
Job.Release
End If
End Sub
Any idea?
Thank you