Here is the intent I use to open a word file:
Intent intent = new Intent();
intent.setAction(Intent.ACTION_EDIT);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.setDataAndType(fileUri, MimeTypeMap.getSingleton().getFileExtensionFromUrl(fileUri));
intent.addFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
mContext.startActivity(intent);
I feth the fileUri
using this line:
FileProvider.getUriForFile(context, "my authority", file);
File is opened correctly in both Microsoft word app and OfficeSuite app, but in both apps, the file is in read only mode and I cannot edit the file directly. When I open that word file with a file manager app like ES File Explorer, the file is in read write mode and edit is enabled.
I tried both ACTION_VIEW
and ACTION_EDIT
and the same happened.