Adding Images to Image View through Image URL – Android

ImageView img = (ImageView) findViewById(;

try {
URL url = new URL("your image url here");
//try this url :-

HttpGet httpRequest = null;
httpRequest = new HttpGet(url.toURI());
HttpClient httpclient = new DefaultHttpClient();
HttpResponse response = (HttpResponse) httpclient
HttpEntity entity = response.getEntity();
BufferedHttpEntity b_entity = new BufferedHttpEntity(entity);
InputStream input = b_entity.getContent();
Bitmap bitmap = BitmapFactory.decodeStream(input);
catch (Exception ex) {

Toast t2 = Toast.makeText(getApplicationContext(),
                "Image Loading Failed", Toast.LENGTH_LONG);
        t2.setGravity(Gravity.CENTER, 0, 0);;

Here we are getting the image from the url as a InputStream, and converting it to Bitmap and feeding into the
ImageView img. If there was any error the toast message will display the message “Image Loading Failed”.

Hope you guys understood it

Download Sample Project

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.