Android activity with intent action.SEND gets uri which cannot be open?
<p>Activity is defined as:</p>

<pre><code>    &lt;activity android:name="com.tralev.android.UploadFromCameraAppActivity" android:exported="true"&gt;
        &lt;intent-filter&gt;
            &lt;action android:name="android.intent.action.SEND" /&gt;
            &lt;category android:name="android.intent.category.DEFAULT" /&gt;
            &lt;data android:mimeType="image/*" /&gt;
        &lt;/intent-filter&gt;
    &lt;/activity&gt;
</code></pre>

<p>UploadFromCameraAppActivity is trying to get URI:</p>

<pre><code>Uri uri = (Uri) extras.getParcelable(Intent.EXTRA_STREAM);
String filename = uri.getPath();
</code></pre>

<p>But when trying to open that filename I get exception: </p>

<p>03-12 23:10:30.787: W/System.err(9840): java.io.FileNotFoundException: /external/images/media/2437: open failed: ENOENT (No such file or directory)</p>

<p>Note: This happens on Nexus 7 which I'm using to test.</p>

<p>SOLVED: This problem is solved using</p>

<pre><code>public String getRealPathFromURI(Uri contentUri) {
  String[] proj = { MediaStore.Images.Media.DATA };
  Cursor cursor = getContentResolver().query(contentUri, proj, null, null, null);
  int column_index = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
  cursor.moveToFirst();
  return cursor.getString(column_index);
}
</code></pre>
