Android Question HttpUtil.SaveFile

cbanks

Active Member
Licensed User
Longtime User
I have some lines in my code that begin with HttpUtil.SaveFile

I'm converting to the new okHttp/HttpUtil2 etc.

How do I make that code work with the new library?
 
Like you did it with httputils2.

In Jobdone event you save the file

Code: Copy
        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
 
Upvote 0

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

Code: Copy
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
 
Upvote 0

Similar Threads

Back
Top