Permission Denial while sharing file with FileProvider
Sorry about the late response. I solved it like this:
Intent chooser = Intent.createChooser(intentShareFile, "Share File");
List<ResolveInfo> resInfoList = this.getPackageManager().queryIntentActivities(chooser, PackageManager.MATCH_DEFAULT_ONLY);
for (ResolveInfo resolveInfo : resInfoList) {
String packageName = resolveInfo.activityInfo.packageName;
this.grantUriPermission(packageName, uri, Intent.FLAG_GRANT_WRITE_URI_PERMISSION | Intent.FLAG_GRANT_READ_URI_PERMISSION);
}
startActivity(chooser);
This helped me: Permission Denial with File Provider through intent
Android 10 - file provider - permission denial: reading android.support.v4.content.FileProvider uri
I finally worked it out. Tunes out my URI construction has some problems. I changed it to
Context context = getApplicationContext();
File filelocation = new File(getFilesDir(), fileName);
Uri path = FileProvider.getUriForFile(context, "com.example.charleschung.mci_pa1", filelocation);
And it works. Hope it helps :)
Related Topics
Bitmap Recycle with Largeheap Enabled
How to Encrypt File from Sd Card Using Aes in Android
Use a Custom Contextual Action Bar for Webview Text Selection
Android ==> Memory Analysing ==> Eclipse Memory Analyzer
Android Studio Fails to Debug with Error Org.Gradle.Process.Internal.Execexception
How to Create a Transparent Demo Screen for an Android App
How to Use Assert on Android Devices
How to Put Gridview Inside Scrollview
Error: "Adb Connection Error:An Existing Connection Was Forcibly Closed by the Remote Host"
Cursor Size Limit in Android SQLitedatabase
How to Implement a View Holder
How Does Push Notification Technology Work on Android
Using Viewpagerindicator Library with Android Studio and Gradle
Android Saving Created Bitmap to Directory on Sd Card
Gson Noclassdeffounderror After Adt and Sdk Tools Update to V17
How to Add a Library (Android-Support-V7-Appcompat) in Intellij Idea