How android calls WPS to display work files

Source: Internet
Author: User

How android calls WPS to display work files

 

 

The following is a sample code for opening a document using the WPS Chinese edition (the package names of different WPS languages are slightly different. Please note the red part ):

 

<Open a file>

 

Open startActivity by calling: boolean openFile (String path) {Intent intent = new Intent (); Bundle bundle = new Bundle ();
// Set requirements based on different situations
// The following budle is the bundle that controls the scenario. 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 ;}

In this example, classnameis “cn.wps.moffice.doc umentmanager. PreStartActivity2 ", and packageName is" cn. wps. moffice_eng "(Basic edition) and" cn. wps. moffice_eng "(English version ). The file to be opened is passed in through Uri. For other parameters to be passed in, see the following table:

 

 

 

[Save file] a broadcast of cn. wps. moffice. file. save is sent when the file is saved. A third-party program receives the broadcast as needed. Broadcast the path information of the file, the package name that is passed when the file is opened, and parse it as needed. The details are shown in the following table:

Close a file]
When the file is closed, a broadcast of cn. wps. moffice. file. close will be sent, and a third-party program will answer the broadcast as needed. Broadcast the path information of the file, the package name that is passed when the file is opened, and parse it as needed. The details are shown in the following table:

 

Supported Methods

Close file

Save files

 

Open a file

 

 

 

 

 

 

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.