title: Attempt to invoke virtual method 'int android.graphics.Bitmap.getHeight()' on a null object reference
body: <p>I'm working on image selection from "Gallery" or "Take photo". My problem is, while back pressed when taking the photo by using camera. I'm getting the error. </p>
  
  <p><strong>My code is</strong></p>
  
  <pre><code>if (items[position].equals("Take photo")) {
                          Intent i = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
                          File file= getOutputMediaFile();
                          Uri picUri = Uri.fromFile(file);
                          filepath = picUri.getPath();
                          i.putExtra(MediaStore.EXTRA_OUTPUT,picUri);
                          _a.startActivityForResult(i, 1);
                      }
  </code></pre>
  
  <hr>
  
  <pre><code>@Override
  protected void onActivityResult(int requestCode, int resultCode, Intent data) {
      // TODO Auto-generated method stub
      super.onActivityResult(requestCode, resultCode, data);
      Log.e("Action", action);
      if (action.equals("add_car")) {
          if(_addLayout.filepath != null){
              filePath = _addLayout.filepath;
              _addLayout.filepath = null;
          }
          if(data != null)
          filePath = CommonUtilities.getPath(data.getData(), "Image");
          _addLayout.filepath = filePath;
          setImage(UI_AddCar.ivTakenPicture);
      }
    }
  </code></pre>
  
  <hr>
  
  <pre><code>void setImage(ImageView im){
      BitmapFactory.Options options = new BitmapFactory.Options();
      options.inSampleSize = 4;
  
       Bitmap bitmap = BitmapFactory.decodeFile(filePath);
  
       if(filePath != null){
           int height = bitmap.getHeight(), width = bitmap.getWidth();
              if (height &gt; 1280 &amp;&amp; width &gt; 960){
                  Bitmap imgbitmap = BitmapFactory.decodeFile(filePath, options);
                  im.setImageBitmap(imgbitmap);
                  im.setVisibility(View.VISIBLE);
           } else {
                  im.setImageBitmap(bitmap);
                  im.setVisibility(View.VISIBLE);
              }
       }
  </code></pre>
  
  <p>In this UI_AddCar.ivTakenPicture is the ImageView</p>