-
Notifications
You must be signed in to change notification settings - Fork 1.9k
FilePicker doesn't take into account IsExternalStorageManager #6015
Description
Description
When using FilePicker with the permissions: https://developer.android.com/training/data-storage/manage-all-files, I still get a cached file copy rather than the original file path.
My use case is that I am building a document editor and need an easy way to read and write files anywhere on the device file system.
My original issue that this stems from: #4195
My work around: #6004
Steps to Reproduce
Give your application MANAGE_EXTERNAL_STORAGE permissions, as well as special intent: ACTION_MANAGE_ALL_FILES_ACCESS_PERMISSION by going into Android settings -> Application Permissions -> Special App Access -> All Files Access -> Enable
Then open the MAUI.Essentials.FilePicker and select a file. The file path returned will be a cached copy.
Version with bug
RC1
Last version that worked well
Unknown/Other
Affected platforms
Android
Affected platform versions
Android 11 - API 30
Did you find any workaround?
I have managed to work around the issue by creating platform specific file handling, and on android, Im calling the android API directly:
var currentActivity = Platform.CurrentActivity;
// Makes sure the app has ACTION_MANAGE_ALL_FILES_ACCESS_PERMISSION before trying to read the file.
if (!Environment.IsExternalStorageManager)
{
var uri = Uri.Parse($"package:{Application.Context?.ApplicationInfo?.PackageName}");
var permissionIntent = new Intent(Settings.ActionManageAppAllFilesAccessPermission, uri);
currentActivity.StartActivity(permissionIntent);
}
var intent = new Intent(Intent.ActionOpenDocument);
intent.AddCategory(Intent.CategoryOpenable);
intent.SetType("application/json");
intent.PutExtra(DocumentsContract.ExtraInitialUri, MediaStore.Downloads.ExternalContentUri);
currentActivity.StartActivityForResult(intent, 1);And then using the System.IO.File API to write data back to the path returned by the android file select activity.
Relevant log output
No response

