title: Intent recieved from action send generates SecurityException on URI
body: <p>I'm trying to accept images with my app to send them to a server. Setting up the intent filter was easy enough and that works like a charm. The thing i can't seem to figure out is the way i need to retrieve the file path from the uri in the intent.</p>
  
  <p>I receive intents on my activity with this filter</p>
  
  <pre><code>&lt;intent-filter&gt;
     &lt;action android:name="android.intent.action.SEND" /&gt;
     &lt;action android:name="android.intent.action.SEND_MULTIPLE" /&gt;
     &lt;category android:name="android.intent.category.DEFAULT" /&gt;
     &lt;data android:mimeType="image/jpeg" /&gt;
     &lt;data android:mimeType="image/png" /&gt;
     &lt;data android:mimeType="image/gif" /&gt; 
  &lt;/intent-filter&gt;
  </code></pre>
  
  <p>By trying to process the uri to get the file path I get this error by calling takePersistableUriPermission(uri, modeFlags):</p>
  
  <pre><code>java.lang.SecurityException: No persistable permission grants found for UID 10098 and Uri 0 @ content://media/external/images/media/124
  </code></pre>
  
  <p>The logic I use works for requesting images with an intent from inside my app, but receiving an intent from outside the app generates the error.</p>
  
  <p>for Kitkat and above: </p>
  
  <pre><code>   final int flags = data.getFlags() &amp; (Intent.FLAG_GRANT_READ_URI_PERMISSION | Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
     final String[] imageColumns = {MediaStore.Images.Media.DATA};
     getActivity().getContentResolver().takePersistableUriPermission(uri, flags);
     String id = uri.getLastPathSegment().split(":")[1]; 
     Cursor imageCursor = context.managedQuery(getStorageUri(), imageColumns, MediaStore.Images.Media._ID + "=" + id, null, null);
  </code></pre>