Я пытаюсь открыть PDF в этом месте - "/data/user/0/com.notes.taker/cache/engineering.pdf" на Android 8.1.
Но я получаюошибка как это - "не может отобразить pdf, файл не получен".Невозможно понять, что здесь не так.Любая помощь будет оценена.
Код намерения -
File file= new File(getApplicationContext().getCacheDir(), "engineering.pdf");
Uri path = FileProvider.getUriForFile(MainActivity.this, "com.mynotes.fileprovider", file);
Intent intent = new Intent();
intent.putExtra(Intent.ACTION_VIEW, path);
intent.setType("application/pdf");
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(intent);
Объявление AndroidManifest.xml для провайдера выглядит так:
<provider
tools:replace="android:authorities"
android:name="android.support.v4.content.FileProvider"
android:authorities="com.mynotes.fileprovider"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/file_paths" />
</provider>
И мой file_paths.xml таков -
<?xml version="1.0" encoding="utf-8"?>
<paths>
<files-path name="." path="/"/>
<external-path path="." name="external_storage_root" />
</paths>