title: imageView setImageBitmap() | null pointer exception
body: <p>I'm trying to download and show an image with Bitmap and ImageView. I'm using an AsyncTask which takes url arguments but I always get a</p>
  
  <p>I'm trying to download and show an image with Bitmap and ImageView. I'm using an AsyncTask which takes url arguments but I always get a</p>
  
  <p>java.lang.NullPointerException: Attempt to invoke virtual method 'void  android.widget.ImageView.setImageBitmap(android.graphics.Bitmap)' on a  null object reference</p>
  
  <p>Code:</p>
  
  <pre><code>public class MainActivity extends AppCompatActivity {
  
   ImageView imageView;
  
   public void images(View view)
   {
  
       ImageDownloader task=new ImageDownloader();
       Bitmap myImage;
       try
       {
           myImage=task.execute("https://upload.wikimedia.org/wikipedia/en/a/aa/Bart_Simpson_200px.png").get();
  
           imageView.setImageBitmap(myImage);     //Here is the part where i am
                                                  //Getting exception
       }
       catch (InterruptedException e)
       {
           e.printStackTrace();
       }
       catch (ExecutionException e)
       {
           e.printStackTrace();
       }
   }
  
  
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      imageView=(ImageView)findViewById(R.id.myimg);  //imageView
  
      setContentView(R.layout.activity_main);
  
  }
  
  
  
  public class ImageDownloader extends AsyncTask&lt;String,Void,Bitmap&gt;{
      @Override
      protected Bitmap doInBackground(String... urls)
      {
          try {
              URL url=new URL(urls[0]);
              HttpsURLConnection connection=(HttpsURLConnection)url.openConnection();
              connection.connect();
              InputStream inputStream=connection.getInputStream();
              Bitmap bitmap= BitmapFactory.decodeStream(inputStream);
              return bitmap;
  
  
          } catch (MalformedURLException e) {
              e.printStackTrace();
          } catch (IOException e) {
              e.printStackTrace();
          }
          return null;
      }
  }
  }
  </code></pre>