title: Bitmap from gallery cause crash - Android
body: <p>I'm using a code to get Bitmap from gallery and use it for my purposes.
  this is the code:</p>
  
  <pre><code>protected void onActivityResult(int requestCode, int resultCode,Intent data) {                  
               if (resultCode == RESULT_OK) {
               Uri targetUri = data.getData();
               Bitmap bitmap = null;
               bitmap = BitmapFactory.decodeFile(getRealPathFromURI(targetUri));
                   //bitmap = BitmapFactory.decodeStream(getContentResolver().openInputStream(targetUri));
              addMarker(bitmap);
              }
  }
  
  public String getRealPathFromURI(Uri contentUri) {
      // can post image
      String [] proj={MediaStore.Images.Media.DATA};
      Cursor cursor = managedQuery( contentUri,
      proj, // Which columns to return
      null, // WHERE clause; which rows to return (all rows)
      null, // WHERE clause selection arguments (none)
      null); // Order-by clause (ascending by name)
      int column_index = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
      cursor.moveToFirst();
      return cursor.getString(column_index);
      }
  </code></pre>
  
  <p>for some reason the app crashing when doing it. the problem is not with the addMarker method, cause it's working fine with other bitmaps tested with. only with bitmaps from gallery it won't work and crush.</p>
  
  <p>That's the error i get:</p>
  
  <pre><code>09-29 21:28:35.960: E/AndroidRuntime(4746): 
  java.lang.RuntimeException: Failure delivering result ResultInfo
  {who=null, request=1, result=-1, data=Intent 
  { dat=content://media/external/images/media/3 }} to activity
  {com.sit.augmented_reality/com.sit.augmented_reality.activity.Demo}: 
  java.lang.NullPointerException
  </code></pre>