私はアンドロイドFileProviderに関する質問があります。 私はpdf文書を保存し、それをデフォルトのプログラムで開きたいと思います。 外部ストレージに保存したくありません。Android Fileprovider:IllegalArgumentException:含まれている構成済みルートを見つけることができませんでした
FileDirectory/export/temp.pdfにpdfを保存した後、
FileProvider.getUriForFile()を使用してURIを生成しようとしました。
File path = new File(getFilesDir(), "export");
File pdf = new File(path + File.separator + "temp.pdf");
pdf.getParentFile().mkdirs();
if (!pdf.exists())
pdf.createNewFile();
Uri uri = FileProvider.getUriForFile(getApplicationContext(), "?", pdf);
質問:私は「権威」2番目のパラメータとして渡すために何を持っていない - 私のファイルの場所、URI-権限を付与するか、他の何かできるクラス?私が何をしようとしたとしても、IllegalArgumentExceptionまたはNullPointerExceptionが発生しました。 マイFileProvider(XML):
<provider
android:name="android.support.v4.content.FileProvider"
android:authorities="com.example.myApp.myActivity"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/file_path"/>
</provider>
参照ファイル:
<?xml version="1.0" encoding="utf-8"?>
<paths xmlns:android="http://schemas.android.com/apk/res/android">
<cache-path name="pdfTemplates" path="export/" />
</paths>
私は全く同じ問題があります。あなたはまだ答えを見つけましたか? –