標籤:putextra style view 參數 image sha open package ref
原文連結:http://bbs.wps.cn/thread-22349340-1-1.html
從V5.1版本開始,WPS移動版本提供了額外的功能,可以供第三方程式通過整合的方式調用“WPS移動版”開啟檔案,開啟的檔案儲存和關閉時第三方也可接收到廣播通知。 通過此介面,開發人員可以實現通過某程式開啟office文檔時,直接進入閱讀模式,同時退出後,會將閱讀進度返回給該程式,這樣下次再閱讀時可以從上次閱讀的位置繼續閱讀。以下是具體介面使用說明和注意事項。
【開啟檔案】 調用startActivity 開啟, 具體如下: boolean openFile(String path) { Intent intent = new Intent(); Bundle bundle = new Bundle(); bundle.putString(OPEN_MODE, READ_ONLY); bundle.putBoolean(SEND_CLOSE_BROAD, true); bundle.putString(THIRD_PACKAGE, selfPackageName); bundle.putBoolean(CLEAR_BUFFER, true); bundle.putBoolean(CLEAR_TRACE, true); //bundle.putBoolean(CLEAR_FILE, true); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); intent.setAction(android.content.Intent.ACTION_VIEW); intent.setClassName(packageName, className); File file = new File(path); if (file == null || !file.exists()) { return false; } Uri uri = Uri.fromFile(file); intent.setData(uri); intent.putExtras(bundle); try { startActivity(intent); } catch (ActivityNotFoundException e) { e.printStackTrace(); return false; } return true; } 其中className為“cn.wps.moffice.documentmanager.PreStartActivity2”,packageName根據版本分別為: ”cn.wps.moffice_eng”(普通版),”cn.wps.moffice_eng”(英文版)。要開啟的檔案通過Uri傳入,其它要傳入參數詳見下表:
“OpenMode”目前支援以下幾種方式:
【儲存檔案】 檔案儲存時會發送一個"cn.wps.moffice.file.save"的廣播,第三方程式根據需要接聽廣播。廣播含有檔案的路徑資訊,開啟檔案時傳遞的包名等,使用時酌情解析,具體見下表:
【關閉檔案】 檔案關閉時會發送一個"cn.wps.moffice.file.close"的廣播,第三方程式根據需要接聽廣播。廣播含有檔案的路徑資訊,開啟檔案時傳遞的包名等,使用時酌情解析,具體見下表:
具體可以參考附件的例子testThirdInterface
|
<ignore_js_op>
-
支援方式.JPG (20.75 KB, 下載次數: 1132)
<ignore_js_op>
-
儲存檔案.JPG (19.68 KB, 下載次數: 1132)
<ignore_js_op>
-
open file.JPG (78.29 KB, 下載次數: 916)
<ignore_js_op>
-
關閉檔案.JPG (35.16 KB, 下載次數: 945)
<ignore_js_op>
-
testThirdInterface.rar
45.21 KB, 下載次數: 2296
WPS Office手機版調用介面代碼指導帖之二 [複製連結]