title: createChooser() intent exception "requires the provider be exported, or grantUriPermission()"
body: <p>The app needs to share a PDF file stored in the root of the cacheDir with other apps. The issue is seen on Android 12, possibly other versions too.</p>
  <p>Manifest:</p>
  <pre><code>    &lt;provider
          android:name=&quot;androidx.core.content.FileProvider&quot;
          android:authorities=&quot;${applicationId}.provider&quot;
          android:exported=&quot;false&quot;
          android:grantUriPermissions=&quot;true&quot;&gt;
          &lt;meta-data
              android:name=&quot;android.support.FILE_PROVIDER_PATHS&quot;
              android:resource=&quot;@xml/file_paths&quot; /&gt;
      &lt;/provider&gt;
  </code></pre>
  <p>Provider paths:</p>
  <pre><code>&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
  &lt;paths&gt;
      &lt;cache-path name=&quot;cache&quot; path=&quot;.&quot; /&gt;
  &lt;/paths&gt;
  </code></pre>
  <p>Intent:</p>
  <pre><code>        val pdfFile = File(requireContext().cacheDir, pdfFileName)
          val fileUri: Uri = FileProvider.getUriForFile(
              requireContext().applicationContext,
              requireContext().packageName.toString() + &quot;.provider&quot;,
              pdfFile
          )
          val intent = Intent()
          intent.action = Intent.ACTION_SEND
          intent.putExtra(Intent.EXTRA_STREAM, fileUri)
          intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION)
          intent.type = &quot;application/pdf&quot;
          startActivity(Intent.createChooser(intent, &quot;Share Document&quot;))
  </code></pre>
  <p>The share sheet successfully opens but this exception always shows at that point and subsequently sharing to another app fails.</p>
  <pre><code>Writing exception to parcel
      java.lang.SecurityException: Permission Denial: reading 
  androidx.core.content.FileProvider uri
  content://uk.co.packagename.provider/cache/8BEDF7212-0DE46-42B0-9FA9-32C434BDD2F3HO.pdf
  from pid=15363, uid=1000 requires the provider be exported, or grantUriPermission()
  </code></pre>
  <p>The provider as a whole cannot be exported and the URI permission appears to already be granted. I've read through the Android file sharing docs and many S/O answers but I cannot see what needs correcting, can you?</p>