1

I'm trying to make an app that opens files in PDF format. I got stuck because when I click on a file and select my app to open them with, the URI I get through the Intent cannot be converted to an InputStream. Below is my code:

        Uri uri = getIntent().getData();
        try {
            pdfView.fromStream(getContentResolver().openInputStream(uri))
                    .load();
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        }

The URI I get when debugging looks like this:

content://com.mi.android.globalFileexplorer.myprovider/external_files/Download/3E-Summatif-C%CC%A7%C4%B1km%C4%B1s%CC%A7-Birles%CC%A7tirilmis%CC%A7.pdf

and I get this error:

Permission Denial: opening provider com.android.fileexplorer.provider.FileExplorerFileProvider from ProcessRecord{897bfb1 6648:com.example.pdfviewer/u0a585} (pid=6648, uid=10585) that is not exported from UID 10151

The compile SDK version is 29. Thank you in advance!

EDIT: The intent-filter of the redirected activity looks like the following:

<activity android:exported="true"
            android:name=".PdfActivity">

            <intent-filter>
                <action android:name="android.intent.action.VIEW"/>
                <category android:name="android.intent.category.DEFAULT"/>
                <category android:name="android.intent.category.BROWSABLE"/>
                <data
                    android:scheme="content"
                    android:mimeType="application/pdf"
                    android:pathPattern=".*\\.pdf" />

            </intent-filter>

            <intent-filter>
                <data android:scheme="file"
                    android:mimeType="*/*"
                    android:pathPattern=".*\\.pdf "
                    android:host="*"/>

                <action android:name="android.intent.action.VIEW" />

                <category android:name="android.intent.category.DEFAULT" />
                <category android:name="android.intent.category.BROWSABLE" />
            </intent-filter>

        </activity>
melihozcann
  • 403
  • 1
  • 4
  • 9
  • refer https://stackoverflow.com/questions/24467696/android-file-provider-permission-denial – sasikumar Jan 31 '22 at 04:38
  • I saw that thread, the problem is the app that calls my app is not one that I wrote, it is the file manager or another program such as WhatsApp. @sasikumar – melihozcann Jan 31 '22 at 09:14
  • `com.mi.android.globalFileexplorer.myprovider` Please tell which app delivers this uri as i find it pretty strange that `myprovider` would be used in an Android filemanager. Further: How can that uri and specially the autority change to `com.android.fileexplorer.provider.FileExplorerFileProvider` ? Pretty strange. – blackapps Jan 31 '22 at 12:38
  • I tried to click on a PDF file using File Manager by MIUI and I got error above. When I clicked on a PDF file on WhatsApp the URI changed to this: `content://com.whatsapp.provider.media/item/9624f82c-2a14-4a7d-8d3a-eddaf5508135.`. and the error changed to this: `Permission Denial: opening provider com.whatsapp.contentprovider.MediaProvider` – melihozcann Jan 31 '22 at 13:17

0 Answers0