I have files in a user folder in internal storage. I need to open files using an external application such as Adobe. I planned to open using FileProvider. However, a third-party application stops trying to open a document. I really don't know what mistake I made in the code.
package name = "com.example.doc"
actions are in package = "com.example.doc.activities"
manifest
<provider android:name="android.support.v4.content.FileProvider" android:authorities="com.example.doc.fileprovider" android:exported="false" android:grantUriPermissions="true" android:readPermission="com.example.doc.fileprovider.READ"> <meta-data android:name="android.support.FILE_PROVIDER_PATHS" android:resource="@xml/filepath" /> </provider>
Res /XML/filepath.xml
<?xml version="1.0" encoding="utf-8"?> <paths xmlns:android="http://schemas.android.com/apk/res/android"> <files-path name="files" path="." /> </paths>
activity
//tempfilePath = /data/data/com.example.doc/files/RBC/sample.docx File file = new File(tempfilePath); Uri exportUri = FileProvider.getUriForFile (this, "com.example.doc.fileprovider", file); Intent docViewIntent = new Intent(); docViewIntent.setAction(Intent.ACTION_VIEW); docViewIntent.setDataAndType(exportUri , extensionType); docViewIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION | Intent.FLAG_GRANT_WRITE_URI_PERMISSION); docViewIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(docViewIntent);
Do I need to specify any permission in the manifest?
Any help would be appreciated.
Thanks Jomia
source share