Edit: It is recommended to use this code instead: [B4X] OkHttpUtils2 with Wait For
Description: Download an online image and show it as the activity background.
Depends on HttpUtils2 library
Description: Download an online file and copy it to the external storage.
Tags: download, http, httputil2, web
Description: Download an online image and show it as the activity background.
B4X:
Dim job As HttpJob
job.Initialize("j", Me)
job.Download(<link>)
Sub JobDone(job As HttpJob)
If job.Success Then
'we can check the of value job.JobName if there is more than one job
Activity.SetBackgroundImage(job.GetBitmap)
Else
Log("Error: " & job.ErrorMessage)
End If
job.Release
End Sub
Description: Download an online file and copy it to the external storage.
B4X:
Dim job As HttpJob
job.Initialize("j", Me)
job.Download(<link>)
Sub JobDone(job As HttpJob)
If job.Success Then
Dim out As OutputStream = File.OpenOutput(File.DirRootExternal, "filename.dat", False)
File.Copy2(job.GetInputStream, out)
out.Close '<------ very important
Else
Log("Error: " & job.ErrorMessage)
End If
job.Release
End Sub
Tags: download, http, httputil2, web
Last edited: