Android Question Downloading image question

GaNdAlF89

Active Member
Licensed User
Longtime User
Hi, I have a question with the download of images. I want to download an image before that execution of calling routine continues.

Something like:

B4X:
Sub Authentication
'initial code

LoadImage 'Function

'other code that I want to execute after the download of image

End Sub

Sub LoadImage

Dim imageRequest As HttpRequest
imageRequest.InitializeGet(url & "imagename.jpg")
     
Client.Execute(imageRequest,1)

End Sub

Sub Client_ResponseSuccess(Response As HttpResponse, TaskId As Int)

Response.GetAsynchronously("ResponseSub",File.OpenOutput.......
 
End Sub

Sub ResponseSub_StreamFinish (Success As Boolean, TaskId As Int)
 
If Success = True Then
   
  Photo.Initialize......... 'Photo is a Bitmap
   
End If
 
'Now I want to execute the other code of "Sub Authentication" after calling "LoadImage"

End Sub

How can I do?
 

GaNdAlF89

Active Member
Licensed User
Longtime User
Is JobDone event similar to ResponseSub_StreamFinish? Does it works asynchronously with the rest of code? How it works?
 
Last edited:
Upvote 0

GaNdAlF89

Active Member
Licensed User
Longtime User
Yes, I know that network calls are always asynchronous. I mean something that "waits for" the network response, either 'success' or 'error' events, and then it continues the execution.
 
Upvote 0
Top