title: Permissions on Android M when sharing Data to other apps
body: <p>It seems that sharing data to other apps on Android M is only possible when the other app has manually asked for READ_EXTERNAL_STORAGE permission, and I am wondering if anyone knows a way around this without manually opening all apps I can share to and selecting Storage permission.</p>
  <p>For example I have the following Intent to share some data:</p>
  <pre><code>  Intent shareIntent = new Intent(Intent.ACTION_SEND);
    shareIntent.setType(&quot;image/*&quot;);
    shareIntent.putExtra(Intent.EXTRA_SUBJECT, &quot;Some Image Subject&quot;);
    shareIntent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(someFile));
    startActivity(Intent.createChooser(shareIntent, &quot;Share via...&quot;));
  </code></pre>
  <p>Assume <code>someFile</code> exists and that i have already followed the recommended Runtime Permission model suggested at <a href="http://developer.android.com/training/permissions/requesting.html" rel="noreferrer">http://developer.android.com/training/permissions/requesting.html</a> and the user has agreed to allowing my Permission, so the File was in fact created on the system.</p>
  <p>Is there a way to tell the Application I am sharing to, that I have granted this permission to my user can you please grant this on my behalf?</p>
  <p>This does not work :</p>
  <pre><code>  shareIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
  </code></pre>
  <p>According to the documentation:</p>
  <blockquote>
  <p>int   FLAG_GRANT_READ_URI_PERMISSION</p>
  <p>If set, the recipient of this Intent will be granted permission to perform read operations on the URI in the Intent's data and any URIs specified in its ClipData.</p>
  </blockquote>
  <p>And even more interesting that if this flag is set and i share to Gmail, the flag is not detected and Google does not prompt to request the permission but rather just catches the Exception and does not attach my file.</p>
  <p>Any help would be appreciated.</p>