If Job.JobName = "DownloadImage" Then
Dim m As Map = Job.Tag
Dim OutStream As OutputStream
Log("DownloadReady: "&Job.Tag)
OutStream = File.OpenOutput(File.DirRootExternal, m.Get("filename"), False)
File.Copy2(Job.GetInputStream,OutStream) ' save the file
OutStream.Close
Log(m.Get("filename")&" is written to "&File.DirRootExternal)
Note that i was using a Map inside the Job.Tag to store some infos.
But the principle you should see
Start the job. Wait for the JobDone event get raised and check the Job.Success inside this sub. You can not hold the mainthread.
The job will run async
B4X:
Sub JobDone(Job As HttpJob)
ProgressDialogHide
If Job.Success = False Then
Log(Job.ErrorMessage)
else If Job.Success Then
end if
Job.Release
end sub