Set Home| Set Favorite|

WPS Office Forum

 Forgot password?
 Register
Search
View: 9060|Reply: 3

Codes for calling Kingsoft Office to Open files(2)

[ Promote this link! ]
Post time: 2012-11-06 04:41:24
| Show all posts |!read_mode!
Edited by bonnie at 2012-11-06 04:51

From Kingsoft Office V5.1 we have provided the additional functionality. The third-party programs can call the “Kingsoft Office” to open files by the integrated manner. Also when saving or closing files, the third-party programs can receive broadcast notification. The following are instructions and precautions.

Open File
Call the “starActivity” to open:

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.PreStartActivity”
* packageName: “cn.wps.moffice_eng”

The file which will be opened is sent by Uri. Other parameter descriptions are as follows:
2-1.PNG

Save File
It will send a “cn.wps.moffice.file.save” broadcast when saving files, and the third-party program can receive the broadcast according to the need.
2-2.PNG

Close File
It will send a “cn.wps.moffice.file.save” broadcast when closing files, and the third-party program can receive the broadcast according to the need.
2-3.PNG

Example: testThirdInterface.rar (123.89 KB, Downloads: 589)
Reply

Use magic Report

Post time: 2012-12-06 14:09:55
| Show all posts
Hi,

I have tried to use the example all works fine but my application end up without read permissions on the file...

In both BroadcastReceiver I have added :

File file = new File(fileName);
                                       
if(file.canRead())
        strLog += "status: can read!!";
else
        strLog += "status: CAN'T read!!";

and in both cases save/close my app has no access to the file so I can't save the
file to the server ...

Thanks,

Post time: 2014-02-14 16:52:31
| Show all posts
版主在中文版论坛里面怎么不好好写呢,这里的demo不能下载,中文版论坛只有apk,让我们怎么过啊
Post time: 2014-02-15 14:23:49
| Show all posts
好吧,我已经把程序反编译了
You have to log in before you can reply Login | Register

Points Rules

Dark room|Mobile|Archiver|WPS Office   

2019-01-21 21:00 GMT+8 , !processed_in! 0.080432 !seconds!, 18 !queries! .

Powered by Discuz! X3.2

Release 20151208, © 2001-2019 Comsenz Inc.

MultiLingual version, Rev. 469, © 2009-2019 codersclub.org

!fastreply! To Top !return_list!