title: Null Pointer Exception when grabbing picture from Gallery
body: <p>i have the following code, which is used to grab images (either from camera or gallery) and then display it on an ImageView:</p>
  
  <pre><code>@Override
  protected void onActivityResult(int requestCode, int resultCode, Intent data)
  {
      if(resultCode == RESULT_OK)
      {
          if(requestCode == 1888)
          {
              final boolean isCamera;
              if(data == null)
              {
                  isCamera = true;
              }
              else
              {
                  final String action = data.getAction();
                  if(action == null)
                  {
                      isCamera = false;
                  }
                  else
                  {
                      isCamera = action.equals(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
                  }
              }
  
              Uri selectedImageUriTemp;
              Uri selectedImageUri;
              if(isCamera)
              {
                  selectedImageUriTemp = outputFileUri;
                  Bitmap image = decodeFile(new File(selectedImageUriTemp.getPath()));
                  selectedImageUri = getImageUri(image);
              }
              else
              {
                  selectedImageUriTemp = data == null ? null : data.getData();
                  Bitmap image = decodeFile(new File(selectedImageUriTemp.getPath()));
                  selectedImageUri = getImageUri(image);
              }
  
              Log.i("TAG", "IMAGEURI: " + selectedImageUri);
  
              pictureThumb.setImageURI(selectedImageUri);
              setRealPath(selectedImageUri);
          }
      }
  }
  
  private Uri getImageUri(Bitmap image){
      ByteArrayOutputStream bytes = new ByteArrayOutputStream();
      image.compress(Bitmap.CompressFormat.JPEG, 100, bytes);
      String path = Images.Media.insertImage(getApplicationContext().getContentResolver(), image, "Title", null);
      return Uri.parse(path);
  }
  </code></pre>
  
  <p>The code works if i try to grab an image using Camera, however when i try to grab an image from Gallery it returns NULL pointer exception.</p>
  
  <p>Can anyone suggest me to the right direction? Thanks</p>
  
  <p>here is the full log:</p>
  
  <pre><code>02-12 10:34:56.249: E/AndroidRuntime(14607): FATAL EXCEPTION: main
  02-12 10:34:56.249: E/AndroidRuntime(14607): java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=1888, result=-1, data=Intent { dat=content://media/external/images/media/29 }} to activity {com.gelliesmedia.thumbqoo/com.gelliesmedia.thumbqoo.PictureBooth}: java.lang.NullPointerException: uriString
  02-12 10:34:56.249: E/AndroidRuntime(14607):    at android.app.ActivityThread.deliverResults(ActivityThread.java:3216)
  02-12 10:34:56.249: E/AndroidRuntime(14607):    at android.app.ActivityThread.handleSendResult(ActivityThread.java:3259)
  02-12 10:34:56.249: E/AndroidRuntime(14607):    at android.app.ActivityThread.access$1100(ActivityThread.java:138)
  02-12 10:34:56.249: E/AndroidRuntime(14607):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1253)
  02-12 10:34:56.249: E/AndroidRuntime(14607):    at android.os.Handler.dispatchMessage(Handler.java:99)
  02-12 10:34:56.249: E/AndroidRuntime(14607):    at android.os.Looper.loop(Looper.java:137)
  02-12 10:34:56.249: E/AndroidRuntime(14607):    at android.app.ActivityThread.main(ActivityThread.java:4954)
  02-12 10:34:56.249: E/AndroidRuntime(14607):    at java.lang.reflect.Method.invokeNative(Native Method)
  02-12 10:34:56.249: E/AndroidRuntime(14607):    at java.lang.reflect.Method.invoke(Method.java:511)
  02-12 10:34:56.249: E/AndroidRuntime(14607):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:798)
  02-12 10:34:56.249: E/AndroidRuntime(14607):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:565)
  02-12 10:34:56.249: E/AndroidRuntime(14607):    at dalvik.system.NativeStart.main(Native Method)
  02-12 10:34:56.249: E/AndroidRuntime(14607): Caused by: java.lang.NullPointerException: uriString
  02-12 10:34:56.249: E/AndroidRuntime(14607):    at android.net.Uri$StringUri.&lt;init&gt;(Uri.java:464)
  02-12 10:34:56.249: E/AndroidRuntime(14607):    at android.net.Uri$StringUri.&lt;init&gt;(Uri.java:454)
  02-12 10:34:56.249: E/AndroidRuntime(14607):    at android.net.Uri.parse(Uri.java:426)
  02-12 10:34:56.249: E/AndroidRuntime(14607):    at com.gelliesmedia.thumbqoo.PictureBooth.getImageUri(PictureBooth.java:224)
  02-12 10:34:56.249: E/AndroidRuntime(14607):    at com.gelliesmedia.thumbqoo.PictureBooth.onActivityResult(PictureBooth.java:206)
  </code></pre>