title: Can't Get Path Of Photos Taken By ACTION_IMAGE_CAPTURE
body: <p>I use Intent and the ACTION_IMAGE_CAPTUREto use the camera and take photos, I successfully get the uri of the photo, however when I use this uri to get path, an exception occurred. And when I go to the gallery, I didn't see the photo. I restart the phone and then I see the photo in the gallery. Can anyone tell me how to get the path or let the bitmap in gallery as soon as I finish the intent? </p>
  
  <p>MyCodes:</p>
  
  <pre><code> Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
  
                      Date today = new Date();
  
                      fileName = Integer.toString(today.getYear()) + Integer.toString(today.getMonth()) + Integer.toString(today.getDay()) +
                              Integer.toString(today.getHours()) + Integer.toString(today.getMinutes()) + Integer.toString(today.getSeconds());
  
                      File out = new File(Environment.getExternalStorageDirectory(), fileName + ".jpg");
                      tempUri = Uri.fromFile(out);
                      intent.putExtra(MediaStore.EXTRA_OUTPUT, tempUri);
                      startActivityForResult(intent, TAKEPHOTO);
                      break;
  </code></pre>
  
  <p>And in onActivityResult</p>
  
  <pre><code>public void onActivityResult(int requestCode, int resultCode, Intent data)
  {
      if (requestCode == COMPLETE)
      {
          if (data != null)
          {
              Uri uri = data.getData();
              if (uri != null)
              {
                      uris[currentIndex] = uri;
                      setBitmapFromUri();
              }
          }
      }
      else if (requestCode == TAKEPHOTO)
      {
          uris[currentIndex] = tempUri;
          setBitmapFromUri();
      }
  
      super.onActivityResult(requestCode, resultCode, data);
  }
  </code></pre>
  
  <p>Here is the setBitmapFromUri:</p>
  
  <pre><code>private void setBitmapFromUri()
  {
      Uri uri = uris[currentIndex];
  
      BitmapFactory.Options options = new BitmapFactory.Options();
      options.inSampleSize = 3;
      try
      {
          String path = getAbsoluteImagePath(uri);
  
          ExifInterface exif = new ExifInterface(path);
  
          int tag = exif.getAttributeInt(ExifInterface.TAG_ORIENTATION, -1);
  
          int degree = 0;
          if (tag == ExifInterface.ORIENTATION_ROTATE_90)
          {
              degree = 90;
          }
          else if (tag == ExifInterface.ORIENTATION_ROTATE_180)
          {
              degree = 180;
          }
          else if (tag == ExifInterface.ORIENTATION_ROTATE_270)
          {
              degree = 270;
          }
  
          Bitmap bitmap = BitmapFactory.decodeStream(getContentResolver().openInputStream(uri), null, options);
          Matrix matrix = new Matrix();
          matrix.setScale (2 * getWindowManager().getDefaultDisplay().getWidth() / 3 / bitmap.getWidth(), 2 * getWindowManager().getDefaultDisplay().getHeight() / 3 / bitmap.getHeight());
          matrix.setRotate(degree);
  
          bitmap = Bitmap.createBitmap(bitmap, 0, 0, bitmap.getWidth(), bitmap.getHeight(), matrix, true);
  
          imageViews.get(currentIndex).setImageBitmap(bitmap);
      } catch (IOException e)
      {
          e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
      }
  
  
  }
  </code></pre>
  
  <p>Here is the exception:</p>
  
  <pre><code>05-18 10:38:20.645: ERROR/AndroidRuntime(3342): FATAL EXCEPTION: main
      java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=1, result=-1, data=null} to activity {com.Trine.HideAndSeek/com.Trine.HideAndSeek.UploadHints}: java.lang.NullPointerException
      at android.app.ActivityThread.deliverResults(ActivityThread.java:2653)
      at android.app.ActivityThread.handleSendResult(ActivityThread.java:2695)
      at android.app.ActivityThread.access$2000(ActivityThread.java:123)
      at android.app.ActivityThread$H.handleMessage(ActivityThread.java:969)
      at android.os.Handler.dispatchMessage(Handler.java:99)
      at android.os.Looper.loop(Looper.java:130)
      at android.app.ActivityThread.main(ActivityThread.java:3835)
      at java.lang.reflect.Method.invokeNative(Native Method)
      at java.lang.reflect.Method.invoke(Method.java:507)
      at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:864)
      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:622)
      at dalvik.system.NativeStart.main(Native Method)
      Caused by: java.lang.NullPointerException
      at com.Trine.HideAndSeek.UploadHints.getAbsoluteImagePath(UploadHints.java:324)
      at com.Trine.HideAndSeek.UploadHints.setBitmapFromUri(UploadHints.java:140)
      at com.Trine.HideAndSeek.UploadHints.onActivityResult(UploadHints.java:196)
      at android.app.Activity.dispatchActivityResult(Activity.java:3908)
      at android.app.ActivityThread.deliverResults(ActivityThread.java:2649)
  </code></pre>