title: Impossible to get ContentResolver.openInputStream(Uri uri) in the app with targetSdk 29 and compileSdk 29 on the device with API 29
body: <p>I have two apps running on <strong>Android 10 (API 29)</strong> device. From the first app (&quot;sender&quot;) I send a picture <code>uri</code> of a <code>jpg</code> file placed on the phone file system:</p>
  <pre><code>Intent intent = new Intent(Intent.ACTION_VIEW);        
  intent.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); 
  String mimeType = AppUtils.getFileMimeType(uri, context);
  intent.setDataAndType(uri, &quot;image/jpeg&quot;);
  if (intent.resolveActivity(context.getPackageManager()) != null)
      context.startActivity(Intent.createChooser(intent, &quot;Open with&quot;));
  </code></pre>
  <p>In the second app (&quot;receiver&quot;) I try to open <code>InputStream</code> from above <code>uri</code>:</p>
  <pre><code>context.getContentResolver().openInputStream(uri);
  </code></pre>
  <p>and get this exception as a result:</p>
  <pre><code>java.lang.SecurityException: Permission Denial: reading com.android.externalstorage.ExternalStorageProvider uri content://com.android.externalstorage.documents/tree/primary%3AMovies%2FNew/document/primary%3AMovies%2FNew%2FPanorama.jpg from pid=30753, uid=10487 requires that you obtain access using ACTION_OPEN_DOCUMENT or related APIs
      at android.os.Parcel.createException(Parcel.java:2071)
      at android.os.Parcel.readException(Parcel.java:2039)
      at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:188)
      at android.database.DatabaseUtils.readExceptionWithFileNotFoundExceptionFromParcel(DatabaseUtils.java:151)
      at android.content.ContentProviderProxy.openTypedAssetFile(ContentProviderNative.java:705)
      at android.content.ContentResolver.openTypedAssetFileDescriptor(ContentResolver.java:1687)
      at android.content.ContentResolver.openAssetFileDescriptor(ContentResolver.java:1503)
      at android.content.ContentResolver.openInputStream(ContentResolver.java:1187)
  </code></pre>
  <p>There is no problem if these two apps running on <strong>Android 9 (API 28)</strong> device. What is changed on <strong>Android 10 (API 29)</strong> regarding access thru <code>Intent.ACTION_VIEW</code> and <code>ContentResolver.openInputStream</code> to an <code>uri</code> from third party apps!?</p>
  <p>&quot;Sender&quot; app has</p>
  <pre><code>compileSdkVersion 30
  targetSdkVersion 30
  </code></pre>
  <p>&quot;Receiver&quot; app has</p>
  <pre><code>compileSdkVersion 29
  targetSdkVersion 29
  </code></pre>
  <p>and <code>android:requestLegacyExternalStorage=&quot;true&quot;</code> in the <code>Manifest</code>.</p>