StefanPMF
StefanPMF

Reputation: 11

Display images from url using json in android

I'm new in android ... so I need help. I have JSON link where I have for example like this

[{"id":"82","percent":"3","image_name":"something.jpg"....

I try some tutorial just for reading text, it was okay. But I have problem how to show in my layout the images from JSON...

Can you help or share some code about this?

Upvotes: 1

Views: 49

Answers (2)

devcodes
devcodes

Reputation: 1088

Parse the json string : -

String jsonString = "your json string goes here" ;

JSONObject rootObj = new JSONObject(jsonString);

String link = rootObj.getString("image_name");

You can now use this url/link to convert it into bitmap : -

Bitmap image ;    

 InputStream in = new java.net.URL(link).openStream();

   image = BitmapFactory.decodeStream(in);

    in.close();

Upvotes: 1

Lingviston
Lingviston

Reputation: 5671

By default you can't disaplay image using web link. However lots of libraries have been created to solve this problem. You can try this one. There's also a list of alternative libraries.

Upvotes: 0

Related Questions