Hello,
i use in B4i httputils2 to download many small files from a http Server.
Here is a simple example:
But how can i make that the download process run in background when (for example) the screen goes in "auto off"?
In B4a i use a service modul for this. Ther is a simple way to do this in B4i?
i use in B4i httputils2 to download many small files from a http Server.
Here is a simple example:
B4X:
Sub Button1_Click
downloaderror = False
downloadfile = 1
label1.Text = "Download Start"
downloadstart
End Sub
Sub downloadstart
Dim job1 As HttpJob
job1.Initialize("job1", Me)
job1.Download("somelink" & downloadfile & ".txt")
End Sub
Sub JobDone (job As HttpJob)
If job.Success Then
Dim out As OutputStream
out = File.OpenOutput(File.DirDocuments, downloadfile & ".txt",False)
File.Copy2(job.GetInputStream, out)
out.Close
Else
label1.Text = "Error: " & job.ErrorMessage
downloaderror = True
End If
job.Release
If downloaderror = False And downloadfile < 1000 Then
downloadfile = downloadfile + 1
downloadstart
End If
But how can i make that the download process run in background when (for example) the screen goes in "auto off"?
In B4a i use a service modul for this. Ther is a simple way to do this in B4i?
Last edited: