使用Android文件提供程序时,尽管在intent中标记了FLAG_GRANT_WRITE_URI_PERMISSION,但文件没有正确的权限

我正在尝试使用Microsoft Word和PDF查看器从我的应用程序中的文件加载文档,我正在使用FileProvider处理Android 7.0+,不允许文件URI自由传递。 我得到这样的URI并设置Intent标志以允许在打开它之前进行读写,如下所示:

// From the byte array create a file containing that data, and get extension and MIME type. File fileToOpen = byteArrayToFile(documentData, shortFileName); String fileExtension = UtilityMethods.getFileExtension(fileToOpen.getName()); String mime = MimeTypeMap.getSingleton().getMimeTypeFromExtension(fileExtension); // Get the Uri for the file from the file provider, open using intent. Uri documentUri = FileProvider.getUriForFile(getContext(), "com.mycompany.provider", fileToOpen); Intent intent = new Intent(); intent.setDataAndType(documentUri, mime); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); intent.addFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION); intent.setAction(Intent.ACTION_VIEW); startActivity(intent); 

但是,当文件在MS Word中加载时,该文件是只读的,并且无法编辑,这不是所需的行为。 我哪里错了?