Not yet tried above solution as I thought I'd try solution for downloading two files without progress being displayed: not sure about that as being suitable for B4A as it was in B4J sub-topic. So I have:
[CODE lang="b4x" title="Private
Private Sub B4XPage_Appear
...
Dim WebServer As String = "
https://johnrose.mywire.org"
Dim TextHTML As String = "httpsLargeFile"
Dim TextFileName As String = "httpsLargeFile.txt"
Dim ImageHTML As String = "summer"
Dim ImageFileName As String = "summer.jpg"
FileName = TextFileName
ServerPath = WebServer & "/" & TextHTML
Wait For (Download(ServerPath)) Complete (Success As Boolean)
If Success Then
FileSize = File.Size(ISFolder, FileName)
Log(NumberFormat(FileSize, 0, 0) & " of " & NumberFormat(FileSize, 0, 0))
Log("File was downloaded successfully")
LabelFileStatus.Text = "Download of File Completed"
Else
Log("File was NOT downloaded successfully")
xui.MsgboxAsync("File was NOT downloaded successfully", Title)
Wait For MsgBox_Result (Result As Int)
B4XPages.ClosePage(Me)
End If
FileName = ImageFileName
ServerPath = WebServer & "/" & ImageHTML
Wait For (Download(ServerPath)) Complete (Success As Boolean)
If Success Then
FileSize = File.Size(ISFolder, FileName)
Log(NumberFormat(FileSize, 0, 0) & " of " & NumberFormat(FileSize, 0, 0))
Log("Image was downloaded successfully")
LabelImageStatus.Text = "Download of Image Completed"
Else
Log("Image was NOT downloaded successfully")
xui.MsgboxAsync("Image was NOT downloaded successfully", Title)
Wait For MsgBox_Result (Result As Int)
B4XPages.ClosePage(Me)
End If
End Sub
Private Sub Download (url As String) As ResumableSub
...
Dim j As HttpJob
j.Initialize("", Me)
j.Download(url)
Dim TaskToJob As Map = HttpUtils2Service.TaskIdToJob
Do While HttpUtils2Service.TaskIdToJob.IsInitialized = False Or TaskToJob.Size = 0
Sleep(30)
Loop
Wait For (j) JobDone (j As HttpJob)
If j.Success Then
Dim out As OutputStream = File.OpenOutput(ISFolder, FileName, False)
File.Copy2(j. GetInputStream, out)
out.Close '<------ very important
End If
j.Release
Return j.Success
End Sub[/CODE]
However, that code results in the app hanging after downloading the first (text) file and during the download of the second (image) file.