title: Android : How to set an image to an imageview from a url programatically
body: <p>I have an image url coming from my rest API.  Now I want to set it to an imageview when activity is loading. Below is how I get the bean from the rest api and then get the URL out of it.</p>
  
  <pre><code>Message message=new Message();
  String imageUrl=message.getImageUrl();
  </code></pre>
  
  <p>I get Message object from my database and image url is include in that Message object.</p>
  
  <p>Then I used Url object to get that image url.</p>
  
  <pre><code>URL url = null;
  try {
       url = new URL(imageUrl);
       Bitmap bmp = BitmapFactory.decodeStream(url.openConnection().getInputStream());
       contentImageView.setImageBitmap(bmp);
  } catch (Exception e) {
       e.printStackTrace();
  }
  </code></pre>
  
  <p>I used above codes to load image to an imageview object which is <code>contentImageView</code>.</p>
  
  <p>But still I cannot load this image to imageview, Nothing is getting loaded.</p>
  
  <p>have any ideas?</p>