How Android calls WPS to display working files

Source: Internet
Author: User


Reference: http://bbs.wps.cn/thread-22327642-1-1.html


The following is a code example that specifies that the document be opened using the WPS Chinese version (WPS differs slightly from the language version of the package, please note the Red Mark section):


< open File >

Call StartActivity Open, as follows: Boolean openFile (String path)     {             Intent Intent = new Intent ();                 Bundle bundle = new bundle ();
<span style= "White-space:pre" ></span>//set requirements according to different circumstances
<span style= "White-space:pre" ></span>//the following budle are control scenarios 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:


"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:

Support Mode


Close File

Save File



Open File






To provide you with a Demo:Android_WPS.rar




How Android calls WPS to display working files

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.