Android Office / Word - App ignoring FileProvider Permissions

33 Views Asked by At

My Xamarin-Forms-Android App (targetSDK 33 minSdk 21) is using a Custom FileProvider to edit Files (.docx) in other Apps.

I've Inserted the FileProvider in the AndroidManifest.xml

<application android:label="My App" android:icon="@drawable/app_icon" android:requestLegacyExternalStorage="true">
<provider android:name="androidx.core.content.FileProvider" android:authorities="com.myapp.android.fileprovider" android:exported="false" android:grantUriPermissions="true">
<meta-data android:name="android.support.FILE_PROVIDER_PATHS" android:resource="@xml/file_paths" />
</provider>

And inserted a file_paths.xml File in Resources\xml Directory:

<paths xmlns:android="http://schemas.android.com/apk/res/android">
  <cache-path name="export" path="export/" />
  <cache-path name="mail" path="mail/" />  
  <external-path name="external" path="/"/>
  <external-files-path name="external_files" path="/"/>
  <files-path name="files" path="/"/>
</paths>

Then I am starting an Intent with ActionEdit for the File Path

Context act = MainApplication.CurrentContext;
Java.IO.File file = new Java.IO.File("/storage/emulated/0/Android/data/com.myapp.android/files/Dokumente/983.docx");
Intent intent = new Intent(Intent.ActionEdit);
var uri = FileProvider.GetUriForFile(act, "com.myapp.android.fileprovider", file);
intent.SetDataAndType(uri, "application/vnd.openxmlformats-officedocument.wordprocessingml.document");
intent.SetFlags(ActivityFlags.GrantReadUriPermission | ActivityFlags.GrantWriteUriPermission | ActivityFlags.GrantPersistableUriPermission);
act.StartActivity(intent);

If I choose Google-Docs everything works fine, the file can be edited and saved.

But if I choose Microsoft Office-App or Word-App the file is opened readonly...even though I am logged in into my Micorsoft Account so it's no Licensing-Problem....

0

There are 0 best solutions below