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>