title: Loading images in ImageView from a url
body: <p>I found this snippet on the internet:</p>
  
  <pre><code>try{
          URL url = new URL(imgUrl+imageId[position]+".png");
          HttpURLConnection con = (HttpURLConnection)url.openConnection();
          InputStream is = con.getInputStream();
          Bitmap bmp = BitmapFactory.decodeStream(is);
          imageView.setImageBitmap(bmp);
      }catch(Exception e) {
          System.out.println(e.getMessage());
      }
  </code></pre>
  
  <p>The code doesn't give me any errors,I am getting the exact url I want. But the ImageView stays empty. Running the debugger I got no problem upto: <code>InputStream is = con.getInputStream();</code>
  After this the debugger goes to the catch block, and debugger window shows </p>
  
  <pre><code>NetworkOnMainThreadException
  </code></pre>
  
  <p>I know it's because I am doing network operations on the UI thread , but my activity already is extending another class, so I can't extend AsycnTask. Any workaround for this?</p>
  
  <p>Plus: If there is an exception, shouldn't the app crash? My app runs fine, but the imageview doesn't show anything.</p>