Android implementation calls WPS Office Phone Edition interface

Source: Internet
Author: User

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.

Use intent to open WPS as follows:

BooleanopenFile (String path) {Intent Intent=NewIntent (); Bundle Bundle=NewBundle ();                 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=NewFile (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; }

The save file file is saved with a "Cn.wps.moffice.file.save" broadcast, and a 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:

"Parameter description"

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"

"Open File"

"Close File"

Original address: http://bbs.wps.cn/thread-22349340-1-1.html

Android implementation calls WPS Office Phone Edition interface

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.