Google ドライブ PDF ビューアーなどの他のリーダー アプリケーションを使用して、アプリから PDF またはテキスト ファイルを開こうとしていますが、次のエラーが表示されます。
java.lang.SecurityException: Permission Denial: opening provider com.my.app.provider.GenericFileProvider from ProcessRecord{87fdcbb 31761:com.google.android.apps.docs/u0a37} (pid=31761, uid=10037) that is not exported from uid 10081
マニフェスト ファイル:
<provider
android:name="com.my.app.provider.GenericFileProvider"
android:authorities="${applicationId}.my.package.name.provider"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/provider_paths"/>
</provider>
provider_paths ファイル:
<paths xmlns:android="http://schemas.android.com/apk/res/android">
<external-path name="external_files" path="."/>
</paths>
コード:
Intent intent = new Intent(Intent.ACTION_VIEW);
String mimeType = myMime.getMimeTypeFromExtension(ChatAdapterHelper.Document.getDocumentExtension(message.content));
String authority = AppContext.getAccess().getContext().getPackageName() + ".my.package.name.provider";
Uri fileUri = GenericFileProvider.getUriForFile(AppContext.getAccess().getContext(), authority, file);
Log.d("fileUri", "openDocument: fileUri " + fileUri);
intent.setDataAndType(fileUri, mimeType);
Intent chooser = Intent.createChooser(intent, context.getString(R.string.open_file_with));
chooser.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
chooser.setFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
chooser.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
AppContext.getAccess().getContext().startActivity(chooser);
SDK のバージョン:
minSdkVersion 16
targetSdkVersion 27
Android 開発者の Web サイトや他のフォーラムの投稿で説明されているコンテンツ プロバイダーを使用する手順に従おうとしていますが、何が問題なのかわかりません!