java.lang.SecurityException: Permission Denial: opening provider
<p>I start image picker intent using:</p>

<pre><code>final Intent pickIntent = new Intent(Intent.ACTION_PICK, MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
pickIntent.putExtra(Intent.EXTRA_ALLOW_MULTIPLE, true);
startActivityForResult(intent, PICK_IMAGE);
</code></pre>

<p>and in <code>onActivityResult()</code> I get uris of all picked images and start Jobs which run in background and upload those images (<a href="https://github.com/yigit/android-priority-jobqueue" rel="noreferrer">https://github.com/yigit/android-priority-jobqueue</a>). But if I press back button and exit out of activity then any job that was not started, can't access picked image when it runs and throws an exception:</p>

<blockquote>
  <p>java.lang.SecurityException: Permission Denial: opening provider com.google.android.apps.photos.contentprovider.MediaContentProvider from ProcessRecord{...} (pid=2407, uid=10117) that is not exported from uid 10123</p>
</blockquote>

<p>The reason its happening is because permission is revoked once activity is finished. According to doc <a href="https://developer.android.com/guide/topics/providers/content-provider-basics.html" rel="noreferrer">https://developer.android.com/guide/topics/providers/content-provider-basics.html</a>:</p>

<blockquote>
  <p>These are permissions for a specific content URI that last until the activity that receives them is finished.</p>
</blockquote>

<p>My question is, is there a workaround to this? Like getting permission at application level or something?</p>

<p>What are alternates to solve this problem? One quick solutions seems to be making a copy of all picked images and then uploading them but that seems like last resort.</p>