Starting with the V5.1 version, the WPS Mobile version provides additional functionality that can be used by third-party programs to open files in an integrated way by invoking "WPS Mobile", and third parties can also receive broadcast notifications when open files are saved and closed.
Through this interface, developers can open Office documents through a program, directly into the reading mode, while exiting, will return the reading progress to the program, so the next time you read, you can continue to read from the last location. The following are specific interface usage instructions and considerations.
"Open File"
Call StartActivity Open, as follows:
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;
}
Where classname is "Cn.wps.moffice.documentmanager.PreStartActivity2", PackageName according to the version: "Cn.wps.moffice_eng"(normal edition)," Cn.wps.moffice_eng "(English version). The file to be opened is passed through the URI, and the other parameters to be passed are described in the following table:
"OpenMode" is currently supported in the following ways:
"Save File"When the file is saved, a "Cn.wps.moffice.file.save" broadcast is sent, and the third-party program listens to the broadcast as needed. The broadcast contains the path information of the file, the package name that is passed when the file is opened, and so on, when used as appropriate, as shown in the following table:
"Close File"
When the file is closed, a "cn.wps.moffice.file.close" broadcast is sent, and the third-party program listens to the broadcast as needed. The broadcast contains the path information of the file, the package name that is passed when the file is opened, and so on, when used as appropriate, as shown in the following table:
for details, refer to the attachment example Testthirdinterface
|