title: java.lang.NullPointerException on Bundle extras = data.getExtras();
body: <p>I'm trying to capture image and save it in gallery. For that in onCreate my code</p>
  
  <pre><code>    Intent intent = new Intent("android.media.action.IMAGE_CAPTURE");
      File photo = new File(Environment.getExternalStorageDirectory(), "Pic.jpg");
      imageUri = Uri.fromFile(photo);
      intent.putExtra(MediaStore.EXTRA_OUTPUT, imageUri);
      startActivityForResult(intent, TAKE_PICTURE);
  </code></pre>
  
  <p>and </p>
  
  <pre><code>@Override
  protected void onActivityResult(int requestCode, int resultCode, Intent data) {
      super.onActivityResult(requestCode, resultCode, data);
      if (resultCode == RESULT_OK &amp;&amp; requestCode == TAKE_PICTURE) {
          Log.v("data", "data: " + data);
          Bundle extras = data.getExtras();
          if (extras.containsKey("data")) {
              bitmap = (Bitmap) extras.get("data");
              // ByteArrayOutputStream baos = new ByteArrayOutputStream();
              // bmp.compress(Bitmap.CompressFormat.PNG, 100, baos);
              // byte[] image = baos.toByteArray();
              if (bitmap != null) {
                  // BitmapFactory.Options options = new
                  // BitmapFactory.Options();
                  // options.inSampleSize = 5;
                  // Bitmap myImage = BitmapFactory.decodeByteArray(image, 0,
                  // image.length, options);
                  imageView.setImageBitmap(bitmap);
              }
          } else {
              Toast.makeText(getBaseContext(), "Please capture again", Toast.LENGTH_LONG).show();
          }
          showPopUpForUpload();
      }
  }
  </code></pre>
  
  <p>Now I'm able to capture image, but after that I'm getting error</p>
  
  <pre><code>12-17 15:28:56.090: E/AndroidRuntime(4684): FATAL EXCEPTION: main
  12-17 15:28:56.090: E/AndroidRuntime(4684): java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=1888, result=-1, data=null} to activity {com.example.fashiongirl/com.example.fashiongirl.HomeActivity}: java.lang.NullPointerException
  12-17 15:28:56.090: E/AndroidRuntime(4684):     at android.app.ActivityThread.deliverResults(ActivityThread.java:2744)
  12-17 15:28:56.090: E/AndroidRuntime(4684):     at android.app.ActivityThread.handleSendResult(ActivityThread.java:2787)
  12-17 15:28:56.090: E/AndroidRuntime(4684):     at android.app.ActivityThread.access$2000(ActivityThread.java:122)
  12-17 15:28:56.090: E/AndroidRuntime(4684):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1032)
  12-17 15:28:56.090: E/AndroidRuntime(4684):     at android.os.Handler.dispatchMessage(Handler.java:99)
  12-17 15:28:56.090: E/AndroidRuntime(4684):     at android.os.Looper.loop(Looper.java:132)
  12-17 15:28:56.090: E/AndroidRuntime(4684):     at android.app.ActivityThread.main(ActivityThread.java:4025)
  12-17 15:28:56.090: E/AndroidRuntime(4684):     at java.lang.reflect.Method.invokeNative(Native Method)
  12-17 15:28:56.090: E/AndroidRuntime(4684):     at java.lang.reflect.Method.invoke(Method.java:491)
  12-17 15:28:56.090: E/AndroidRuntime(4684):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:841)
  12-17 15:28:56.090: E/AndroidRuntime(4684):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:599)
  12-17 15:28:56.090: E/AndroidRuntime(4684):     at dalvik.system.NativeStart.main(Native Method)
  12-17 15:28:56.090: E/AndroidRuntime(4684): Caused by: java.lang.NullPointerException
  12-17 15:28:56.090: E/AndroidRuntime(4684):     at com.example.fashiongirl.HomeActivity.onActivityResult(HomeActivity.java:47)
  12-17 15:28:56.090: E/AndroidRuntime(4684):     at android.app.Activity.dispatchActivityResult(Activity.java:4541)
  12-17 15:28:56.090: E/AndroidRuntime(4684):     at android.app.ActivityThread.deliverResults(ActivityThread.java:2740)
  12-17 15:28:56.090: E/AndroidRuntime(4684):     ... 11 more
  </code></pre>
  
  <p>The null pointer exception is on line </p>
  
  <pre><code>Bundle extras = data.getExtras();
  </code></pre>
  
  <p>So what is the problem?</p>