title: Android - Image Picker, Wrong Image
body: <p>I am starting a request for an image pick:</p>
  
  <pre><code>Intent intent = new Intent();
  intent.setType( "image/*" );
  intent.setAction( Intent.ACTION_GET_CONTENT );
  startActivityForResult( Intent.createChooser( intent, "Choose"), PHOTO_GALLERY );
  </code></pre>
  
  <p>And getting the data back out in <code>onActivityResult</code>:</p>
  
  <pre><code>if( resultCode == Activity.RESULT_OK &amp;&amp; requestCode == PHOTO_GALLERY )
  {
    U.log( data.getData() );
    Bitmap bm = ... // built from the getData() Uri
    this.postImagePreview.setImageBitmap( bm );
  }
  </code></pre>
  
  <p>When I launch the Intent, I see some folders, such as <code>sdcard</code>, <code>Drop Box</code>, <code>MyCameraApp</code>, and so on.</p>
  
  <p>If I chose a picture from <code>sdcard</code>, when I load the preview, it is the completely wrong image. The other folders don't seem to be giving me this problem.</p>
  
  <p>Does anyone know why it'd let me pick one image, then give me the Uri for another?</p>
  
  <p><strong>EDIT:</strong> Here are some exampled logged <code>getData()</code>s:</p>
  
  <p>Good:</p>
  
  <p><code>content://com.google.android.gallery3d.provider/picasa/item/5668377679792530210</code></p>
  
  <p>Bad:</p>
  
  <p><code>content://media/external/images/media/28</code></p>
  
  <p><strong>EDIT:</strong> I'm still having issues, when picking from the sdcard folder of gallery.</p>
  
  <p>Here is a bit more expansion of what I'm doing in onActivityResult:</p>
  
  <pre><code>// cursor
  Uri selectedImage = data.getData();
  
  String[] filePathColumn = { MediaStore.Images.Media.DATA };
  
  Cursor cursor = mContext.getContentResolver().query( selectedImage, filePathColumn, null, null, null );
  cursor.moveToFirst();
  
  int columnIndex = cursor.getColumnIndex( filePathColumn[0] );
  String filePath = cursor.getString( columnIndex );
  cursor.close();
  
  // Cursor: /mnt/sdcard/Pic.jpg : /mnt/sdcard/Pic.jpg
  U.log( "Cursor: " + filePath + " : " + Uri.parse( filePath ) );
  
  // "regular" 
  
  // Regular: content://media/external/images/media/28 : content://media/external/images/media/28
  U.log( "Regular: " + data.getDataString() + " : " + Uri.parse( data.getDataString() ) );
  
  // Regular 2: content://media/external/images/media/28 : content://media/external/images/media/28
  U.log( "Regular 2: " + data.getData() + " : " + data.getData() );
  
  
  mPostImagePreview.setImageBitmap( BitmapFactory.decodeFile( filePath ) );
  mPostImagePreview.setVisibility( View.VISIBLE );
  </code></pre>
  
  <p>They still set the wrong image. If I go into the Gallery, long press the image, and view its details I get:</p>
  
  <pre><code>TItle: Pic
  Time: May 2, 2012
  Width: 720
  Height: 1280
  Orientation: 0
  File size: 757KB
  Maker: Abso Camera
  Model: Inspire 4G
  Path: /mnt/sdcard/Pic.jpg
  </code></pre>
  
  <p>So, the Gallery is telling me the path is the same as the pick action, and the Gallery is rendering it correctly. So why on earth is it not rendering if I set it from onActivityResult?</p>
  
  <p>Also, this is the code I'm using to fire the Intent now:</p>
  
  <pre><code>private void selectPhoto()
  {
    Intent intent = new Intent( Intent.ACTION_GET_CONTENT );
    intent.setType( "image/*" );
    ( ( Activity )mContext ).startActivityForResult( Intent.createChooser( intent, "Select Picture" ), PHOTO_GALLERY );
  }
  </code></pre>