[英]How do I open a Word Document as an Editable file using an Intent on Android?
我正在嘗試使用Intent在Android上的Word中打開docx文件,但它始終會打開“只讀”(Word會提示說它是只讀的)。
該文件在其他可以編輯docx的應用程序中是讀寫的(例如WPS Office)。 問題只有Microsoft Word。
String fileUrl = "/storage/emulated/0/Download/test.docx";
File file = new File(fileUrl);
String mime = "application/vnd.openxmlformats-officedocument.wordprocessingml.document";
Uri theUri = FileProvider.getUriForFile(this,
"com.example.testint.fileprovider",
file);
Intent intent = new Intent();
intent.setAction(android.content.Intent.ACTION_VIEW);
intent.addFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION | Intent.FLAG_GRANT_READ_URI_PERMISSION | Intent.FLAG_GRANT_PERSISTABLE_URI_PERMISSION);
intent.setDataAndType(theUri, mime);
startActivity(intent);
我已經與其他幾個應用程序進行了意圖攔截。 ASUS文件管理器和ASTRO文件管理器以及文件管理器1.36都能夠使用content://以讀/寫方式打開Word文檔,並且沒有只讀問題。 這些意圖看起來與我的意圖相同,所以我看不到它們如何工作,而實際上卻不行。
這是從華碩文件管理器:
intent://com.asus.filemanager.OpenFileProvider/file/sdcard/Documents/Test.docx#Intent;scheme=content;type=application/vnd.openxmlformats-officedocument.wordprocessingml.document;launchFlags=0x3000000;end
------------
ACTION: android.intent.action.VIEW
DATA: content://com.asus.filemanager.OpenFileProvider/file/sdcard/Documents/Test.docx
MIME: application/vnd.openxmlformats-officedocument.wordprocessingml.document
URI: intent://com.asus.filemanager.OpenFileProvider/file/sdcard/Documents/Test.docx#Intent;scheme=content;type=application/vnd.openxmlformats-officedocument.wordprocessingml.document;launchFlags=0x3000000;end
FLAGS:
FLAG_ACTIVITY_FORWARD_RESULT
FLAG_ACTIVITY_PREVIOUS_IS_TOP
這里是否還有其他人設法打開Word文檔進行讀寫?
您可以使用舊文件格式,例如file:///storage/emulated/0/Android/data/.../hello.docx
或內容提供商,例如content://org.cryptomator.fileprovider/external_files/Android/data/org.cryptomator/cache/decrypted/hallo.docx
但該文件不允許位於應用程序的內部存儲中。 然后文件是可寫的!
帶有.doc
擴展名的文件不可寫,或者位於內部存儲中的文件也不可寫。 在這里您可以找到簡短的概述: https : //github.com/cryptomator/cryptomator-android/issues/150#issuecomment-514401775
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.