Android Question Httputils2: download and show an image

FrankBerra

Active Member
Licensed User
Longtime User
Hi there
I am trying to download an image from a remote server and load it with an imageviewer.
It downloades the image but i can't see anything.


Here some portions of the code:

The downloader code is
B4X:
down.Download("http://xxx.xxx.xxx.xxx/media/resized" & Username.text & ".jpg")

After download is finished:
B4X:
If Job.JobName="downloaded" Then
Msgbox("Photo downloaded" & Job.GetBitmap, "OK")
ImageView1.Gravity= Gravity.FILL
ImageView1.SetBackgroundImage(Job.GetBitmap)
ImageView1.Bitmap=Job.GetBitmap
End If

Nothing happens on ImageView1....no errors, no images, nothing.
The MsgBox says: "Photo downloaded(Bitmap): 250x400"
Anyone can help me?
Thanks!
 

LucaMs

Expert
Licensed User
Longtime User
Hi there
I am trying to download an image from a remote server and load it with an imageviewer.
It downloades the image but i can't see anything.


Here some portions of the code:

The downloader code is
B4X:
down.Download("http://xxx.xxx.xxx.xxx/media/resized" & Username.text & ".jpg")

After download is finished:
B4X:
If Job.JobName="downloaded" Then
Msgbox("Photo downloaded" & Job.GetBitmap, "OK")
ImageView1.Gravity= Gravity.FILL
ImageView1.SetBackgroundImage(Job.GetBitmap)
ImageView1.Bitmap=Job.GetBitmap
End If

Nothing happens on ImageView1....no errors, no images, nothing.
The MsgBox says: "Photo downloaded(Bitmap): 250x400"
Anyone can help me?
Thanks!

The URI is a little strange, but if you don't get some error, maybe it is ok.

Are you sure the ImageView1 is visible? Is it on foreground (BringToFront)?
 
Upvote 0

FrankBerra

Active Member
Licensed User
Longtime User
I found the problem.
I created the ImageView1 element with the designer and then i initialized it in the Sub Activity_Create with
B4X:
ImageView1.Initialize("")

The B4A editor sometimes warns me saying that i shouldn't initialize the object because it is already initialized(?) by the designer. In any case the program runs correctly with no errors.
If i comment out the initialization command of ImageView1 everything works fine and the image is correctly loaded into ImageView.

That sounds strange for me.
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
I created the ImageView1 element with the designer and then i initialized it in the Sub Activity_Create with
Why you initialize it when you have loaded it with the designer. Designerviews dont need to initialized
 
Upvote 0
Top