0

I have an app that retrieves data from , including the URL of the image I want to display in my app.

How exactly do I create an image with that URL?

I've been searching the web and found some third-party libraries (Glide & Picasso) but I was hoping there was a way to do it without those libraries.

1
  • 2
    It is strongly recommended to use third party library like Glide, Picasso, Volly etc. because it enhance your application performance by providing image caching which also saves user internet data. If you will not use this then you have to manage these thing yourself and also have to download image from URL prior to setting image to your imageview. Commented Mar 14, 2017 at 13:03

3 Answers 3

2

It is strongly recommended third-party libraries (I prefer Picasso). It is more that just downloading the image. Functionalities like local storage to avoid unnecessary data transfer are too good to ignore, also complex enough to create from scratch... But if you still want to do it manually try this:

URL url = new URL("www.yourimagepathgoeshere.com");
Bitmap bmp = BitmapFactory.decodeStream(url.openConnection().getInputStream());
imageView.setImageBitmap(bmp);

If you also need JSON parser, try JSONSimple.

Sign up to request clarification or add additional context in comments.

Comments

1

You can use it by downloading the image from its url and then making Bitmap of the saved image path and then setting it to your imageview using:-

imageView.setImageBitmap(yourBitmap);

But, i will prefer you to use the 3rd party libraries instead for this purpose as they manages everything efficiently from downloading of images in multiple threads to Bitmap Handling for memory efficient implementation.

Comments

1

Easy way is use picasso or glide libraries.

But u can try this Accepted Answer link

2 Comments

picasso has a perfect integration with URL to image. you can even choose the crop type or limits or zoomable functions to expand the frame after.
Picasso .with(getContext()) .load("URL AS STRING") .into(IMAGEVIEW VARIABLE); and boom you have it :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.