fileprovider fails to open file with write permission
Description
hi, i'm building an app that download and store file inside the android file system (into a subfolder of /documents).
after downloading it i need to open selected file with the best aviable app (ex: if a file has .xlsx extension it should open with excel app) and into the app it should be able to modify and save in the same path.
the problem is that if my application target the sdk v33 the file opens but it remanin in what it seems read-only mode because if the user try to save the changes excel promt to the "save as" tab.
instead if my application target sdk less then 24 i could open the file without using the file provider (and it opens with write permission and i can save the changes).
whta i'm missing to use the 33sdk and the file provider?
Steps to Reproduce
Crate maui app
add this code to the androidmanifest:
<application android:allowBackup="true" android:icon="@mipmap/appicon" android:supportsRtl="true" android:usesCleartextTraffic="true" android:label="DimasiGestioneDocumentale">
<provider android:name="androidx.core.content.FileProvider" android:authorities="${applicationId}.provider" android:exported="false" android:grantUriPermissions="true">
<meta-data android:name="android.support.FILE_PROVIDER_PATHS" android:resource="@xml/provider_path" />
</provider>
</application>
- add the provider path file inside the android/resources/xml with this text:
<paths xmlns:android="
<external-path name="external_files" path="."/>
</paths>
- add a custom android service with the method:
public async void OpenFile(FileInfo fileInfo)
var fileUri = CustomFileProvider.GetUriForFile(Android.App.Application.Context, Android.App.Application.Context.PackageName + ".provider", file);
fileUri.BuildUpon().AppendQueryParameter("grant_read_uri_permission", "true").Build();
fileUri.BuildUpon().AppendQueryParameter("grant_write_uri_permission", "true").Build();
var intent = new Intent(Intent.ActionView);
intent.AddFlags(ActivityFlags.NewTask);
intent.AddFlags(ActivityFlags.GrantReadUriPermission | ActivityFlags.GrantWriteUriPermission);
string extension = MimeTypeMap.GetFileExtensionFromUrl(fileInfo.Name);
string mimeType = GetMimeType(extension);
intent.SetDataAndType(fileUri, mimeType);
Android.App.Application.Context.StartActivity(intent);
}