提交 d3b1f7de 编写于 作者: E ester.zhou

update docs

Signed-off-by: Nester.zhou <ester.zhou@huawei.com>
上级 5efe02fd
# Getting Started with eTS in the Low-Code Approach # Getting Started with eTS in the Low-Code Approach
> ![icon-note.gif](public_sys-resources/icon-note.gif) **Note:** > ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**<br/>This feature is supported in DevEco Studio V3.0 Beta3 and later versions.
> This feature is supported in DevEco Studio V3.0 Beta3 and later versions.
> >
> The component lineup that supports low-code development in eTS is now at its preliminary stage and will be expanding in coming versions. > The component lineup that supports low-code development in eTS is now at its preliminary stage and will be expanding in coming versions.
> >
...@@ -21,7 +20,7 @@ You can develop applications or services in the low-code approach using either o ...@@ -21,7 +20,7 @@ You can develop applications or services in the low-code approach using either o
## Creating a Project That Supports Low-Code Development ## Creating a Project That Supports Low-Code Development
1. Open DevEco Studio, choose **File** &gt; **New** &gt; **Create Project**, select **Empty Ability**, and click **Next**. 1. In DevEco Studio, if no project is open, click **Create Project**; if a project is already open, choose **File** &gt; **New** &gt; **Create Project**. Then, select **Empty Ability** and click **Next**.
![en-us_image_0000001233528152](figures/en-us_image_0000001233528152.png) ![en-us_image_0000001233528152](figures/en-us_image_0000001233528152.png)
...@@ -50,26 +49,32 @@ After the project synchronization is complete, the default first page contains t ...@@ -50,26 +49,32 @@ After the project synchronization is complete, the default first page contains t
Add **Column**, **Text**, and **Button** components to the first page. A column is a container component whose child components are vertically arranged. For details, see [Column](../reference/arkui-ts/ts-container-column.md). Add **Column**, **Text**, and **Button** components to the first page. A column is a container component whose child components are vertically arranged. For details, see [Column](../reference/arkui-ts/ts-container-column.md).
1. Delete the existing template components from the canvas.<a name="delete_origin_content"></a> 1. Delete the existing template components from the canvas.<a name="delete_origin_content"></a>
Open the index.visual file, right-click the existing template components on the canvas, and choose **Delete** from the shortcut menu to delete them. Below is an illustration of the operations.
![en-us_image_0000001233208980](figures/en-us_image_0000001233208980.gif) Open the **index.visual** file, right-click the existing template components on the canvas, and choose **Delete** from the shortcut menu to delete them. Below is an illustration of the operations.
![en-us_image_0000001233208980](figures/en-us_image_0000001233208980.gif)
2. Add a **Column** component and set its styles and attributes.<a name="add_container"></a> 2. Add a **Column** component and set its styles and attributes.<a name="add_container"></a>
Drag the **Column** component from the **UI Control** area to the canvas. In the **Attributes &amp; Styles** area on the right, click ![en-us_image_0000001233048996](figures/en-us_image_0000001233048996.png)**General** and set **Height** to **100%** so that the component fills the entire screen. Click ![en-us_image_0000001233368860](figures/en-us_image_0000001233368860.png)**Feature** and set **AlignItems** to **center** so that the child components of the **Column** component are centered along the horizontal axis. Below is an illustration of the operations. Drag the **Column** component from the **UI Control** area to the canvas. In the **Attributes &amp; Styles** area on the right, click ![en-us_image_0000001233048996](figures/en-us_image_0000001233048996.png)**General** and set **Height** to **100%** so that the component fills the entire screen. Click ![en-us_image_0000001233368860](figures/en-us_image_0000001233368860.png)**Feature** and set **AlignItems** to **center** so that the child components of the **Column** component are centered along the horizontal axis. Below is an illustration of the operations.
![en-us_image_0000001277488977](figures/en-us_image_0000001277488977.gif) ![en-us_image_0000001277488977](figures/en-us_image_0000001277488977.gif)
3. Add a **Text** component. 3. Add a **Text** component.
Drag the **Text** component from the **UI Control** area to the canvas and then to the center area of the **Column** component. In the **Attributes &amp; Styles** area, click ![en-us_image_0000001277608813](figures/en-us_image_0000001277608813.png)**Feature**, set **Content** of the **Text** component to **this.message** (that is, **Hello World**), set **FontSize** to **30fp**, and set **TextAlign** to **center**. Then, select the **Text** component on the canvas and drag its corners to fully display the text. Below is an illustration of the operations. Drag the **Text** component from the **UI Control** area to the canvas and then to the center area of the **Column** component. In the **Attributes &amp; Styles** area, click ![en-us_image_0000001277608813](figures/en-us_image_0000001277608813.png)**Feature**, set **Content** of the **Text** component to **this.message** (that is, **Hello World**), set **FontSize** to **30fp**, and set **TextAlign** to **center**. Then, select the **Text** component on the canvas and drag its corners to fully display the text. Below is an illustration of the operations.
![en-us_image_0000001235731706](figures/en-us_image_0000001235731706.gif) ![en-us_image_0000001235731706](figures/en-us_image_0000001235731706.gif)
4. Add a **Button** component. 4. Add a **Button** component.
Drag the **Button** component from the **UI Control** area to the canvas and then to a position under the **Text** component. In the **Attributes &amp; Styles** area on the right, click ![en-us_image_0000001277728577](figures/en-us_image_0000001277728577.png)**General** and set **Height** of the **Button** component to **40vp**. Click ![en-us_image_0000001277809337](figures/en-us_image_0000001277809337.png)**Feature** and set **Label** to **Next** and **FontSize** to **25fp**. Below is an illustration of the operations. Drag the **Button** component from the **UI Control** area to the canvas and then to a position under the **Text** component. In the **Attributes &amp; Styles** area on the right, click ![en-us_image_0000001277728577](figures/en-us_image_0000001277728577.png)**General** and set **Height** of the **Button** component to **40vp**. Click ![en-us_image_0000001277809337](figures/en-us_image_0000001277809337.png)**Feature** and set **Label** to **Next** and **FontSize** to **25fp**. Below is an illustration of the operations.
![en-us_image_0000001235732402](figures/en-us_image_0000001235732402.gif) ![en-us_image_0000001235732402](figures/en-us_image_0000001235732402.gif)
5. On the toolbar in the upper right corner of the editing window, click **Previewer** to open the Previewer.
5. On the toolbar in the upper right corner of the editing window, click **Previewer** to open the Previewer. Below is how the first page looks in the Previewer. Below is how the first page looks in the Previewer.
![en-us_image_0000001235892798](figures/en-us_image_0000001235892798.png) ![en-us_image_0000001235892798](figures/en-us_image_0000001235892798.png)
...@@ -77,9 +82,10 @@ Add **Column**, **Text**, and **Button** components to the first page. A column ...@@ -77,9 +82,10 @@ Add **Column**, **Text**, and **Button** components to the first page. A column
## Building the Second Page ## Building the Second Page
1. Create the second page. 1. Create the second page.
In the **Project** window, choose **entry** &gt; **src** &gt; **main** &gt; **ets** &gt; **MainAbility**, right-click the **pages** folder, choose **New** &gt; **Visual**, name the page **second**, and click **Finish**. Below is the structure of the **pages** folder.
![en-us_image_0000001233368868](figures/en-us_image_0000001233368868.png) In the **Project** window, choose **entry** &gt; **src** &gt; **main** &gt; **ets** &gt; **MainAbility**, right-click the **pages** folder, choose **New** &gt; **Visual**, name the page **second**, and click **Finish**. Below, you can see the structure of the **pages** folder.
![en-us_image_0000001233368868](figures/en-us_image_0000001233368868.png)
2. [Delete the existing template components from the canvas.](#delete_origin_content) 2. [Delete the existing template components from the canvas.](#delete_origin_content)
...@@ -108,6 +114,7 @@ Add **Column**, **Text**, and **Button** components to the first page. A column ...@@ -108,6 +114,7 @@ Add **Column**, **Text**, and **Button** components to the first page. A column
![en-us_image_0000001280255513](figures/en-us_image_0000001280255513.gif) ![en-us_image_0000001280255513](figures/en-us_image_0000001280255513.gif)
5. Add a **Button** component. 5. Add a **Button** component.
Drag the **Button** component from the **UI Control** area to the canvas and then to a position under the **Text** component. In the **Attributes &amp; Styles** area on the right, click ![en-us_image_0000001233528160](figures/en-us_image_0000001233528160.png)**General** and set **Height** of the **Button** component to **40vp**. Click ![en-us_image_0000001277728597](figures/en-us_image_0000001277728597.png)**Feature** and set **Value** to **Back** and **FontSize** to **25fp**. Below is an illustration of the operations. Drag the **Button** component from the **UI Control** area to the canvas and then to a position under the **Text** component. In the **Attributes &amp; Styles** area on the right, click ![en-us_image_0000001233528160](figures/en-us_image_0000001233528160.png)**General** and set **Height** of the **Button** component to **40vp**. Click ![en-us_image_0000001277728597](figures/en-us_image_0000001277728597.png)**Feature** and set **Value** to **Back** and **FontSize** to **25fp**. Below is an illustration of the operations.
![en-us_image_0000001280383937](figures/en-us_image_0000001280383937.gif) ![en-us_image_0000001280383937](figures/en-us_image_0000001280383937.gif)
...@@ -118,7 +125,9 @@ Add **Column**, **Text**, and **Button** components to the first page. A column ...@@ -118,7 +125,9 @@ Add **Column**, **Text**, and **Button** components to the first page. A column
You can implement page redirection through the page router, which finds the target page based on the page URI. Import the **router** module and then perform the steps below: You can implement page redirection through the page router, which finds the target page based on the page URI. Import the **router** module and then perform the steps below:
1. Implement redirection from the first page to the second page. 1. Implement redirection from the first page to the second page.
In the files of the first page, bind the **onclick** method to the button so that clicking the button redirects the user to the second page. This operation needs to be completed in both .ets and .visual files. In the files of the first page, bind the **onclick** method to the button so that clicking the button redirects the user to the second page. This operation needs to be completed in both .ets and .visual files.
- In the **index.ets** file: - In the **index.ets** file:
``` ```
...@@ -144,11 +153,12 @@ You can implement page redirection through the page router, which finds the targ ...@@ -144,11 +153,12 @@ You can implement page redirection through the page router, which finds the targ
} }
``` ```
- In the index.visual file, select the **Button** component on the canvas. In the **Attributes &amp; Styles** area, click ![en-us_image_0000001233209020](figures/en-us_image_0000001233209020.png)**Events** and set **OnClick** to **this.onclick**. - In the **index.visual** file, select the **Button** component on the canvas. In the **Attributes &amp; Styles** area, click ![en-us_image_0000001233209020](figures/en-us_image_0000001233209020.png)**Events** and set **OnClick** to **this.onclick**.
![en-us_image_0000001235745716](figures/en-us_image_0000001235745716.png) ![en-us_image_0000001235745716](figures/en-us_image_0000001235745716.png)
2. Implement redirection from the second page to the first page. 2. Implement redirection from the second page to the first page.
In the files of the second page, bind the **back** method to the **Back** button so that clicking the button redirects the user back to the first page. This operation needs to be completed in both .ets and .visual files. In the files of the second page, bind the **back** method to the **Back** button so that clicking the button redirects the user back to the first page. This operation needs to be completed in both .ets and .visual files.
- In the **second.ets** file: - In the **second.ets** file:
...@@ -174,7 +184,7 @@ You can implement page redirection through the page router, which finds the targ ...@@ -174,7 +184,7 @@ You can implement page redirection through the page router, which finds the targ
} }
} }
``` ```
- In the second.visual file, select the **Button** component on the canvas. In the **Attributes &amp; Styles** area, click ![en-us_image_0000001233368900](figures/en-us_image_0000001233368900.png)**Events** and set **OnClick** to **this.back**. - In the **second.visual** file, select the **Button** component on the canvas. In the **Attributes &amp; Styles** area, click ![en-us_image_0000001233368900](figures/en-us_image_0000001233368900.png)**Events** and set **OnClick** to **this.back**.
![en-us_image_0000001280385809](figures/en-us_image_0000001280385809.png) ![en-us_image_0000001280385809](figures/en-us_image_0000001280385809.png)
......
# Getting Started with eTS in the Traditional Coding Approach # Getting Started with eTS in the Traditional Coding Approach
> ![icon-note.gif](public_sys-resources/icon-note.gif) **Note:** > ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**<br/>To use eTS, your DevEco Studio must be V3.0.0.601 Beta1 or later.
> To use eTS, your DevEco Studio must be V3.0.0.601 Beta1 or later.
> >
> For best possible results, use [DevEco Studio V3.0.0.900 Beta3](https://developer.harmonyos.com/cn/develop/deveco-studio#download_beta_openharmony) for your development. > For best possible results, use [DevEco Studio V3.0.0.900 Beta3](https://developer.harmonyos.com/cn/develop/deveco-studio#download_beta_openharmony) for your development.
## Creating an eTS Project ## Creating an eTS Project
1. Open DevEco Studio, choose **File** &gt; **New** &gt; **Create Project**, select **Empty Ability**, and click **Next**. 1. In DevEco Studio, if no project is open, click **Create Project**; if a project is already open, choose **File** &gt; **New** &gt; **Create Project**. Then, select **Empty Ability** and click **Next**.
![en-us_image_0000001223556342](figures/en-us_image_0000001223556342.png) ![en-us_image_0000001223556342](figures/en-us_image_0000001223556342.png)
...@@ -21,14 +20,14 @@ ...@@ -21,14 +20,14 @@
## eTS Project Files ## eTS Project Files
- **entry** : OpenHarmony project module, which can be built into an ability package (HAP). - **entry** : OpenHarmony project module, which can be built into an ability package ([HAP](../../glossary.md#hap)).
- **src &gt; main &gt; ets** : a collection of eTS source code. - **src &gt; main &gt; ets** : a collection of eTS source code.
- **src &gt; main &gt; ets &gt; MainAbility** : entry to your application/service. - **src &gt; main &gt; ets &gt; MainAbility** : entry to your application/service.
- **src &gt; main &gt; ets &gt; MainAbility &gt; pages** : pages contained in **MainAbility**. - **src &gt; main &gt; ets &gt; MainAbility &gt; pages** : pages contained in **MainAbility**.
- **src &gt; main &gt; ets &gt; MainAbility &gt; app.ets** : ability lifecycle file. - **src &gt; main &gt; ets &gt; MainAbility &gt; app.ets** : ability lifecycle file.
- **src &gt; main &gt; resources** : a collection of resource files used by your application/service, such as graphics, multimedia, character strings, and layout files. - **src &gt; main &gt; resources** : a collection of resource files used by your application/service, such as graphics, multimedia, character strings, and layout files.
- **src &gt; main &gt; config.json** : module configuration file. This file describes the global configuration information of the application/service, the device-specific configuration information, and the configuration information of the HAP file. - **src &gt; main &gt; config.json** : module configuration file. This file describes the global configuration information of the application/service, the device-specific configuration information, and the configuration information of the HAP file.
- **build-profile.json5** : module information and build configuration options, including **buildOption target**. - **build-profile.json5** : current module information and build configuration options, including **buildOption target**.
- **hvigorfile.js** : module-level compilation and build task script. You can customize related tasks and code implementation. - **hvigorfile.js** : module-level compilation and build task script. You can customize related tasks and code implementation.
- **build-profile.json5** : application-level configuration information, including the signature and product configuration. - **build-profile.json5** : application-level configuration information, including the signature and product configuration.
- **hvigorfile.js** : application-level compilation and build task script. - **hvigorfile.js** : application-level compilation and build task script.
...@@ -37,6 +36,7 @@ ...@@ -37,6 +36,7 @@
## Building the First Page ## Building the First Page
1. Use the **Text** component. 1. Use the **Text** component.
After the project synchronization is complete, choose **entry** &gt; **src** &gt; **main** &gt; **ets** &gt; **MainAbility** &gt; **pages** in the **Project** window and open the **index.ets** file. You can see that the file contains a **&lt;Text&gt;** component. The sample code in the **index.ets** file is shown below: After the project synchronization is complete, choose **entry** &gt; **src** &gt; **main** &gt; **ets** &gt; **MainAbility** &gt; **pages** in the **Project** window and open the **index.ets** file. You can see that the file contains a **&lt;Text&gt;** component. The sample code in the **index.ets** file is shown below:
...@@ -61,6 +61,7 @@ ...@@ -61,6 +61,7 @@
``` ```
2. Add a **&lt;Button&gt;** component. 2. Add a **&lt;Button&gt;** component.
On the default page, add a **&lt;Button&gt;** component to accept user clicks and implement redirection to another page. The sample code in the **index.ets** file is shown below: On the default page, add a **&lt;Button&gt;** component to accept user clicks and implement redirection to another page. The sample code in the **index.ets** file is shown below:
...@@ -97,7 +98,9 @@ ...@@ -97,7 +98,9 @@
} }
``` ```
3. On the toolbar in the upper right corner of the editing window, click **Previewer** to open the Previewer. Below is how the first page looks on the Previewer. 3. On the toolbar in the upper right corner of the editing window, click **Previewer** to open the Previewer.
Below is how the first page looks on the Previewer.
![en-us_image_0000001216239356](figures/en-us_image_0000001216239356.png) ![en-us_image_0000001216239356](figures/en-us_image_0000001216239356.png)
...@@ -105,11 +108,13 @@ ...@@ -105,11 +108,13 @@
## Building the Second Page ## Building the Second Page
1. Create the second page. 1. Create the second page.
In the **Project** window, choose **entry** &gt; **src** &gt; **main** &gt; **ets** &gt; **MainAbility**, right-click the **pages** folder, choose **New** &gt; **Page**, name the page **second**, and click **Finish**. Below is the structure of the **pages** folder:
![en-us_image_0000001223397122](figures/en-us_image_0000001223397122.png) In the **Project** window, choose **entry** &gt; **src** &gt; **main** &gt; **ets** &gt; **MainAbility**, right-click the **pages** folder, choose **New** &gt; **Page**, name the page **second**, and click **Finish**. Below, you can see the structure of the **pages** folder.
![en-us_image_0000001223397122](figures/en-us_image_0000001223397122.png)
2. Add **&lt;Text&gt;** and **&lt;Button&gt;** components. 2. Add **&lt;Text&gt;** and **&lt;Button&gt;** components.
Add **&lt;Text&gt;** and **&lt;Button&gt;** components and set their styles, as you do for the first page. The sample code in the **second.ets** file is shown below: Add **&lt;Text&gt;** and **&lt;Button&gt;** components and set their styles, as you do for the first page. The sample code in the **second.ets** file is shown below:
...@@ -151,6 +156,7 @@ ...@@ -151,6 +156,7 @@
You can implement page redirection through the page router, which finds the target page based on the page URI. Import the **router** module and then perform the steps below: You can implement page redirection through the page router, which finds the target page based on the page URI. Import the **router** module and then perform the steps below:
1. Implement redirection from the first page to the second page. 1. Implement redirection from the first page to the second page.
In the **index.ets** file of the first page, bind the **onClick** event to the **Next** button so that clicking the button redirects the user to the second page. The sample code in the **index.ets** file is shown below: In the **index.ets** file of the first page, bind the **onClick** event to the **Next** button so that clicking the button redirects the user to the second page. The sample code in the **index.ets** file is shown below:
...@@ -194,6 +200,7 @@ You can implement page redirection through the page router, which finds the targ ...@@ -194,6 +200,7 @@ You can implement page redirection through the page router, which finds the targ
``` ```
2. Implement redirection from the second page to the first page. 2. Implement redirection from the second page to the first page.
In the **second.ets** file of the second page, bind the **onClick** event to the **Back** button so that clicking the button redirects the user back to the first page. The sample code in the **second.ets** file is shown below: In the **second.ets** file of the second page, bind the **onClick** event to the **Back** button so that clicking the button redirects the user back to the first page. The sample code in the **second.ets** file is shown below:
......
# Getting Started with JavaScript in the Low-Code Approach # Getting Started with JavaScript in the Low-Code Approach
> ![icon-note.gif](public_sys-resources/icon-note.gif) **Note:** > ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**<br/>This feature will be available in DevEco Studio V2.2 Beta1 and later versions.
> This feature will be available in DevEco Studio V2.2 Beta1 and later versions.
> >
> For best possible results, use [DevEco Studio V3.0.0.900 Beta3](https://developer.harmonyos.com/cn/develop/deveco-studio#download_beta_openharmony) for your development. > For best possible results, use [DevEco Studio V3.0.0.900 Beta3](https://developer.harmonyos.com/cn/develop/deveco-studio#download_beta_openharmony) for your development.
...@@ -19,10 +18,10 @@ You can develop applications or services in the low-code approach using either o ...@@ -19,10 +18,10 @@ You can develop applications or services in the low-code approach using either o
## Creating a Project That Supports Low-Code Development ## Creating a Project That Supports Low-Code Development
> ![icon-note.gif](public_sys-resources/icon-note.gif) **Note:** > ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**<br/>This feature is available in DevEco Studio 3.0 Beta2 and later versions and works with compileSdkVersion 7 or later.
> This feature is available in DevEco Studio 3.0 Beta2 and later versions and works with compileSdkVersion 7 or later. >
1. Open DevEco Studio, choose **File** &gt; **New** &gt; **Create Project**, select **Empty Ability**, and click **Next**. 1. In DevEco Studio, if no project is open, click **Create Project**; if a project is already open, choose **File** &gt; **New** &gt; **Create Project**. Then, select **Empty Ability** and click **Next**.
![en-us_image_0000001268198893](figures/en-us_image_0000001268198893.png) ![en-us_image_0000001268198893](figures/en-us_image_0000001268198893.png)
2. Go to the project configuration page, select **Enable Super Visual**, set **UI Syntax** to **JS**, and retain the default values for other parameters. 2. Go to the project configuration page, select **Enable Super Visual**, set **UI Syntax** to **JS**, and retain the default values for other parameters.
...@@ -39,8 +38,8 @@ After the project synchronization is complete, a low-code directory structure is ...@@ -39,8 +38,8 @@ After the project synchronization is complete, a low-code directory structure is
![en-us_image_0000001223558810](figures/en-us_image_0000001223558810.png) ![en-us_image_0000001223558810](figures/en-us_image_0000001223558810.png)
- **entry &gt; src &gt; main &gt; js &gt; MainAbility &gt; pages &gt; index &gt; index.js** : defines logical relationships, such as data and events, used on low-code pages. For details, see [JavaScript](../ui/js-framework-syntax-js.md). If multiple low-code development pages are created, a page folder and the corresponding **.js** file will be created for each of these pages. - **entry &gt; src &gt; main &gt; js &gt; MainAbility &gt; pages &gt; index &gt; index.js** : defines logical relationships, such as data and events, used on low-code pages. For details, see [JavaScript](../ui/js-framework-syntax-js.md). If multiple low-code development pages are created, a page folder and the corresponding **.js** file will be created for each of these pages.
> ![icon-note.gif](public_sys-resources/icon-note.gif) **Note:** > ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**<br/>To avoid build errors when using the low-code development page, make sure the directory where the corresponding **.js** file is located does not contain **.hml** or **.css** files. For example, in the preceding example, no **.hml** or **.css** file is allowed in **js** &gt; **MainAbility** &gt; **pages** &gt; **index**.
> To avoid build errors when using the low-code development page, make sure the directory where the corresponding **.js** file is located does not contain **.hml** or **.css** files. For example, in the preceding example, no **.hml** or **.css** file is allowed in **js** &gt; **MainAbility** &gt; **pages** &gt; **index**. >
- **entry &gt; src &gt; main &gt; supervisual &gt; MainAbility &gt; pages &gt; index &gt; index.visual** : stores the data model of the low-code development page. You can double-click the file to open the low-code development page. If multiple low-code development pages are created, a page folder and the corresponding **.visual** file will be created for each of these pages. - **entry &gt; src &gt; main &gt; supervisual &gt; MainAbility &gt; pages &gt; index &gt; index.visual** : stores the data model of the low-code development page. You can double-click the file to open the low-code development page. If multiple low-code development pages are created, a page folder and the corresponding **.visual** file will be created for each of these pages.
...@@ -51,26 +50,33 @@ After the project synchronization is complete, the default first page contains t ...@@ -51,26 +50,33 @@ After the project synchronization is complete, the default first page contains t
Add **Div**, **Text**, and **Button** components to the first page. Add **Div**, **Text**, and **Button** components to the first page.
1. Delete the existing template components from the canvas.<a name= delete_origin_content></a> 1. Delete the existing template components from the canvas.<a name= delete_origin_content></a>
Open the index.visual file, right-click the existing template components on the canvas, and choose **Delete** from the shortcut menu to delete them. Below is an illustration of the operations.
![en-us_image_0000001216600980](figures/en-us_image_0000001216600980.gif)
Open the index.visual file, right-click the existing template components on the canvas, and choose **Delete** from the shortcut menu to delete them. Below is an illustration of the operations.
![en-us_image_0000001216600980](figures/en-us_image_0000001216600980.gif)
2. Add a **Div** component and set its styles and attributes.<a name = add_container></a> 2. Add a **Div** component and set its styles and attributes.<a name = add_container></a>
Drag the **Div** component from the **UI Control** area to the canvas. In the **Attributes &amp; Styles** area on the right, click ![en-us_image_0000001260226691](figures/en-us_image_0000001260226691.png)**General** and set **Height** to **100%** so that the component fills the entire screen. Click ![en-us_image_0000001215226858](figures/en-us_image_0000001215226858.png)**Flex**, set **FlexDirection** to **column** so that the main axis of the component is vertical, and set both **JustifyContent** and **AlignItems** to **center** so that the child components of the **Div** component are centered along the main axis and cross axis. Below is an illustration of the operations. Drag the **Div** component from the **UI Control** area to the canvas. In the **Attributes &amp; Styles** area on the right, click ![en-us_image_0000001260226691](figures/en-us_image_0000001260226691.png)**General** and set **Height** to **100%** so that the component fills the entire screen. Click ![en-us_image_0000001215226858](figures/en-us_image_0000001215226858.png)**Flex**, set **FlexDirection** to **column** so that the main axis of the component is vertical, and set both **JustifyContent** and **AlignItems** to **center** so that the child components of the **Div** component are centered along the main axis and cross axis. Below is an illustration of the operations.
![en-us_image_0000001216448880](figures/en-us_image_0000001216448880.gif) ![en-us_image_0000001216448880](figures/en-us_image_0000001216448880.gif)
3. Add a **Text** component. 3. Add a **Text** component.
Drag the **Text** component from the **UI Control** area to the center area of the **Div** component. In the **Attributes &amp; Styles** area, click ![en-us_image_0000001215066868](figures/en-us_image_0000001215066868.png)**Properties** and set **Content** of the **Text** component to **Hello World**. Click ![en-us_image_0000001215386842](figures/en-us_image_0000001215386842.png)**Feature**, and set **FontSize** to **60px** and **TextAlign** to **center**. Then, select the **Text** component on the canvas and drag its corners to fully display the text. Below is an illustration of the operations. Drag the **Text** component from the **UI Control** area to the center area of the **Div** component. In the **Attributes &amp; Styles** area, click ![en-us_image_0000001215066868](figures/en-us_image_0000001215066868.png)**Properties** and set **Content** of the **Text** component to **Hello World**. Click ![en-us_image_0000001215386842](figures/en-us_image_0000001215386842.png)**Feature**, and set **FontSize** to **60px** and **TextAlign** to **center**. Then, select the **Text** component on the canvas and drag its corners to fully display the text. Below is an illustration of the operations.
![en-us_image_0000001216446670](figures/en-us_image_0000001216446670.gif) ![en-us_image_0000001216446670](figures/en-us_image_0000001216446670.gif)
4. Add a **Button** component. 4. Add a **Button** component.
Drag the **Button** component from the **UI Control** area to a position under the **Text** component on the canvas. In the **Attributes &amp; Styles** area on the right, click ![en-us_image_0000001260106745](figures/en-us_image_0000001260106745.png)**Properties** and set **Value** of the **Button** component to **Next**. Click ![en-us_image_0000001259866741](figures/en-us_image_0000001259866741.png)**Feature** and set **FontSize** to **40px**. Then, select the **Button** component on the canvas and drag its corners to fully display the text. Below is an illustration of the operations. Drag the **Button** component from the **UI Control** area to a position under the **Text** component on the canvas. In the **Attributes &amp; Styles** area on the right, click ![en-us_image_0000001260106745](figures/en-us_image_0000001260106745.png)**Properties** and set **Value** of the **Button** component to **Next**. Click ![en-us_image_0000001259866741](figures/en-us_image_0000001259866741.png)**Feature** and set **FontSize** to **40px**. Then, select the **Button** component on the canvas and drag its corners to fully display the text. Below is an illustration of the operations.
![en-us_image_0000001260928361](figures/en-us_image_0000001260928361.gif) ![en-us_image_0000001260928361](figures/en-us_image_0000001260928361.gif)
5. On the toolbar in the upper right corner of the editing window, click **Previewer** to open the Previewer. Below is how the first page looks on the Previewer. 5. On the toolbar in the upper right corner of the editing window, click **Previewer** to open the Previewer.
Below is how the first page looks on the Previewer.
![en-us_image_0000001216288558](figures/en-us_image_0000001216288558.png) ![en-us_image_0000001216288558](figures/en-us_image_0000001216288558.png)
...@@ -78,20 +84,23 @@ Add **Div**, **Text**, and **Button** components to the first page. ...@@ -78,20 +84,23 @@ Add **Div**, **Text**, and **Button** components to the first page.
## Building the Second Page ## Building the Second Page
1. Create the second page. 1. Create the second page.
In the **Project** window, choose **entry** &gt; **src** &gt; **main** &gt; **js** &gt; **MainAbility**, right-click the **pages** folder, choose **New** &gt; **Visual**, name the page **second**, and click **Finish**. Below is the structure of the **pages** folder:
![en-us_image_0000001223882030](figures/en-us_image_0000001223882030.png) In the **Project** window, choose **entry** &gt; **src** &gt; **main** &gt; **js** &gt; **MainAbility**, right-click the **pages** folder, choose **New** &gt; **Visual**, name the page **second**, and click **Finish**. Below, you can see the structure of the **pages** folder.
![en-us_image_0000001223882030](figures/en-us_image_0000001223882030.png)
2. [Delete the existing template components from the canvas.](#delete_origin_content) 2. [Delete the existing template components from the canvas.](#delete_origin_content)
3. [Add a Div component and set its styles and attributes.](#add_container) 3. [Add a Div component and set its styles and attributes.](#add_container)
4. Add a **Text** component. 4. Add a **Text** component.
Drag the **Text** component from the **UI Control** area to the center area of the **Div** component. In the **Attributes &amp; Styles** area, click ![en-us_image_0000001260227453](figures/en-us_image_0000001260227453.png)**Properties** and set **Content** of the **Text** component to **Hi there**. Click ![en-us_image_0000001260107497](figures/en-us_image_0000001260107497.png)**Feature**, and set **FontSize** to **60px** and **TextAlign** to **center**. Then, select the **Text** component on the canvas and drag its corners to fully display the text. Below is an illustration of the operations. Drag the **Text** component from the **UI Control** area to the center area of the **Div** component. In the **Attributes &amp; Styles** area, click ![en-us_image_0000001260227453](figures/en-us_image_0000001260227453.png)**Properties** and set **Content** of the **Text** component to **Hi there**. Click ![en-us_image_0000001260107497](figures/en-us_image_0000001260107497.png)**Feature**, and set **FontSize** to **60px** and **TextAlign** to **center**. Then, select the **Text** component on the canvas and drag its corners to fully display the text. Below is an illustration of the operations.
![en-us_image_0000001216614132](figures/en-us_image_0000001216614132.gif) ![en-us_image_0000001216614132](figures/en-us_image_0000001216614132.gif)
5. Add a **Button** component. 5. Add a **Button** component.
Drag the **Button** component from the **UI Control** area to a position under the **Text** component on the canvas. In the **Attributes &amp; Styles** area on the right, click ![en-us_image_0000001215227618](figures/en-us_image_0000001215227618.png)**Properties** and set **Value** of the **Button** component to **Back**. Click ![en-us_image_0000001259987441](figures/en-us_image_0000001259987441.png)**Feature** and set **FontSize** to **40px**. Then, select the **Button** component on the canvas and drag its corners to fully display the text. Below is an illustration of the operations. Drag the **Button** component from the **UI Control** area to a position under the **Text** component on the canvas. In the **Attributes &amp; Styles** area on the right, click ![en-us_image_0000001215227618](figures/en-us_image_0000001215227618.png)**Properties** and set **Value** of the **Button** component to **Back**. Click ![en-us_image_0000001259987441](figures/en-us_image_0000001259987441.png)**Feature** and set **FontSize** to **40px**. Then, select the **Button** component on the canvas and drag its corners to fully display the text. Below is an illustration of the operations.
![en-us_image_0000001261017331](figures/en-us_image_0000001261017331.gif) ![en-us_image_0000001261017331](figures/en-us_image_0000001261017331.gif)
...@@ -102,7 +111,9 @@ Add **Div**, **Text**, and **Button** components to the first page. ...@@ -102,7 +111,9 @@ Add **Div**, **Text**, and **Button** components to the first page.
You can implement page redirection through the [page router](../ui/ui-js-building-ui-routes.md), which finds the target page based on the page URI. Import the **router** module and then perform the steps below: You can implement page redirection through the [page router](../ui/ui-js-building-ui-routes.md), which finds the target page based on the page URI. Import the **router** module and then perform the steps below:
1. Implement redirection from the first page to the second page. 1. Implement redirection from the first page to the second page.
In the files of the first page, bind the **onclick** method to the button so that clicking the button redirects the user to the second page. This operation needs to be completed in both .js and .visual files. In the files of the first page, bind the **onclick** method to the button so that clicking the button redirects the user to the second page. This operation needs to be completed in both .js and .visual files.
- In the **index.js** file: - In the **index.js** file:
```js ```js
...@@ -122,6 +133,7 @@ You can implement page redirection through the [page router](../ui/ui-js-buildin ...@@ -122,6 +133,7 @@ You can implement page redirection through the [page router](../ui/ui-js-buildin
![en-us_image_0000001223722586](figures/en-us_image_0000001223722586.png) ![en-us_image_0000001223722586](figures/en-us_image_0000001223722586.png)
2. Implement redirection from the second page to the first page. 2. Implement redirection from the second page to the first page.
In the files of the second page, bind the **back** method to the **Back** button so that clicking the button redirects the user back to the first page. In the files of the second page, bind the **back** method to the **Back** button so that clicking the button redirects the user back to the first page.
This operation needs to be completed in both .js and .visual files. This operation needs to be completed in both .js and .visual files.
...@@ -137,7 +149,7 @@ You can implement page redirection through the [page router](../ui/ui-js-buildin ...@@ -137,7 +149,7 @@ You can implement page redirection through the [page router](../ui/ui-js-buildin
} }
} }
``` ```
- In the second.visual file, select the **Button** component on the canvas. In the **Attributes &amp; Styles** area, click ![en-us_image_0000001215388262](figures/en-us_image_0000001215388262.png)**Events** and set **Click** to **back**. - In the **second.visual** file, select the **Button** component on the canvas. In the **Attributes &amp; Styles** area, click ![en-us_image_0000001215388262](figures/en-us_image_0000001215388262.png)**Events** and set **Click** to **back**.
![en-us_image_0000001268082945](figures/en-us_image_0000001268082945.png) ![en-us_image_0000001268082945](figures/en-us_image_0000001268082945.png)
......
# Getting Started with JavaScript in the Traditional Coding Approach # Getting Started with JavaScript in the Traditional Coding Approach
> ![icon-note.gif](public_sys-resources/icon-note.gif) **Note:** > ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**<br/>For best possible results, use [DevEco Studio V3.0.0.900 Beta3](https://developer.harmonyos.com/cn/develop/deveco-studio#download_beta_openharmony) for your development.
> For best possible results, use [DevEco Studio V3.0.0.900 Beta3](https://developer.harmonyos.com/cn/develop/deveco-studio#download_beta_openharmony) for your development. >
## Creating a JavaScript Project ## Creating a JavaScript Project
1. Open DevEco Studio, choose **File** &gt; **New** &gt; **Create Project**, select **Empty Ability**, and click **Next**. 1. In DevEco Studio, if no project is open, click **Create Project**; if a project is already open, choose **File** &gt; **New** &gt; **Create Project**. Then, select **Empty Ability** and click **Next**.
![en-us_image_0000001223558814](figures/en-us_image_0000001223558814.png) ![en-us_image_0000001223558814](figures/en-us_image_0000001223558814.png)
...@@ -19,23 +19,24 @@ ...@@ -19,23 +19,24 @@
## JavaScript Project Files ## JavaScript Project Files
- **entry** : OpenHarmony project module, which can be built into an ability package (HAP). - **entry** : OpenHarmony project module, which can be built into an ability package ([HAP](../../glossary.md#hap)).
- **src &gt; main &gt; js** : a collection of JS source code. - **src &gt; main &gt; js**: a collection of JS source code.
- **src &gt; main &gt; js &gt; MainAbility** : entry to your application/service. - **src &gt; main &gt; js &gt; MainAbility**: entry to your application/service.
- **src &gt; main &gt; js &gt; MainAbility &gt; i18n** : resources in different languages, for example, UI strings and image paths. - **src &gt; main &gt; js &gt; MainAbility &gt; i18n**: resources in different languages, for example, UI strings and image paths.
- **src &gt; main &gt; js &gt; MainAbility &gt; pages** : pages contained in **MainAbility**. - **src &gt; main &gt; js &gt; MainAbility &gt; pages**: pages contained in **MainAbility**.
- **src &gt; main &gt; js &gt; MainAbility &gt; app.js** : ability lifecycle file. - **src &gt; main &gt; js &gt; MainAbility &gt; app.js**: ability lifecycle file.
- **src &gt; main &gt; resources** : a collection of resource files used by your application/service, such as graphics, multimedia, character strings, and layout files. - **src &gt; main &gt; resources**: a collection of resource files used by your application/service, such as graphics, multimedia, character strings, and layout files.
- **src &gt; main &gt; config.json** : module configuration file. This file describes the global configuration information of the application/service, the device-specific configuration information, and the configuration information of the HAP file. - **src &gt; main &gt; config.json**: module configuration file. This file describes the global configuration information of the application/service, the device-specific configuration information, and the configuration information of the HAP file.
- **build-profile.json5** : module information and build configuration options, including **buildOption target**. - **build-profile.json5**: current module information and build configuration options, including **buildOption target**.
- **hvigorfile.js** : module-level compilation and build task script. You can customize related tasks and code implementation. - **hvigorfile.js**: module-level compilation and build task script. You can customize related tasks and code implementation.
- **build-profile.json5** : application-level configuration information, including the signature and product configuration. - **build-profile.json5**: application-level configuration information, including the signature and product configuration.
- **hvigorfile.js** : application-level compilation and build task script. - **hvigorfile.js**: application-level compilation and build task script.
## Building the First Page ## Building the First Page
1. Use the **Text** component. 1. Use the **Text** component.
After the project synchronization is complete, choose **entry** &gt; **src** &gt; **main** &gt; **js** &gt; **MainAbility** &gt; **pages** &gt; **index** in the **Project** window and open the **index.hml** file. You can see that the file contains a **&lt;Text&gt;** component. The sample code in the **index.hml** file is shown below: After the project synchronization is complete, choose **entry** &gt; **src** &gt; **main** &gt; **js** &gt; **MainAbility** &gt; **pages** &gt; **index** in the **Project** window and open the **index.hml** file. You can see that the file contains a **&lt;Text&gt;** component. The sample code in the **index.hml** file is shown below:
...@@ -48,6 +49,7 @@ ...@@ -48,6 +49,7 @@
``` ```
2. Add a button and bind the **onclick** method to this button. 2. Add a button and bind the **onclick** method to this button.
On the default page, add an **&lt;input&gt;** component of the button type to accept user clicks and implement redirection to another page. The sample code in the **index.hml** file is shown below: On the default page, add an **&lt;input&gt;** component of the button type to accept user clicks and implement redirection to another page. The sample code in the **index.hml** file is shown below:
...@@ -63,6 +65,7 @@ ...@@ -63,6 +65,7 @@
``` ```
3. Set the page style in the **index.css** file. 3. Set the page style in the **index.css** file.
From the **Project** window, choose **entry** &gt; **src** &gt; **main** &gt; **js** &gt; **MainAbility** &gt; **pages** &gt; **index**, open the **index.css** file, and set the page styles, such as the width, height, font size, and spacing. The sample code in the **index.css** file is shown below: From the **Project** window, choose **entry** &gt; **src** &gt; **main** &gt; **js** &gt; **MainAbility** &gt; **pages** &gt; **index**, open the **index.css** file, and set the page styles, such as the width, height, font size, and spacing. The sample code in the **index.css** file is shown below:
...@@ -96,7 +99,9 @@ ...@@ -96,7 +99,9 @@
} }
``` ```
4. On the toolbar in the upper right corner of the editing window, click **Previewer** to open the Previewer. Below is how the first page looks on the Previewer. 4. On the toolbar in the upper right corner of the editing window, click **Previewer** to open the Previewer.
Below is how the first page looks on the Previewer.
![en-us_image_0000001216084724](figures/en-us_image_0000001216084724.png) ![en-us_image_0000001216084724](figures/en-us_image_0000001216084724.png)
...@@ -104,11 +109,13 @@ ...@@ -104,11 +109,13 @@
## Building the Second Page ## Building the Second Page
1. Create the second page. 1. Create the second page.
In the **Project** window, choose **entry** &gt; **src** &gt; **main** &gt; **js** &gt; **MainAbility**, right-click the **pages** folder, choose **New** &gt; **Page**, name the page **second**, and click **Finish**. Below is the structure of the **second** folder:
![en-us_image_0000001223877210](figures/en-us_image_0000001223877210.png) In the **Project** window, choose **entry** &gt; **src** &gt; **main** &gt; **js** &gt; **MainAbility**, right-click the **pages** folder, choose **New** &gt; **Page**, name the page **second**, and click **Finish**. Below, you can see the structure of the **second** folder.
![en-us_image_0000001223877210](figures/en-us_image_0000001223877210.png)
2. Add **&lt;Text&gt;** and **&lt;Button&gt;** components. 2. Add **&lt;Text&gt;** and **&lt;Button&gt;** components.
Add **&lt;Text&gt;** and **&lt;Button&gt;** components and set their styles, as you do for the first page. The sample code in the **second.hml** file is shown below: Add **&lt;Text&gt;** and **&lt;Button&gt;** components and set their styles, as you do for the first page. The sample code in the **second.hml** file is shown below:
...@@ -161,6 +168,7 @@ ...@@ -161,6 +168,7 @@
You can implement page redirection through the [page router](../ui/ui-js-building-ui-routes.md), which finds the target page based on the page URI. Import the **router** module and then perform the steps below: You can implement page redirection through the [page router](../ui/ui-js-building-ui-routes.md), which finds the target page based on the page URI. Import the **router** module and then perform the steps below:
1. Implement redirection from the first page to the second page. 1. Implement redirection from the first page to the second page.
In the **index.js** file of the first page, bind the **onclick** method to the button so that clicking the button redirects the user to the second page. The sample code in the **index.js** file is shown below: In the **index.js** file of the first page, bind the **onclick** method to the button so that clicking the button redirects the user to the second page. The sample code in the **index.js** file is shown below:
...@@ -177,6 +185,7 @@ You can implement page redirection through the [page router](../ui/ui-js-buildin ...@@ -177,6 +185,7 @@ You can implement page redirection through the [page router](../ui/ui-js-buildin
``` ```
2. Implement redirection from the second page to the first page. 2. Implement redirection from the second page to the first page.
In the **second.ets** file of the second page, bind the **back** method to the **Back** button so that clicking the button redirects the user back to the first page. The sample code in the **second.js** file is shown below: In the **second.ets** file of the second page, bind the **back** method to the **Back** button so that clicking the button redirects the user back to the first page. The sample code in the **second.js** file is shown below:
......
# Input Method Framework # Input Method Framework
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** > ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**<br>The initial APIs of this module are supported since API version 6. Newly added APIs will be marked with a superscript to indicate their earliest API version.
> The initial APIs of this module are supported since API version 6. Newly added APIs will be marked with a superscript to indicate their earliest API version. >
## Modules to Import ## Modules to Import
...@@ -40,16 +40,18 @@ Obtains an [InputMethodController](#InputMethodController) instance. ...@@ -40,16 +40,18 @@ Obtains an [InputMethodController](#InputMethodController) instance.
**System capability**: SystemCapability.Miscservices.InputMethodFramework **System capability**: SystemCapability.Miscservices.InputMethodFramework
- Return value **Return value**
| Type| Description| | Type| Description|
| -------- | -------- | | -------- | -------- |
| [InputMethodController](#InputMethodController) | Returns the current **InputMethodController** instance.| | [InputMethodController](#InputMethodController) | Returns the current **InputMethodController** instance.|
**Example**
```
var InputMethodController = inputMethod.getInputMethodController();
```
- Example
```
var InputMethodController = inputMethod.getInputMethodController();
```
## inputMethod.getInputMethodSetting<sup>8+</sup><a name="getInputMethodSetting"></a> ## inputMethod.getInputMethodSetting<sup>8+</sup><a name="getInputMethodSetting"></a>
getInputMethodSetting(): InputMethodSetting getInputMethodSetting(): InputMethodSetting
...@@ -58,17 +60,17 @@ Obtains an [InputMethodSetting](#InputMethodSetting) instance. ...@@ -58,17 +60,17 @@ Obtains an [InputMethodSetting](#InputMethodSetting) instance.
**System capability**: SystemCapability.Miscservices.InputMethodFramework **System capability**: SystemCapability.Miscservices.InputMethodFramework
- Return value **Return value**
| Type | Description | | Type | Description |
| ----------------------------------------- | ---------------------------- | | ----------------------------------------- | ---------------------------- |
| [InputMethodSetting](#InputMethodSetting) | Returns the current **InputMethodSetting** instance.| | [InputMethodSetting](#InputMethodSetting) | Returns the current **InputMethodSetting** instance.|
**Example**
- Example ```js
``` var InputMethodSetting = inputMethod.getInputMethodSetting();
var InputMethodSetting = inputMethod.getInputMethodSetting(); ```
```
## InputMethodController<a name="InputMethodController"></a> ## InputMethodController<a name="InputMethodController"></a>
...@@ -82,15 +84,15 @@ Hides the keyboard. This API uses an asynchronous callback to return the result. ...@@ -82,15 +84,15 @@ Hides the keyboard. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Miscservices.InputMethodFramework **System capability**: SystemCapability.Miscservices.InputMethodFramework
- Parameters **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| callback | AsyncCallback&lt;boolean&gt; | Yes| Callback used to return whether the keyboard is successfully hidden.| | callback | AsyncCallback&lt;boolean&gt; | Yes| Callback used to return whether the keyboard is successfully hidden.|
- Example **Example**
``` ```js
InputMethodController.stopInput((error)=>{ InputMethodController.stopInput((error)=>{
console.info('stopInput'); console.info('stopInput');
}); });
...@@ -104,16 +106,16 @@ Hides the keyboard. This API uses an asynchronous callback to return the result. ...@@ -104,16 +106,16 @@ Hides the keyboard. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Miscservices.InputMethodFramework **System capability**: SystemCapability.Miscservices.InputMethodFramework
- Return value **Return value**
| Type| Description| | Type| Description|
| -------- | -------- | | -------- | -------- |
| Promise&lt;boolean&gt; | Promise used to return whether the keyboard is successfully hidden.| | Promise&lt;boolean&gt; | Promise used to return whether the keyboard is successfully hidden.|
- Example **Example**
``` ```js
var isSuccess = InputMethodController.stopInput(); var isSuccess = InputMethodController.stopInput();
console.info('stopInput isSuccess = ' + isSuccess); console.info('stopInput isSuccess = ' + isSuccess);
``` ```
...@@ -130,20 +132,22 @@ Obtains the list of installed input methods. This API uses an asynchronous callb ...@@ -130,20 +132,22 @@ Obtains the list of installed input methods. This API uses an asynchronous callb
**System capability**: SystemCapability.Miscservices.InputMethodFramework **System capability**: SystemCapability.Miscservices.InputMethodFramework
- Parameters **Parameters**
| Name | Type | Mandatory| Description |
| -------- | -------------------------------------------------- | ---- | ---------------------- | | Name | Type | Mandatory| Description |
| callback | Array<[InputMethodProperty](#InputMethodProperty)> | Yes | Callback used to return the list of installed input methods.| | -------- | -------------------------------------------------- | ---- | ---------------------- |
| callback | Array<[InputMethodProperty](#InputMethodProperty)> | Yes | Callback used to return the list of installed input methods.|
**Example**
- Example ```js
```
InputMethodSetting.listInputMethod((properties)=>{ InputMethodSetting.listInputMethod((properties)=>{
for (var i = 0;i < properties.length; i++) { for (var i = 0;i < properties.length; i++) {
var property = properties[i]; var property = properties[i];
console.info(property.packageName + "/" + property.methodId); console.info(property.packageName + "/" + property.methodId);
} }
}); });
``` ```
### listInputMethod ### listInputMethod
...@@ -153,19 +157,21 @@ Obtains the list of installed input methods. This API uses an asynchronous callb ...@@ -153,19 +157,21 @@ Obtains the list of installed input methods. This API uses an asynchronous callb
**System capability**: SystemCapability.Miscservices.InputMethodFramework **System capability**: SystemCapability.Miscservices.InputMethodFramework
- Return value **Return value**
| Type | Description |
| ----------------------------------------------------------- | ---------------------- | | Type | Description |
| Promise<Array<[InputMethodProperty](#InputMethodProperty)>> | Promise used to return the list of installed input methods.| | ----------------------------------------------------------- | ---------------------- |
| Promise<Array<[InputMethodProperty](#InputMethodProperty)>> | Promise used to return the list of installed input methods.|
- Example **Example**
```
```js
var properties = InputMethodSetting.listInputMethod(); var properties = InputMethodSetting.listInputMethod();
for (var i = 0;i < properties.length; i++) { for (var i = 0;i < properties.length; i++) {
var property = properties[i]; var property = properties[i];
console.info(property.packageName + "/" + property.methodId); console.info(property.packageName + "/" + property.methodId);
} }
``` ```
### displayOptionalInputMethod ### displayOptionalInputMethod
...@@ -181,12 +187,12 @@ Displays a dialog box for selecting an input method. This API uses an asynchrono ...@@ -181,12 +187,12 @@ Displays a dialog box for selecting an input method. This API uses an asynchrono
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| callback | AsyncCallback&lt;void&gt; | Yes| Callback used to return the execution result.| | callback | AsyncCallback&lt;void&gt; | Yes| Callback used to return the execution result.|
- Example **Example**
``` ```js
InputMethodSetting.displayOptionalInputMethod(()=>{ InputMethodSetting.displayOptionalInputMethod(()=>{
console.info('displayOptionalInputMethod is called'); console.info('displayOptionalInputMethod is called');
}); });
``` ```
### displayOptionalInputMethod ### displayOptionalInputMethod
...@@ -194,15 +200,16 @@ displayOptionalInputMethod(): Promise&lt;void&gt; ...@@ -194,15 +200,16 @@ displayOptionalInputMethod(): Promise&lt;void&gt;
Displays a dialog box for selecting an input method. This API uses an asynchronous callback to return the result. Displays a dialog box for selecting an input method. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Miscservices.InputMethodFramework **System capability**: SystemCapability.Miscservices.InputMethodFramework
- Return value **Return value**
| Type| Description| | Type| Description|
| -------- | -------- | | -------- | -------- |
| Promise&lt;void&gt; | Promise used to return the execution result.| | Promise&lt;void&gt; | Promise used to return the execution result.|
- Example **Example**
```
```js
InputMethodSetting.displayOptionalInputMethod(); InputMethodSetting.displayOptionalInputMethod();
``` ```
\ No newline at end of file
# Input Method Engine # Input Method Engine
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** > ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**<br>The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version.
> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version. >
## Modules to Import ## Modules to Import
...@@ -52,17 +52,17 @@ Obtains an **InputMethodEngine** instance. ...@@ -52,17 +52,17 @@ Obtains an **InputMethodEngine** instance.
**System capability**: SystemCapability.Miscservices.InputMethodFramework **System capability**: SystemCapability.Miscservices.InputMethodFramework
- Return value **Return value**
| Type | Description | | Type | Description |
| --------------------------------------- | ------------ | | --------------------------------------- | ------------ |
| [InputMethodEngine](#InputMethodEngine) | **InputMethodEngine** instance obtained.| | [InputMethodEngine](#InputMethodEngine) | **InputMethodEngine** instance obtained.|
- Example **Example**
``` ```js
var InputMethodEngine = inputMethodEngine.getInputMethodEngine(); var InputMethodEngine = inputMethodEngine.getInputMethodEngine();
``` ```
## inputMethodEngine.createKeyboardDelegate<a name="createKeyboardDelegate"></a> ## inputMethodEngine.createKeyboardDelegate<a name="createKeyboardDelegate"></a>
...@@ -72,17 +72,17 @@ Obtains a **KeyboardDelegate** instance. ...@@ -72,17 +72,17 @@ Obtains a **KeyboardDelegate** instance.
**System capability**: SystemCapability.Miscservices.InputMethodFramework **System capability**: SystemCapability.Miscservices.InputMethodFramework
- Return value **Return value**
| Type | Description | | Type | Description |
| ------------------------------------- | ---------------- | | ------------------------------------- | ---------------- |
| [KeyboardDelegate](#KeyboardDelegate) | **KeyboardDelegate** instance obtained.| | [KeyboardDelegate](#KeyboardDelegate) | **KeyboardDelegate** instance obtained.|
- Example **Example**
``` ```js
var KeyboardDelegate = inputMethodEngine.createKeyboardDelegate(); var KeyboardDelegate = inputMethodEngine.createKeyboardDelegate();
``` ```
## InputMethodEngine<a name="InputMethodEngine"></a> ## InputMethodEngine<a name="InputMethodEngine"></a>
...@@ -96,21 +96,21 @@ Listens for the input method binding event. This API uses a callback to return t ...@@ -96,21 +96,21 @@ Listens for the input method binding event. This API uses a callback to return t
**System capability**: SystemCapability.Miscservices.InputMethodFramework **System capability**: SystemCapability.Miscservices.InputMethodFramework
- Parameters **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ------------------------------- | ---- | ------------------------------------------------------------ | | -------- | ------------------------------- | ---- | ------------------------------------------------------------ |
| type | string | Yes | Listening type.<br>Set it to **'inputStart'**, which indicates listening for the input method binding event.| | type | string | Yes | Listening type.<br>Set it to **'inputStart'**, which indicates listening for the input method binding event.|
| callback | [KeyboardController](#KeyboardController), [TextInputClient](#TextInputClient) | Yes| Callback used to return the result.| | callback | [KeyboardController](#KeyboardController), [TextInputClient](#TextInputClient) | Yes| Callback used to return the result.|
- Example **Example**
``` ```js
InputMethodEngine.on('inputStart', (kbController, textInputClient) => { InputMethodEngine.on('inputStart', (kbController, textInputClient) => {
KeyboardController = kbController; KeyboardController = kbController;
TextInputClient = textInputClient; TextInputClient = textInputClient;
}); });
``` ```
### off('inputStart') ### off('inputStart')
...@@ -120,20 +120,18 @@ Cancels listening for the input method binding event. ...@@ -120,20 +120,18 @@ Cancels listening for the input method binding event.
**System capability**: SystemCapability.Miscservices.InputMethodFramework **System capability**: SystemCapability.Miscservices.InputMethodFramework
- Parameters **Parameters**
| Name | Type | Mandatory| Description |
| -------- | -------------------- | ---- | ------------------------ |
| type | string | Yes | Listening type.<br>Set it to **'inputStart'**, which indicates listening for the input method binding event.|
| callback | [KeyboardController](#KeyboardController), [TextInputClient](#TextInputClient) | No| Callback used to return the result.|
| Name | Type | Mandatory| Description |
| -------- | -------------------- | ---- | ------------------------ |
| type | string | Yes | Listening type.<br>Set it to **'inputStart'**, which indicates listening for the input method binding event.|
| callback | [KeyboardController](#KeyboardController), [TextInputClient](#TextInputClient) | No| Callback used to return the result.|
- Example **Example**
``` ```js
InputMethodEngine.off('inputStart'); InputMethodEngine.off('inputStart');
``` ```
### on('keyboardShow'|'keyboardHide') ### on('keyboardShow'|'keyboardHide')
...@@ -143,20 +141,20 @@ Listens for an input method event. ...@@ -143,20 +141,20 @@ Listens for an input method event.
**System capability**: SystemCapability.Miscservices.InputMethodFramework **System capability**: SystemCapability.Miscservices.InputMethodFramework
- Parameters **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ------ | ---- | ------------------------------------------------------------ | | -------- | ------ | ---- | ------------------------------------------------------------ |
| type | string | Yes | Listening type.<br>-&nbsp;The value **'keyboardShow'** means to listen for displaying of the input method.<br>-&nbsp;The value **'keyboardHide'** means to listen for hiding of the input method.| | type | string | Yes | Listening type.<br>- The value **'keyboardShow'** means to listen for displaying of the input method.<br>- The value **'keyboardHide'** means to listen for hiding of the input method.|
| callback | void | No | Callback used to return the result. | | callback | void | No | Callback used to return the result. |
- Example **Example**
``` ```js
InputMethodEngine.on('keyboardShow', (err) => { InputMethodEngine.on('keyboardShow', (err) => {
console.info('keyboardShow'); console.info('keyboardShow');
}); });
``` ```
### off('keyboardShow'|'keyboardHide') ### off('keyboardShow'|'keyboardHide')
...@@ -166,19 +164,18 @@ Cancels listening for an input method event. ...@@ -166,19 +164,18 @@ Cancels listening for an input method event.
**System capability**: SystemCapability.Miscservices.InputMethodFramework **System capability**: SystemCapability.Miscservices.InputMethodFramework
- Parameters **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ------ | ---- | ------------------------------------------------------------ | | -------- | ------ | ---- | ------------------------------------------------------------ |
| type | string | Yes | Listening type.<br>-&nbsp;The value **'keyboardShow'** means to listen for displaying of the input method.<br>-&nbsp;The value **'keyboardHide'** means to listen for hiding of the input method.| | type | string | Yes | Listening type.<br>- The value **'keyboardShow'** means to listen for displaying of the input method.<br>- The value **'keyboardHide'** means to listen for hiding of the input method.|
| callback | void | No | Callback used to return the result. | | callback | void | No | Callback used to return the result. |
- Example
``` **Example**
InputMethodEngine.off('keyboardShow');
```
```js
InputMethodEngine.off('keyboardShow');
```
## KeyboardDelegate<a name="KeyboardDelegate"></a> ## KeyboardDelegate<a name="KeyboardDelegate"></a>
...@@ -192,22 +189,20 @@ Listens for a hard keyboard even. This API uses a callback to return the key inf ...@@ -192,22 +189,20 @@ Listens for a hard keyboard even. This API uses a callback to return the key inf
**System capability**: SystemCapability.Miscservices.InputMethodFramework **System capability**: SystemCapability.Miscservices.InputMethodFramework
- Parameters **Parameters**
| Name | Type | Mandatory| Description |
| -------- | ------------------------------- | ---- | ------------------------------------------------------------ |
| type | string | Yes | Listening type.<br>-&nbsp;The value **'keyDown'** means to listen for pressing of a key.<br>-&nbsp;The value **'keyUp'** means to listen for releasing of a key.|
| callback | [KeyEvent](#KeyEvent) | Yes| Callback used to return the key information.|
| Name | Type | Mandatory| Description |
| -------- | ------------------------------- | ---- | ------------------------------------------------------------ |
| type | string | Yes | Listening type.<br>- The value **'keyDown'** means to listen for pressing of a key.<br>- The value **'keyUp'** means to listen for releasing of a key.|
| callback | [KeyEvent](#KeyEvent) | Yes| Callback used to return the key information.|
- Example **Example**
``` ```js
KeyboardDelegate.on('keyDown', (event) => { KeyboardDelegate.on('keyDown', (event) => {
console.info('keyDown'); console.info('keyDown');
}); });
``` ```
### off('keyDown'|'keyUp') ### off('keyDown'|'keyUp')
...@@ -217,18 +212,18 @@ Cancels listening for a hard keyboard even. ...@@ -217,18 +212,18 @@ Cancels listening for a hard keyboard even.
**System capability**: SystemCapability.Miscservices.InputMethodFramework **System capability**: SystemCapability.Miscservices.InputMethodFramework
- Parameters **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | --------------------- | ---- | ------------------------------------------------------------ | | -------- | --------------------- | ---- | ------------------------------------------------------------ |
| type | string | Yes | Listening type.<br>-&nbsp;The value **'keyDown'** means to listen for pressing of a key.<br>-&nbsp;The value **'keyUp'** means to listen for releasing of a key.| | type | string | Yes | Listening type.<br>- The value **'keyDown'** means to listen for pressing of a key.<br>- The value **'keyUp'** means to listen for releasing of a key.|
| callback | [KeyEvent](#KeyEvent) | No | Callback used to return the key information. | | callback | [KeyEvent](#KeyEvent) | No | Callback used to return the key information. |
- Example **Example**
``` ```js
KeyboardDelegate.off('keyDown'); KeyboardDelegate.off('keyDown');
``` ```
### on('cursorContextChange') ### on('cursorContextChange')
...@@ -236,24 +231,22 @@ on(type: 'cursorContextChange', callback: (x: number, y:number, height:number) = ...@@ -236,24 +231,22 @@ on(type: 'cursorContextChange', callback: (x: number, y:number, height:number) =
Listens for cursor context changes. This API uses a callback to return the cursor information. Listens for cursor context changes. This API uses a callback to return the cursor information.
**System capability**: SystemCapability.Miscservices.InputMethodFramework **System capability**: SystemCapability.Miscservices.InputMethodFramework
- Parameters
| Name | Type | Mandatory| Description |
| -------- | ------ | ---- | ------------------------------------------------------------ |
| type | string | Yes | Listening type.<br>Set it to **'cursorContextChange'**, which indicates listening for cursor context changes.|
| callback | number | Yes | Callback used to return the cursor information. |
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ------ | ---- | ------------------------------------------------------------ |
| type | string | Yes | Listening type.<br>Set it to **'cursorContextChange'**, which indicates listening for cursor context changes.|
| callback | number | Yes | Callback used to return the cursor information. |
- Example **Example**
``` ```js
KeyboardDelegate.on('cursorContextChange', (x, y, height) => { KeyboardDelegate.on('cursorContextChange', (x, y, height) => {
console.info('cursorContextChange'); console.info('cursorContextChange');
}); });
``` ```
### off('cursorContextChange') ### off('cursorContextChange')
...@@ -263,19 +256,19 @@ Cancels listening for cursor context changes. ...@@ -263,19 +256,19 @@ Cancels listening for cursor context changes.
**System capability**: SystemCapability.Miscservices.InputMethodFramework **System capability**: SystemCapability.Miscservices.InputMethodFramework
- Parameters **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | -------------------- | ---- | ------------------------ | | -------- | -------------------- | ---- | ------------------------ |
| type | string | Yes | Listening type.<br>Set it to **'cursorContextChange'**, which indicates listening for cursor context changes.| | type | string | Yes | Listening type.<br>Set it to **'cursorContextChange'**, which indicates listening for cursor context changes.|
| callback | number | No| Callback used to return the cursor information.| | callback | number | No| Callback used to return the cursor information.|
**Example**
- Example ```js
KeyboardDelegate.off('cursorContextChange');
```
```
KeyboardDelegate.off('cursorContextChange');
```
### on('selectionChange') ### on('selectionChange')
on(type: 'selectionChange', callback: (oldBegin: number, oldEnd: number, newBegin: number, newEnd: number) => void): void on(type: 'selectionChange', callback: (oldBegin: number, oldEnd: number, newBegin: number, newEnd: number) => void): void
...@@ -284,20 +277,20 @@ Listens for text selection changes. This API uses a callback to return the text ...@@ -284,20 +277,20 @@ Listens for text selection changes. This API uses a callback to return the text
**System capability**: SystemCapability.Miscservices.InputMethodFramework **System capability**: SystemCapability.Miscservices.InputMethodFramework
- Parameters **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ------ | ---- | ------------------------------------------------------------ | | -------- | ------ | ---- | ------------------------------------------------------------ |
| type | string | Yes | Listening type.<br>Set it to **'selectionChange'**, which indicates listening for text selection changes.| | type | string | Yes | Listening type.<br>Set it to **'selectionChange'**, which indicates listening for text selection changes.|
| callback | number | Yes | Callback used to return the text selection information. | | callback | number | Yes | Callback used to return the text selection information. |
- Example **Example**
``` ```js
KeyboardDelegate.on('selectionChange', (oldBegin, oldEnd, newBegin, newEnd) => { KeyboardDelegate.on('selectionChange', (oldBegin, oldEnd, newBegin, newEnd) => {
console.info('selectionChange'); console.info('selectionChange');
}); });
``` ```
### off('selectionChange') ### off('selectionChange')
...@@ -307,18 +300,18 @@ Cancels listening for text selection changes. ...@@ -307,18 +300,18 @@ Cancels listening for text selection changes.
**System capability**: SystemCapability.Miscservices.InputMethodFramework **System capability**: SystemCapability.Miscservices.InputMethodFramework
- Parameters **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | -------------------- | ---- | ------------------------ | | -------- | -------------------- | ---- | ------------------------ |
| type | string | Yes | Listening type.<br>Set it to **'selectionChange'**, which indicates listening for text selection changes.| | type | string | Yes | Listening type.<br>Set it to **'selectionChange'**, which indicates listening for text selection changes.|
| callback | number | No| Callback used to return the text selection information.| | callback | number | No| Callback used to return the text selection information.|
- Example **Example**
``` ```js
KeyboardDelegate.off('selectionChange'); KeyboardDelegate.off('selectionChange');
``` ```
### on('textChange') ### on('textChange')
...@@ -329,20 +322,20 @@ Listens for text changes. This API uses a callback to return the current text co ...@@ -329,20 +322,20 @@ Listens for text changes. This API uses a callback to return the current text co
**System capability**: SystemCapability.Miscservices.InputMethodFramework **System capability**: SystemCapability.Miscservices.InputMethodFramework
- Parameters **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ------------------------------- | ---- | ------------------------------------------------------------ | | -------- | ------------------------------- | ---- | ------------------------------------------------------------ |
| type | string | Yes | Listening type.<br>Set it to **'textChange'**, which indicates listening for text changes.| | type | string | Yes | Listening type.<br>Set it to **'textChange'**, which indicates listening for text changes.|
| callback | string | Yes| Callback used to return the current text content.| | callback | string | Yes| Callback used to return the current text content.|
- Example **Example**
``` ```js
KeyboardDelegate.on('textChange', (text) => { KeyboardDelegate.on('textChange', (text) => {
console.info('textChange'); console.info('textChange');
}); });
``` ```
### off('textChange') ### off('textChange')
...@@ -352,18 +345,18 @@ Cancels listening for text changes. ...@@ -352,18 +345,18 @@ Cancels listening for text changes.
**System capability**: SystemCapability.Miscservices.InputMethodFramework **System capability**: SystemCapability.Miscservices.InputMethodFramework
- Parameters **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | -------------------- | ---- | ------------------------ | | -------- | -------------------- | ---- | ------------------------ |
| type | string | Yes | Listening type.<br>Set it to **'textChange'**, which indicates listening for text changes.| | type | string | Yes | Listening type.<br>Set it to **'textChange'**, which indicates listening for text changes.|
| callback | string | No| Callback used to return the current text content.| | callback | string | No| Callback used to return the current text content.|
- Example **Example**
``` ```js
KeyboardDelegate.off('textChange'); KeyboardDelegate.off('textChange');
``` ```
## KeyboardController<a name="KeyboardController"></a> ## KeyboardController<a name="KeyboardController"></a>
...@@ -377,16 +370,16 @@ Hides the keyboard. This API uses an asynchronous callback to return the result. ...@@ -377,16 +370,16 @@ Hides the keyboard. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Miscservices.InputMethodFramework **System capability**: SystemCapability.Miscservices.InputMethodFramework
- Parameters **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ---------------------- | ---- | -------- | | -------- | ---------------------- | ---- | -------- |
| callback | AsyncCallback&lt;void> | No | Callback used to return the result.| | callback | AsyncCallback&lt;void> | No | Callback used to return the result.|
- Example **Example**
``` ```js
KeyboardController.hideKeyboard(()=>{ KeyboardController.hideKeyboard(()=>{
}); });
``` ```
...@@ -399,16 +392,16 @@ Hides the keyboard. This API uses a promise to return the result. ...@@ -399,16 +392,16 @@ Hides the keyboard. This API uses a promise to return the result.
**System capability**: SystemCapability.Miscservices.InputMethodFramework **System capability**: SystemCapability.Miscservices.InputMethodFramework
- Return value **Return value**
| Type | Description: | | Type | Description: |
| ---------------- | -------- | | ---------------- | -------- |
| Promise&lt;void> | Promise used to return the result.| | Promise&lt;void> | Promise used to return the result.|
- Example **Example**
``` ```js
KeyboardController.hideKeyboard(); KeyboardController.hideKeyboard();
``` ```
...@@ -424,19 +417,20 @@ Obtains the specific-length text before the cursor. This API uses an asynchronou ...@@ -424,19 +417,20 @@ Obtains the specific-length text before the cursor. This API uses an asynchronou
**System capability**: SystemCapability.Miscservices.InputMethodFramework **System capability**: SystemCapability.Miscservices.InputMethodFramework
- Parameters **Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| length | number | Yes| Text length.|
| callback | AsyncCallback&lt;string&gt; | Yes| Text returned.|
| Name| Type| Mandatory| Description| **Example**
| -------- | -------- | -------- | -------- |
| length | number | Yes| Text length.|
| callback | AsyncCallback&lt;string&gt; | Yes| Text returned.|
- Example ```js
```
TextInputClient.getForward(5,(text) =>{ TextInputClient.getForward(5,(text) =>{
console.info("text = " + text); console.info("text = " + text);
}); });
``` ```
### getForward ### getForward
...@@ -446,22 +440,24 @@ Obtains the specific-length text before the cursor. This API uses a promise to r ...@@ -446,22 +440,24 @@ Obtains the specific-length text before the cursor. This API uses a promise to r
**System capability**: SystemCapability.Miscservices.InputMethodFramework **System capability**: SystemCapability.Miscservices.InputMethodFramework
- Parameters **Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| length | number | Yes| Text length.|
**Return value**
| Name| Type| Mandatory| Description| | Type | Description |
| -------- | -------- | -------- | -------- | | ------------------------------- | ------------------------------------------------------------ |
| length | number | Yes| Text length.| | Promise&lt;string&gt; | Text returned. |
- Return value **Example**
| Type | Description |
| ------------------------------- | ------------------------------------------------------------ |
| Promise&lt;string&gt; | Text returned. |
- Example ```js
```
var text = TextInputClient.getForward(5); var text = TextInputClient.getForward(5);
console.info("text = " + text); console.info("text = " + text);
``` ```
### getBackward ### getBackward
...@@ -471,19 +467,20 @@ Obtains the specific-length text after the cursor. This API uses an asynchronous ...@@ -471,19 +467,20 @@ Obtains the specific-length text after the cursor. This API uses an asynchronous
**System capability**: SystemCapability.Miscservices.InputMethodFramework **System capability**: SystemCapability.Miscservices.InputMethodFramework
- Parameters **Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| length | number | Yes| Text length.|
| callback | AsyncCallback&lt;string&gt; | Yes| Text returned.|
| Name| Type| Mandatory| Description| **Example**
| -------- | -------- | -------- | -------- |
| length | number | Yes| Text length.|
| callback | AsyncCallback&lt;string&gt; | Yes| Text returned.|
- Example ```js
```
TextInputClient.getBackward(5,(text)=>{ TextInputClient.getBackward(5,(text)=>{
console.info("text = " + text); console.info("text = " + text);
}); });
``` ```
### getBackward ### getBackward
...@@ -493,22 +490,24 @@ Obtains the specific-length text after the cursor. This API uses a promise to re ...@@ -493,22 +490,24 @@ Obtains the specific-length text after the cursor. This API uses a promise to re
**System capability**: SystemCapability.Miscservices.InputMethodFramework **System capability**: SystemCapability.Miscservices.InputMethodFramework
- Parameters **Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| length | number | Yes| Text length.|
**Return value**
| Name| Type| Mandatory| Description| | Type | Description |
| -------- | -------- | -------- | -------- | | ------------------------------- | ------------------------------------------------------------ |
| length | number | Yes| Text length.| | Promise&lt;string&gt; | Text returned. |
- Return value **Example**
| Type | Description |
| ------------------------------- | ------------------------------------------------------------ |
| Promise&lt;string&gt; | Text returned. |
- Example ```js
```
var text = TextInputClient.getBackward(5); var text = TextInputClient.getBackward(5);
console.info("text = " + text); console.info("text = " + text);
``` ```
### deleteForward ### deleteForward
...@@ -518,19 +517,21 @@ Deletes the fixed-length text before the cursor. This API uses an asynchronous c ...@@ -518,19 +517,21 @@ Deletes the fixed-length text before the cursor. This API uses an asynchronous c
**System capability**: SystemCapability.Miscservices.InputMethodFramework **System capability**: SystemCapability.Miscservices.InputMethodFramework
- Parameters **Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| length | number | Yes| Text length.|
| callback | AsyncCallback&lt;boolean&gt; | Yes| Returns whether the operation is successful.|
| Name| Type| Mandatory| Description| **Example**
| -------- | -------- | -------- | -------- |
| length | number | Yes| Text length.|
| callback | AsyncCallback&lt;boolean&gt; | Yes| Returns whether the operation is successful.|
- Example ```js
``` TextInputClient.deleteForward(5,(isSuccess)=>{
TextInputClient.deleteForward(5,(isSuccess)=>{
console.info("isSuccess = " + isSuccess); console.info("isSuccess = " + isSuccess);
}); });
``` ```
### deleteForward ### deleteForward
deleteForward(length:number): Promise&lt;boolean&gt; deleteForward(length:number): Promise&lt;boolean&gt;
...@@ -539,22 +540,24 @@ Deletes the fixed-length text before the cursor. This API uses a promise to retu ...@@ -539,22 +540,24 @@ Deletes the fixed-length text before the cursor. This API uses a promise to retu
**System capability**: SystemCapability.Miscservices.InputMethodFramework **System capability**: SystemCapability.Miscservices.InputMethodFramework
- Parameters **Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| length | number | Yes| Text length.|
| Name| Type| Mandatory| Description| **Return value**
| -------- | -------- | -------- | -------- |
| length | number | Yes| Text length.|
- Return value | Type | Description |
| Type | Description | | ------------------------------- | ------------------------------------------------------------ |
| ------------------------------- | ------------------------------------------------------------ | | Promise&lt;boolean&gt; | Returns whether the operation is successful. |
| Promise&lt;boolean&gt; | Returns whether the operation is successful. |
- Example **Example**
```
```js
var isSuccess = TextInputClient.deleteForward(5); var isSuccess = TextInputClient.deleteForward(5);
console.info("isSuccess = " + isSuccess); console.info("isSuccess = " + isSuccess);
``` ```
### deleteBackward ### deleteBackward
...@@ -564,19 +567,20 @@ Deletes the fixed-length text after the cursor. This API uses an asynchronous ca ...@@ -564,19 +567,20 @@ Deletes the fixed-length text after the cursor. This API uses an asynchronous ca
**System capability**: SystemCapability.Miscservices.InputMethodFramework **System capability**: SystemCapability.Miscservices.InputMethodFramework
- Parameters **Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| length | number | Yes| Text length.|
| callback | AsyncCallback&lt;boolean&gt; | Yes| Returns whether the operation is successful.|
| Name| Type| Mandatory| Description| **Example**
| -------- | -------- | -------- | -------- |
| length | number | Yes| Text length.|
| callback | AsyncCallback&lt;boolean&gt; | Yes| Returns whether the operation is successful.|
- Example ```js
```
TextInputClient.deleteBackward(5, (isSuccess)=>{ TextInputClient.deleteBackward(5, (isSuccess)=>{
console.info("isSuccess = " + isSuccess); console.info("isSuccess = " + isSuccess);
}); });
``` ```
### deleteBackward ### deleteBackward
...@@ -586,22 +590,25 @@ Deletes the fixed-length text after the cursor. This API uses a promise to retur ...@@ -586,22 +590,25 @@ Deletes the fixed-length text after the cursor. This API uses a promise to retur
**System capability**: SystemCapability.Miscservices.InputMethodFramework **System capability**: SystemCapability.Miscservices.InputMethodFramework
- Parameters **Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| length | number | Yes| Text length.|
- Return value | Name| Type| Mandatory| Description|
| Type | Description | | -------- | -------- | -------- | -------- |
| ------------------------------- | ------------------------------------------------------------ | | length | number | Yes| Text length.|
| Promise&lt;boolean&gt; | Returns whether the operation is successful. |
- Example **Return value**
| Type | Description |
| ------------------------------- | ------------------------------------------------------------ |
| Promise&lt;boolean&gt; | Returns whether the operation is successful. |
**Example**
```js
var isSuccess = TextInputClient.deleteBackward(5);
console.info("isSuccess = " + isSuccess);
```
```
var isSuccess = TextInputClient.deleteBackward(5);
console.info("isSuccess = " + isSuccess);
```
### sendKeyFunction ### sendKeyFunction
sendKeyFunction(action:number, callback: AsyncCallback&lt;boolean&gt;): void sendKeyFunction(action:number, callback: AsyncCallback&lt;boolean&gt;): void
...@@ -610,19 +617,20 @@ Sets the Enter key to send the text to its target. This API uses an asynchronous ...@@ -610,19 +617,20 @@ Sets the Enter key to send the text to its target. This API uses an asynchronous
**System capability**: SystemCapability.Miscservices.InputMethodFramework **System capability**: SystemCapability.Miscservices.InputMethodFramework
- Parameters **Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| action | number | Yes| Edit box attribute.|
| callback | AsyncCallback&lt;boolean&gt; | Yes| Returns whether the operation is successful.|
| Name| Type| Mandatory| Description| **Example**
| -------- | -------- | -------- | -------- |
| action | number | Yes| Edit box attribute.|
| callback | AsyncCallback&lt;boolean&gt; | Yes| Returns whether the operation is successful.|
- Example ```js
```
TextInputClient.sendKeyFunction(inputMethod.ENTER_KEY_TYPE_NEXT,(isSuccess)=>{ TextInputClient.sendKeyFunction(inputMethod.ENTER_KEY_TYPE_NEXT,(isSuccess)=>{
console.info("isSuccess = " + isSuccess); console.info("isSuccess = " + isSuccess);
}); });
``` ```
### sendKeyFunction ### sendKeyFunction
...@@ -632,22 +640,24 @@ Sets the Enter key to send the text to its target. This API uses a promise to re ...@@ -632,22 +640,24 @@ Sets the Enter key to send the text to its target. This API uses a promise to re
**System capability**: SystemCapability.Miscservices.InputMethodFramework **System capability**: SystemCapability.Miscservices.InputMethodFramework
- Parameters **Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| action | number | Yes| Edit box attribute.|
- Return value | Name| Type| Mandatory| Description|
| Type | Description | | -------- | -------- | -------- | -------- |
| ------------------------------- | ------------------------------------------------------------ | | action | number | Yes| Edit box attribute.|
| Promise&lt;boolean&gt; | Returns whether the operation is successful. |
- Example **Return value**
``` | Type | Description |
var isSuccess = TextInputClient.sendKeyFunction(inputMethod.ENTER_KEY_TYPE_NEXT); | ------------------------------- | ------------------------------------------------------------ |
console.info("isSuccess = " + isSuccess); | Promise&lt;boolean&gt; | Returns whether the operation is successful. |
```
**Example**
```js
var isSuccess = TextInputClient.sendKeyFunction(inputMethod.ENTER_KEY_TYPE_NEXT);
console.info("isSuccess = " + isSuccess);
```
### insertText ### insertText
...@@ -657,19 +667,20 @@ Inserts text. This API uses an asynchronous callback to return the result. ...@@ -657,19 +667,20 @@ Inserts text. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Miscservices.InputMethodFramework **System capability**: SystemCapability.Miscservices.InputMethodFramework
- Parameters **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| text | string | Yes| Text to insert.| | text | string | Yes| Text to insert.|
| callback | AsyncCallback&lt;boolean&gt; | Yes| Returns whether the operation is successful.| | callback | AsyncCallback&lt;boolean&gt; | Yes| Returns whether the operation is successful.|
- Example **Example**
```
TextInputClient.insertText("test", (isSuccess)=>{ ```js
TextInputClient.insertText("test", (isSuccess)=>{
console.info("isSuccess = " + isSuccess); console.info("isSuccess = " + isSuccess);
}); });
``` ```
### insertText ### insertText
...@@ -679,22 +690,24 @@ Inserts text. This API uses a promise to return the result. ...@@ -679,22 +690,24 @@ Inserts text. This API uses a promise to return the result.
**System capability**: SystemCapability.Miscservices.InputMethodFramework **System capability**: SystemCapability.Miscservices.InputMethodFramework
- Parameters **Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| text | string | Yes| Text to insert.|
- Return value | Name| Type| Mandatory| Description|
| Type | Description | | -------- | -------- | -------- | -------- |
| ------------------------------- | ------------------------------------------------------------ | | text | string | Yes| Text to insert.|
| Promise&lt;boolean&gt; | Returns whether the operation is successful. |
- Example **Return value**
``` | Type | Description |
var isSuccess = TextInputClient.insertText("test"); | ------------------------------- | ------------------------------------------------------------ |
console.info("isSuccess = " + isSuccess); | Promise&lt;boolean&gt; | Returns whether the operation is successful. |
```
**Example**
```js
var isSuccess = TextInputClient.insertText("test");
console.info("isSuccess = " + isSuccess);
```
### getEditorAttribute ### getEditorAttribute
...@@ -704,16 +717,18 @@ Obtains the attribute of the edit box. This API uses an asynchronous callback to ...@@ -704,16 +717,18 @@ Obtains the attribute of the edit box. This API uses an asynchronous callback to
**System capability**: SystemCapability.Miscservices.InputMethodFramework **System capability**: SystemCapability.Miscservices.InputMethodFramework
- Parameters **Parameters**
| Name | Type | Mandatory | Description |
| ------------------------------- | ------------------------------------------------------------ | ------------------------------------------------------------ | ------------------------------------------------------------ | | Name | Type | Mandatory | Description |
| callback | AsyncCallback&lt;[EditorAttribute](#EditorAttribute)&gt; | Yes| Attribute of the edit box. | | ------------------------------- | ------------------------------------------------------------ | ------------------------------------------------------------ | ------------------------------------------------------------ |
| callback | AsyncCallback&lt;[EditorAttribute](#EditorAttribute)&gt; | Yes| Attribute of the edit box. |
- Example **Example**
```
```js
TextInputClient.getEditorAttribute((EditorAttribute)=>{ TextInputClient.getEditorAttribute((EditorAttribute)=>{
}); });
``` ```
### getEditorAttribute ### getEditorAttribute
...@@ -723,15 +738,17 @@ Obtains the attribute of the edit box. This API uses a promise to return the res ...@@ -723,15 +738,17 @@ Obtains the attribute of the edit box. This API uses a promise to return the res
**System capability**: SystemCapability.Miscservices.InputMethodFramework **System capability**: SystemCapability.Miscservices.InputMethodFramework
- Return value **Return value**
| Type | Description |
| ------------------------------- | ------------------------------------------------------------ | | Type | Description |
| Promise&lt;[EditorAttribute](#EditorAttribute)&gt; | Returns the attribute of the edit box. | | ------------------------------- | ------------------------------------------------------------ |
| Promise&lt;[EditorAttribute](#EditorAttribute)&gt; | Returns the attribute of the edit box. |
- Example **Example**
```
var EditorAttribute = TextInputClient.getEditorAttribute(); ```js
``` var EditorAttribute = TextInputClient.getEditorAttribute();
```
## EditorAttribute<a name="EditorAttribute"></a> ## EditorAttribute<a name="EditorAttribute"></a>
......
# Pasteboard # Pasteboard
> ![icon-note.gif](public_sys-resources/icon-note.gif) **Note:** > ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**<br>The initial APIs of this module are supported since API version 6. Newly added APIs will be marked with a superscript to indicate their earliest API version.
> The initial APIs of this module are supported since API version 6. Newly added APIs will be marked with a superscript to indicate their earliest API version. >
## Modules to Import ## Modules to Import
...@@ -19,11 +19,11 @@ import pasteboard from '@ohos.pasteboard'; ...@@ -19,11 +19,11 @@ import pasteboard from '@ohos.pasteboard';
| Name | Type | Readable | Writable | Description | | Name | Type | Readable | Writable | Description |
| -------- | -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- | -------- |
| MAX_RECORD_NUM<sup>7+</sup> | number | Yes | No | Maximum&nbsp;number&nbsp;of&nbsp;records&nbsp;allowed&nbsp;in&nbsp;a&nbsp;**PasteData**&nbsp;object. | | MAX_RECORD_NUM<sup>7+</sup> | number | Yes | No | Maximum number of records allowed in a **PasteData** object. |
| MIMETYPE_TEXT_HTML<sup>7+</sup> | string | Yes | No | MIME&nbsp;type&nbsp;of&nbsp;the&nbsp;HTML&nbsp;text. | | MIMETYPE_TEXT_HTML<sup>7+</sup> | string | Yes | No | MIME type of the HTML text. |
| MIMETYPE_TEXT_WANT<sup>7+</sup> | string | Yes | No | MIME&nbsp;type&nbsp;of&nbsp;the&nbsp;Want&nbsp;text. | | MIMETYPE_TEXT_WANT<sup>7+</sup> | string | Yes | No | MIME type of the Want text. |
| MIMETYPE_TEXT_PLAIN<sup>7+</sup> | string | Yes | No | MIME&nbsp;type&nbsp;of&nbsp;the&nbsp;plain&nbsp;text. | | MIMETYPE_TEXT_PLAIN<sup>7+</sup> | string | Yes | No | MIME type of the plain text. |
| MIMETYPE_TEXT_URI<sup>7+</sup> | string | Yes | No | MIME&nbsp;type&nbsp;of&nbsp;the&nbsp;URI&nbsp;text. | | MIMETYPE_TEXT_URI<sup>7+</sup> | string | Yes | No | MIME type of the URI text. |
## pasteboard.createPlainTextData ## pasteboard.createPlainTextData
...@@ -34,21 +34,23 @@ Creates a **PasteData** object for plain text. ...@@ -34,21 +34,23 @@ Creates a **PasteData** object for plain text.
**System capability**: SystemCapability.MiscServices.Pasteboard **System capability**: SystemCapability.MiscServices.Pasteboard
- Parameters **Parameters**
| Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- |
| text | string | Yes | Plain&nbsp;text. |
- Return values | Name | Type | Mandatory | Description |
| Type | Description | | -------- | -------- | -------- | -------- |
| -------- | -------- | | text | string | Yes | Plain text. |
| [PasteData](#pastedata) | **PasteData**&nbsp;object&nbsp;with&nbsp;the&nbsp;specified&nbsp;content. |
- Example **Return value**
``` | Type | Description |
var pasteData = pasteboard.createPlainTextData("content"); | -------- | -------- |
``` | [PasteData](#pastedata) | **PasteData** object with the specified content. |
**Example**
```js
var pasteData = pasteboard.createPlainTextData("content");
```
## pasteboard.createHtmlData<sup>7+</sup> ## pasteboard.createHtmlData<sup>7+</sup>
...@@ -59,22 +61,24 @@ Creates a **PasteData** object for HTML text. ...@@ -59,22 +61,24 @@ Creates a **PasteData** object for HTML text.
**System capability**: SystemCapability.MiscServices.Pasteboard **System capability**: SystemCapability.MiscServices.Pasteboard
- Parameters **Parameters**
| Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- |
| htmlText | string | Yes | HTML&nbsp;text. |
- Return values | Name | Type | Mandatory | Description |
| Type | Description | | -------- | -------- | -------- | -------- |
| -------- | -------- | | htmlText | string | Yes | HTML text. |
| [PasteData](#pastedata) | **PasteData**&nbsp;object&nbsp;with&nbsp;the&nbsp;specified&nbsp;content. |
- Example **Return value**
``` | Type | Description |
var html = "<!DOCTYPE html>\n" + "<html>\n" + "<head>\n" + "<meta charset=\"utf-8\">\n" + "<title>HTML-PASTEBOARD_HTML</title>\n" + "</head>\n" + "<body>\n" + " <h1>HEAD</h1>\n" + " <p></p>\n" + "</body>\n" + "</html>"; | -------- | -------- |
var pasteData = pasteboard.createHtmlData(html); | [PasteData](#pastedata) | **PasteData** object with the specified content. |
```
**Example**
```js
var html = "<!DOCTYPE html>\n" + "<html>\n" + "<head>\n" + "<meta charset=\"utf-8\">\n" + "<title>HTML-PASTEBOARD_HTML</title>\n" + "</head>\n" + "<body>\n" + " <h1>HEAD</h1>\n" + " <p></p>\n" + "</body>\n" + "</html>";
var pasteData = pasteboard.createHtmlData(html);
```
## pasteboard.createWantData<sup>7+</sup> ## pasteboard.createWantData<sup>7+</sup>
...@@ -85,25 +89,27 @@ Creates a **PasteData** object for Want text. ...@@ -85,25 +89,27 @@ Creates a **PasteData** object for Want text.
**System capability**: SystemCapability.MiscServices.Pasteboard **System capability**: SystemCapability.MiscServices.Pasteboard
- Parameters **Parameters**
| Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- | | Name | Type | Mandatory | Description |
| want | [Want](js-apis-featureAbility.md#want) | Yes | Want&nbsp;text. | | -------- | -------- | -------- | -------- |
| want | [Want](js-apis-application-Want.md) | Yes | Want text. |
- Return values **Return value**
| Type | Description |
| -------- | -------- |
| [PasteData](#pastedata) | **PasteData**&nbsp;object&nbsp;with&nbsp;the&nbsp;specified&nbsp;content. |
- Example | Type | Description |
| -------- | -------- |
| [PasteData](#pastedata) | **PasteData** object with the specified content. |
``` **Example**
var object = {
```js
var object = {
bundleName: "com.example.aafwk.test", bundleName: "com.example.aafwk.test",
abilityName: "com.example.aafwk.test.TwoAbility" abilityName: "com.example.aafwk.test.TwoAbility"
}; };
var pasteData = pasteboard.createWantData(object); var pasteData = pasteboard.createWantData(object);
``` ```
## pasteboard.createUriData<sup>7+</sup> ## pasteboard.createUriData<sup>7+</sup>
...@@ -114,21 +120,23 @@ Creates a **PasteData** object for URI text. ...@@ -114,21 +120,23 @@ Creates a **PasteData** object for URI text.
**System capability**: SystemCapability.MiscServices.Pasteboard **System capability**: SystemCapability.MiscServices.Pasteboard
- Parameters **Parameters**
| Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- | | Name | Type | Mandatory | Description |
| uri | string | Yes | URI&nbsp;text. | | -------- | -------- | -------- | -------- |
| uri | string | Yes | URI text. |
- Return values **Return value**
| Type | Description |
| -------- | -------- |
| [PasteData](#pastedata) | **PasteData**&nbsp;object&nbsp;with&nbsp;the&nbsp;specified&nbsp;content. |
- Example | Type | Description |
| -------- | -------- |
| [PasteData](#pastedata) | **PasteData** object with the specified content. |
``` **Example**
var pasteData = pasteboard.createUriData("dataability:///com.example.myapplication1?user.txt");
``` ```js
var pasteData = pasteboard.createUriData("dataability:///com.example.myapplication1?user.txt");
```
## pasteboard.createPlainTextRecord<sup>7+</sup> ## pasteboard.createPlainTextRecord<sup>7+</sup>
...@@ -139,21 +147,23 @@ Creates a **PasteDataRecord** object of the plain text type. ...@@ -139,21 +147,23 @@ Creates a **PasteDataRecord** object of the plain text type.
**System capability**: SystemCapability.MiscServices.Pasteboard **System capability**: SystemCapability.MiscServices.Pasteboard
- Parameters **Parameters**
| Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- |
| text | string | Yes | Plain&nbsp;text. |
- Return values | Name | Type | Mandatory | Description |
| Type | Description | | -------- | -------- | -------- | -------- |
| -------- | -------- | | text | string | Yes | Plain text. |
| [PasteDataRecord](#pastedatarecord7) | New&nbsp;plain&nbsp;text&nbsp;record. |
- Example **Return value**
``` | Type | Description |
var record = pasteboard.createPlainTextRecord("hello"); | -------- | -------- |
``` | [PasteDataRecord](#pastedatarecord7) | New plain text record. |
**Example**
```js
var record = pasteboard.createPlainTextRecord("hello");
```
## pasteboard.createHtmlTextRecord<sup>7+</sup> ## pasteboard.createHtmlTextRecord<sup>7+</sup>
...@@ -164,22 +174,24 @@ Creates a **PasteDataRecord** object of the HTML text type. ...@@ -164,22 +174,24 @@ Creates a **PasteDataRecord** object of the HTML text type.
**System capability**: SystemCapability.MiscServices.Pasteboard **System capability**: SystemCapability.MiscServices.Pasteboard
- Parameters **Parameters**
| Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- | | Name | Type | Mandatory | Description |
| htmlText | string | Yes | HTML&nbsp;text. | | -------- | -------- | -------- | -------- |
| htmlText | string | Yes | HTML text. |
- Return values **Return value**
| Type | Description |
| -------- | -------- |
| [PasteDataRecord](#pastedatarecord7) | New&nbsp;HTML&nbsp;record. |
- Example | Type | Description |
| -------- | -------- |
| [PasteDataRecord](#pastedatarecord7) | New HTML record. |
``` **Example**
var html = "<!DOCTYPE html>\n" + "<html>\n" + "<head>\n" + "<meta charset=\"utf-8\">\n" + "<title>HTML-PASTEBOARD_HTML</title>\n" + "</head>\n" + "<body>\n" + " <h1>HEAD</h1>\n" + " <p></p>\n" + "</body>\n" + "</html>";
var record = pasteboard.createHtmlTextRecord(html); ```js
``` var html = "<!DOCTYPE html>\n" + "<html>\n" + "<head>\n" + "<meta charset=\"utf-8\">\n" + "<title>HTML-PASTEBOARD_HTML</title>\n" + "</head>\n" + "<body>\n" + " <h1>HEAD</h1>\n" + " <p></p>\n" + "</body>\n" + "</html>";
var record = pasteboard.createHtmlTextRecord(html);
```
## pasteboard.createWantRecord<sup>7+</sup> ## pasteboard.createWantRecord<sup>7+</sup>
...@@ -190,25 +202,27 @@ Creates a **PasteDataRecord** object of the Want text type. ...@@ -190,25 +202,27 @@ Creates a **PasteDataRecord** object of the Want text type.
**System capability**: SystemCapability.MiscServices.Pasteboard **System capability**: SystemCapability.MiscServices.Pasteboard
- Parameters **Parameters**
| Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- | | Name | Type | Mandatory | Description |
| want | [Want](js-apis-featureAbility.md#want) | Yes | Want&nbsp;text. | | -------- | -------- | -------- | -------- |
| want | [Want](js-apis-application-Want.md) | Yes | Want text. |
- Return values **Return value**
| Type | Description |
| -------- | -------- |
| [PasteDataRecord](#pastedatarecord7) | New&nbsp;Want&nbsp;record. |
- Example | Type | Description |
| -------- | -------- |
| [PasteDataRecord](#pastedatarecord7) | New Want record. |
``` **Example**
var object = {
```js
var object = {
bundleName: "com.example.aafwk.test", bundleName: "com.example.aafwk.test",
abilityName: "com.example.aafwk.test.TwoAbility" abilityName: "com.example.aafwk.test.TwoAbility"
}; };
var record = pasteboard.createWantRecord(object); var record = pasteboard.createWantRecord(object);
``` ```
## pasteboard.createUriRecord<sup>7+</sup> ## pasteboard.createUriRecord<sup>7+</sup>
...@@ -219,21 +233,23 @@ Creates a **PasteDataRecord** object of the URI text type. ...@@ -219,21 +233,23 @@ Creates a **PasteDataRecord** object of the URI text type.
**System capability**: SystemCapability.MiscServices.Pasteboard **System capability**: SystemCapability.MiscServices.Pasteboard
- Parameters **Parameters**
| Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- | | Name | Type | Mandatory | Description |
| uri | string | Yes | URI&nbsp;text. | | -------- | -------- | -------- | -------- |
| uri | string | Yes | URI text. |
- Return values **Return value**
| Type | Description |
| -------- | -------- |
| [PasteDataRecord](#pastedatarecord7) | New&nbsp;URI&nbsp;record. |
- Example | Type | Description |
| -------- | -------- |
| [PasteDataRecord](#pastedatarecord7) | New URI record. |
``` **Example**
var record = pasteboard.createUriRecord("dataability:///com.example.myapplication1?user.txt");
``` ```js
var record = pasteboard.createUriRecord("dataability:///com.example.myapplication1?user.txt");
```
## PasteDataProperty<sup>7+</sup> ## PasteDataProperty<sup>7+</sup>
...@@ -244,11 +260,11 @@ Defines the properties of all data records on the pasteboard, including the time ...@@ -244,11 +260,11 @@ Defines the properties of all data records on the pasteboard, including the time
| Name | Type | Readable | Writable | Description | | Name | Type | Readable | Writable | Description |
| -------- | -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- | -------- |
| additions | {[key:&nbsp;string]:&nbsp;object} | Yes | Yes | Additional&nbsp;property&nbsp;data. | | additions | {[key: string]: object} | Yes | Yes | Additional property data. |
| mimeTypes | Array&lt;string&gt; | Yes | No | Non-repeating&nbsp;data&nbsp;types&nbsp;of&nbsp;the&nbsp;data&nbsp;records&nbsp;on&nbsp;the&nbsp;pasteboard. | | mimeTypes | Array&lt;string&gt; | Yes | No | Non-repeating data types of the data records on the pasteboard. |
| tag | string | Yes | Yes | User-defined&nbsp;tag. | | tag | string | Yes | Yes | User-defined tag. |
| timestamp | number | Yes | No | Timestamp&nbsp;at&nbsp;which&nbsp;the&nbsp;data&nbsp;is&nbsp;written&nbsp;to&nbsp;the&nbsp;pasteboard,&nbsp;in&nbsp;milliseconds. | | timestamp | number | Yes | No | Timestamp at which the data is written to the pasteboard, in milliseconds. |
| localOnly | boolean | Yes | Yes | Whether&nbsp;local&nbsp;access&nbsp;only&nbsp;is&nbsp;set&nbsp;for&nbsp;the&nbsp;pasteboard.<br/>-&nbsp;The&nbsp;default&nbsp;value&nbsp;is&nbsp;**true**.<br/>-&nbsp;**true**:&nbsp;The&nbsp;**PasteData**&nbsp;is&nbsp;set&nbsp;for&nbsp;local&nbsp;access&nbsp;only.<br/>-&nbsp;**false**:&nbsp;The&nbsp;**PasteData**&nbsp;can&nbsp;be&nbsp;shared&nbsp;between&nbsp;devices. | | localOnly | boolean | Yes | Yes | Whether local access only is set for the pasteboard.<br/>- The default value is **true**.<br/>- **true**: The **PasteData** is set for local access only.<br/>- **false**: The **PasteData** can be shared between devices. |
## PasteDataRecord<sup>7+</sup> ## PasteDataRecord<sup>7+</sup>
...@@ -262,63 +278,65 @@ A data record is an abstract definition of the content on the pasteboard. The pa ...@@ -262,63 +278,65 @@ A data record is an abstract definition of the content on the pasteboard. The pa
| Name | Type | Readable | Writable | Description | | Name | Type | Readable | Writable | Description |
| -------- | -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- | -------- |
| htmlText<sup>7+</sup> | string | Yes | No | HTML&nbsp;text. | | htmlText<sup>7+</sup> | string | Yes | No | HTML text. |
| want<sup>7+</sup> | [Want](js-apis-featureAbility.md#want) | Yes | No | Want&nbsp;text. | | want<sup>7+</sup> | [Want](js-apis-featureAbility.md#want) | Yes | No | Want text. |
| mimeType<sup>7+</sup> | string | Yes | No | Data&nbsp;type. | | mimeType<sup>7+</sup> | string | Yes | No | Data type. |
| plainText<sup>7+</sup> | string | Yes | No | Plain&nbsp;text. | | plainText<sup>7+</sup> | string | Yes | No | Plain text. |
| uri<sup>7+</sup> | string | Yes | No | URI&nbsp;text. | | uri<sup>7+</sup> | string | Yes | No | URI text. |
### convertToText<sup>7+</sup> ### convertToText<sup>7+</sup>
convertToText(): Promise&lt;string&gt; convertToText(): Promise&lt;string&gt;
Forcibly converts the content in this **PasteData** object to the plain text. This method uses a promise to return the result. Forcibly converts the content in this **PasteData** object to the plain text. This API uses a promise to return the result.
**System capability**: SystemCapability.MiscServices.Pasteboard **System capability**: SystemCapability.MiscServices.Pasteboard
- Return values **Return value**
| Type | Description |
| -------- | -------- | | Type | Description |
| Promise&lt;void&gt; | Promise&nbsp;used&nbsp;to&nbsp;return&nbsp;the&nbsp;result.&nbsp;If&nbsp;the&nbsp;operation&nbsp;is&nbsp;successful,&nbsp;the&nbsp;plain&nbsp;text&nbsp;content&nbsp;after&nbsp;conversion&nbsp;is&nbsp;returned.&nbsp;Otherwise,&nbsp;error&nbsp;information&nbsp;is&nbsp;returned. | | -------- | -------- |
| Promise&lt;void&gt; | Promise used to return the result. If the operation is successful, the plain text content after conversion is returned. Otherwise, error information is returned. |
- Example **Example**
``` ```js
var record = pasteboard.createUriRecord("dataability:///com.example.myapplication1?user.txt"); var record = pasteboard.createUriRecord("dataability:///com.example.myapplication1?user.txt");
record.convertToText().then((data) => { record.convertToText().then((data) => {
console.info('convertToText success data : ' + JSON.stringify(data)); console.info('convertToText success data : ' + JSON.stringify(data));
}).catch((error) => { }).catch((error) => {
console.error('convertToText failed because ' + JSON.stringify(error)); console.error('convertToText failed because ' + JSON.stringify(error));
}); });
``` ```
### convertToText<sup>7+</sup> ### convertToText<sup>7+</sup>
convertToText(callback: AsyncCallback&lt;string&gt;): void convertToText(callback: AsyncCallback&lt;string&gt;): void
Forcibly converts the content in this **PasteData** object to the plain text. This method uses an asynchronous callback to return the result. Forcibly converts the content in this **PasteData** object to the plain text. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.MiscServices.Pasteboard **System capability**: SystemCapability.MiscServices.Pasteboard
- Parameters **Parameters**
| Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- | | Name | Type | Mandatory | Description |
| callback | AsyncCallback&lt;string&gt; | Yes | Callback&nbsp;used&nbsp;to&nbsp;return&nbsp;the&nbsp;result.&nbsp;If&nbsp;this&nbsp;callback&nbsp;is&nbsp;successful,&nbsp;the&nbsp;plain&nbsp;text&nbsp;content&nbsp;after&nbsp;conversion&nbsp;is&nbsp;returned.&nbsp;Otherwise,&nbsp;error&nbsp;information&nbsp;is&nbsp;returned. | | -------- | -------- | -------- | -------- |
| callback | AsyncCallback&lt;string&gt; | Yes | Callback used to return the result. If this callback is successful, the plain text content after conversion is returned. Otherwise, error information is returned. |
- Example **Example**
``` ```js
var record = pasteboard.createUriRecord("dataability:///com.example.myapplication1?user.txt"); var record = pasteboard.createUriRecord("dataability:///com.example.myapplication1?user.txt");
record.convertToText((err, data) => { record.convertToText((err, data) => {
if (err) { if (err) {
console.error('convertToText failed because ' + JSON.stringify(err)); console.error('convertToText failed because ' + JSON.stringify(err));
return; return;
} }
console.info('convertToText success data : ' + JSON.stringify(data)); console.info('convertToText success data : ' + JSON.stringify(data));
}); });
``` ```
## PasteData ## PasteData
...@@ -339,22 +357,19 @@ Obtains the plain text of the primary record. ...@@ -339,22 +357,19 @@ Obtains the plain text of the primary record.
**System capability**: SystemCapability.MiscServices.Pasteboard **System capability**: SystemCapability.MiscServices.Pasteboard
**Return value**
- Parameters
None
| Type | Description |
| -------- | -------- |
| string | Plain text. |
- Return values **Example**
| Type | Description |
| -------- | -------- |
| string | Plain&nbsp;text. |
- Example ```js
var pasteData = pasteboard.createPlainTextData("hello");
``` var plainText = pasteData.getPrimaryText();
var pasteData = pasteboard.createPlainTextData("hello"); ```
var plainText = pasteData.getPrimaryText();
```
### getPrimaryHtml<sup>7+</sup> ### getPrimaryHtml<sup>7+</sup>
...@@ -365,18 +380,19 @@ Obtains the HTML text of the primary record. ...@@ -365,18 +380,19 @@ Obtains the HTML text of the primary record.
**System capability**: SystemCapability.MiscServices.Pasteboard **System capability**: SystemCapability.MiscServices.Pasteboard
- Return values **Return value**
| Type | Description |
| -------- | -------- | | Type | Description |
| string | HTML&nbsp;text. | | -------- | -------- |
| string | HTML text. |
- Example **Example**
``` ```js
var html = "<!DOCTYPE html>\n" + "<html>\n" + "<head>\n" + "<meta charset=\"utf-8\">\n" + "<title>HTML-PASTEBOARD_HTML</title>\n" + "</head>\n" + "<body>\n" + " <h1>HEAD</h1>\n" + " <p></p>\n" + "</body>\n" + "</html>"; var html = "<!DOCTYPE html>\n" + "<html>\n" + "<head>\n" + "<meta charset=\"utf-8\">\n" + "<title>HTML-PASTEBOARD_HTML</title>\n" + "</head>\n" + "<body>\n" + " <h1>HEAD</h1>\n" + " <p></p>\n" + "</body>\n" + "</html>";
var pasteData = pasteboard.createHtmlData(html); var pasteData = pasteboard.createHtmlData(html);
var htmlText = pasteData.getPrimaryHtml(); var htmlText = pasteData.getPrimaryHtml();
``` ```
### getPrimaryWant<sup>7+</sup> ### getPrimaryWant<sup>7+</sup>
...@@ -387,21 +403,22 @@ Obtains the **Want** object of the primary record. ...@@ -387,21 +403,22 @@ Obtains the **Want** object of the primary record.
**System capability**: SystemCapability.MiscServices.Pasteboard **System capability**: SystemCapability.MiscServices.Pasteboard
- Return values **Return value**
| Type | Description |
| -------- | -------- | | Type | Description |
| [Want](js-apis-featureAbility.md#want) | Want&nbsp;object. | | -------- | -------- |
| [Want](js-apis-application-Want.md) | Want object. |
- Example **Example**
``` ```js
var object = { var object = {
bundleName: "com.example.aafwk.test", bundleName: "com.example.aafwk.test",
abilityName: "com.example.aafwk.test.TwoAbility" abilityName: "com.example.aafwk.test.TwoAbility"
}; };
var pasteData = pasteboard.createWantData(object); var pasteData = pasteboard.createWantData(object);
var want = pasteData.getPrimaryWant(); var want = pasteData.getPrimaryWant();
``` ```
### getPrimaryUri<sup>7+</sup> ### getPrimaryUri<sup>7+</sup>
...@@ -412,17 +429,18 @@ Obtains the URI text of the primary record. ...@@ -412,17 +429,18 @@ Obtains the URI text of the primary record.
**System capability**: SystemCapability.MiscServices.Pasteboard **System capability**: SystemCapability.MiscServices.Pasteboard
- Return values **Return value**
| Type | Description |
| -------- | -------- |
| string | URI&nbsp;text. |
- Example | Type | Description |
| -------- | -------- |
| string | URI text. |
``` **Example**
var pasteData = pasteboard.createUriData("dataability:///com.example.myapplication1?user.txt");
var uri = pasteData.getPrimaryUri(); ```js
``` var pasteData = pasteboard.createUriData("dataability:///com.example.myapplication1?user.txt");
var uri = pasteData.getPrimaryUri();
```
### addTextRecord<sup>7+</sup> ### addTextRecord<sup>7+</sup>
...@@ -435,17 +453,18 @@ The pasteboard supports a maximum number of 128 data records. ...@@ -435,17 +453,18 @@ The pasteboard supports a maximum number of 128 data records.
**System capability**: SystemCapability.MiscServices.Pasteboard **System capability**: SystemCapability.MiscServices.Pasteboard
- Parameters **Parameters**
| Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- | | Name | Type | Mandatory | Description |
| text | string | Yes | Plain&nbsp;text. | | -------- | -------- | -------- | -------- |
| text | string | Yes | Plain text. |
- Example **Example**
``` ```js
var pasteData = pasteboard.createPlainTextData("hello"); var pasteData = pasteboard.createPlainTextData("hello");
pasteData.addTextRecord("good"); pasteData.addTextRecord("good");
``` ```
### addHtmlRecord<sup>7+</sup> ### addHtmlRecord<sup>7+</sup>
...@@ -458,18 +477,19 @@ The pasteboard supports a maximum number of 128 data records. ...@@ -458,18 +477,19 @@ The pasteboard supports a maximum number of 128 data records.
**System capability**: SystemCapability.MiscServices.Pasteboard **System capability**: SystemCapability.MiscServices.Pasteboard
- Parameters **Parameters**
| Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- | | Name | Type | Mandatory | Description |
| htmlText | string | Yes | HTML&nbsp;text. | | -------- | -------- | -------- | -------- |
| htmlText | string | Yes | HTML text. |
- Example **Example**
``` ```js
var pasteData = pasteboard.createPlainTextData("hello"); var pasteData = pasteboard.createPlainTextData("hello");
var html = "<!DOCTYPE html>\n" + "<html>\n" + "<head>\n" + "<meta charset=\"utf-8\">\n" + "<title>HTML-PASTEBOARD_HTML</title>\n" + "</head>\n" + "<body>\n" + " <h1>HEAD</h1>\n" + " <p></p>\n" + "</body>\n" + "</html>"; var html = "<!DOCTYPE html>\n" + "<html>\n" + "<head>\n" + "<meta charset=\"utf-8\">\n" + "<title>HTML-PASTEBOARD_HTML</title>\n" + "</head>\n" + "<body>\n" + " <h1>HEAD</h1>\n" + " <p></p>\n" + "</body>\n" + "</html>";
pasteData.addHtmlRecord(html); pasteData.addHtmlRecord(html);
``` ```
### addWantRecord<sup>7+</sup> ### addWantRecord<sup>7+</sup>
...@@ -482,21 +502,22 @@ The pasteboard supports a maximum number of 128 data records. ...@@ -482,21 +502,22 @@ The pasteboard supports a maximum number of 128 data records.
**System capability**: SystemCapability.MiscServices.Pasteboard **System capability**: SystemCapability.MiscServices.Pasteboard
- Parameters **Parameters**
| Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- |
| want | [Want](js-apis-featureAbility.md#want) | Yes | Want&nbsp;object. |
- Example | Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- |
| want | [Want](js-apis-featureAbility.md#want) | Yes | Want object. |
``` **Example**
var pasteData = pasteboard.createPlainTextData("hello");
var object = { ```js
var pasteData = pasteboard.createPlainTextData("hello");
var object = {
bundleName: "com.example.aafwk.test", bundleName: "com.example.aafwk.test",
abilityName: "com.example.aafwk.test.TwoAbility" abilityName: "com.example.aafwk.test.TwoAbility"
}; };
pasteData.addWantRecord(object); pasteData.addWantRecord(object);
``` ```
### addUriRecord<sup>7+</sup> ### addUriRecord<sup>7+</sup>
...@@ -509,17 +530,18 @@ The pasteboard supports a maximum number of 128 data records. ...@@ -509,17 +530,18 @@ The pasteboard supports a maximum number of 128 data records.
**System capability**: SystemCapability.MiscServices.Pasteboard **System capability**: SystemCapability.MiscServices.Pasteboard
- Parameters **Parameters**
| Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- | | Name | Type | Mandatory | Description |
| uri | string | Yes | URI&nbsp;text. | | -------- | -------- | -------- | -------- |
| uri | string | Yes | URI text. |
- Example **Example**
``` ```js
var pasteData = pasteboard.createPlainTextData("hello"); var pasteData = pasteboard.createPlainTextData("hello");
pasteData.addUriRecord("dataability:///com.example.myapplication1?user.txt"); pasteData.addUriRecord("dataability:///com.example.myapplication1?user.txt");
``` ```
### addRecord<sup>7+</sup> ### addRecord<sup>7+</sup>
...@@ -532,21 +554,22 @@ The pasteboard supports a maximum number of 128 data records. ...@@ -532,21 +554,22 @@ The pasteboard supports a maximum number of 128 data records.
**System capability**: SystemCapability.MiscServices.Pasteboard **System capability**: SystemCapability.MiscServices.Pasteboard
- Parameters **Parameters**
| Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- | | Name | Type | Mandatory | Description |
| record | [PasteDataRecord](#pastedatarecord7) | Yes | Record&nbsp;to&nbsp;add. | | -------- | -------- | -------- | -------- |
| record | [PasteDataRecord](#pastedatarecord7) | Yes | Record to add. |
- Example **Example**
``` ```js
var pasteData = pasteboard.createUriData("dataability:///com.example.myapplication1?user.txt"); var pasteData = pasteboard.createUriData("dataability:///com.example.myapplication1?user.txt");
var textRecord = pasteboard.createPlainTextRecord("hello"); var textRecord = pasteboard.createPlainTextRecord("hello");
var html = "<!DOCTYPE html>\n" + "<html>\n" + "<head>\n" + "<meta charset=\"utf-8\">\n" + "<title>HTML-PASTEBOARD_HTML</title>\n" + "</head>\n" + "<body>\n" + " <h1>HEAD</h1>\n" + " <p></p>\n" + "</body>\n" + "</html>"; var html = "<!DOCTYPE html>\n" + "<html>\n" + "<head>\n" + "<meta charset=\"utf-8\">\n" + "<title>HTML-PASTEBOARD_HTML</title>\n" + "</head>\n" + "<body>\n" + " <h1>HEAD</h1>\n" + " <p></p>\n" + "</body>\n" + "</html>";
var htmlRecord = pasteboard.createHtmlTextRecord(html); var htmlRecord = pasteboard.createHtmlTextRecord(html);
pasteData.addRecord(textRecord); pasteData.addRecord(textRecord);
pasteData.addRecord(htmlRecord); pasteData.addRecord(htmlRecord);
``` ```
### getMimeTypes<sup>7+</sup> ### getMimeTypes<sup>7+</sup>
...@@ -557,17 +580,18 @@ Obtains **mimeTypes** in [PasteDataProperty](#pastedataproperty7) from this past ...@@ -557,17 +580,18 @@ Obtains **mimeTypes** in [PasteDataProperty](#pastedataproperty7) from this past
**System capability**: SystemCapability.MiscServices.Pasteboard **System capability**: SystemCapability.MiscServices.Pasteboard
- Return values **Return value**
| Type | Description |
| -------- | -------- |
| Array&lt;string&gt; | List&nbsp;of&nbsp;non-duplicate&nbsp;MIME&nbsp;types. |
- Example | Type | Description |
| -------- | -------- |
| Array&lt;string&gt; | List of non-duplicate MIME types. |
``` **Example**
var pasteData = pasteboard.createPlainTextData("hello");
var types = pasteData.getMimeTypes(); ```js
``` var pasteData = pasteboard.createPlainTextData("hello");
var types = pasteData.getMimeTypes();
```
### getPrimaryMimeType<sup>7+</sup> ### getPrimaryMimeType<sup>7+</sup>
...@@ -578,17 +602,18 @@ Obtains the data type of the primary record. ...@@ -578,17 +602,18 @@ Obtains the data type of the primary record.
**System capability**: SystemCapability.MiscServices.Pasteboard **System capability**: SystemCapability.MiscServices.Pasteboard
- Return values **Return value**
| Type | Description |
| -------- | -------- |
| string | Data&nbsp;type&nbsp;of&nbsp;the&nbsp;primary&nbsp;record. |
- Example | Type | Description |
| -------- | -------- |
| string | Data type of the primary record. |
``` **Example**
var pasteData = pasteboard.createPlainTextData("hello");
var type = pasteData.getPrimaryMimeType(); ```js
``` var pasteData = pasteboard.createPlainTextData("hello");
var type = pasteData.getPrimaryMimeType();
```
### getProperty<sup>7+</sup> ### getProperty<sup>7+</sup>
...@@ -599,17 +624,18 @@ Obtains the property description object. ...@@ -599,17 +624,18 @@ Obtains the property description object.
**System capability**: SystemCapability.MiscServices.Pasteboard **System capability**: SystemCapability.MiscServices.Pasteboard
- Return values **Return value**
| Type | Description |
| -------- | -------- | | Type | Description |
| [PasteDataProperty](#pastedataproperty7) | Property&nbsp;description&nbsp;object. | | -------- | -------- |
| [PasteDataProperty](#pastedataproperty7) | Property description object. |
- Example **Example**
``` ```js
var pasteData = pasteboard.createPlainTextData("hello"); var pasteData = pasteboard.createPlainTextData("hello");
var property = pasteData.getProperty(); var property = pasteData.getProperty();
``` ```
### getRecordAt<sup>7+</sup> ### getRecordAt<sup>7+</sup>
...@@ -620,22 +646,24 @@ Obtains the record with the specified index. ...@@ -620,22 +646,24 @@ Obtains the record with the specified index.
**System capability**: SystemCapability.MiscServices.Pasteboard **System capability**: SystemCapability.MiscServices.Pasteboard
- Parameters **Parameters**
| Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- |
| index | number | Yes | Index&nbsp;of&nbsp;the&nbsp;specified&nbsp;record. |
- Return values | Name | Type | Mandatory | Description |
| Type | Description | | -------- | -------- | -------- | -------- |
| -------- | -------- | | index | number | Yes | Index of the specified record. |
| [PasteDataRecord](#pastedatarecord7) | Record&nbsp;with&nbsp;the&nbsp;specified&nbsp;index. |
- Example **Return value**
``` | Type | Description |
var pasteData = pasteboard.createPlainTextData("hello"); | -------- | -------- |
var record = pasteData.getRecordAt(0); | [PasteDataRecord](#pastedatarecord7) | Record with the specified index. |
```
**Example**
```js
var pasteData = pasteboard.createPlainTextData("hello");
var record = pasteData.getRecordAt(0);
```
### getRecordCount<sup>7+</sup> ### getRecordCount<sup>7+</sup>
...@@ -646,17 +674,18 @@ Obtains the number of data records in this pasteboard. ...@@ -646,17 +674,18 @@ Obtains the number of data records in this pasteboard.
**System capability**: SystemCapability.MiscServices.Pasteboard **System capability**: SystemCapability.MiscServices.Pasteboard
- Return values **Return value**
| Type | Description |
| -------- | -------- |
| number | Number&nbsp;of&nbsp;records. |
- Example | Type | Description |
| -------- | -------- |
| number | Number of records. |
``` **Example**
var pasteData = pasteboard.createPlainTextData("hello");
var count = pasteData.getRecordCount(); ```js
``` var pasteData = pasteboard.createPlainTextData("hello");
var count = pasteData.getRecordCount();
```
### getTag<sup>7+</sup> ### getTag<sup>7+</sup>
...@@ -667,17 +696,18 @@ Obtains the user-defined tag content. If the tag content is not set, null is ret ...@@ -667,17 +696,18 @@ Obtains the user-defined tag content. If the tag content is not set, null is ret
**System capability**: SystemCapability.MiscServices.Pasteboard **System capability**: SystemCapability.MiscServices.Pasteboard
- Return values **Return value**
| Type | Description |
| -------- | -------- | | Type | Description |
| string | User-defined&nbsp;tag&nbsp;content&nbsp;if&nbsp;obtained&nbsp;and&nbsp;null&nbsp;if&nbsp;no&nbsp;tag&nbsp;is&nbsp;set. | | -------- | -------- |
| string | User-defined tag content if obtained and null if no tag is set. |
- Example **Example**
``` ```js
var pasteData = pasteboard.createPlainTextData("hello"); var pasteData = pasteboard.createPlainTextData("hello");
var tag = pasteData.getTag(); var tag = pasteData.getTag();
``` ```
### hasMimeType<sup>7+</sup> ### hasMimeType<sup>7+</sup>
...@@ -688,22 +718,24 @@ Checks whether the content of this pasteboard contains the specified data type. ...@@ -688,22 +718,24 @@ Checks whether the content of this pasteboard contains the specified data type.
**System capability**: SystemCapability.MiscServices.Pasteboard **System capability**: SystemCapability.MiscServices.Pasteboard
- Parameters **Parameters**
| Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- | | Name | Type | Mandatory | Description |
| mimeType | string | Yes | Type&nbsp;of&nbsp;the&nbsp;data&nbsp;to&nbsp;query. | | -------- | -------- | -------- | -------- |
| mimeType | string | Yes | Type of the data to query. |
**Return value**
- Return values | Type | Description |
| Type | Description | | -------- | -------- |
| -------- | -------- | | boolean | Returns **true** if the specified data type exists; returns **false** otherwise. |
| boolean | Returns&nbsp;**true**&nbsp;if&nbsp;the&nbsp;specified&nbsp;data&nbsp;type&nbsp;exists;&nbsp;returns&nbsp;**false**&nbsp;otherwise. |
- Example **Example**
``` ```js
var pasteData = pasteboard.createPlainTextData("hello"); var pasteData = pasteboard.createPlainTextData("hello");
var hasType = pasteData.hasMimeType(pasteboard.MIMETYPE_TEXT_PLAIN); var hasType = pasteData.hasMimeType(pasteboard.MIMETYPE_TEXT_PLAIN);
``` ```
### removeRecordAt<sup>7+</sup> ### removeRecordAt<sup>7+</sup>
...@@ -714,22 +746,24 @@ Removes the data record with a specified index from this pasteboard. ...@@ -714,22 +746,24 @@ Removes the data record with a specified index from this pasteboard.
**System capability**: SystemCapability.MiscServices.Pasteboard **System capability**: SystemCapability.MiscServices.Pasteboard
- Parameters **Parameters**
| Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- | | Name | Type | Mandatory | Description |
| index | number | Yes | Specified&nbsp;index. | | -------- | -------- | -------- | -------- |
| index | number | Yes | Specified index. |
**Return value**
- Return values | Type | Description |
| Type | Description | | -------- | -------- |
| -------- | -------- | | boolean | Returns **true** if the operation is successful; returns **false** otherwise. |
| boolean | Returns&nbsp;**true**&nbsp;if&nbsp;the&nbsp;operation&nbsp;is&nbsp;successful;&nbsp;returns&nbsp;**false**&nbsp;otherwise. |
- Example **Example**
``` ```js
var pasteData = pasteboard.createPlainTextData("hello"); var pasteData = pasteboard.createPlainTextData("hello");
var isRemove = pasteData.removeRecordAt(0); var isRemove = pasteData.removeRecordAt(0);
``` ```
### replaceRecordAt<sup>7+</sup> ### replaceRecordAt<sup>7+</sup>
...@@ -740,24 +774,26 @@ Replaces the data record with a specified index in this pasteboard. ...@@ -740,24 +774,26 @@ Replaces the data record with a specified index in this pasteboard.
**System capability**: SystemCapability.MiscServices.Pasteboard **System capability**: SystemCapability.MiscServices.Pasteboard
- Parameters **Parameters**
| Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- | | Name | Type | Mandatory | Description |
| index | number | Yes | Specified&nbsp;index. | | -------- | -------- | -------- | -------- |
| record | [PasteDataRecord](#pastedatarecord7) | Yes | New&nbsp;record. | | index | number | Yes | Specified index. |
| record | [PasteDataRecord](#pastedatarecord7) | Yes | New record. |
**Return value**
- Return values | Type | Description |
| Type | Description | | -------- | -------- |
| -------- | -------- | | boolean | Returns **true** if the operation is successful; returns **false** otherwise. |
| boolean | Returns&nbsp;**true**&nbsp;if&nbsp;the&nbsp;operation&nbsp;is&nbsp;successful;&nbsp;returns&nbsp;**false**&nbsp;otherwise. |
- Example **Example**
``` ```js
var pasteData = pasteboard.createPlainTextData("hello"); var pasteData = pasteboard.createPlainTextData("hello");
var record = pasteboard.createUriRecord("dataability:///com.example.myapplication1?user.txt"); var record = pasteboard.createUriRecord("dataability:///com.example.myapplication1?user.txt");
var isReplace = pasteData.replaceRecordAt(0, record); var isReplace = pasteData.replaceRecordAt(0, record);
``` ```
## pasteboard.getSystemPasteboard ## pasteboard.getSystemPasteboard
...@@ -768,21 +804,22 @@ Obtains the system pasteboard. ...@@ -768,21 +804,22 @@ Obtains the system pasteboard.
**System capability**: SystemCapability.MiscServices.Pasteboard **System capability**: SystemCapability.MiscServices.Pasteboard
- Return values **Return value**
| Type | Description |
| -------- | -------- | | Type | Description |
| [SystemPasteboard](#systempasteboard) | System&nbsp;pasteboard. | | -------- | -------- |
| [SystemPasteboard](#systempasteboard) | System pasteboard. |
- Example **Example**
``` ```js
var systemPasteboard = pasteboard.getSystemPasteboard(); var systemPasteboard = pasteboard.getSystemPasteboard();
``` ```
## SystemPasteboard ## SystemPasteboard
Before calling any **SystemPasteboard** method, you must obtain a **SystemPasteboard** object using [getSystemPasteboard](#pasteboardgetsystempasteboard). Before calling any **SystemPasteboard** method, you must obtain a **SystemPasteboard** object using [getSystemPasteboard](#pasteboardgetsystempasteboard).
``` ```
var systemPasteboard = pasteboard.getSystemPasteboard(); var systemPasteboard = pasteboard.getSystemPasteboard();
...@@ -793,112 +830,117 @@ var systemPasteboard = pasteboard.getSystemPasteboard(); ...@@ -793,112 +830,117 @@ var systemPasteboard = pasteboard.getSystemPasteboard();
setPasteData(data:PasteData, callback:AsyncCallback&lt;void&gt;): void setPasteData(data:PasteData, callback:AsyncCallback&lt;void&gt;): void
Writes data to a pasteboard. This method uses an asynchronous callback to return the result. Writes data to a pasteboard. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.MiscServices.Pasteboard **System capability**: SystemCapability.MiscServices.Pasteboard
- Parameters **Parameters**
| Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- | | Name | Type | Mandatory | Description |
| data | [PasteData](#pastedata) | Yes | **PasteData**&nbsp;object. | | -------- | -------- | -------- | -------- |
| callback | AsyncCallback&lt;void&gt; | Yes | Callback&nbsp;used&nbsp;to&nbsp;return&nbsp;the&nbsp;data&nbsp;write&nbsp;result. | | data | [PasteData](#pastedata) | Yes | **PasteData** object. |
| callback | AsyncCallback&lt;void> | Yes | Callback used to return the data write result. |
- Example **Example**
``` ```js
var pasteData = pasteboard.createPlainTextData("content"); var pasteData = pasteboard.createPlainTextData("content");
var systemPasteboard = pasteboard.getSystemPasteboard(); var systemPasteboard = pasteboard.getSystemPasteboard();
systemPasteboard.setPasteData(pasteData, (error, data) => { systemPasteboard.setPasteData(pasteData, (error, data) => {
if (error) { if (error) {
console.error('Failed to setPasteData. Cause: ' + error.message); console.error('Failed to setPasteData. Cause: ' + error.message);
return; return;
} }
console.info('setPasteData successfully.'); console.info('setPasteData successfully.');
}); });
``` ```
### setPasteData ### setPasteData
setPasteData(data:PasteData): Promise&lt;void&gt; setPasteData(data:PasteData): Promise&lt;void&gt;
Writes data to a pasteboard. This method uses a promise to return the result. Writes data to a pasteboard. This API uses a promise to return the result.
**System capability**: SystemCapability.MiscServices.Pasteboard **System capability**: SystemCapability.MiscServices.Pasteboard
- Parameters **Parameters**
| Name | Type | Description |
| -------- | -------- | -------- | | Name | Type | Description |
| data | [PasteData](#pastedata) | **PasteData**&nbsp;object. | | -------- | -------- | -------- |
| data | [PasteData](#pastedata) | **PasteData** object. |
**Return value**
- Return values | Type | Description |
| Type | Description | | -------- | -------- |
| -------- | -------- | | Promise&lt;void&gt; | Promise used to return the data write result. |
| Promise&lt;void&gt; | Promise&nbsp;used&nbsp;to&nbsp;return&nbsp;the&nbsp;data&nbsp;write&nbsp;result. |
- Example **Example**
``` ```js
var pasteData = pasteboard.createPlainTextData("content"); var pasteData = pasteboard.createPlainTextData("content");
var systemPasteboard = pasteboard.getSystemPasteboard(); var systemPasteboard = pasteboard.getSystemPasteboard();
systemPasteboard.setPasteData(pasteData).then((data) => { systemPasteboard.setPasteData(pasteData).then((data) => {
console.info('setPasteData success.'); console.info('setPasteData success.');
}).catch((error) => { }).catch((error) => {
console.error('Failed to setPasteData. Cause: ' + error.message); console.error('Failed to setPasteData. Cause: ' + error.message);
}); });
``` ```
### getPasteData ### getPasteData
getPasteData( callback:AsyncCallback&lt;PasteData&gt;): void getPasteData( callback:AsyncCallback&lt;PasteData&gt;): void
Reads the system pasteboard content. This method uses an asynchronous callback to return the result. Reads the system pasteboard content. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.MiscServices.Pasteboard **System capability**: SystemCapability.MiscServices.Pasteboard
- Parameters **Parameters**
| Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- | | Name | Type | Mandatory | Description |
| callback | AsyncCallback&lt;[PasteData](#pastedata)&gt; | Yes | Callback&nbsp;used&nbsp;to&nbsp;return&nbsp;the&nbsp;system&nbsp;pasteboard&nbsp;data. | | -------- | -------- | -------- | -------- |
| callback | AsyncCallback&lt;[PasteData](#pastedata)&gt; | Yes | Callback used to return the system pasteboard data. |
- Example **Example**
``` ```js
var systemPasteboard = pasteboard.getSystemPasteboard(); var systemPasteboard = pasteboard.getSystemPasteboard();
systemPasteboard.getPasteData((error, pasteData) => { systemPasteboard.getPasteData((error, pasteData) => {
if (error) { if (error) {
console.error('Failed to getPasteData. Cause: ' + error.message); console.error('Failed to getPasteData. Cause: ' + error.message);
return; return;
} }
var text = pasteData.getPrimaryText(); var text = pasteData.getPrimaryText();
}); });
``` ```
### getPasteData ### getPasteData
getPasteData(): Promise&lt;PasteData&gt; getPasteData(): Promise&lt;PasteData&gt;
Reads the system pasteboard content. This method uses a promise to return the result. Reads the system pasteboard content. This API uses a promise to return the result.
**System capability**: SystemCapability.MiscServices.Pasteboard **System capability**: SystemCapability.MiscServices.Pasteboard
- Return values **Return value**
| Type | Description |
| -------- | -------- | | Type | Description |
| Promise&lt;[PasteData](#pastedata)&gt; | Promise&nbsp;used&nbsp;to&nbsp;return&nbsp;the&nbsp;system&nbsp;pasteboard&nbsp;data. | | -------- | -------- |
| Promise&lt;[PasteData](#pastedata)&gt; | Promise used to return the system pasteboard data. |
- Example **Example**
``` ```js
var systemPasteboard = pasteboard.getSystemPasteboard(); var systemPasteboard = pasteboard.getSystemPasteboard();
systemPasteboard.getPasteData().then((pasteData) => { systemPasteboard.getPasteData().then((pasteData) => {
var text = pasteData.getPrimaryText(); var text = pasteData.getPrimaryText();
}).catch((error) => { }).catch((error) => {
console.error('Failed to getPasteData. Cause: ' + error.message); console.error('Failed to getPasteData. Cause: ' + error.message);
}) })
``` ```
### on('update')<sup>7+</sup> ### on('update')<sup>7+</sup>
...@@ -909,21 +951,22 @@ Subscribes to the content change event of the system pasteboard. If the pasteboa ...@@ -909,21 +951,22 @@ Subscribes to the content change event of the system pasteboard. If the pasteboa
**System capability**: SystemCapability.MiscServices.Pasteboard **System capability**: SystemCapability.MiscServices.Pasteboard
- Parameters **Parameters**
| Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- | | Name | Type | Mandatory | Description |
| type | string | Yes | Data&nbsp;type.&nbsp;The&nbsp;value&nbsp;**update**&nbsp;indicates&nbsp;the&nbsp;pasteboard&nbsp;content&nbsp;has&nbsp;changed. | | -------- | -------- | -------- | -------- |
| callback | function | Yes | Callback&nbsp;invoked&nbsp;when&nbsp;the&nbsp;pasteboard&nbsp;content&nbsp;changes. | | type | string | Yes | Data type. The value **update** indicates the pasteboard content has changed. |
| callback | function | Yes | Callback invoked when the pasteboard content changes. |
- Example **Example**
``` ```js
var systemPasteboard = pasteboard.getSystemPasteboard(); var systemPasteboard = pasteboard.getSystemPasteboard();
var listener = ()=>{ var listener = ()=>{
console.info('The system pasteboard has changed'); console.info('The system pasteboard has changed');
}; };
systemPasteboard.on('update', listener); systemPasteboard.on('update', listener);
``` ```
### off('update')<sup>7+</sup> ### off('update')<sup>7+</sup>
...@@ -934,114 +977,119 @@ Unsubscribes from the system pasteboard content change event. ...@@ -934,114 +977,119 @@ Unsubscribes from the system pasteboard content change event.
**System capability**: SystemCapability.MiscServices.Pasteboard **System capability**: SystemCapability.MiscServices.Pasteboard
- Parameters **Parameters**
| Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- | | Name | Type | Mandatory | Description |
| type | string | Yes | Data&nbsp;type.&nbsp;The&nbsp;value&nbsp;**update**&nbsp;indicates&nbsp;the&nbsp;pasteboard&nbsp;content&nbsp;has&nbsp;changed. | | -------- | -------- | -------- | -------- |
| callback | function | No | Callback&nbsp;invoked&nbsp;when&nbsp;the&nbsp;pasteboard&nbsp;content&nbsp;changes. | | type | string | Yes | Data type. The value **update** indicates the pasteboard content has changed. |
| callback | function | No | Callback invoked when the pasteboard content changes. |
- Example **Example**
``` ```js
systemPasteboard.off('update', listener); systemPasteboard.off('update', listener);
``` ```
### hasPasteData<sup>7+</sup> ### hasPasteData<sup>7+</sup>
hasPasteData(callback: AsyncCallback&lt;boolean&gt;): void hasPasteData(callback: AsyncCallback&lt;boolean&gt;): void
Checks whether the system pasteboard contains content. This method uses an asynchronous callback to return the result. Checks whether the system pasteboard contains content. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.MiscServices.Pasteboard **System capability**: SystemCapability.MiscServices.Pasteboard
- Parameters **Parameters**
| Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- | | Name | Type | Mandatory | Description |
| callback | AsyncCallback&lt;boolean&gt; | Yes | Returns&nbsp;**true**&nbsp;if&nbsp;the&nbsp;pasteboard&nbsp;contains&nbsp;content;&nbsp;returns&nbsp;**false**&nbsp;otherwise. | | -------- | -------- | -------- | -------- |
| callback | AsyncCallback&lt;boolean&gt; | Yes | Returns **true** if the pasteboard contains content; returns **false** otherwise. |
- Example **Example**
``` ```js
systemPasteboard.hasPasteData((err, data) => { systemPasteboard.hasPasteData((err, data) => {
if (err) { if (err) {
console.error('failed to hasPasteData because ' + JSON.stringify(err)); console.error('failed to hasPasteData because ' + JSON.stringify(err));
return; return;
} }
console.info('success hasPasteData : ' + JSON.stringify(data)); console.info('success hasPasteData : ' + JSON.stringify(data));
}); });
``` ```
### hasPasteData<sup>7+</sup> ### hasPasteData<sup>7+</sup>
hasPasteData(): Promise&lt;boolean&gt; hasPasteData(): Promise&lt;boolean&gt;
Checks whether the system pasteboard contains content. This method uses a promise to return the result. Checks whether the system pasteboard contains content. This API uses a promise to return the result.
**System capability**: SystemCapability.MiscServices.Pasteboard **System capability**: SystemCapability.MiscServices.Pasteboard
- Return values **Return value**
| Type | Description |
| -------- | -------- |
| Promise&lt;boolean&gt; | Returns&nbsp;**true**&nbsp;if&nbsp;the&nbsp;pasteboard&nbsp;contains&nbsp;content;&nbsp;returns&nbsp;**false**&nbsp;otherwise. |
- Example | Type | Description |
| -------- | -------- |
| Promise&lt;boolean&gt; | Returns **true** if the pasteboard contains content; returns **false** otherwise. |
``` **Example**
systemPasteboard.hasPasteData().then((data) => {
```js
systemPasteboard.hasPasteData().then((data) => {
console.info('Operation succeeded. ' + JSON.stringify(data)); console.info('Operation succeeded. ' + JSON.stringify(data));
}).catch((error) => { }).catch((error) => {
console.error('failed to hasPasteData because ' + JSON.stringify(error)); console.error('failed to hasPasteData because ' + JSON.stringify(error));
}); });
``` ```
### clear<sup>7+</sup> ### clear<sup>7+</sup>
clear(callback: AsyncCallback&lt;void&gt;): void clear(callback: AsyncCallback&lt;void&gt;): void
Clears the system pasteboard content. This method uses an asynchronous callback to return the result. Clears the system pasteboard content. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.MiscServices.Pasteboard **System capability**: SystemCapability.MiscServices.Pasteboard
- Parameters **Parameters**
| Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- | | Name | Type | Mandatory | Description |
| callback | AsyncCallback&lt;void&gt; | Yes | Callback&nbsp;used&nbsp;to&nbsp;return&nbsp;the&nbsp;result. | | -------- | -------- | -------- | -------- |
| callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result. |
- Example **Example**
``` ```js
systemPasteboard.clear((err, data) => { systemPasteboard.clear((err, data) => {
if (err) { if (err) {
console.error('failed to clear because ' + JSON.stringify(err)); console.error('failed to clear because ' + JSON.stringify(err));
return; return;
} }
console.info('success clear'); console.info('success clear');
}); });
``` ```
### clear<sup>7+</sup> ### clear<sup>7+</sup>
clear(): Promise&lt;void&gt; clear(): Promise&lt;void&gt;
Clears the system pasteboard content. This method uses a promise to return the result. Clears the system pasteboard content. This API uses a promise to return the result.
**System capability**: SystemCapability.MiscServices.Pasteboard **System capability**: SystemCapability.MiscServices.Pasteboard
- Return values **Return value**
| Type | Description |
| -------- | -------- | | Type | Description |
| Promise&lt;void&gt; | Promise&nbsp;used&nbsp;to&nbsp;return&nbsp;the&nbsp;result. | | -------- | -------- |
| Promise&lt;void&gt; | Promise used to return the result. |
- Example **Example**
``` ```js
systemPasteboard.clear().then((data) => { systemPasteboard.clear().then((data) => {
console.info('success clear'); console.info('success clear');
}).catch((error) => { }).catch((error) => {
console.error('failed to clear because ' + JSON.stringify(error)); console.error('failed to clear because ' + JSON.stringify(error));
}); });
``` ```
\ No newline at end of file
# Upload and Download # Upload and Download
> ![icon-note.gif](public_sys-resources/icon-note.gif) **Note:** > ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**<br>The initial APIs of this module are supported since API version 6. Newly added APIs will be marked with a superscript to indicate their earliest API version.
> The initial APIs of this module are supported since API version 6. Newly added APIs will be marked with a superscript to indicate their earliest API version. >
## Modules to Import ## Modules to Import
...@@ -37,56 +37,58 @@ import request from '@ohos.request'; ...@@ -37,56 +37,58 @@ import request from '@ohos.request';
| Name | Type | Readable | Writable | Description | | Name | Type | Readable | Writable | Description |
| -------- | -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- | -------- |
| NETWORK_MOBILE | number | Yes | No | Whether&nbsp;download&nbsp;is&nbsp;allowed&nbsp;when&nbsp;the&nbsp;cellular&nbsp;network&nbsp;is&nbsp;used. | | NETWORK_MOBILE | number | Yes | No | Whether download is allowed when the cellular network is used. |
| NETWORK_WIFI | number | Yes | No | Whether&nbsp;download&nbsp;is&nbsp;allowed&nbsp;when&nbsp;the&nbsp;WLAN&nbsp;is&nbsp;used. | | NETWORK_WIFI | number | Yes | No | Whether download is allowed when the WLAN is used. |
| ERROR_CANNOT_RESUME<sup>7+</sup> | number | Yes | No | Failure&nbsp;to&nbsp;resume&nbsp;the&nbsp;download&nbsp;due&nbsp;to&nbsp;an&nbsp;error. | | ERROR_CANNOT_RESUME<sup>7+</sup> | number | Yes | No | Failure to resume the download due to an error. |
| ERROR_DEVICE_NOT_FOUND<sup>7+</sup> | number | Yes | No | Failure&nbsp;to&nbsp;find&nbsp;a&nbsp;storage&nbsp;device&nbsp;such&nbsp;as&nbsp;an&nbsp;SD&nbsp;card. | | ERROR_DEVICE_NOT_FOUND<sup>7+</sup> | number | Yes | No | Failure to find a storage device such as an SD card. |
| ERROR_FILE_ALREADY_EXISTS<sup>7+</sup> | number | Yes | No | Failure&nbsp;to&nbsp;download&nbsp;the&nbsp;file&nbsp;because&nbsp;it&nbsp;already&nbsp;exists. | | ERROR_FILE_ALREADY_EXISTS<sup>7+</sup> | number | Yes | No | Failure to download the file because it already exists. |
| ERROR_FILE_ERROR<sup>7+</sup> | number | Yes | No | File&nbsp;operation&nbsp;failure. | | ERROR_FILE_ERROR<sup>7+</sup> | number | Yes | No | File operation failure. |
| ERROR_HTTP_DATA_ERROR<sup>7+</sup> | number | Yes | No | HTTP&nbsp;transmission&nbsp;failure. | | ERROR_HTTP_DATA_ERROR<sup>7+</sup> | number | Yes | No | HTTP transmission failure. |
| ERROR_INSUFFICIENT_SPACE<sup>7+</sup> | number | Yes | No | Insufficient&nbsp;storage&nbsp;space. | | ERROR_INSUFFICIENT_SPACE<sup>7+</sup> | number | Yes | No | Insufficient storage space. |
| ERROR_TOO_MANY_REDIRECTS<sup>7+</sup> | number | Yes | No | Error&nbsp;caused&nbsp;by&nbsp;too&nbsp;many&nbsp;network&nbsp;redirections. | | ERROR_TOO_MANY_REDIRECTS<sup>7+</sup> | number | Yes | No | Error caused by too many network redirections. |
| ERROR_UNHANDLED_HTTP_CODE<sup>7+</sup> | number | Yes | No | Unidentified&nbsp;HTTP&nbsp;code. | | ERROR_UNHANDLED_HTTP_CODE<sup>7+</sup> | number | Yes | No | Unidentified HTTP code. |
| ERROR_UNKNOWN<sup>7+</sup> | number | Yes | No | Unknown&nbsp;error. | | ERROR_UNKNOWN<sup>7+</sup> | number | Yes | No | Unknown error. |
| PAUSED_QUEUED_FOR_WIFI<sup>7+</sup> | number | Yes | No | Download&nbsp;paused&nbsp;and&nbsp;queuing&nbsp;for&nbsp;WLAN&nbsp;connection,&nbsp;because&nbsp;the&nbsp;file&nbsp;size&nbsp;exceeds&nbsp;the&nbsp;maximum&nbsp;value&nbsp;allowed&nbsp;by&nbsp;a&nbsp;cellular&nbsp;network&nbsp;session. | | PAUSED_QUEUED_FOR_WIFI<sup>7+</sup> | number | Yes | No | Download paused and queuing for WLAN connection, because the file size exceeds the maximum value allowed by a cellular network session. |
| PAUSED_UNKNOWN<sup>7+</sup> | number | Yes | No | Download&nbsp;paused&nbsp;due&nbsp;to&nbsp;unknown&nbsp;reasons. | | PAUSED_UNKNOWN<sup>7+</sup> | number | Yes | No | Download paused due to unknown reasons. |
| PAUSED_WAITING_FOR_NETWORK<sup>7+</sup> | number | Yes | No | Download&nbsp;paused&nbsp;due&nbsp;to&nbsp;a&nbsp;network&nbsp;connection&nbsp;problem,&nbsp;for&nbsp;example,&nbsp;network&nbsp;disconnection. | | PAUSED_WAITING_FOR_NETWORK<sup>7+</sup> | number | Yes | No | Download paused due to a network connection problem, for example, network disconnection. |
| PAUSED_WAITING_TO_RETRY<sup>7+</sup> | number | Yes | No | Download&nbsp;paused&nbsp;and&nbsp;then&nbsp;retried. | | PAUSED_WAITING_TO_RETRY<sup>7+</sup> | number | Yes | No | Download paused and then retried. |
| SESSION_FAILED<sup>7+</sup> | number | Yes | No | Download&nbsp;failure&nbsp;without&nbsp;retry. | | SESSION_FAILED<sup>7+</sup> | number | Yes | No | Download failure without retry. |
| SESSION_PAUSED<sup>7+</sup> | number | Yes | No | Download&nbsp;paused. | | SESSION_PAUSED<sup>7+</sup> | number | Yes | No | Download paused. |
| SESSION_PENDING<sup>7+</sup> | number | Yes | No | Download&nbsp;pending. | | SESSION_PENDING<sup>7+</sup> | number | Yes | No | Download pending. |
| SESSION_RUNNING<sup>7+</sup> | number | Yes | No | Download&nbsp;in&nbsp;progress. | | SESSION_RUNNING<sup>7+</sup> | number | Yes | No | Download in progress. |
| SESSION_SUCCESSFUL<sup>7+</sup> | number | Yes | No | Successful&nbsp;download. | | SESSION_SUCCESSFUL<sup>7+</sup> | number | Yes | No | Successful download. |
## request.upload ## request.upload
upload(config: UploadConfig): Promise&lt;UploadTask&gt; upload(config: UploadConfig): Promise&lt;UploadTask&gt;
Uploads files. This method uses a promise to return the result. Uploads files. This API uses a promise to return the result.
**Required permission**: ohos.permission.INTERNET **Required permission**: ohos.permission.INTERNET
**System capability**: SystemCapability.MiscServices.Upload **System capability**: SystemCapability.MiscServices.Upload
- Parameters **Parameters**
| Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- |
| config | [UploadConfig](#uploadconfig) | Yes | Configurations&nbsp;of&nbsp;the&nbsp;upload. |
- Return values | Name | Type | Mandatory | Description |
| Type | Description | | -------- | -------- | -------- | -------- |
| -------- | -------- | | config | [UploadConfig](#uploadconfig) | Yes | Configurations of the upload. |
| Promise&lt;[UploadTask](#uploadtask)&gt; | Promise&nbsp;used&nbsp;to&nbsp;return&nbsp;the&nbsp;**UploadTask**&nbsp;object. |
- Example **Return value**
``` | Type | Description |
request.upload({ url: 'https://patch' }).then((data) => { | -------- | -------- |
| Promise&lt;[UploadTask](#uploadtask)&gt; | Promise used to return the **UploadTask** object. |
**Example**
```js
request.upload({ url: 'https://patch' }).then((data) => {
uploadTask = data; uploadTask = data;
}).catch((err) => { }).catch((err) => {
console.error('Failed to request the upload. Cause: ' + JSON.stringify(err)); console.error('Failed to request the upload. Cause: ' + JSON.stringify(err));
}) })
``` ```
...@@ -94,28 +96,29 @@ Uploads files. This method uses a promise to return the result. ...@@ -94,28 +96,29 @@ Uploads files. This method uses a promise to return the result.
upload(config: UploadConfig, callback: AsyncCallback&lt;UploadTask&gt;): void upload(config: UploadConfig, callback: AsyncCallback&lt;UploadTask&gt;): void
Uploads files. This method uses an asynchronous callback to return the result. Uploads files. This API uses an asynchronous callback to return the result.
**Required permission**: ohos.permission.INTERNET **Required permission**: ohos.permission.INTERNET
**System capability**: SystemCapability.MiscServices.Upload **System capability**: SystemCapability.MiscServices.Upload
- Parameters **Parameters**
| Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- |
| config | [UploadConfig](#uploadconfig) | Yes | Configurations&nbsp;of&nbsp;the&nbsp;upload. |
| callback | AsyncCallback&lt;[UploadTask](#uploadtask)&gt; | No | Callback&nbsp;used&nbsp;to&nbsp;return&nbsp;the&nbsp;**UploadTask**&nbsp;object. |
- Example | Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- |
| config | [UploadConfig](#uploadconfig) | Yes | Configurations of the upload. |
| callback | AsyncCallback&lt;[UploadTask](#uploadtask)&gt; | No | Callback used to return the **UploadTask** object. |
``` **Example**
request.upload({ url: 'https://patch' }, (err, data) => {
```js
request.upload({ url: 'https://patch' }, (err, data) => {
if (err) { if (err) {
console.error('Failed to request the upload. Cause: ' + JSON.stringify(err)); console.error('Failed to request the upload. Cause: ' + JSON.stringify(err));
return; return;
} }
uploadTask = data; uploadTask = data;
}); });
``` ```
...@@ -128,32 +131,33 @@ Implements file uploads. Before using a method of this class, you must obtain an ...@@ -128,32 +131,33 @@ Implements file uploads. Before using a method of this class, you must obtain an
on(type: 'progress', callback:(uploadedSize: number, totalSize: number) =&gt; void): void on(type: 'progress', callback:(uploadedSize: number, totalSize: number) =&gt; void): void
Subscribes to the upload progress event. This method uses an asynchronous callback to return the result. Subscribes to the upload progress event. This API uses an asynchronous callback to return the result.
**Required permission**: ohos.permission.INTERNET **Required permission**: ohos.permission.INTERNET
**System capability**: SystemCapability.MiscServices.Upload **System capability**: SystemCapability.MiscServices.Upload
- Parameters **Parameters**
| Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- |
| type | string | Yes | Type&nbsp;of&nbsp;the&nbsp;event&nbsp;to&nbsp;subscribe&nbsp;to.&nbsp;The&nbsp;value&nbsp;is&nbsp;**progress**&nbsp;(upload&nbsp;progress). |
| callback | function | Yes | Callback&nbsp;for&nbsp;the&nbsp;upload&nbsp;progress&nbsp;event. |
Parameters of the callback function | Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- |
| type | string | Yes | Type of the event to subscribe to. The value is **progress** (upload progress). |
| callback | function | Yes | Callback for the upload progress event. |
| Name | Type | Mandatory | Description | Parameters of the callback function
| -------- | -------- | -------- | -------- |
| uploadedSize | number | Yes | Size&nbsp;of&nbsp;the&nbsp;uploaded&nbsp;files,&nbsp;in&nbsp;KB. |
| totalSize | number | Yes | Total&nbsp;size&nbsp;of&nbsp;the&nbsp;files&nbsp;to&nbsp;upload,&nbsp;in&nbsp;KB. |
- Example | Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- |
| uploadedSize | number | Yes | Size of the uploaded files, in KB. |
| totalSize | number | Yes | Total size of the files to upload, in KB. |
``` **Example**
uploadTask.on('progress', function callback(uploadedSize, totalSize) {
```js
uploadTask.on('progress', function callback(uploadedSize, totalSize) {
console.info("upload totalSize:" + totalSize + " uploadedSize:" + uploadedSize); console.info("upload totalSize:" + totalSize + " uploadedSize:" + uploadedSize);
} }
); );
``` ```
...@@ -161,31 +165,32 @@ Subscribes to the upload progress event. This method uses an asynchronous callba ...@@ -161,31 +165,32 @@ Subscribes to the upload progress event. This method uses an asynchronous callba
on(type: 'headerReceive', callback: (header: object) =&gt; void): void on(type: 'headerReceive', callback: (header: object) =&gt; void): void
Subscribes to the **headerReceive** event, which is triggered when an HTTP response header is received. This method uses an asynchronous callback to return the result. Subscribes to the **headerReceive** event, which is triggered when an HTTP response header is received. This API uses an asynchronous callback to return the result.
**Required permission**: ohos.permission.INTERNET **Required permission**: ohos.permission.INTERNET
**System capability**: SystemCapability.MiscServices.Upload **System capability**: SystemCapability.MiscServices.Upload
- Parameters **Parameters**
| Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- |
| type | string | Yes | Type&nbsp;of&nbsp;the&nbsp;event&nbsp;to&nbsp;subscribe&nbsp;to.&nbsp;The&nbsp;value&nbsp;is&nbsp;**headerReceive**&nbsp;(response&nbsp;header). |
| callback | function | Yes | Callback&nbsp;for&nbsp;the&nbsp;HTTP&nbsp;Response&nbsp;Header&nbsp;event. |
Parameters of the callback function | Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- |
| type | string | Yes | Type of the event to subscribe to. The value is **headerReceive** (response header). |
| callback | function | Yes | Callback for the HTTP Response Header event. |
| Name | Type | Mandatory | Description | Parameters of the callback function
| -------- | -------- | -------- | -------- |
| header | object | Yes | HTTP&nbsp;Response&nbsp;Header. |
- Example | Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- |
| header | object | Yes | HTTP Response Header. |
``` **Example**
uploadTask.on('headerReceive', function callback(headers){
```js
uploadTask.on('headerReceive', function callback(headers){
console.info("upOnHeader headers:" + JSON.stringify(headers)); console.info("upOnHeader headers:" + JSON.stringify(headers));
} }
); );
``` ```
...@@ -193,32 +198,33 @@ Subscribes to the **headerReceive** event, which is triggered when an HTTP respo ...@@ -193,32 +198,33 @@ Subscribes to the **headerReceive** event, which is triggered when an HTTP respo
off(type: 'progress', callback?: (uploadedSize: number, totalSize: number) =&gt; void): void off(type: 'progress', callback?: (uploadedSize: number, totalSize: number) =&gt; void): void
Unsubscribes from the upload progress event. This method uses an asynchronous callback to return the result. Unsubscribes from the upload progress event. This API uses an asynchronous callback to return the result.
**Required permission**: ohos.permission.INTERNET **Required permission**: ohos.permission.INTERNET
**System capability**: SystemCapability.MiscServices.Upload **System capability**: SystemCapability.MiscServices.Upload
- Parameters **Parameters**
| Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- | | Name | Type | Mandatory | Description |
| type | string | Yes | Type&nbsp;of&nbsp;the&nbsp;event&nbsp;to&nbsp;unsubscribe&nbsp;from.&nbsp;The&nbsp;value&nbsp;is&nbsp;**progress**&nbsp;(upload&nbsp;progress). | | -------- | -------- | -------- | -------- |
| callback | function | No | Callback&nbsp;for&nbsp;the&nbsp;upload&nbsp;progress&nbsp;event. | | type | string | Yes | Type of the event to unsubscribe from. The value is **progress** (upload progress). |
| callback | function | No | Callback for the upload progress event. |
Parameters of the callback function Parameters of the callback function
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| uploadedSize | number | Yes | Size&nbsp;of&nbsp;the&nbsp;uploaded&nbsp;files,&nbsp;in&nbsp;KB. | | uploadedSize | number | Yes | Size of the uploaded files, in KB. |
| totalSize | number | Yes | Total&nbsp;size&nbsp;of&nbsp;the&nbsp;files&nbsp;to&nbsp;upload,&nbsp;in&nbsp;KB. | | totalSize | number | Yes | Total size of the files to upload, in KB. |
- Example **Example**
``` ```js
uploadTask.off('progress', function callback(uploadedSize, totalSize) { uploadTask.off('progress', function callback(uploadedSize, totalSize) {
console.info('uploadedSize: ' + uploadedSize, 'totalSize: ' + totalSize); console.info('uploadedSize: ' + uploadedSize, 'totalSize: ' + totalSize);
} }
); );
``` ```
...@@ -226,31 +232,32 @@ Unsubscribes from the upload progress event. This method uses an asynchronous ca ...@@ -226,31 +232,32 @@ Unsubscribes from the upload progress event. This method uses an asynchronous ca
off(type: 'headerReceive', callback?: (header: object) =&gt; void): void off(type: 'headerReceive', callback?: (header: object) =&gt; void): void
Unsubscribes from the **headerReceive** event. This method uses an asynchronous callback to return the result. Unsubscribes from the **headerReceive** event. This API uses an asynchronous callback to return the result.
**Required permission**: ohos.permission.INTERNET **Required permission**: ohos.permission.INTERNET
**System capability**: SystemCapability.MiscServices.Upload **System capability**: SystemCapability.MiscServices.Upload
- Parameters **Parameters**
| Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- |
| type | string | Yes | Type&nbsp;of&nbsp;the&nbsp;event&nbsp;to&nbsp;unsubscribe&nbsp;from.&nbsp;The&nbsp;value&nbsp;is&nbsp;**headerReceive**&nbsp;(response&nbsp;header). |
| callback | function | No | Callback&nbsp;for&nbsp;the&nbsp;HTTP&nbsp;Response&nbsp;Header&nbsp;event. |
Parameters of the callback function | Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- |
| type | string | Yes | Type of the event to unsubscribe from. The value is **headerReceive** (response header). |
| callback | function | No | Callback for the HTTP Response Header event. |
| Name | Type | Mandatory | Description | Parameters of the callback function
| -------- | -------- | -------- | -------- |
| header | object | Yes | HTTP&nbsp;Response&nbsp;Header. |
- Example | Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- |
| header | object | Yes | HTTP Response Header. |
``` **Example**
uploadTask.off('headerReceive', function callback(headers) {
```js
uploadTask.off('headerReceive', function callback(headers) {
console.info("upOnHeader headers:" + JSON.stringify(headers)); console.info("upOnHeader headers:" + JSON.stringify(headers));
} }
); );
``` ```
...@@ -258,29 +265,30 @@ Unsubscribes from the **headerReceive** event. This method uses an asynchronous ...@@ -258,29 +265,30 @@ Unsubscribes from the **headerReceive** event. This method uses an asynchronous
remove(): Promise&lt;boolean&gt; remove(): Promise&lt;boolean&gt;
Removes this upload task. This method uses a promise to return the result. Removes this upload task. This API uses a promise to return the result.
**Required permission**: ohos.permission.INTERNET **Required permission**: ohos.permission.INTERNET
**System capability**: SystemCapability.MiscServices.Upload **System capability**: SystemCapability.MiscServices.Upload
- Return values **Return value**
| Type | Description |
| -------- | -------- |
| Promise&lt;boolean&gt; | Promise&nbsp;used&nbsp;to&nbsp;return&nbsp;the&nbsp;task&nbsp;removal&nbsp;result.&nbsp;If&nbsp;**true**&nbsp;is&nbsp;returned,&nbsp;the&nbsp;task&nbsp;is&nbsp;removed.&nbsp;If&nbsp;**false**&nbsp;is&nbsp;returned,&nbsp;the&nbsp;task&nbsp;fails&nbsp;to&nbsp;be&nbsp;removed. |
- Example | Type | Description |
| -------- | -------- |
| Promise&lt;boolean&gt; | Promise used to return the task removal result. If **true** is returned, the task is removed. If **false** is returned, the task fails to be removed. |
``` **Example**
uploadTask.remove().then((result) => {
```js
uploadTask.remove().then((result) => {
if (result) { if (result) {
console.info('Upload task removed successfully. '); console.info('Upload task removed successfully. ');
} else { } else {
console.error('Failed to remove the upload task. '); console.error('Failed to remove the upload task. ');
} }
}).catch((err) => { }).catch((err) => {
console.error('Failed to remove the upload task. Cause: ' + JSON.stringify(err)); console.error('Failed to remove the upload task. Cause: ' + JSON.stringify(err));
}); });
``` ```
...@@ -288,21 +296,22 @@ Removes this upload task. This method uses a promise to return the result. ...@@ -288,21 +296,22 @@ Removes this upload task. This method uses a promise to return the result.
remove(callback: AsyncCallback&lt;boolean&gt;): void remove(callback: AsyncCallback&lt;boolean&gt;): void
Removes this upload task. This method uses an asynchronous callback to return the result. Removes this upload task. This API uses an asynchronous callback to return the result.
**Required permission**: ohos.permission.INTERNET **Required permission**: ohos.permission.INTERNET
**System capability**: SystemCapability.MiscServices.Upload **System capability**: SystemCapability.MiscServices.Upload
- Parameters **Parameters**
| Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- | | Name | Type | Mandatory | Description |
| callback | AsyncCallback&lt;boolean&gt; | Yes | Callback&nbsp;used&nbsp;to&nbsp;return&nbsp;the&nbsp;result. | | -------- | -------- | -------- | -------- |
| callback | AsyncCallback&lt;boolean&gt; | Yes | Callback used to return the result. |
- Example **Example**
``` ```js
uploadTask.remove((err, result) => { uploadTask.remove((err, result) => {
if (err) { if (err) {
console.error('Failed to remove the upload task. Cause: ' + JSON.stringify(err)); console.error('Failed to remove the upload task. Cause: ' + JSON.stringify(err));
return; return;
...@@ -312,7 +321,7 @@ Removes this upload task. This method uses an asynchronous callback to return th ...@@ -312,7 +321,7 @@ Removes this upload task. This method uses an asynchronous callback to return th
} else { } else {
console.error('Failed to remove the upload task.'); console.error('Failed to remove the upload task.');
} }
}); });
``` ```
...@@ -322,11 +331,11 @@ Removes this upload task. This method uses an asynchronous callback to return th ...@@ -322,11 +331,11 @@ Removes this upload task. This method uses an asynchronous callback to return th
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| url | string | Yes | Resource&nbsp;URL. | | url | string | Yes | Resource URL. |
| header | object | No | HTTP&nbsp;or&nbsp;HTTPS&nbsp;header&nbsp;added&nbsp;to&nbsp;an&nbsp;upload&nbsp;request. | | header | object | No | HTTP or HTTPS header added to an upload request. |
| method | string | No | Request&nbsp;methods&nbsp;available:&nbsp;**POST**&nbsp;and&nbsp;**PUT**.&nbsp;The&nbsp;default&nbsp;value&nbsp;is&nbsp;**POST**. | | method | string | No | Request methods available: **POST** and **PUT**. The default value is **POST**. |
| files | Array&lt;[File](#file)&gt; | Yes | List&nbsp;of&nbsp;files&nbsp;to&nbsp;upload,&nbsp;which&nbsp;is&nbsp;submitted&nbsp;through&nbsp;**multipart/form-data**. | | files | Array&lt;[File](#file)&gt; | Yes | List of files to upload, which is submitted through **multipart/form-data**. |
| data | Array&lt;[RequestData](#requestdata)&gt; | No | Form&nbsp;data&nbsp;in&nbsp;the&nbsp;request&nbsp;body. | | data | Array&lt;[RequestData](#requestdata)&gt; | No | Form data in the request body. |
## File ## File
...@@ -335,10 +344,10 @@ Removes this upload task. This method uses an asynchronous callback to return th ...@@ -335,10 +344,10 @@ Removes this upload task. This method uses an asynchronous callback to return th
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| filename | string | No | File&nbsp;name&nbsp;in&nbsp;the&nbsp;header&nbsp;when&nbsp;**multipart**&nbsp;is&nbsp;used. | | filename | string | No | File name in the header when **multipart** is used. |
| name | string | No | Name&nbsp;of&nbsp;a&nbsp;form&nbsp;item&nbsp;when&nbsp;**multipart**&nbsp;is&nbsp;used.&nbsp;The&nbsp;default&nbsp;value&nbsp;is&nbsp;**file**. | | name | string | No | Name of a form item when **multipart** is used. The default value is **file**. |
| uri | string | Yes | Local&nbsp;path&nbsp;for&nbsp;storing&nbsp;files.<br/>The&nbsp;**dataability**&nbsp;and&nbsp;**internal**&nbsp;protocol&nbsp;types&nbsp;are&nbsp;supported.&nbsp;However,&nbsp;the&nbsp;**internal**&nbsp;protocol&nbsp;type&nbsp;supports&nbsp;only&nbsp;temporary&nbsp;directories.&nbsp;The&nbsp;following&nbsp;is&nbsp;an&nbsp;example:<br/>dataability:///com.domainname.dataability.persondata/person/10/file.txt<br/>internal://cache/path/to/file.txt | | uri | string | Yes | Local path for storing files.<br/>The **dataability** and **internal** protocol types are supported. However, the **internal** protocol type supports only temporary directories. The following is an example:<br/>dataability:///com.domainname.dataability.persondata/person/10/file.txt<br/>internal://cache/path/to/file.txt |
| type | string | No | Type&nbsp;of&nbsp;the&nbsp;file&nbsp;content.&nbsp;By&nbsp;default,&nbsp;the&nbsp;type&nbsp;is&nbsp;obtained&nbsp;based&nbsp;on&nbsp;the&nbsp;extension&nbsp;of&nbsp;the&nbsp;file&nbsp;name&nbsp;or&nbsp;URI. | | type | string | No | Type of the file content. By default, the type is obtained based on the extension of the file name or URI. |
## RequestData ## RequestData
...@@ -347,68 +356,71 @@ Removes this upload task. This method uses an asynchronous callback to return th ...@@ -347,68 +356,71 @@ Removes this upload task. This method uses an asynchronous callback to return th
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| name | string | Yes | Name&nbsp;of&nbsp;a&nbsp;form&nbsp;element. | | name | string | Yes | Name of a form element. |
| value | string | Yes | Value&nbsp;of&nbsp;a&nbsp;form&nbsp;element. | | value | string | Yes | Value of a form element. |
## request.download ## request.download
download(config: DownloadConfig): Promise&lt;DownloadTask&gt; download(config: DownloadConfig): Promise&lt;DownloadTask&gt;
Downloads files. This method uses a promise to return the result. Downloads files. This API uses a promise to return the result.
**Required permission**: ohos.permission.INTERNET **Required permission**: ohos.permission.INTERNET
**System capability**: SystemCapability.MiscServices.Download **System capability**: SystemCapability.MiscServices.Download
- Parameters **Parameters**
| Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- |
| config | [DownloadConfig](#downloadconfig) | Yes | Configurations&nbsp;of&nbsp;the&nbsp;download. |
- Return values | Name | Type | Mandatory | Description |
| Type | Description | | -------- | -------- | -------- | -------- |
| -------- | -------- | | config | [DownloadConfig](#downloadconfig) | Yes | Configurations of the download. |
| Promise&lt;[DownloadTask](#downloadtask)&gt; | Promise&nbsp;used&nbsp;to&nbsp;return&nbsp;the&nbsp;result. |
- Example **Return value**
``` | Type | Description |
request.download({ url: 'https://xxxx/xxxx.hap' }).then((data) => { | -------- | -------- |
| Promise&lt;[DownloadTask](#downloadtask)&gt; | Promise used to return the result. |
**Example**
```js
request.download({ url: 'https://xxxx/xxxx.hap' }).then((data) => {
downloadTask = data; downloadTask = data;
}).catch((err) => { }).catch((err) => {
console.error('Failed to request the download. Cause: ' + JSON.stringify(err)); console.error('Failed to request the download. Cause: ' + JSON.stringify(err));
}) })
``` ```
## request.download ## request.download
download(config: DownloadConfig, callback: AsyncCallback&lt;DownloadTask&gt;): void download(config: DownloadConfig, callback: AsyncCallback&lt;DownloadTask&gt;): void
Downloads files. This method uses an asynchronous callback to return the result. Downloads files. This API uses an asynchronous callback to return the result.
**Required permission**: ohos.permission.INTERNET **Required permission**: ohos.permission.INTERNET
**System capability**: SystemCapability.MiscServices.Download **System capability**: SystemCapability.MiscServices.Download
- Parameters **Parameters**
| Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- |
| config | [DownloadConfig](#downloadconfig) | Yes | Configurations&nbsp;of&nbsp;the&nbsp;download. |
| callback | AsyncCallback&lt;[DownloadTask](#downloadtask)&gt; | No | Callback&nbsp;used&nbsp;to&nbsp;return&nbsp;the&nbsp;result. |
- Example | Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- |
| config | [DownloadConfig](#downloadconfig) | Yes | Configurations of the download. |
| callback | AsyncCallback&lt;[DownloadTask](#downloadtask)&gt; | No | Callback used to return the result. |
``` **Example**
request.download({ url: 'https://xxxx/xxxxx.hap',
filePath: 'xxx/xxxxx.hap'}, (err, data) => { ```js
request.download({ url: 'https://xxxx/xxxxx.hap',
filePath: 'xxx/xxxxx.hap'}, (err, data) => {
if (err) { if (err) {
console.error('Failed to request the download. Cause: ' + JSON.stringify(err)); console.error('Failed to request the download. Cause: ' + JSON.stringify(err));
return; return;
} }
downloadTask = data; downloadTask = data;
}); });
``` ```
...@@ -421,28 +433,29 @@ Implements file downloads. ...@@ -421,28 +433,29 @@ Implements file downloads.
on(type: 'progress', callback:(receivedSize: number, totalSize: number) =&gt; void): void on(type: 'progress', callback:(receivedSize: number, totalSize: number) =&gt; void): void
Subscribes to the download progress event. This method uses an asynchronous callback to return the result. Subscribes to the download progress event. This API uses an asynchronous callback to return the result.
**Required permission**: ohos.permission.INTERNET **Required permission**: ohos.permission.INTERNET
**System capability**: SystemCapability.MiscServices.Download **System capability**: SystemCapability.MiscServices.Download
- Parameters **Parameters**
| Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- | | Name | Type | Mandatory | Description |
| type | string | Yes | Type&nbsp;of&nbsp;the&nbsp;event&nbsp;to&nbsp;subscribe&nbsp;to.&nbsp;The&nbsp;value&nbsp;is&nbsp;**progress**&nbsp;(download&nbsp;progress). | | -------- | -------- | -------- | -------- |
| callback | function | Yes | Callback&nbsp;for&nbsp;the&nbsp;download&nbsp;progress&nbsp;event. | | type | string | Yes | Type of the event to subscribe to. The value is **progress** (download progress). |
| callback | function | Yes | Callback for the download progress event. |
Parameters of the callback function Parameters of the callback function
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| receivedSize | number | Yes | Size&nbsp;of&nbsp;the&nbsp;downloaded&nbsp;files,&nbsp;in&nbsp;KB. | | receivedSize | number | Yes | Size of the downloaded files, in KB. |
| totalSize | number | Yes | Total&nbsp;size&nbsp;of&nbsp;the&nbsp;files&nbsp;to&nbsp;download,&nbsp;in&nbsp;KB. | | totalSize | number | Yes | Total size of the files to download, in KB. |
- Example **Example**
``` ```js
request.download({ url: 'https://xxxx/xxxx.hap' }, (err, data)=> { request.download({ url: 'https://xxxx/xxxx.hap' }, (err, data)=> {
if (err) { if (err) {
console.error('Failed to request download. Cause:' + err); console.error('Failed to request download. Cause:' + err);
...@@ -461,29 +474,30 @@ Subscribes to the download progress event. This method uses an asynchronous call ...@@ -461,29 +474,30 @@ Subscribes to the download progress event. This method uses an asynchronous call
off(type: 'progress', callback?: (receivedSize: number, totalSize: number) =&gt; void): void off(type: 'progress', callback?: (receivedSize: number, totalSize: number) =&gt; void): void
Unsubscribes from the download progress event. This method uses an asynchronous callback to return the result. Unsubscribes from the download progress event. This API uses an asynchronous callback to return the result.
**Required permission**: ohos.permission.INTERNET **Required permission**: ohos.permission.INTERNET
**System capability**: SystemCapability.MiscServices.Download **System capability**: SystemCapability.MiscServices.Download
- Parameters **Parameters**
| Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- |
| type | string | Yes | Type&nbsp;of&nbsp;the&nbsp;event&nbsp;to&nbsp;unsubscribe&nbsp;from.&nbsp;The&nbsp;value&nbsp;is&nbsp;**progress**&nbsp;(download&nbsp;progress). |
| callback | function | No | Callback&nbsp;for&nbsp;the&nbsp;download&nbsp;progress&nbsp;event. |
Parameters of the callback function | Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- |
| type | string | Yes | Type of the event to unsubscribe from. The value is **progress** (download progress). |
| callback | function | No | Callback for the download progress event. |
| Name | Type | Mandatory | Description | Parameters of the callback function
| -------- | -------- | -------- | -------- |
| receivedSize | number | Yes | Size&nbsp;of&nbsp;the&nbsp;downloaded&nbsp;files,&nbsp;in&nbsp;KB. |
| totalSize | number | Yes | Total&nbsp;size&nbsp;of&nbsp;the&nbsp;files&nbsp;to&nbsp;download,&nbsp;in&nbsp;KB. |
- Example | Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- |
| receivedSize | number | Yes | Size of the downloaded files, in KB. |
| totalSize | number | Yes | Total size of the files to download, in KB. |
``` **Example**
request.download({ url: 'https://xxxx/xxxx.hap' }, (err, data)=> {
```js
request.download({ url: 'https://xxxx/xxxx.hap' }, (err, data)=> {
if (err) { if (err) {
console.error('Failed to request download. Cause:' + err); console.error('Failed to request download. Cause:' + err);
return; return;
...@@ -492,8 +506,8 @@ Unsubscribes from the download progress event. This method uses an asynchronous ...@@ -492,8 +506,8 @@ Unsubscribes from the download progress event. This method uses an asynchronous
downloadTask .off('progress', function download_callback(receivedSize, totalSize) { downloadTask .off('progress', function download_callback(receivedSize, totalSize) {
console.info("download receivedSize:" + receivedSize + " totalSize:" + totalSize); console.info("download receivedSize:" + receivedSize + " totalSize:" + totalSize);
} }
); );
}); });
``` ```
...@@ -501,22 +515,23 @@ Unsubscribes from the download progress event. This method uses an asynchronous ...@@ -501,22 +515,23 @@ Unsubscribes from the download progress event. This method uses an asynchronous
on(type: 'complete'|'pause'|'remove', callback:() =&gt; void): void on(type: 'complete'|'pause'|'remove', callback:() =&gt; void): void
Subscribes to a download event. This method uses an asynchronous callback to return the result. Subscribes to a download event. This API uses an asynchronous callback to return the result.
**Required permission**: ohos.permission.INTERNET **Required permission**: ohos.permission.INTERNET
**System capability**: SystemCapability.MiscServices.Download **System capability**: SystemCapability.MiscServices.Download
- Parameters **Parameters**
| Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- |
| type | string | Yes | Event&nbsp;type.<br/>-&nbsp;**complete**:&nbsp;download&nbsp;task&nbsp;completion&nbsp;event.<br/>-&nbsp;**pause**:&nbsp;download&nbsp;task&nbsp;pause&nbsp;event.<br/>-&nbsp;**remove**:&nbsp;download&nbsp;task&nbsp;removal&nbsp;event. |
| callback | function | Yes | Callback&nbsp;used&nbsp;to&nbsp;return&nbsp;the&nbsp;result. |
- Example | Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- |
| type | string | Yes | Event type.<br/>- **complete**: download task completion event.<br/>- **pause**: download task pause event.<br/>- **remove**: download task removal event. |
| callback | function | Yes | Callback used to return the result. |
``` **Example**
request.download({ url: 'https://xxxx/xxxx.hap' }, (err, data)=> {
```js
request.download({ url: 'https://xxxx/xxxx.hap' }, (err, data)=> {
if (err) { if (err) {
console.error('Failed to request download. Cause:' + err); console.error('Failed to request download. Cause:' + err);
return; return;
...@@ -525,8 +540,8 @@ Subscribes to a download event. This method uses an asynchronous callback to ret ...@@ -525,8 +540,8 @@ Subscribes to a download event. This method uses an asynchronous callback to ret
downloadTask.on('complete', function callback() { downloadTask.on('complete', function callback() {
console.info('Download task completed.'); console.info('Download task completed.');
} }
); );
}); });
``` ```
...@@ -534,22 +549,23 @@ Subscribes to a download event. This method uses an asynchronous callback to ret ...@@ -534,22 +549,23 @@ Subscribes to a download event. This method uses an asynchronous callback to ret
off(type: 'complete'|'pause'|'remove', callback?:() =&gt; void): void off(type: 'complete'|'pause'|'remove', callback?:() =&gt; void): void
Unsubscribes from the download event. This method uses an asynchronous callback to return the result. Unsubscribes from the download event. This API uses an asynchronous callback to return the result.
**Required permission**: ohos.permission.INTERNET **Required permission**: ohos.permission.INTERNET
**System capability**: SystemCapability.MiscServices.Download **System capability**: SystemCapability.MiscServices.Download
- Parameters **Parameters**
| Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- |
| type | string | Yes | Event&nbsp;type.<br/>-&nbsp;**complete**:&nbsp;download&nbsp;task&nbsp;completion&nbsp;event.<br/>-&nbsp;**pause**:&nbsp;download&nbsp;task&nbsp;pause&nbsp;event.<br/>-&nbsp;**remove**:&nbsp;download&nbsp;task&nbsp;removal&nbsp;event. |
| callback | function | No | Callback&nbsp;used&nbsp;to&nbsp;return&nbsp;the&nbsp;result. |
- Example | Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- |
| type | string | Yes | Event type.<br/>- **complete**: download task completion event.<br/>- **pause**: download task pause event.<br/>- **remove**: download task removal event. |
| callback | function | No | Callback used to return the result. |
``` **Example**
request.download({ url: 'https://xxxx/xxxx.hap' }, (err, data)=> {
```js
request.download({ url: 'https://xxxx/xxxx.hap' }, (err, data)=> {
if (err) { if (err) {
console.error('Failed to request download. Cause:' + JSON.stringify(err)); console.error('Failed to request download. Cause:' + JSON.stringify(err));
return; return;
...@@ -558,8 +574,8 @@ Unsubscribes from the download event. This method uses an asynchronous callback ...@@ -558,8 +574,8 @@ Unsubscribes from the download event. This method uses an asynchronous callback
downloadTask.off('complete', function callback() { downloadTask.off('complete', function callback() {
console.info('Download task completed.'); console.info('Download task completed.');
} }
); );
}); });
``` ```
...@@ -567,28 +583,29 @@ Unsubscribes from the download event. This method uses an asynchronous callback ...@@ -567,28 +583,29 @@ Unsubscribes from the download event. This method uses an asynchronous callback
on(type: 'fail', callback: (err: number) =&gt; void): void on(type: 'fail', callback: (err: number) =&gt; void): void
Subscribes to the download task failure event. This method uses an asynchronous callback to return the result. Subscribes to the download task failure event. This API uses an asynchronous callback to return the result.
**Required permission**: ohos.permission.INTERNET **Required permission**: ohos.permission.INTERNET
**System capability**: SystemCapability.MiscServices.Download **System capability**: SystemCapability.MiscServices.Download
- Parameters **Parameters**
| Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- |
| type | string | Yes | Type&nbsp;of&nbsp;the&nbsp;subscribed&nbsp;event.&nbsp;The&nbsp;value&nbsp;is&nbsp;**fail**&nbsp;(download&nbsp;failure). |
| callback | function | Yes | Callback&nbsp;for&nbsp;the&nbsp;download&nbsp;task&nbsp;failure&nbsp;event. |
Parameters of the callback function | Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- |
| type | string | Yes | Type of the subscribed event. The value is **fail** (download failure). |
| callback | function | Yes | Callback for the download task failure event. |
| Name | Type | Mandatory | Description | Parameters of the callback function
| -------- | -------- | -------- | -------- |
| err | number | Yes | Error&nbsp;code&nbsp;of&nbsp;the&nbsp;download&nbsp;failure.&nbsp;For&nbsp;details&nbsp;about&nbsp;the&nbsp;error&nbsp;cause,&nbsp;see&nbsp;[ERROR_*](#constants). |
- Example | Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- |
| err | number | Yes | Error code of the download failure. For details about the error cause, see [ERROR_*](#constants). |
``` **Example**
request.download({ url: 'https://xxxx/xxxx.hap' }, (err, data)=> {
```js
request.download({ url: 'https://xxxx/xxxx.hap' }, (err, data)=> {
if (err) { if (err) {
console.error('Failed to request download. Cause:' + err); console.error('Failed to request download. Cause:' + err);
return; return;
...@@ -597,8 +614,8 @@ Subscribes to the download task failure event. This method uses an asynchronous ...@@ -597,8 +614,8 @@ Subscribes to the download task failure event. This method uses an asynchronous
downloadTask.on('fail', function callBack(err) { downloadTask.on('fail', function callBack(err) {
console.info('Download task failed. Cause:' + err); console.info('Download task failed. Cause:' + err);
} }
); );
}); });
``` ```
...@@ -606,27 +623,28 @@ Subscribes to the download task failure event. This method uses an asynchronous ...@@ -606,27 +623,28 @@ Subscribes to the download task failure event. This method uses an asynchronous
off(type: 'fail', callback?: (err: number) =&gt; void): void off(type: 'fail', callback?: (err: number) =&gt; void): void
Unsubscribes from the download task failure event. This method uses an asynchronous callback to return the result. Unsubscribes from the download task failure event. This API uses an asynchronous callback to return the result.
**Required permission**: ohos.permission.INTERNET **Required permission**: ohos.permission.INTERNET
**System capability**: SystemCapability.MiscServices.Download **System capability**: SystemCapability.MiscServices.Download
- Parameters **Parameters**
| Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- |
| type | string | Yes | Type&nbsp;of&nbsp;the&nbsp;event&nbsp;to&nbsp;unsubscribe&nbsp;from.&nbsp;The&nbsp;value&nbsp;is&nbsp;**fail**&nbsp;(download&nbsp;failure). |
| callback | function | No | Callback&nbsp;for&nbsp;the&nbsp;download&nbsp;task&nbsp;failure&nbsp;event. |
Parameters of the callback function | Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- |
| type | string | Yes | Type of the event to unsubscribe from. The value is **fail** (download failure). |
| callback | function | No | Callback for the download task failure event. |
| Name | Type | Mandatory | Description | Parameters of the callback function
| -------- | -------- | -------- | -------- |
| err | number | Yes | Error&nbsp;code&nbsp;of&nbsp;the&nbsp;download&nbsp;failure.&nbsp;For&nbsp;details&nbsp;about&nbsp;the&nbsp;error&nbsp;cause,&nbsp;see&nbsp;[ERROR_*](#constants). |
- Example | Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- |
| err | number | Yes | Error code of the download failure. For details about the error cause, see [ERROR_*](#constants). |
``` **Example**
```js
request.download({ url: 'https://xxxx/xxxx.hap' }, (err, data)=> { request.download({ url: 'https://xxxx/xxxx.hap' }, (err, data)=> {
if (err) { if (err) {
console.error('Failed to request download. Cause:' + err); console.error('Failed to request download. Cause:' + err);
...@@ -645,20 +663,21 @@ Unsubscribes from the download task failure event. This method uses an asynchron ...@@ -645,20 +663,21 @@ Unsubscribes from the download task failure event. This method uses an asynchron
remove(): Promise&lt;boolean&gt; remove(): Promise&lt;boolean&gt;
Removes this download task. This method uses a promise to return the result. Removes this download task. This API uses a promise to return the result.
**Required permission**: ohos.permission.INTERNET **Required permission**: ohos.permission.INTERNET
**System capability**: SystemCapability.MiscServices.Download **System capability**: SystemCapability.MiscServices.Download
- Return values **Return value**
| Type | Description |
| -------- | -------- |
| Promise&lt;boolean&gt; | Promise&nbsp;used&nbsp;to&nbsp;return&nbsp;the&nbsp;task&nbsp;removal&nbsp;result. |
- Example | Type | Description |
| -------- | -------- |
| Promise&lt;boolean&gt; | Promise used to return the task removal result. |
``` **Example**
```js
downloadTask.remove().then((result) => { downloadTask.remove().then((result) => {
if (result) { if (result) {
console.info('Download task removed.'); console.info('Download task removed.');
...@@ -675,21 +694,22 @@ Removes this download task. This method uses a promise to return the result. ...@@ -675,21 +694,22 @@ Removes this download task. This method uses a promise to return the result.
remove(callback: AsyncCallback&lt;boolean&gt;): void remove(callback: AsyncCallback&lt;boolean&gt;): void
Removes this download task. This method uses an asynchronous callback to return the result. Removes this download task. This API uses an asynchronous callback to return the result.
**Required permission**: ohos.permission.INTERNET **Required permission**: ohos.permission.INTERNET
**System capability**: SystemCapability.MiscServices.Download **System capability**: SystemCapability.MiscServices.Download
- Parameters **Parameters**
| Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- | | Name | Type | Mandatory | Description |
| callback | AsyncCallback&lt;boolean&gt; | Yes | Callback&nbsp;used&nbsp;to&nbsp;return&nbsp;the&nbsp;task&nbsp;removal&nbsp;result. | | -------- | -------- | -------- | -------- |
| callback | AsyncCallback&lt;boolean&gt; | Yes | Callback used to return the task removal result. |
- Example **Example**
``` ```js
downloadTask.remove((err, result)=>{ downloadTask.remove((err, result)=>{
if(err) { if(err) {
console.error('Failed to remove the download task.'); console.error('Failed to remove the download task.');
return; return;
...@@ -699,7 +719,7 @@ Removes this download task. This method uses an asynchronous callback to return ...@@ -699,7 +719,7 @@ Removes this download task. This method uses an asynchronous callback to return
} else { } else {
console.error('Failed to remove the download task.'); console.error('Failed to remove the download task.');
} }
}); });
``` ```
...@@ -707,25 +727,26 @@ Removes this download task. This method uses an asynchronous callback to return ...@@ -707,25 +727,26 @@ Removes this download task. This method uses an asynchronous callback to return
query(): Promise&lt;DownloadInfo&gt; query(): Promise&lt;DownloadInfo&gt;
Queries this download task. This method uses a promise to return the result. Queries this download task. This API uses a promise to return the result.
**Required permission**: ohos.permission.INTERNET **Required permission**: ohos.permission.INTERNET
**System capability**: SystemCapability.MiscServices.Download **System capability**: SystemCapability.MiscServices.Download
- Parameters **Parameters**
| Type | Description |
| -------- | -------- |
| Promise&lt;[DownloadInfo](#downloadinfo7)&gt; | Promise&nbsp;used&nbsp;to&nbsp;return&nbsp;the&nbsp;download&nbsp;task&nbsp;information. |
- Example | Type | Description |
| -------- | -------- |
| Promise&lt;[DownloadInfo](#downloadinfo7)&gt; | Promise used to return the download task information. |
``` **Example**
downloadTask.query().then((downloadInfo) => {
```js
downloadTask.query().then((downloadInfo) => {
console.info('Download task queried. Data:' + JSON.stringify(downloadInfo)) console.info('Download task queried. Data:' + JSON.stringify(downloadInfo))
}) .catch((err) => { }) .catch((err) => {
console.error('Failed to query the download task. Cause:' + err) console.error('Failed to query the download task. Cause:' + err)
}); });
``` ```
...@@ -733,27 +754,28 @@ Queries this download task. This method uses a promise to return the result. ...@@ -733,27 +754,28 @@ Queries this download task. This method uses a promise to return the result.
query(callback: AsyncCallback&lt;DownloadInfo&gt;): void query(callback: AsyncCallback&lt;DownloadInfo&gt;): void
Queries this download task. This method uses an asynchronous callback to return the result. Queries this download task. This API uses an asynchronous callback to return the result.
**Required permission**: ohos.permission.INTERNET **Required permission**: ohos.permission.INTERNET
**System capability**: SystemCapability.MiscServices.Download **System capability**: SystemCapability.MiscServices.Download
- Parameters **Parameters**
| Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- | | Name | Type | Mandatory | Description |
| callback | AsyncCallback&lt;[DownloadInfo](#downloadinfo7)&gt; | Yes | Callback&nbsp;used&nbsp;to&nbsp;return&nbsp;the&nbsp;download&nbsp;task&nbsp;information. | | -------- | -------- | -------- | -------- |
| callback | AsyncCallback&lt;[DownloadInfo](#downloadinfo7)&gt; | Yes | Callback used to return the download task information. |
- Example **Example**
``` ```js
downloadTask.query((err, downloadInfo)=>{ downloadTask.query((err, downloadInfo)=>{
if(err) { if(err) {
console.error('Failed to query the download mimeType. Cause:' + JSON.stringify(err)); console.error('Failed to query the download mimeType. Cause:' + JSON.stringify(err));
} else { } else {
console.info('download query success. data:'+ JSON.stringify(downloadInfo)); console.info('download query success. data:'+ JSON.stringify(downloadInfo));
} }
}); });
``` ```
...@@ -761,25 +783,26 @@ Queries this download task. This method uses an asynchronous callback to return ...@@ -761,25 +783,26 @@ Queries this download task. This method uses an asynchronous callback to return
queryMimeType(): Promise&lt;string&gt; queryMimeType(): Promise&lt;string&gt;
Queries **MimeType** of this download task. This method uses a promise to return the result. Queries **MimeType** of this download task. This API uses a promise to return the result.
**Required permission**: ohos.permission.INTERNET **Required permission**: ohos.permission.INTERNET
**System capability**: SystemCapability.MiscServices.Download **System capability**: SystemCapability.MiscServices.Download
- Return values **Return value**
| Type | Description |
| -------- | -------- |
| Promise&lt;string&gt; | Promise&nbsp;used&nbsp;to&nbsp;return&nbsp;**MimeType**&nbsp;of&nbsp;the&nbsp;download&nbsp;task. |
- Example | Type | Description |
| -------- | -------- |
| Promise&lt;string&gt; | Promise used to return **MimeType** of the download task. |
``` **Example**
downloadTask.queryMimeType().then((data) => {
```js
downloadTask.queryMimeType().then((data) => {
console.info('Download task queried. Data:' + JSON.stringify(data)); console.info('Download task queried. Data:' + JSON.stringify(data));
}).catch((err) => { }).catch((err) => {
console.error('Failed to query the download MimeType. Cause:' + JSON.stringify(err)) console.error('Failed to query the download MimeType. Cause:' + JSON.stringify(err))
}); });
``` ```
...@@ -787,27 +810,28 @@ Queries **MimeType** of this download task. This method uses a promise to return ...@@ -787,27 +810,28 @@ Queries **MimeType** of this download task. This method uses a promise to return
queryMimeType(callback: AsyncCallback&lt;string&gt;): void; queryMimeType(callback: AsyncCallback&lt;string&gt;): void;
Queries **MimeType** of this download task. This method uses an asynchronous callback to return the result. Queries **MimeType** of this download task. This API uses an asynchronous callback to return the result.
**Required permission**: ohos.permission.INTERNET **Required permission**: ohos.permission.INTERNET
**System capability**: SystemCapability.MiscServices.Download **System capability**: SystemCapability.MiscServices.Download
- Parameters **Parameters**
| Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- |
| callback | AsyncCallback&lt;string&gt; | Yes | Callback&nbsp;used&nbsp;to&nbsp;return&nbsp;**MimeType**&nbsp;of&nbsp;the&nbsp;download&nbsp;task. |
- Example | Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- |
| callback | AsyncCallback&lt;string&gt; | Yes | Callback used to return **MimeType** of the download task. |
``` **Example**
downloadTask.queryMimeType((err, data)=>{
```js
downloadTask.queryMimeType((err, data)=>{
if(err) { if(err) {
console.error('Failed to query the download mimeType. Cause:' + JSON.stringify(err)); console.error('Failed to query the download mimeType. Cause:' + JSON.stringify(err));
} else { } else {
console.info('Download task queried. data:' + JSON.stringify(data)); console.info('Download task queried. data:' + JSON.stringify(data));
} }
}); });
``` ```
...@@ -815,29 +839,30 @@ Queries **MimeType** of this download task. This method uses an asynchronous cal ...@@ -815,29 +839,30 @@ Queries **MimeType** of this download task. This method uses an asynchronous cal
pause(): Promise&lt;void&gt; pause(): Promise&lt;void&gt;
Pauses this download task. This method uses a promise to return the result. Pauses this download task. This API uses a promise to return the result.
**Required permission**: ohos.permission.INTERNET **Required permission**: ohos.permission.INTERNET
**System capability**: SystemCapability.MiscServices.Download **System capability**: SystemCapability.MiscServices.Download
- Return values **Return value**
| Type | Description |
| -------- | -------- |
| Promise&lt;void&gt; | Promise&nbsp;used&nbsp;to&nbsp;return&nbsp;the&nbsp;download&nbsp;task&nbsp;pause&nbsp;result. |
- Example | Type | Description |
| -------- | -------- |
| Promise&lt;void&gt; | Promise used to return the download task pause result. |
``` **Example**
downloadTask.pause().then((result) => {
```js
downloadTask.pause().then((result) => {
if (result) { if (result) {
console.info('Download task paused. '); console.info('Download task paused. ');
} else { } else {
console.error('Failed to pause the download task. Cause:' + JSON.stringify(result)); console.error('Failed to pause the download task. Cause:' + JSON.stringify(result));
} }
}).catch((err) => { }).catch((err) => {
console.error('Failed to pause the download task. Cause:' + JSON.stringify(err)); console.error('Failed to pause the download task. Cause:' + JSON.stringify(err));
}); });
``` ```
...@@ -845,21 +870,22 @@ Pauses this download task. This method uses a promise to return the result. ...@@ -845,21 +870,22 @@ Pauses this download task. This method uses a promise to return the result.
pause(callback: AsyncCallback&lt;void&gt;): void pause(callback: AsyncCallback&lt;void&gt;): void
Pauses this download task. This method uses an asynchronous callback to return the result. Pauses this download task. This API uses an asynchronous callback to return the result.
**Required permission**: ohos.permission.INTERNET **Required permission**: ohos.permission.INTERNET
**System capability**: SystemCapability.MiscServices.Download **System capability**: SystemCapability.MiscServices.Download
- Parameters **Parameters**
| Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- |
| callback | AsyncCallback&lt;void&gt; | Yes | Callback&nbsp;used&nbsp;to&nbsp;return&nbsp;the&nbsp;result. |
- Example | Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- |
| callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result. |
``` **Example**
downloadTask.pause((err, result)=>{
```js
downloadTask.pause((err, result)=>{
if(err) { if(err) {
console.error('Failed to pause the download task. Cause:' + JSON.stringify(err)); console.error('Failed to pause the download task. Cause:' + JSON.stringify(err));
return; return;
...@@ -869,7 +895,7 @@ Pauses this download task. This method uses an asynchronous callback to return t ...@@ -869,7 +895,7 @@ Pauses this download task. This method uses an asynchronous callback to return t
} else { } else {
console.error('Failed to pause the download task. Cause:' + JSON.stringify(result)); console.error('Failed to pause the download task. Cause:' + JSON.stringify(result));
} }
}); });
``` ```
...@@ -877,30 +903,31 @@ Pauses this download task. This method uses an asynchronous callback to return t ...@@ -877,30 +903,31 @@ Pauses this download task. This method uses an asynchronous callback to return t
resume(): Promise&lt;void&gt; resume(): Promise&lt;void&gt;
Resumes this download task. This method uses a promise to return the result. Resumes this download task. This API uses a promise to return the result.
**Required permission**: ohos.permission.INTERNET **Required permission**: ohos.permission.INTERNET
**System capability**: SystemCapability.MiscServices.Download **System capability**: SystemCapability.MiscServices.Download
- Parameters **Parameters**
| Type | Description |
| -------- | -------- |
| Promise&lt;void&gt; | Promise&nbsp;used&nbsp;to&nbsp;return&nbsp;the&nbsp;result. |
- Example | Type | Description |
| -------- | -------- |
| Promise&lt;void&gt; | Promise used to return the result. |
``` **Example**
downloadTask.resume().then((result) => {
```js
downloadTask.resume().then((result) => {
if (result) { if (result) {
console.info('Download task resumed.') console.info('Download task resumed.')
} else { } else {
console.error('Failed to resume the download task. '); console.error('Failed to resume the download task. ');
} }
console.info('Download task resumed.') console.info('Download task resumed.')
}).catch((err) => { }).catch((err) => {
console.error('Failed to resume the download task. Cause:' + err); console.error('Failed to resume the download task. Cause:' + err);
}); });
``` ```
...@@ -908,21 +935,22 @@ Resumes this download task. This method uses a promise to return the result. ...@@ -908,21 +935,22 @@ Resumes this download task. This method uses a promise to return the result.
resume(callback: AsyncCallback&lt;void&gt;): void resume(callback: AsyncCallback&lt;void&gt;): void
Resumes this download task. This method uses an asynchronous callback to return the result. Resumes this download task. This API uses an asynchronous callback to return the result.
**Required permission**: ohos.permission.INTERNET **Required permission**: ohos.permission.INTERNET
**System capability**: SystemCapability.MiscServices.Download **System capability**: SystemCapability.MiscServices.Download
- Parameters **Parameters**
| Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- |
| callback | AsyncCallback&lt;void&gt; | Yes | Callback&nbsp;used&nbsp;to&nbsp;return&nbsp;the&nbsp;result. |
- Example | Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- |
| callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result. |
``` **Example**
downloadTask.resume((err, result)=>{
```js
downloadTask.resume((err, result)=>{
if (err) { if (err) {
console.error('Failed to resume the download task. Cause:' + err); console.error('Failed to resume the download task. Cause:' + err);
return; return;
...@@ -932,7 +960,7 @@ Resumes this download task. This method uses an asynchronous callback to return ...@@ -932,7 +960,7 @@ Resumes this download task. This method uses an asynchronous callback to return
} else { } else {
console.error('Failed to resume the download task.'); console.error('Failed to resume the download task.');
} }
}); });
``` ```
...@@ -942,14 +970,14 @@ Resumes this download task. This method uses an asynchronous callback to return ...@@ -942,14 +970,14 @@ Resumes this download task. This method uses an asynchronous callback to return
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| url | string | Yes | Resource&nbsp;URL. | | url | string | Yes | Resource URL. |
| header | object | No | HTTP&nbsp;or&nbsp;HTTPS&nbsp;header&nbsp;added&nbsp;to&nbsp;a&nbsp;download&nbsp;request. | | header | object | No | HTTP or HTTPS header added to a download request. |
| enableMetered | boolean | No | Download&nbsp;allowed&nbsp;in&nbsp;metered&nbsp;connections. | | enableMetered | boolean | No | Download allowed in metered connections. |
| enableRoaming | boolean | No | Download&nbsp;allowed&nbsp;on&nbsp;a&nbsp;roaming&nbsp;network. | | enableRoaming | boolean | No | Download allowed on a roaming network. |
| description | string | No | Description&nbsp;of&nbsp;the&nbsp;download&nbsp;session. | | description | string | No | Description of the download session. |
| filePath<sup>7+</sup> | string | No | Download&nbsp;path.&nbsp;(The&nbsp;default&nbsp;path&nbsp;is&nbsp;[ERROR:Invalid&nbsp;link:en-us_topic_0000001135742582.xml#xref8132147102215,link:en-us_topic_0000001127125012.xml#section1856519365229](en-us_topic_0000001127125012.xml#section1856519365229)).<br/>-&nbsp;filePath:'workspace/test.txt':&nbsp;The&nbsp;**workspace**&nbsp;directory&nbsp;is&nbsp;created&nbsp;in&nbsp;the&nbsp;default&nbsp;path&nbsp;to&nbsp;store&nbsp;files.<br/>-&nbsp;filePath:'test.txt':&nbsp;Files&nbsp;are&nbsp;stored&nbsp;in&nbsp;the&nbsp;default&nbsp;path.<br/>-&nbsp;filePath:'workspace/':&nbsp;The&nbsp;**workspace**&nbsp;directory&nbsp;is&nbsp;created&nbsp;in&nbsp;the&nbsp;default&nbsp;path&nbsp;to&nbsp;store&nbsp;files. | | filePath<sup>7+</sup> | string | No | Download path. (The default path is [ERROR:Invalid link:en-us_topic_0000001135742582.xml#xref8132147102215,link:en-us_topic_0000001127125012.xml#section1856519365229](en-us_topic_0000001127125012.xml#section1856519365229)).<br/>- filePath:'workspace/test.txt': The **workspace** directory is created in the default path to store files.<br/>- filePath:'test.txt': Files are stored in the default path.<br/>- filePath:'workspace/': The **workspace** directory is created in the default path to store files. |
| networkType | number | No | Network&nbsp;type&nbsp;allowed&nbsp;for&nbsp;download. | | networkType | number | No | Network type allowed for download. |
| title | string | No | Title&nbsp;of&nbsp;the&nbsp;download&nbsp;session. | | title | string | No | Title of the download session. |
## DownloadInfo<sup>7+</sup> ## DownloadInfo<sup>7+</sup>
...@@ -958,14 +986,14 @@ Resumes this download task. This method uses an asynchronous callback to return ...@@ -958,14 +986,14 @@ Resumes this download task. This method uses an asynchronous callback to return
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| downloadId | number | Yes | ID&nbsp;of&nbsp;the&nbsp;downloaded&nbsp;file. | | downloadId | number | Yes | ID of the downloaded file. |
| failedReason | number | No | Download&nbsp;failure&nbsp;cause,&nbsp;which&nbsp;can&nbsp;be&nbsp;any&nbsp;constant&nbsp;of&nbsp;[ERROR_*](#constants). | | failedReason | number | No | Download failure cause, which can be any constant of [ERROR_*](#constants). |
| fileName | string | Yes | Name&nbsp;of&nbsp;the&nbsp;downloaded&nbsp;file. | | fileName | string | Yes | Name of the downloaded file. |
| filePath | string | Yes | URI&nbsp;of&nbsp;the&nbsp;saved&nbsp;file. | | filePath | string | Yes | URI of the saved file. |
| pausedReason | number | No | Reason&nbsp;for&nbsp;session&nbsp;pause,&nbsp;which&nbsp;can&nbsp;be&nbsp;any&nbsp;constant&nbsp;of&nbsp;[PAUSED_*](#constants). | | pausedReason | number | No | Reason for session pause, which can be any constant of [PAUSED_*](#constants). |
| status | number | Yes | Download&nbsp;status&nbsp;code,&nbsp;which&nbsp;can&nbsp;be&nbsp;any&nbsp;constant&nbsp;of&nbsp;[SESSION_*](#constants). | | status | number | Yes | Download status code, which can be any constant of [SESSION_*](#constants). |
| targetURI | string | Yes | URI&nbsp;of&nbsp;the&nbsp;downloaded&nbsp;file. | | targetURI | string | Yes | URI of the downloaded file. |
| downloadTitle | string | Yes | Title&nbsp;of&nbsp;the&nbsp;downloaded&nbsp;file. | | downloadTitle | string | Yes | Title of the downloaded file. |
| downloadTotalBytes | number | Yes | Total&nbsp;size&nbsp;of&nbsp;the&nbsp;downloaded&nbsp;file&nbsp;(int&nbsp;bytes). | | downloadTotalBytes | number | Yes | Total size of the downloaded file (int bytes). |
| description | string | Yes | Description&nbsp;of&nbsp;the&nbsp;file&nbsp;to&nbsp;download. | | description | string | Yes | Description of the file to download. |
| downloadedBytes | number | Yes | Size&nbsp;of&nbsp;the&nbsp;files&nbsp;downloaded&nbsp;(int&nbsp;bytes). | | downloadedBytes | number | Yes | Size of the files downloaded (int bytes). |
# Setting the System Time # Setting the System Time
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** > ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**<br>The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version.
> The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version. >
## Modules to Import ## Modules to Import
...@@ -22,16 +22,17 @@ Sets the system time. This API uses an asynchronous callback to return the resul ...@@ -22,16 +22,17 @@ Sets the system time. This API uses an asynchronous callback to return the resul
**System capability**: SystemCapability.MiscServices.Time **System capability**: SystemCapability.MiscServices.Time
- **Parameters** **Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| time | number | Yes| Timestamp to set, in milliseconds.|
| callback | AsyncCallback&lt;void&gt; | Yes| Callback used to process the received return value.|
- Example | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| time | number | Yes| Timestamp to set, in milliseconds.|
| callback | AsyncCallback&lt;void&gt; | Yes| Callback used to process the received return value.|
``` **Example**
// Set the system time to 2021-01-20 02:36:25.
```js
// Set the system time to 2021-01-20 02:36:25.
var time = 1611081385000; var time = 1611081385000;
systemTime.setTime(time, (error, data) => { systemTime.setTime(time, (error, data) => {
if (error) { if (error) {
...@@ -53,26 +54,28 @@ Sets the system time. This API uses a promise to return the result. ...@@ -53,26 +54,28 @@ Sets the system time. This API uses a promise to return the result.
**System capability**: SystemCapability.MiscServices.Time **System capability**: SystemCapability.MiscServices.Time
- **Parameters** **Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| time | number | Yes| Timestamp to set, in milliseconds.|
- Return value | Name| Type| Mandatory| Description|
| Type| Description| | -------- | -------- | -------- | -------- |
| -------- | -------- | | time | number | Yes| Timestamp to set, in milliseconds.|
| Promise&lt;void&gt; | Promise used to return the result.|
- Example **Return value**
``` | Type| Description|
// Set the system time to 2021-01-20 02:36:25. | -------- | -------- |
var time = 1611081385000; | Promise&lt;void&gt; | Promise used to return the result.|
systemTime.setTime(time).then((data) => {
**Example**
```js
// Set the system time to 2021-01-20 02:36:25.
var time = 1611081385000;
systemTime.setTime(time).then((data) => {
console.log(`systemTime.setTime success data : ` + JSON.stringify(data)); console.log(`systemTime.setTime success data : ` + JSON.stringify(data));
}).catch((error) => { }).catch((error) => {
console.error(`failed to systemTime.setTime because ` + JSON.stringify(error)); console.error(`failed to systemTime.setTime because ` + JSON.stringify(error));
}); });
``` ```
...@@ -84,15 +87,16 @@ Obtains the time elapsed since the Unix epoch. This API uses an asynchronous cal ...@@ -84,15 +87,16 @@ Obtains the time elapsed since the Unix epoch. This API uses an asynchronous cal
**System capability**: SystemCapability.MiscServices.Time **System capability**: SystemCapability.MiscServices.Time
- **Parameters** **Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| isNano | boolean | No| Whether nanoseconds or milliseconds will be returned. If the value is **true**, nanoseconds will be returned. Otherwise, milliseconds will be returned.|
| callback | AsyncCallback&lt;number&gt; | Yes| Callback used to return the time.|
- Example | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| isNano | boolean | No| Whether nanoseconds or milliseconds will be returned. If the value is **true**, nanoseconds will be returned. Otherwise, milliseconds will be returned.|
| callback | AsyncCallback&lt;number&gt; | Yes| Callback used to return the time.|
``` **Example**
```js
systemTime.getCurrentTime(true, (error, data) => { systemTime.getCurrentTime(true, (error, data) => {
if (error) { if (error) {
console.error(`failed to systemTime.getCurrentTime because ` + JSON.stringify(error)); console.error(`failed to systemTime.getCurrentTime because ` + JSON.stringify(error));
...@@ -111,19 +115,21 @@ Obtains the time elapsed since the Unix epoch. This API uses a promise to return ...@@ -111,19 +115,21 @@ Obtains the time elapsed since the Unix epoch. This API uses a promise to return
**System capability**: SystemCapability.MiscServices.Time **System capability**: SystemCapability.MiscServices.Time
- **Parameters** **Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| isNano | boolean | No| Whether nanoseconds or milliseconds will be returned. If the value is **true**, nanoseconds will be returned. Otherwise, milliseconds will be returned.|
- Return value | Name| Type| Mandatory| Description|
| Type| Description| | -------- | -------- | -------- | -------- |
| -------- | -------- | | isNano | boolean | No| Whether nanoseconds or milliseconds will be returned. If the value is **true**, nanoseconds will be returned. Otherwise, milliseconds will be returned.|
| Promise&lt;number&gt; | Promise used to return the time.|
- Example **Return value**
``` | Type| Description|
| -------- | -------- |
| Promise&lt;number&gt; | Promise used to return the time.|
**Example**
```js
systemTime.getCurrentTime().then((data) => { systemTime.getCurrentTime().then((data) => {
console.log(`systemTime.getCurrentTime success data : ` + JSON.stringify(data)); console.log(`systemTime.getCurrentTime success data : ` + JSON.stringify(data));
}).catch((error) => { }).catch((error) => {
...@@ -140,15 +146,16 @@ Obtains the time elapsed since system start, excluding the deep sleep time. This ...@@ -140,15 +146,16 @@ Obtains the time elapsed since system start, excluding the deep sleep time. This
**System capability**: SystemCapability.MiscServices.Time **System capability**: SystemCapability.MiscServices.Time
- **Parameters** **Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| isNano | boolean | No| Whether nanoseconds or milliseconds will be returned. If the value is **true**, nanoseconds will be returned. Otherwise, milliseconds will be returned.|
| callback | AsyncCallback&lt;number&gt; | Yes| Callback used to return the time.|
- Example | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| isNano | boolean | No| Whether nanoseconds or milliseconds will be returned. If the value is **true**, nanoseconds will be returned. Otherwise, milliseconds will be returned.|
| callback | AsyncCallback&lt;number&gt; | Yes| Callback used to return the time.|
``` **Example**
```js
systemTime.getRealActiveTime(true, (error, data) => { systemTime.getRealActiveTime(true, (error, data) => {
if (error) { if (error) {
console.error(`failed to systemTime.getRealActiveTimebecause ` + JSON.stringify(error)); console.error(`failed to systemTime.getRealActiveTimebecause ` + JSON.stringify(error));
...@@ -167,19 +174,21 @@ Obtains the time elapsed since system start, excluding the deep sleep time. This ...@@ -167,19 +174,21 @@ Obtains the time elapsed since system start, excluding the deep sleep time. This
**System capability**: SystemCapability.MiscServices.Time **System capability**: SystemCapability.MiscServices.Time
- **Parameters** **Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| isNano | boolean | No| Whether nanoseconds or milliseconds will be returned. If the value is **true**, nanoseconds will be returned. Otherwise, milliseconds will be returned.|
- Return value | Name| Type| Mandatory| Description|
| Type| Description| | -------- | -------- | -------- | -------- |
| -------- | -------- | | isNano | boolean | No| Whether nanoseconds or milliseconds will be returned. If the value is **true**, nanoseconds will be returned. Otherwise, milliseconds will be returned.|
| Promise&lt;number&gt; | Promise used to return the time.|
- Example **Return value**
``` | Type| Description|
| -------- | -------- |
| Promise&lt;number&gt; | Promise used to return the time.|
**Example**
```js
systemTime.getCurrentTime().then((data) => { systemTime.getCurrentTime().then((data) => {
console.log(`systemTime.getRealActiveTime success data : ` + JSON.stringify(data)); console.log(`systemTime.getRealActiveTime success data : ` + JSON.stringify(data));
}).catch((error) => { }).catch((error) => {
...@@ -196,15 +205,16 @@ Obtains the time elapsed since system start, including the deep sleep time. This ...@@ -196,15 +205,16 @@ Obtains the time elapsed since system start, including the deep sleep time. This
**System capability**: SystemCapability.MiscServices.Time **System capability**: SystemCapability.MiscServices.Time
- **Parameters** **Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| isNano | boolean | No| Whether nanoseconds or milliseconds will be returned. If the value is **true**, nanoseconds will be returned. Otherwise, milliseconds will be returned.|
| callback | AsyncCallback&lt;number&gt; | Yes| Callback used to return the time.|
- Example | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| isNano | boolean | No| Whether nanoseconds or milliseconds will be returned. If the value is **true**, nanoseconds will be returned. Otherwise, milliseconds will be returned.|
| callback | AsyncCallback&lt;number&gt; | Yes| Callback used to return the time.|
``` **Example**
```js
systemTime.getRealTime(true, (error, data) => { systemTime.getRealTime(true, (error, data) => {
if (error) { if (error) {
console.error(`failed to systemTime.getRealTime because ` + JSON.stringify(error)); console.error(`failed to systemTime.getRealTime because ` + JSON.stringify(error));
...@@ -223,19 +233,21 @@ Obtains the time elapsed since system start, including the deep sleep time. This ...@@ -223,19 +233,21 @@ Obtains the time elapsed since system start, including the deep sleep time. This
**System capability**: SystemCapability.MiscServices.Time **System capability**: SystemCapability.MiscServices.Time
- **Parameters** **Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| isNano | boolean | No| Whether nanoseconds or milliseconds will be returned. If the value is **true**, nanoseconds will be returned. Otherwise, milliseconds will be returned.|
- Return value | Name| Type| Mandatory| Description|
| Type| Description| | -------- | -------- | -------- | -------- |
| -------- | -------- | | isNano | boolean | No| Whether nanoseconds or milliseconds will be returned. If the value is **true**, nanoseconds will be returned. Otherwise, milliseconds will be returned.|
| Promise&lt;number&gt; | Promise used to return the time.|
- Example **Return value**
``` | Type| Description|
| -------- | -------- |
| Promise&lt;number&gt; | Promise used to return the time.|
**Example**
```js
systemTime.getRealTime().then((data) => { systemTime.getRealTime().then((data) => {
console.log(`systemTime.getRealTime success data: ` + JSON.stringify(data)); console.log(`systemTime.getRealTime success data: ` + JSON.stringify(data));
}).catch((error) => { }).catch((error) => {
...@@ -254,15 +266,16 @@ Sets the system date. This API uses an asynchronous callback to return the resul ...@@ -254,15 +266,16 @@ Sets the system date. This API uses an asynchronous callback to return the resul
**System capability**: SystemCapability.MiscServices.Time **System capability**: SystemCapability.MiscServices.Time
- **Parameters** **Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| date | Date | Yes| Target date to set.|
| callback | AsyncCallback&lt;void&gt; | Yes| Callback used to process the received return value.|
- Example | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| date | Date | Yes| Target date to set.|
| callback | AsyncCallback&lt;void&gt; | Yes| Callback used to process the received return value.|
``` **Example**
```js
var data = new Date("October 13, 2020 11:13:00"); var data = new Date("October 13, 2020 11:13:00");
systemTime.setDate(data,(error, data) => { systemTime.setDate(data,(error, data) => {
if (error) { if (error) {
...@@ -284,19 +297,21 @@ Sets the system date. This API uses a promise to return the result. ...@@ -284,19 +297,21 @@ Sets the system date. This API uses a promise to return the result.
**System capability**: SystemCapability.MiscServices.Time **System capability**: SystemCapability.MiscServices.Time
- **Parameters** **Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| date | Date | Yes| Target date to set.|
- Return value | Name| Type| Mandatory| Description|
| Type| Description| | -------- | -------- | -------- | -------- |
| -------- | -------- | | date | Date | Yes| Target date to set.|
| Promise&lt;void&gt; | Promise used to return the result.|
- Example **Return value**
``` | Type| Description|
| -------- | -------- |
| Promise&lt;void&gt; | Promise used to return the result.|
**Example**
```js
var data = new Date("October 13, 2020 11:13:00"); var data = new Date("October 13, 2020 11:13:00");
systemTime.setDate(data).then((value) => { systemTime.setDate(data).then((value) => {
console.log(`systemTime.setDate success data : ` + JSON.stringify(value)); console.log(`systemTime.setDate success data : ` + JSON.stringify(value));
...@@ -314,14 +329,15 @@ Obtains the current system date. This API uses an asynchronous callback to retur ...@@ -314,14 +329,15 @@ Obtains the current system date. This API uses an asynchronous callback to retur
**System capability**: SystemCapability.MiscServices.Time **System capability**: SystemCapability.MiscServices.Time
- **Parameters** **Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| callback | AsyncCallback&lt;Date&gt; | Yes| Callback used to return the current system date.|
- Example | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| callback | AsyncCallback&lt;Date&gt; | Yes| Callback used to return the current system date.|
``` **Example**
```js
systemTime.getDate((error, data) => { systemTime.getDate((error, data) => {
if (error) { if (error) {
console.error(`failed to systemTime.getDate because ` + JSON.stringify(error)); console.error(`failed to systemTime.getDate because ` + JSON.stringify(error));
...@@ -340,14 +356,15 @@ Obtains the current system date. This API uses a promise to return the result. ...@@ -340,14 +356,15 @@ Obtains the current system date. This API uses a promise to return the result.
**System capability**: SystemCapability.MiscServices.Time **System capability**: SystemCapability.MiscServices.Time
- Return value **Return value**
| Type| Description|
| -------- | -------- |
| Promise&lt;Date&gt; | Promise used to return the current system date.|
- Example | Type| Description|
| -------- | -------- |
| Promise&lt;Date&gt; | Promise used to return the current system date.|
``` **Example**
```js
systemTime.getDate().then((data) => { systemTime.getDate().then((data) => {
console.log(`systemTime.getDate success data : ` + JSON.stringify(data)); console.log(`systemTime.getDate success data : ` + JSON.stringify(data));
}).catch((error) => { }).catch((error) => {
...@@ -366,15 +383,16 @@ Sets the system time zone. This API uses an asynchronous callback to return the ...@@ -366,15 +383,16 @@ Sets the system time zone. This API uses an asynchronous callback to return the
**System capability**: SystemCapability.MiscServices.Time **System capability**: SystemCapability.MiscServices.Time
- **Parameters** **Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| timezone | string | Yes| System time zone to set.|
| callback | AsyncCallback&lt;void&gt; | Yes| Callback used to process the received return value.|
- Example | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| timezone | string | Yes| System time zone to set.|
| callback | AsyncCallback&lt;void&gt; | Yes| Callback used to process the received return value.|
``` **Example**
```js
systemTime.setTimezone('Asia/Shanghai', (error, data) => { systemTime.setTimezone('Asia/Shanghai', (error, data) => {
if (error) { if (error) {
console.error('failed to systemTime.setTimezone because ' + JSON.stringify(error)); console.error('failed to systemTime.setTimezone because ' + JSON.stringify(error));
...@@ -395,19 +413,21 @@ Sets the system time zone. This API uses a promise to return the result. ...@@ -395,19 +413,21 @@ Sets the system time zone. This API uses a promise to return the result.
**System capability**: SystemCapability.MiscServices.Time **System capability**: SystemCapability.MiscServices.Time
- **Parameters** **Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| timezone | string | Yes| System time zone to set.|
- Return value | Name| Type| Mandatory| Description|
| Type| Description| | -------- | -------- | -------- | -------- |
| -------- | -------- | | timezone | string | Yes| System time zone to set.|
| Promise&lt;void&gt; | Promise used to return the result.|
- Example **Return value**
``` | Type| Description|
| -------- | -------- |
| Promise&lt;void&gt; | Promise used to return the result.|
**Example**
```js
systemTime.setTimezone('Asia/Shanghai').then((data) => { systemTime.setTimezone('Asia/Shanghai').then((data) => {
console.log(`systemTime.setTimezone success data : ` + JSON.stringify(data)); console.log(`systemTime.setTimezone success data : ` + JSON.stringify(data));
}).catch((error) => { }).catch((error) => {
...@@ -424,14 +444,15 @@ Obtains the system time zone. This API uses an asynchronous callback to return t ...@@ -424,14 +444,15 @@ Obtains the system time zone. This API uses an asynchronous callback to return t
**System capability**: SystemCapability.MiscServices.Time **System capability**: SystemCapability.MiscServices.Time
- **Parameters** **Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| callback | AsyncCallback&lt;string&gt; | Yes| Callback used to return the system time zone.|
- Example | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| callback | AsyncCallback&lt;string&gt; | Yes| Callback used to return the system time zone.|
``` **Example**
```js
systemTime.getTimezone((error, data) => { systemTime.getTimezone((error, data) => {
if (error) { if (error) {
console.error(`failed to systemTime.getTimezone because ` + JSON.stringify(error)); console.error(`failed to systemTime.getTimezone because ` + JSON.stringify(error));
...@@ -450,14 +471,15 @@ Obtains the system time zone. This API uses a promise to return the result. ...@@ -450,14 +471,15 @@ Obtains the system time zone. This API uses a promise to return the result.
**System capability**: SystemCapability.MiscServices.Time **System capability**: SystemCapability.MiscServices.Time
- Return value **Return value**
| Type| Description|
| -------- | -------- |
| Promise&lt;string&gt; | Promise used to return the system time zone.|
- Example | Type| Description|
| -------- | -------- |
| Promise&lt;string&gt; | Promise used to return the system time zone.|
``` **Example**
```js
systemTime.getTimezone().then((data) => { systemTime.getTimezone().then((data) => {
console.log(`systemTime.getTimezone success data : ` + JSON.stringify(data)); console.log(`systemTime.getTimezone success data : ` + JSON.stringify(data));
}).catch((error) => { }).catch((error) => {
......
# Wallpaper # Wallpaper
> ![icon-note.gif](public_sys-resources/icon-note.gif) **Note:** > ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**<br>The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version.
> The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version. >
## Modules to Import ## Modules to Import
...@@ -21,8 +21,8 @@ Defines the wallpaper type. ...@@ -21,8 +21,8 @@ Defines the wallpaper type.
| Name | Description | | Name | Description |
| -------- | -------- | | -------- | -------- |
| WALLPAPER_LOCKSCREEN | Lock&nbsp;screen&nbsp;wallpaper. | | WALLPAPER_LOCKSCREEN | Lock screen wallpaper. |
| WALLPAPER_SYSTEM | Home&nbsp;screen&nbsp;wallpaper. | | WALLPAPER_SYSTEM | Home screen wallpaper. |
## wallpaper.getColors ## wallpaper.getColors
...@@ -36,12 +36,12 @@ Obtains the main color information of the wallpaper of a specified type. ...@@ -36,12 +36,12 @@ Obtains the main color information of the wallpaper of a specified type.
- Parameters - Parameters
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| wallpaperType | [WallpaperType](#wallpapertype) | Yes | Wallpaper&nbsp;type. | | wallpaperType | [WallpaperType](#wallpapertype) | Yes | Wallpaper type. |
| callback | AsyncCallback&lt;Array&lt;[RgbaColor](#rgbacolor)&gt;&gt; | Yes | Callback&nbsp;used&nbsp;to&nbsp;return&nbsp;the&nbsp;main&nbsp;color&nbsp;information&nbsp;of&nbsp;the&nbsp;wallpaper. | | callback | AsyncCallback&lt;Array&lt;[RgbaColor](#rgbacolor)&gt;&gt; | Yes | Callback used to return the main color information of the wallpaper. |
- Example - Example
``` ```js
wallpaper.getColors(wallpaper.WallpaperType.WALLPAPER_SYSTEM, (error, data) => { wallpaper.getColors(wallpaper.WallpaperType.WALLPAPER_SYSTEM, (error, data) => {
if (error) { if (error) {
console.error(`failed to getColors because: ` + JSON.stringify(error)); console.error(`failed to getColors because: ` + JSON.stringify(error));
...@@ -60,25 +60,27 @@ Obtains the main color information of the wallpaper of a specified type. ...@@ -60,25 +60,27 @@ Obtains the main color information of the wallpaper of a specified type.
**System capability**: SystemCapability.MiscServices.Wallpaper **System capability**: SystemCapability.MiscServices.Wallpaper
- Parameters **Parameters**
| Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- |
| wallpaperType | [WallpaperType](#wallpapertype) | Yes | Wallpaper&nbsp;type. |
- Return values | Name | Type | Mandatory | Description |
| Type | Description | | -------- | -------- | -------- | -------- |
| -------- | -------- | | wallpaperType | [WallpaperType](#wallpapertype) | Yes | Wallpaper type. |
| Promise&lt;Array&lt;[RgbaColor](#rgbacolor)&gt;&gt; | Promise&nbsp;used&nbsp;to&nbsp;return&nbsp;the&nbsp;main&nbsp;color&nbsp;information&nbsp;of&nbsp;the&nbsp;wallpaper. |
- Example **Return value**
``` | Type | Description |
wallpaper.getColors(wallpaper.WallpaperType.WALLPAPER_SYSTEM).then((data) => { | -------- | -------- |
| Promise&lt;Array&lt;[RgbaColor](#rgbacolor)&gt;&gt; | Promise used to return the main color information of the wallpaper. |
**Example**
```js
wallpaper.getColors(wallpaper.WallpaperType.WALLPAPER_SYSTEM).then((data) => {
console.log(`success to getColors.`); console.log(`success to getColors.`);
}).catch((error) => { }).catch((error) => {
console.error(`failed to getColors because: ` + JSON.stringify(error)); console.error(`failed to getColors because: ` + JSON.stringify(error));
}); });
``` ```
## wallpaper.getId ## wallpaper.getId
...@@ -89,23 +91,24 @@ Obtains the ID of the wallpaper of the specified type. ...@@ -89,23 +91,24 @@ Obtains the ID of the wallpaper of the specified type.
**System capability**: SystemCapability.MiscServices.Wallpaper **System capability**: SystemCapability.MiscServices.Wallpaper
- Parameters **Parameters**
| Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- |
| wallpaperType | [WallpaperType](#wallpapertype) | Yes | Wallpaper&nbsp;type. |
| callback | AsyncCallback&lt;number&gt; | Yes | Callback&nbsp;used&nbsp;to&nbsp;return&nbsp;the&nbsp;wallpaper&nbsp;ID.&nbsp;If&nbsp;the&nbsp;wallpaper&nbsp;of&nbsp;the&nbsp;specified&nbsp;type&nbsp;is&nbsp;configured,&nbsp;a&nbsp;number&nbsp;greater&nbsp;than&nbsp;or&nbsp;equal&nbsp;to&nbsp;**0**&nbsp;is&nbsp;returned.&nbsp;Otherwise,&nbsp;**-1**&nbsp;is&nbsp;returned.&nbsp;The&nbsp;value&nbsp;ranges&nbsp;from&nbsp;-1&nbsp;to&nbsp;2^31-1. |
- Example | Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- |
| wallpaperType | [WallpaperType](#wallpapertype) | Yes | Wallpaper type. |
| callback | AsyncCallback&lt;number&gt; | Yes | Callback used to return the wallpaper ID. If the wallpaper of the specified type is configured, a number greater than or equal to **0** is returned. Otherwise, **-1** is returned. The value ranges from -1 to 2^31-1. |
``` **Example**
wallpaper.getId(wallpaper.WallpaperType.WALLPAPER_SYSTEM, (error, data) => {
```js
wallpaper.getId(wallpaper.WallpaperType.WALLPAPER_SYSTEM, (error, data) => {
if (error) { if (error) {
console.error(`failed to getId because: ` + JSON.stringify(error)); console.error(`failed to getId because: ` + JSON.stringify(error));
return; return;
} }
console.log(`success to getId: ` + JSON.stringify(data)); console.log(`success to getId: ` + JSON.stringify(data));
}); });
``` ```
## wallpaper.getId ## wallpaper.getId
...@@ -116,26 +119,27 @@ Obtains the ID of the wallpaper of the specified type. ...@@ -116,26 +119,27 @@ Obtains the ID of the wallpaper of the specified type.
**System capability**: SystemCapability.MiscServices.Wallpaper **System capability**: SystemCapability.MiscServices.Wallpaper
**Parameters**
- Parameters | Name | Type | Mandatory | Description |
| Name | Type | Mandatory | Description | | -------- | -------- | -------- | -------- |
| -------- | -------- | -------- | -------- | | wallpaperType | [WallpaperType](#wallpapertype) | Yes | Wallpaper type. |
| wallpaperType | [WallpaperType](#wallpapertype) | Yes | Wallpaper&nbsp;type. |
- Return values **Return value**
| Type | Description |
| -------- | -------- |
| Promise&lt;number&gt; | Promise&nbsp;used&nbsp;to&nbsp;return&nbsp;the&nbsp;wallpaper&nbsp;ID.&nbsp;If&nbsp;this&nbsp;type&nbsp;of&nbsp;wallpaper&nbsp;is&nbsp;configured,&nbsp;a&nbsp;number&nbsp;greater&nbsp;than&nbsp;or&nbsp;equal&nbsp;to&nbsp;**0**&nbsp;is&nbsp;returned.&nbsp;Otherwise,&nbsp;**-1**&nbsp;is&nbsp;returned.&nbsp;The&nbsp;value&nbsp;ranges&nbsp;from&nbsp;-1&nbsp;to&nbsp;2^31-1. |
- Example | Type | Description |
| -------- | -------- |
| Promise&lt;number&gt; | Promise used to return the wallpaper ID. If this type of wallpaper is configured, a number greater than or equal to **0** is returned. Otherwise, **-1** is returned. The value ranges from -1 to 2^31-1. |
``` **Example**
wallpaper.getId(wallpaper.WallpaperType.WALLPAPER_SYSTEM).then((data) => {
```js
wallpaper.getId(wallpaper.WallpaperType.WALLPAPER_SYSTEM).then((data) => {
console.log(`success to getId: ` + JSON.stringify(data)); console.log(`success to getId: ` + JSON.stringify(data));
}).catch((error) => { }).catch((error) => {
console.error(`failed to getId because: ` + JSON.stringify(error)); console.error(`failed to getId because: ` + JSON.stringify(error));
}); });
``` ```
## wallpaper.getMinHeight ## wallpaper.getMinHeight
...@@ -146,22 +150,23 @@ Obtains the minimum height of the wallpaper. ...@@ -146,22 +150,23 @@ Obtains the minimum height of the wallpaper.
**System capability**: SystemCapability.MiscServices.Wallpaper **System capability**: SystemCapability.MiscServices.Wallpaper
- Parameters **Parameters**
| Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- |
| callback | AsyncCallback&lt;number&gt; | Yes | Callback&nbsp;used&nbsp;to&nbsp;return&nbsp;the&nbsp;minimum&nbsp;wallpaper&nbsp;height,&nbsp;in&nbsp;pixels.&nbsp;If&nbsp;the&nbsp;return&nbsp;value&nbsp;is&nbsp;**0**,&nbsp;no&nbsp;wallpaper&nbsp;is&nbsp;set.&nbsp;In&nbsp;this&nbsp;case,&nbsp;the&nbsp;default&nbsp;height&nbsp;should&nbsp;be&nbsp;used&nbsp;instead. |
- Example | Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- |
| callback | AsyncCallback&lt;number&gt; | Yes | Callback used to return the minimum wallpaper height, in pixels. If the return value is **0**, no wallpaper is set. In this case, the default height should be used instead. |
``` **Example**
wallpaper.getMinHeight((error, data) => {
```js
wallpaper.getMinHeight((error, data) => {
if (error) { if (error) {
console.error(`failed to getMinHeight because: ` + JSON.stringify(error)); console.error(`failed to getMinHeight because: ` + JSON.stringify(error));
return; return;
} }
console.log(`success to getMinHeight: ` + JSON.stringify(data)); console.log(`success to getMinHeight: ` + JSON.stringify(data));
}); });
``` ```
## wallpaper.getMinHeight ## wallpaper.getMinHeight
...@@ -172,21 +177,21 @@ Obtains the minimum height of the wallpaper. ...@@ -172,21 +177,21 @@ Obtains the minimum height of the wallpaper.
**System capability**: SystemCapability.MiscServices.Wallpaper **System capability**: SystemCapability.MiscServices.Wallpaper
**Return value**
- Return values | Type | Description |
| Type | Description | | -------- | -------- |
| -------- | -------- | | Promise&lt;number&gt; | Promise used to return the minimum wallpaper height, in pixels. If the return value is **0**, no wallpaper is set. In this case, the default height should be used instead. |
| Promise&lt;number&gt; | Promise&nbsp;used&nbsp;to&nbsp;return&nbsp;the&nbsp;minimum&nbsp;wallpaper&nbsp;height,&nbsp;in&nbsp;pixels.&nbsp;If&nbsp;the&nbsp;return&nbsp;value&nbsp;is&nbsp;**0**,&nbsp;no&nbsp;wallpaper&nbsp;is&nbsp;set.&nbsp;In&nbsp;this&nbsp;case,&nbsp;the&nbsp;default&nbsp;height&nbsp;should&nbsp;be&nbsp;used&nbsp;instead. |
- Example **Example**
``` ```js
wallpaper.getMinHeight().then((data) => { wallpaper.getMinHeight().then((data) => {
console.log(`success to getMinHeight: ` + JSON.stringify(data)); console.log(`success to getMinHeight: ` + JSON.stringify(data));
}).catch((error) => { }).catch((error) => {
console.error(`failed to getMinHeight because: ` + JSON.stringify(error)); console.error(`failed to getMinHeight because: ` + JSON.stringify(error));
}); });
``` ```
## wallpaper.getMinWidth ## wallpaper.getMinWidth
...@@ -197,23 +202,23 @@ Obtains the minimum width of the wallpaper. ...@@ -197,23 +202,23 @@ Obtains the minimum width of the wallpaper.
**System capability**: SystemCapability.MiscServices.Wallpaper **System capability**: SystemCapability.MiscServices.Wallpaper
**Parameters**
- Parameters | Name | Type | Mandatory | Description |
| Name | Type | Mandatory | Description | | -------- | -------- | -------- | -------- |
| -------- | -------- | -------- | -------- | | callback | AsyncCallback&lt;number&gt; | Yes | Callback used to return the minimum wallpaper width, in pixels. If the return value is **0**, no wallpaper is set. In this case, the default width should be used instead. |
| callback | AsyncCallback&lt;number&gt; | Yes | Callback&nbsp;used&nbsp;to&nbsp;return&nbsp;the&nbsp;minimum&nbsp;wallpaper&nbsp;width,&nbsp;in&nbsp;pixels.&nbsp;If&nbsp;the&nbsp;return&nbsp;value&nbsp;is&nbsp;**0**,&nbsp;no&nbsp;wallpaper&nbsp;is&nbsp;set.&nbsp;In&nbsp;this&nbsp;case,&nbsp;the&nbsp;default&nbsp;width&nbsp;should&nbsp;be&nbsp;used&nbsp;instead. |
- Example **Example**
``` ```js
wallpaper.getMinWidth((error, data) => { wallpaper.getMinWidth((error, data) => {
if (error) { if (error) {
console.error(`failed to getMinWidth because: ` + JSON.stringify(error)); console.error(`failed to getMinWidth because: ` + JSON.stringify(error));
return; return;
} }
console.log(`success to getMinWidth: ` + JSON.stringify(data)); console.log(`success to getMinWidth: ` + JSON.stringify(data));
}); });
``` ```
## wallpaper.getMinWidth ## wallpaper.getMinWidth
...@@ -224,20 +229,21 @@ Obtains the minimum width of the wallpaper. ...@@ -224,20 +229,21 @@ Obtains the minimum width of the wallpaper.
**System capability**: SystemCapability.MiscServices.Wallpaper **System capability**: SystemCapability.MiscServices.Wallpaper
- Return values **Return value**
| Type | Description |
| -------- | -------- |
| Promise&lt;number&gt; | Promised&nbsp;used&nbsp;to&nbsp;return&nbsp;the&nbsp;minimum&nbsp;wallpaper&nbsp;width,&nbsp;in&nbsp;pixels.&nbsp;If&nbsp;the&nbsp;return&nbsp;value&nbsp;is&nbsp;**0**,&nbsp;no&nbsp;wallpaper&nbsp;is&nbsp;set.&nbsp;In&nbsp;this&nbsp;case,&nbsp;the&nbsp;default&nbsp;width&nbsp;should&nbsp;be&nbsp;used&nbsp;instead. |
- Example | Type | Description |
| -------- | -------- |
| Promise&lt;number&gt; | Promised used to return the minimum wallpaper width, in pixels. If the return value is **0**, no wallpaper is set. In this case, the default width should be used instead. |
``` **Example**
wallpaper.getMinWidth().then((data) => {
```js
wallpaper.getMinWidth().then((data) => {
console.log(`success to getMinWidth: ` + JSON.stringify(data)); console.log(`success to getMinWidth: ` + JSON.stringify(data));
}).catch((error) => { }).catch((error) => {
console.error(`failed to getMinWidth because: ` + JSON.stringify(error)); console.error(`failed to getMinWidth because: ` + JSON.stringify(error));
}); });
``` ```
## wallpaper.isChangePermitted ## wallpaper.isChangePermitted
...@@ -248,22 +254,23 @@ Checks whether to allow the application to change the wallpaper for the current ...@@ -248,22 +254,23 @@ Checks whether to allow the application to change the wallpaper for the current
**System capability**: SystemCapability.MiscServices.Wallpaper **System capability**: SystemCapability.MiscServices.Wallpaper
- Parameters **Parameters**
| Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- |
| callback | AsyncCallback&lt;boolean&gt; | Yes | Callback&nbsp;used&nbsp;to&nbsp;return&nbsp;the&nbsp;queried&nbsp;result.&nbsp;Returns&nbsp;**true**&nbsp;if&nbsp;it&nbsp;is&nbsp;allowed;&nbsp;returns&nbsp;**false**&nbsp;otherwise. |
- Example | Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- |
| callback | AsyncCallback&lt;boolean&gt; | Yes | Callback used to return the queried result. Returns **true** if it is allowed; returns **false** otherwise. |
``` **Example**
wallpaper.isChangePermitted((error, data) => {
```js
wallpaper.isChangePermitted((error, data) => {
if (error) { if (error) {
console.error(`failed to isChangePermitted because: ` + JSON.stringify(error)); console.error(`failed to isChangePermitted because: ` + JSON.stringify(error));
return; return;
} }
console.log(`success to isChangePermitted: ` + JSON.stringify(data)); console.log(`success to isChangePermitted: ` + JSON.stringify(data));
}); });
``` ```
## wallpaper.isChangePermitted ## wallpaper.isChangePermitted
...@@ -274,20 +281,21 @@ Checks whether to allow the application to change the wallpaper for the current ...@@ -274,20 +281,21 @@ Checks whether to allow the application to change the wallpaper for the current
**System capability**: SystemCapability.MiscServices.Wallpaper **System capability**: SystemCapability.MiscServices.Wallpaper
- Return values **Return value**
| Type | Description |
| -------- | -------- |
| Promise&lt;boolean&gt; | Promise&nbsp;used&nbsp;to&nbsp;return&nbsp;whether&nbsp;to&nbsp;allow&nbsp;the&nbsp;application&nbsp;to&nbsp;change&nbsp;the&nbsp;wallpaper&nbsp;for&nbsp;the&nbsp;current&nbsp;user.&nbsp;Returns&nbsp;**true**&nbsp;if&nbsp;it&nbsp;is&nbsp;allowed;&nbsp;returns&nbsp;**false**&nbsp;otherwise. |
- Example | Type | Description |
| -------- | -------- |
| Promise&lt;boolean&gt; | Promise used to return whether to allow the application to change the wallpaper for the current user. Returns **true** if it is allowed; returns **false** otherwise. |
``` **Example**
wallpaper.isChangePermitted().then((data) => {
```js
wallpaper.isChangePermitted().then((data) => {
console.log(`success to isChangePermitted: ` + JSON.stringify(data)); console.log(`success to isChangePermitted: ` + JSON.stringify(data));
}).catch((error) => { }).catch((error) => {
console.error(`failed to isChangePermitted because: ` + JSON.stringify(error)); console.error(`failed to isChangePermitted because: ` + JSON.stringify(error));
}); });
``` ```
## wallpaper.isOperationAllowed ## wallpaper.isOperationAllowed
...@@ -298,22 +306,23 @@ Checks whether the user is allowed to set wallpapers. ...@@ -298,22 +306,23 @@ Checks whether the user is allowed to set wallpapers.
**System capability**: SystemCapability.MiscServices.Wallpaper **System capability**: SystemCapability.MiscServices.Wallpaper
- Parameters **Parameters**
| Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- |
| callback | AsyncCallback&lt;boolean&gt; | Yes | Callback&nbsp;used&nbsp;to&nbsp;return&nbsp;whether&nbsp;the&nbsp;user&nbsp;is&nbsp;allowed&nbsp;to&nbsp;set&nbsp;wallpapers.&nbsp;Returns&nbsp;**true**&nbsp;if&nbsp;it&nbsp;is&nbsp;allowed;&nbsp;returns&nbsp;**false**&nbsp;otherwise. |
- Example | Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- |
| callback | AsyncCallback&lt;boolean&gt; | Yes | Callback used to return whether the user is allowed to set wallpapers. Returns **true** if it is allowed; returns **false** otherwise. |
``` **Example**
wallpaper.isOperationAllowed((error, data) => {
```js
wallpaper.isOperationAllowed((error, data) => {
if (error) { if (error) {
console.error(`failed to isOperationAllowed because: ` + JSON.stringify(error)); console.error(`failed to isOperationAllowed because: ` + JSON.stringify(error));
return; return;
} }
console.log(`success to isOperationAllowed: ` + JSON.stringify(data)); console.log(`success to isOperationAllowed: ` + JSON.stringify(data));
}); });
``` ```
## wallpaper.isOperationAllowed ## wallpaper.isOperationAllowed
...@@ -324,20 +333,21 @@ Checks whether the user is allowed to set wallpapers. ...@@ -324,20 +333,21 @@ Checks whether the user is allowed to set wallpapers.
**System capability**: SystemCapability.MiscServices.Wallpaper **System capability**: SystemCapability.MiscServices.Wallpaper
- Return values **Return value**
| Type | Description |
| -------- | -------- |
| Promise&lt;boolean&gt; | Promise&nbsp;used&nbsp;to&nbsp;return&nbsp;whether&nbsp;the&nbsp;user&nbsp;is&nbsp;allowed&nbsp;to&nbsp;set&nbsp;wallpapers.&nbsp;Returns&nbsp;**true**&nbsp;if&nbsp;it&nbsp;is&nbsp;allowed;&nbsp;returns&nbsp;**false**&nbsp;otherwise. |
- Example | Type | Description |
| -------- | -------- |
| Promise&lt;boolean&gt; | Promise used to return whether the user is allowed to set wallpapers. Returns **true** if it is allowed; returns **false** otherwise. |
``` **Example**
wallpaper.isOperationAllowed().then((data) => {
```js
wallpaper.isOperationAllowed().then((data) => {
console.log(`success to isOperationAllowed: ` + JSON.stringify(data)); console.log(`success to isOperationAllowed: ` + JSON.stringify(data));
}).catch((error) => { }).catch((error) => {
console.error(`failed to isOperationAllowed because: ` + JSON.stringify(error)); console.error(`failed to isOperationAllowed because: ` + JSON.stringify(error));
}); });
``` ```
## wallpaper.reset ## wallpaper.reset
...@@ -350,23 +360,24 @@ Removes a wallpaper of the specified type and restores the default one. ...@@ -350,23 +360,24 @@ Removes a wallpaper of the specified type and restores the default one.
**System capability**: SystemCapability.MiscServices.Wallpaper **System capability**: SystemCapability.MiscServices.Wallpaper
- Parameters **Parameters**
| Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- |
| wallpaperType | [WallpaperType](#wallpapertype) | Yes | Wallpaper&nbsp;type. |
| callback | AsyncCallback&lt;void&gt; | Yes | Callback&nbsp;used&nbsp;to&nbsp;return&nbsp;the&nbsp;result.&nbsp;If&nbsp;the&nbsp;operation&nbsp;is&nbsp;successful,&nbsp;the&nbsp;result&nbsp;of&nbsp;removal&nbsp;is&nbsp;returned.&nbsp;Otherwise,&nbsp;error&nbsp;information&nbsp;is&nbsp;returned. |
- Example | Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- |
| wallpaperType | [WallpaperType](#wallpapertype) | Yes | Wallpaper type. |
| callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result. If the operation is successful, the result of removal is returned. Otherwise, error information is returned. |
``` **Example**
wallpaper.reset(wallpaper.WallpaperType.WALLPAPER_SYSTEM, (error, data) => {
```js
wallpaper.reset(wallpaper.WallpaperType.WALLPAPER_SYSTEM, (error, data) => {
if (error) { if (error) {
console.error(`failed to reset because: ` + JSON.stringify(error)); console.error(`failed to reset because: ` + JSON.stringify(error));
return; return;
} }
console.log(`success to reset.`); console.log(`success to reset.`);
}); });
``` ```
## wallpaper.reset ## wallpaper.reset
...@@ -379,25 +390,27 @@ Removes a wallpaper of the specified type and restores the default one. ...@@ -379,25 +390,27 @@ Removes a wallpaper of the specified type and restores the default one.
**System capability**: SystemCapability.MiscServices.Wallpaper **System capability**: SystemCapability.MiscServices.Wallpaper
- Parameters **Parameters**
| Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- |
| wallpaperType | [WallpaperType](#wallpapertype) | Yes | Wallpaper&nbsp;type. |
- Return values | Name | Type | Mandatory | Description |
| Type | Description | | -------- | -------- | -------- | -------- |
| -------- | -------- | | wallpaperType | [WallpaperType](#wallpapertype) | Yes | Wallpaper type. |
| Promise&lt;void&gt; | Promise&nbsp;used&nbsp;to&nbsp;return&nbsp;the&nbsp;result.&nbsp;If&nbsp;the&nbsp;operation&nbsp;is&nbsp;successful,&nbsp;the&nbsp;result&nbsp;of&nbsp;removal&nbsp;is&nbsp;returned.&nbsp;Otherwise,&nbsp;error&nbsp;information&nbsp;is&nbsp;returned. |
- Example **Return value**
``` | Type | Description |
wallpaper.reset(wallpaper.WallpaperType.WALLPAPER_SYSTEM).then((data) => { | -------- | -------- |
| Promise&lt;void&gt; | Promise used to return the result. If the operation is successful, the result of removal is returned. Otherwise, error information is returned. |
**Example**
```js
wallpaper.reset(wallpaper.WallpaperType.WALLPAPER_SYSTEM).then((data) => {
console.log(`success to reset.`); console.log(`success to reset.`);
}).catch((error) => { }).catch((error) => {
console.error(`failed to reset because: ` + JSON.stringify(error)); console.error(`failed to reset because: ` + JSON.stringify(error));
}); });
``` ```
## wallpaper.setWallpaper ## wallpaper.setWallpaper
...@@ -410,36 +423,37 @@ Sets a specified source as the wallpaper of a specified type. ...@@ -410,36 +423,37 @@ Sets a specified source as the wallpaper of a specified type.
**System capability**: SystemCapability.MiscServices.Wallpaper **System capability**: SystemCapability.MiscServices.Wallpaper
- Parameters **Parameters**
| Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- |
| source | string&nbsp;\| [PixelMap](js-apis-image.md#pixelmap7) | Yes | Uri&nbsp;path&nbsp;of&nbsp;the&nbsp;JPEG&nbsp;or&nbsp;PNG&nbsp;file,&nbsp;or&nbsp;bitmap&nbsp;of&nbsp;the&nbsp;PNG&nbsp;file. |
| wallpaperType | [WallpaperType](#wallpapertype) | Yes | Wallpaper&nbsp;type. |
| callback | AsyncCallback&lt;void&gt; | Yes | Callback&nbsp;used&nbsp;to&nbsp;return&nbsp;the&nbsp;result.&nbsp;If&nbsp;the&nbsp;operation&nbsp;is&nbsp;successful,&nbsp;the&nbsp;setting&nbsp;result&nbsp;is&nbsp;returned.&nbsp;Otherwise,&nbsp;error&nbsp;information&nbsp;is&nbsp;returned. |
- Example | Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- |
| source | string \| [PixelMap](js-apis-image.md#pixelmap7) | Yes | Uri path of the JPEG or PNG file, or bitmap of the PNG file. |
| wallpaperType | [WallpaperType](#wallpapertype) | Yes | Wallpaper type. |
| callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result. If the operation is successful, the setting result is returned. Otherwise, error information is returned. |
``` **Example**
//The source type is string.
let wallpaperPath = "/data/data/ohos.acts.aafwk.plrdtest.form/files/Cup_ic.jpg"; ```js
wallpaper.setWallpaper(wallpaperPath, wallpaper.WallpaperType.WALLPAPER_SYSTEM, (error, data) => { // The source type is string.
let wallpaperPath = "/data/data/ohos.acts.aafwk.plrdtest.form/files/Cup_ic.jpg";
wallpaper.setWallpaper(wallpaperPath, wallpaper.WallpaperType.WALLPAPER_SYSTEM, (error, data) => {
if (error) { if (error) {
console.error(`failed to setWallpaper because: ` + JSON.stringify(error)); console.error(`failed to setWallpaper because: ` + JSON.stringify(error));
return; return;
} }
console.log(`success to setWallpaper.`); console.log(`success to setWallpaper.`);
}); });
//The source type is image.PixelMap. // The source type is image.PixelMap.
import image from '@ohos.multimedia.image'; import image from '@ohos.multimedia.image';
let imageSource = image.createImageSource("file://" + wallpaperPath); let imageSource = image.createImageSource("file://" + wallpaperPath);
let opts = { let opts = {
"desiredSize": { "desiredSize": {
"height": 3648, "height": 3648,
"width": 2736 "width": 2736
} }
}; };
imageSource.createPixelMap(opts).then((pixelMap) => { imageSource.createPixelMap(opts).then((pixelMap) => {
wallpaper.setWallpaper(pixelMap, wallpaper.WallpaperType.WALLPAPER_SYSTEM, (error, data) => { wallpaper.setWallpaper(pixelMap, wallpaper.WallpaperType.WALLPAPER_SYSTEM, (error, data) => {
if (error) { if (error) {
console.error(`failed to setWallpaper because: ` + JSON.stringify(error)); console.error(`failed to setWallpaper because: ` + JSON.stringify(error));
...@@ -447,10 +461,10 @@ Sets a specified source as the wallpaper of a specified type. ...@@ -447,10 +461,10 @@ Sets a specified source as the wallpaper of a specified type.
} }
console.log(`success to setWallpaper.`); console.log(`success to setWallpaper.`);
}); });
}).catch((error) => { }).catch((error) => {
console.error(`failed to createPixelMap because: ` + JSON.stringify(error)); console.error(`failed to createPixelMap because: ` + JSON.stringify(error));
}); });
``` ```
## wallpaper.setWallpaper ## wallpaper.setWallpaper
...@@ -463,47 +477,49 @@ Sets a specified source as the wallpaper of a specified type. ...@@ -463,47 +477,49 @@ Sets a specified source as the wallpaper of a specified type.
**System capability**: SystemCapability.MiscServices.Wallpaper **System capability**: SystemCapability.MiscServices.Wallpaper
- Parameters **Parameters**
| Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- |
| source | string&nbsp;\|&nbsp;[PixelMap](js-apis-image.md#pixelmap7) | Yes | Uri&nbsp;path&nbsp;of&nbsp;the&nbsp;JPEG&nbsp;or&nbsp;PNG&nbsp;file,&nbsp;or&nbsp;bitmap&nbsp;of&nbsp;the&nbsp;PNG&nbsp;file. |
| wallpaperType | [WallpaperType](#wallpapertype) | Yes | Wallpaper&nbsp;type. |
- Return values | Name | Type | Mandatory | Description |
| Type | Description | | -------- | -------- | -------- | -------- |
| -------- | -------- | | source | string \| [PixelMap](js-apis-image.md#pixelmap7) | Yes | Uri path of the JPEG or PNG file, or bitmap of the PNG file. |
| Promise&lt;void&gt; | Promise&nbsp;used&nbsp;to&nbsp;return&nbsp;the&nbsp;result.&nbsp;If&nbsp;the&nbsp;operation&nbsp;is&nbsp;successful,&nbsp;the&nbsp;setting&nbsp;result&nbsp;is&nbsp;returned.&nbsp;Otherwise,&nbsp;error&nbsp;information&nbsp;is&nbsp;returned. | | wallpaperType | [WallpaperType](#wallpapertype) | Yes | Wallpaper type. |
- Example **Return value**
``` | Type | Description |
//The source type is string. | -------- | -------- |
let wallpaperPath = "/data/data/ohos.acts.aafwk.plrdtest.form/files/Cup_ic.jpg"; | Promise&lt;void&gt; | Promise used to return the result. If the operation is successful, the setting result is returned. Otherwise, error information is returned. |
wallpaper.setWallpaper(wallpaperPath, wallpaper.WallpaperType.WALLPAPER_SYSTEM).then((data) => {
**Example**
```js
// The source type is string.
let wallpaperPath = "/data/data/ohos.acts.aafwk.plrdtest.form/files/Cup_ic.jpg";
wallpaper.setWallpaper(wallpaperPath, wallpaper.WallpaperType.WALLPAPER_SYSTEM).then((data) => {
console.log(`success to setWallpaper.`); console.log(`success to setWallpaper.`);
}).catch((error) => { }).catch((error) => {
console.error(`failed to setWallpaper because: ` + JSON.stringify(error)); console.error(`failed to setWallpaper because: ` + JSON.stringify(error));
}); });
//The source type is image.PixelMap. // The source type is image.PixelMap.
import image from '@ohos.multimedia.image'; import image from '@ohos.multimedia.image';
let imageSource = image.createImageSource("file://" + wallpaperPath); let imageSource = image.createImageSource("file://" + wallpaperPath);
let opts = { let opts = {
"desiredSize": { "desiredSize": {
"height": 3648, "height": 3648,
"width": 2736 "width": 2736
} }
}; };
imageSource.createPixelMap(opts).then((pixelMap) => { imageSource.createPixelMap(opts).then((pixelMap) => {
wallpaper.setWallpaper(pixelMap, wallpaper.WallpaperType.WALLPAPER_SYSTEM).then((data) => { wallpaper.setWallpaper(pixelMap, wallpaper.WallpaperType.WALLPAPER_SYSTEM).then((data) => {
console.log(`success to setWallpaper.`); console.log(`success to setWallpaper.`);
}).catch((error) => { }).catch((error) => {
console.error(`failed to setWallpaper because: ` + JSON.stringify(error)); console.error(`failed to setWallpaper because: ` + JSON.stringify(error));
}); });
}).catch((error) => { }).catch((error) => {
console.error(`failed to createPixelMap because: ` + JSON.stringify(error)); console.error(`failed to createPixelMap because: ` + JSON.stringify(error));
}); });
``` ```
## wallpaper.getFile<sup>8+</sup> ## wallpaper.getFile<sup>8+</sup>
...@@ -511,27 +527,28 @@ getFile(wallpaperType: WallpaperType, callback: AsyncCallback&lt;number&gt;): vo ...@@ -511,27 +527,28 @@ getFile(wallpaperType: WallpaperType, callback: AsyncCallback&lt;number&gt;): vo
Obtains the wallpaper of the specified type. Obtains the wallpaper of the specified type.
**Required permissions**: ohos.permission.GET_WALLPAPER and ohos.permission.READ_USER_STORAGE **Required permissions**: ohos.permission.SET_WALLPAPER and ohos.permission.READ_USER_STORAGE
**System capability**: SystemCapability.MiscServices.Wallpaper **System capability**: SystemCapability.MiscServices.Wallpaper
- Parameters **Parameters**
| Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- |
| wallpaperType | [WallpaperType](#wallpapertype) | Yes | Wallpaper&nbsp;type. |
| callback | AsyncCallback&lt;number&gt; | Yes | Callback&nbsp;used&nbsp;to&nbsp;return&nbsp;the&nbsp;result.&nbsp;If&nbsp;the&nbsp;operation&nbsp;is&nbsp;successful,&nbsp;the&nbsp;file&nbsp;descriptor&nbsp;ID&nbsp;to&nbsp;the&nbsp;wallpaper&nbsp;is&nbsp;returned.&nbsp;Otherwise,&nbsp;error&nbsp;information&nbsp;is&nbsp;returned. |
- Example | Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- |
| wallpaperType | [WallpaperType](#wallpapertype) | Yes | Wallpaper type. |
| callback | AsyncCallback&lt;number&gt; | Yes | Callback used to return the result. If the operation is successful, the file descriptor ID to the wallpaper is returned. Otherwise, error information is returned. |
``` **Example**
wallpaper.getFile(wallpaper.WallpaperType.WALLPAPER_SYSTEM, (error, data) => {
```js
wallpaper.getFile(wallpaper.WallpaperType.WALLPAPER_SYSTEM, (error, data) => {
if (error) { if (error) {
console.error(`failed to getFile because: ` + JSON.stringify(error)); console.error(`failed to getFile because: ` + JSON.stringify(error));
return; return;
} }
console.log(`success to getFile: ` + JSON.stringify(data)); console.log(`success to getFile: ` + JSON.stringify(data));
}); });
``` ```
## wallpaper.getFile<sup>8+</sup> ## wallpaper.getFile<sup>8+</sup>
...@@ -543,25 +560,27 @@ Obtains the wallpaper of the specified type. ...@@ -543,25 +560,27 @@ Obtains the wallpaper of the specified type.
**System capability**: SystemCapability.MiscServices.Wallpaper **System capability**: SystemCapability.MiscServices.Wallpaper
- Parameters **Parameters**
| Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- |
| wallpaperType | [WallpaperType](#wallpapertype) | Yes | Wallpaper&nbsp;type. |
- Return values | Name | Type | Mandatory | Description |
| Type | Description | | -------- | -------- | -------- | -------- |
| -------- | -------- | | wallpaperType | [WallpaperType](#wallpapertype) | Yes | Wallpaper type. |
| Promise&lt;number&gt; | Promise&nbsp;used&nbsp;to&nbsp;return&nbsp;the&nbsp;result.&nbsp;If&nbsp;the&nbsp;operation&nbsp;is&nbsp;successful,&nbsp;the&nbsp;file&nbsp;descriptor&nbsp;ID&nbsp;to&nbsp;the&nbsp;wallpaper&nbsp;is&nbsp;returned.&nbsp;Otherwise,&nbsp;error&nbsp;information&nbsp;is&nbsp;returned. |
- Example **Return value**
``` | Type | Description |
wallpaper.getFile(wallpaper.WallpaperType.WALLPAPER_SYSTEM).then((data) => { | -------- | -------- |
| Promise&lt;number&gt; | Promise used to return the result. If the operation is successful, the file descriptor ID to the wallpaper is returned. Otherwise, error information is returned. |
**Example**
```js
wallpaper.getFile(wallpaper.WallpaperType.WALLPAPER_SYSTEM).then((data) => {
console.log(`success to getFile: ` + JSON.stringify(data)); console.log(`success to getFile: ` + JSON.stringify(data));
}).catch((error) => { }).catch((error) => {
console.error(`failed to getFile because: ` + JSON.stringify(error)); console.error(`failed to getFile because: ` + JSON.stringify(error));
}); });
``` ```
## wallpaper.on('colorChange') ## wallpaper.on('colorChange')
...@@ -572,20 +591,21 @@ Subscribes to the wallpaper color change event. ...@@ -572,20 +591,21 @@ Subscribes to the wallpaper color change event.
**System capability**: SystemCapability.MiscServices.Wallpaper **System capability**: SystemCapability.MiscServices.Wallpaper
- Parameters **Parameters**
| Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- |
| type | string | Yes | Type&nbsp;of&nbsp;the&nbsp;event&nbsp;to&nbsp;subscribe&nbsp;to.&nbsp;The&nbsp;value&nbsp;**colorChange**&nbsp;indicates&nbsp;subscribing&nbsp;to&nbsp;the&nbsp;wallpaper&nbsp;color&nbsp;change&nbsp;event. |
| callback | function | Yes | Callback&nbsp;triggered&nbsp;when&nbsp;the&nbsp;wallpaper&nbsp;color&nbsp;changes.&nbsp;The&nbsp;wallpaper&nbsp;type&nbsp;and&nbsp;main&nbsp;colors&nbsp;are&nbsp;returned.<br/>-&nbsp;colors<br/>&nbsp;&nbsp;Main&nbsp;color&nbsp;information&nbsp;of&nbsp;the&nbsp;wallpaper.&nbsp;For&nbsp;details,&nbsp;see&nbsp;[RgbaColor](#rgbacolor).<br/>-&nbsp;wallpaperType<br/>&nbsp;&nbsp;Wallpaper&nbsp;type. |
- Example | Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- |
| type | string | Yes | Type of the event to subscribe to. The value **colorChange** indicates subscribing to the wallpaper color change event. |
| callback | function | Yes | Callback triggered when the wallpaper color changes. The wallpaper type and main colors are returned.<br/>- colors<br/> Main color information of the wallpaper. For details, see [RgbaColor](#rgbacolor).<br/>- wallpaperType<br/> Wallpaper type. |
``` **Example**
let listener = (colors, wallpaperType) => {
```js
let listener = (colors, wallpaperType) => {
console.log(`wallpaper color changed.`); console.log(`wallpaper color changed.`);
}; };
wallpaper.on('colorChange', listener); wallpaper.on('colorChange', listener);
``` ```
## wallpaper.off('colorChange') ## wallpaper.off('colorChange')
...@@ -596,24 +616,25 @@ Unsubscribes from the wallpaper color change event. ...@@ -596,24 +616,25 @@ Unsubscribes from the wallpaper color change event.
**System capability**: SystemCapability.MiscServices.Wallpaper **System capability**: SystemCapability.MiscServices.Wallpaper
- Parameters **Parameters**
| Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- |
| type | string | Yes | Type&nbsp;of&nbsp;the&nbsp;event&nbsp;to&nbsp;unsubscribe&nbsp;from.&nbsp;The&nbsp;value&nbsp;**colorChange**&nbsp;indicates&nbsp;unsubscribing&nbsp;from&nbsp;the&nbsp;wallpaper&nbsp;color&nbsp;change&nbsp;event. |
| callback | function | No | &nbsp;&nbsp;Callback&nbsp;for&nbsp;the&nbsp;wallpaper&nbsp;color&nbsp;change&nbsp;event.&nbsp;If&nbsp;this&nbsp;parameter&nbsp;is&nbsp;not&nbsp;specified,&nbsp;all&nbsp;callbacks&nbsp;corresponding&nbsp;to&nbsp;the&nbsp;wallpaper&nbsp;color&nbsp;change&nbsp;event&nbsp;are&nbsp;invoked.<br/>-&nbsp;colors<br/>&nbsp;&nbsp;Main&nbsp;color&nbsp;information&nbsp;of&nbsp;the&nbsp;wallpaper.&nbsp;For&nbsp;details,&nbsp;see&nbsp;[RgbaColor](#rgbacolor).<br/>-&nbsp;wallpaperType<br/>&nbsp;&nbsp;Wallpaper&nbsp;type. |
- Example | Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- |
| type | string | Yes | Type of the event to unsubscribe from. The value **colorChange** indicates unsubscribing from the wallpaper color change event. |
| callback | function | No | Callback for the wallpaper color change event. If this parameter is not specified, all callbacks corresponding to the wallpaper color change event are invoked.<br/>- colors<br/> Main color information of the wallpaper. For details, see [RgbaColor](#rgbacolor).<br/>- wallpaperType<br/> Wallpaper type. |
``` **Example**
let listener = (colors, wallpaperType) => {
```js
let listener = (colors, wallpaperType) => {
console.log(`wallpaper color changed.`); console.log(`wallpaper color changed.`);
}; };
wallpaper.on('colorChange', listener); wallpaper.on('colorChange', listener);
// Unsubscribe from the listener. // Unsubscribe from the listener.
wallpaper.off('colorChange', listener); wallpaper.off('colorChange', listener);
//Unsubscribe from all subscriptions of the colorChange type. //Unsubscribe from all subscriptions of the colorChange type.
wallpaper.off('colorChange'); wallpaper.off('colorChange');
``` ```
## RgbaColor ## RgbaColor
...@@ -622,7 +643,7 @@ Unsubscribes from the wallpaper color change event. ...@@ -622,7 +643,7 @@ Unsubscribes from the wallpaper color change event.
| Name | Type | Readable | Writable | Description | | Name | Type | Readable | Writable | Description |
| -------- | -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- | -------- |
| red | number | Yes | Yes | Red&nbsp;color.&nbsp;The&nbsp;value&nbsp;ranges&nbsp;from&nbsp;0&nbsp;to&nbsp;255. | | red | number | Yes | Yes | Red color. The value ranges from 0 to 255. |
| green | number | Yes | Yes | Green&nbsp;color.&nbsp;The&nbsp;value&nbsp;ranges&nbsp;from&nbsp;0&nbsp;to&nbsp;255. | | green | number | Yes | Yes | Green color. The value ranges from 0 to 255. |
| blue | number | Yes | Yes | Blue&nbsp;color.&nbsp;The&nbsp;value&nbsp;ranges&nbsp;from&nbsp;0&nbsp;to&nbsp;255. | | blue | number | Yes | Yes | Blue color. The value ranges from 0 to 255. |
| alpha | number | Yes | Yes | Alpha&nbsp;value.&nbsp;The&nbsp;value&nbsp;ranges&nbsp;from&nbsp;0&nbsp;to&nbsp;255. | | alpha | number | Yes | Yes | Alpha value. The value ranges from 0 to 255. |
...@@ -55,7 +55,7 @@ ...@@ -55,7 +55,7 @@
- [CanvasRenderingContext2D](ui-js-components-canvasrenderingcontext2d.md) - [CanvasRenderingContext2D](ui-js-components-canvasrenderingcontext2d.md)
- [Path2D](ui-js-components-path2d.md) - [Path2D](ui-js-components-path2d.md)
- [OffscreenCanvas](ui-js-components-offscreencanvas.md) - [OffscreenCanvas](ui-js-components-offscreencanvas.md)
- [Grid-container Development](ui-js-components-calendar.md) - [Grid-container Development](ui-js-components-grid.md)
- Svg - Svg
- [Basics](ui-js-components-svg-overview.md) - [Basics](ui-js-components-svg-overview.md)
- [Graph Drawing](ui-js-components-svg-graphics.md) - [Graph Drawing](ui-js-components-svg-graphics.md)
......
...@@ -28,6 +28,8 @@ Create a square and rotate it by 90 degrees to form a rhombus. Cover the lower p ...@@ -28,6 +28,8 @@ Create a square and rotate it by 90 degrees to form a rhombus. Cover the lower p
``` ```
/* xxx.css */ /* xxx.css */
.container { .container {
width:100%;
height:100%;
background-color:#F1F3F5; background-color:#F1F3F5;
align-items: center; align-items: center;
flex-direction: column; flex-direction: column;
...@@ -110,6 +112,8 @@ Decrease the y-coordinate over a time frame to make the ball bounce back. Gradua ...@@ -110,6 +112,8 @@ Decrease the y-coordinate over a time frame to make the ball bounce back. Gradua
``` ```
/* xxx.css */ /* xxx.css */
.container { .container {
width:100%;
height:100%;
background-color:#F1F3F5; background-color:#F1F3F5;
display: flex; display: flex;
justify-content: center; justify-content: center;
...@@ -304,7 +308,7 @@ Set the rotation center around an element in different transform-origin position ...@@ -304,7 +308,7 @@ Set the rotation center around an element in different transform-origin position
![en-us_image_0000001222807776](figures/en-us_image_0000001222807776.gif) ![en-us_image_0000001222807776](figures/en-us_image_0000001222807776.gif)
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**: > ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**<br/>
> transform-origin specifies the origin of an element's transformation. If only one value is set, the other value is 50%. If both values are set, the first value indicates the position on the x-axis, and the second value indicates the position on the y-axis. > transform-origin specifies the origin of an element's transformation. If only one value is set, the other value is 50%. If both values are set, the first value indicates the position on the x-axis, and the second value indicates the position on the y-axis.
...@@ -419,7 +423,7 @@ text{ ...@@ -419,7 +423,7 @@ text{
![en-us_image_0000001267887837](figures/en-us_image_0000001267887837.gif) ![en-us_image_0000001267887837](figures/en-us_image_0000001267887837.gif)
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**: > ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**<br/>
> After the transform attributes are set, the child element changes with the parent element. Value changing of other attributes (such as height and width) of the parent element will not affect the child element. > After the transform attributes are set, the child element changes with the parent element. Value changing of other attributes (such as height and width) of the parent element will not affect the child element.
...@@ -577,9 +581,21 @@ You can set multiple transform attributes at the same time to apply different tr ...@@ -577,9 +581,21 @@ You can set multiple transform attributes at the same time to apply different tr
![en-us_image_0000001223127712](figures/en-us_image_0000001223127712.gif) ![en-us_image_0000001223127712](figures/en-us_image_0000001223127712.gif)
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**: > ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**<br/>
> 1. When multiple transform attributes are set, the later one overwrites the previous one. To apply multiple transform styles at the same time, use the shorthand notation; that is, write multiple style values in one transform, for example, transform: scale(1) rotate(0) translate(0,0). > - When multiple transform attributes are set, the later one overwrites the previous one. To apply multiple transform styles at the same time, use the shorthand notation; that is, write multiple style values in one transform, for example, transform: scale(1) rotate(0) translate(0,0).
> >
> 2. When using the shorthand notion, **NOTE** that the animation effect varies according to the sequence of the style values. > - When using the shorthand notion, note that the animation effect varies according to the sequence of the style values.
> >
> 3. The style values in the transform attribute used when the animation starts and ends must be in one-to-one mapping. Only the styles that have value mappings are played. > - The style values in the transform attribute used when the animation starts and ends must be in one-to-one mapping. Only the styles that have value mappings are played.
## Samples
The following samples are provided to help you better understand how to develop animations with the **transform** attribute:
- [`JsAnimation`: Animation App (JavaScript, API 8)](https://gitee.com/openharmony/app_samples/tree/master/UI/JsAnimation)
- [`JsAnimationStyle`: JS Animation and Custom Font Styles (API 8)](https://gitee.com/openharmony/app_samples/tree/master/UI/JsAnimationStyle)
- [`Clock`: Clock (JavaScript, API 8)](https://gitee.com/openharmony/app_samples/tree/master/common/Clock)
- [Animation Styles (JavaScaript)](https://gitee.com/openharmony/codelabs/tree/master/JSUI/AnimationDemo)
- [Common Image Operations](https://gitee.com/openharmony/codelabs/tree/master/Media/ImageJsDemo)
\ No newline at end of file
...@@ -11,7 +11,7 @@ You can also customize a new component through proper combination of components ...@@ -11,7 +11,7 @@ You can also customize a new component through proper combination of components
Components can be classified into the following types based on their functions. Components can be classified into the following types based on their functions.
| Type | Components | | Type | Components |
| -------- | -------- | | -------- | -------- |
| Container | badge, dialog, div, form, list, list-item, list-item-group, panel, popup, refresh, stack, stepper, stepper-item, swiper, tabs, tab-bar, tab-content | | Container | badge, dialog, div, form, list, list-item, list-item-group, panel, popup, refresh, stack, stepper, stepper-item, swiper, tabs, tab-bar, tab-content |
| Basic | button, chart, divider, image, image-animator, input, label, marquee, menu, option, picker, picker-view, piece, progress, qrcode, rating, richtext, search, select, slider, span, switch, text, textarea, toolbar, toolbar-item, toggle | | Basic | button, chart, divider, image, image-animator, input, label, marquee, menu, option, picker, picker-view, piece, progress, qrcode, rating, richtext, search, select, slider, span, switch, text, textarea, toolbar, toolbar-item, toggle |
...@@ -19,3 +19,18 @@ Components can be classified into the following types based on their functions. ...@@ -19,3 +19,18 @@ Components can be classified into the following types based on their functions.
| Canvas | canvas | | Canvas | canvas |
| Grid | grid-container, grid-row, grid-col | | Grid | grid-container, grid-row, grid-col |
| SVG | svg, rect, circle, ellipse, path, line, polyline, polygon, text, tspan, textPath, animate, animateMotion, animateTransform | | SVG | svg, rect, circle, ellipse, path, line, polyline, polygon, text, tspan, textPath, animate, animateMotion, animateTransform |
## Samples
The following samples are provided to help you better understand how to develop components:
- [`JsPanel`: Content Display Panel (JavaScript, API 8)](https://gitee.com/openharmony/app_samples/tree/master/UI/JsPanel)
- [`Popup`: JavaScript Bubble (API 8)](https://gitee.com/openharmony/app_samples/tree/master/UI/Popup)
- [`RefreshContainer`: Refresh Container (JavaScript, API 8)](https://gitee.com/openharmony/app_samples/tree/master/UI/RefreshContainer)
- [`JSComponments`: JavaScript Bubble (API 8)](https://gitee.com/openharmony/app_samples/tree/master/UI/JSComponments)
- [`JsUserRegistration`: User Registration (JavaScript, API 8)](https://gitee.com/openharmony/app_samples/tree/master/UI/JsUserRegistration)
- [`ECG`: Heart Rate Detection (JavaScript, API 7)](https://gitee.com/openharmony/app_samples/tree/master/common/ECG)
- [`Badge`: Badge (JavaScript, API 8)](https://gitee.com/openharmony/app_samples/tree/master/UI/Badge)
- [`JsVideo`: JsVideo (API 8)](https://gitee.com/openharmony/app_samples/tree/master/media/JsVideo)
- [Rating (JavaScript)](https://gitee.com/openharmony/codelabs/tree/master/JSUI/RatingApplication)
- [Simple Video Player](https://gitee.com/openharmony/codelabs/tree/master/Media/VideoOpenHarmony)
...@@ -7,16 +7,16 @@ An application generally consist of more than one page. For example, in a music ...@@ -7,16 +7,16 @@ An application generally consist of more than one page. For example, in a music
The page router finds the target page based on the page URI. The following describes how to implement redirection between two pages: The page router finds the target page based on the page URI. The following describes how to implement redirection between two pages:
1. In the “Project“ window of DevEco Studio, choose entry > src > mainjsdefault. Right-click the pages folder and choose NewJS Page from the shortcut menu to create the detail page. 1. In the **Project** window of DevEco Studio, choose **entry** > **src** > **mainjsdefault**. Right-click the **pages** folder and choose **NewJS Page** from the shortcut menu to create the detail page.
2. Call router.push() to navigate users to the detail page. 2. Call **router.push()** to navigate users to the detail page.
3. Call router.back() to navigate users to the index page. 3. Call **router.back()** to navigate users to the index page.
## Building the Page Layout ## Building the Page Layout
The index and detail pages each contains a &lt;text> component that specifies the current page, and a &lt;button&gt; component that implements the switching between two pages. Example code in .hml files is as follows: The index and detail pages each contains a &lt;text> component that specifies the current page, and a **\<button>** component that implements the switching between two pages. Example code in .hml files is as follows:
``` ```
...@@ -39,7 +39,7 @@ The index and detail pages each contains a &lt;text> component that specifies th ...@@ -39,7 +39,7 @@ The index and detail pages each contains a &lt;text> component that specifies th
## Setting Page Styles ## Setting Page Styles
Set styles for the index and detail pages. Center the &lt;text&gt; and &lt;button&gt; components and space the two components with 50 pixels. The CSS code for the two pages is as follows: Set styles for the index and detail pages. Center the **\<text>** and **\<button>** components and space the two components with 50 pixels. The CSS code for the two pages is as follows:
``` ```
...@@ -60,7 +60,7 @@ Set styles for the index and detail pages. Center the &lt;text&gt; and &lt;butto ...@@ -60,7 +60,7 @@ Set styles for the index and detail pages. Center the &lt;text&gt; and &lt;butto
## Implementing Redirection ## Implementing Redirection
To make the launch method of the &lt;button&gt; component take effect, the redirection logic needs to be implemented in the .js file of the page. Call router.push() to add the page URI to the route stack, that is, to jump to the page specified by the URI. You need to import the router module before calling the router method. The sample code is as follows: To make the launch method of the **\<button>** component take effect, the redirection logic needs to be implemented in the .js file of the page. Call router.push() to add the page URI to the route stack, that is, to jump to the page specified by the URI. You need to import the router module before calling the router method. The sample code is as follows:
``` ```
...@@ -88,6 +88,10 @@ export default { ...@@ -88,6 +88,10 @@ export default {
The figure below shows the effect. The figure below shows the effect.
figure1 Page routing
![en-us_image_0000001222967784](figures/en-us_image_0000001222967784.png) ![en-us_image_0000001222967784](figures/en-us_image_0000001222967784.png)
## Samples
The following sample is provided to help you better understand how to develop page routing:
[`JsRouter`: Page Routing (JavaScript, API 8)](https://gitee.com/openharmony/app_samples/tree/master/UI/JsRouter)
\ No newline at end of file
...@@ -24,7 +24,7 @@ Create a **&lt;tabs&gt;** component in the .hml file under **pages/index**. ...@@ -24,7 +24,7 @@ Create a **&lt;tabs&gt;** component in the .hml file under **pages/index**.
<text>content2</text> <text>content2</text>
</div> </div>
</tab-content> </tab-content>
</tabs> </tabs>
</div> </div>
``` ```
...@@ -165,7 +165,7 @@ Add the **change** event for the **&lt;tabs&gt;** component to display the index ...@@ -165,7 +165,7 @@ Add the **change** event for the **&lt;tabs&gt;** component to display the index
``` ```
<!-- index.hml --> <!-- index.hml -->
<div class="container" style="background-color:#F1F3F5;"> <div class="container" style="background-color:#F1F3F5;">
<tabs class="tabs"onchange="tabChange"> <tabs class="tabs" onchange="tabChange">
<tab-bar class="tabBar"> <tab-bar class="tabBar">
<text class="tabBarItem">item1</text> <text class="tabBarItem">item1</text>
<text class="tabBarItem">item2</text> <text class="tabBarItem">item2</text>
...@@ -324,6 +324,6 @@ export default { ...@@ -324,6 +324,6 @@ export default {
## Samples ## Samples
The following sample is provided to help you better understand how to develop the **&lt;tabs&gt;** component: The following sample is provided to help you better understand how to develop the **&lt;tabs&gt;** component:
[`Tabs`: Tabs (JavaScript, API 7)](https://gitee.com/openharmony/app_samples/tree/master/UI/Tabs) [`Tabs`: Tabs (JavaScript, API 8)](https://gitee.com/openharmony/app_samples/tree/master/UI/Tabs)
\ No newline at end of file \ No newline at end of file
...@@ -32,7 +32,7 @@ canvas{ ...@@ -32,7 +32,7 @@ canvas{
![en-us_image_0000001232162316](figures/en-us_image_0000001232162316.png) ![en-us_image_0000001232162316](figures/en-us_image_0000001232162316.png)
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE:** > ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**<br/>
> - The default background color of the **&lt;canvas&gt;** component is the same as that of the parent component. > - The default background color of the **&lt;canvas&gt;** component is the same as that of the parent component.
> >
> - The default width and height of **&lt;canvas&gt;** are 300 px and 150 px, respectively. > - The default width and height of **&lt;canvas&gt;** are 300 px and 150 px, respectively.
...@@ -86,9 +86,29 @@ Add the long press event to the **&lt;canvas&gt;** component. When the event is ...@@ -86,9 +86,29 @@ Add the long press event to the **&lt;canvas&gt;** component. When the event is
``` ```
/* xxx.css */.container{ flex-direction: column; justify-content: center; align-items: center; background-color: #F1F3F5;}canvas{ width: 500px; height: 500px; background-color: #fdfdfd; border: 5px solid red; /* xxx.css */
.container{
width:100%;
height:100%;
flex-direction: column;
justify-content: center;
align-items: center;
background-color: #F1F3F5;
}
canvas{
width: 500px;
height: 500px;
background-color: #fdfdfd;
border: 5px solid red;
margin-bottom: 50px; margin-bottom: 50px;
}.content{ border: 5px solid blue; padding: 10px; width: 90%; height: 400px; overflow: scroll;} }
.content{
border: 5px solid blue;
padding: 10px;
width: 90%;
height: 400px;
overflow: scroll;
}
``` ```
...@@ -107,15 +127,22 @@ export default { ...@@ -107,15 +127,22 @@ export default {
ctx.strokeRect(100,100,300,300); ctx.strokeRect(100,100,300,300);
}, },
getUrl(){ getUrl(){
let el = this.$refs.canvas1; let el = this.$refs.canvas1
let dataUrl = el.toDataURL(); let dataUrl = el.toDataURL()
this.dataURL = dataUrl; this.dataURL = dataUrl;
prompt.showToast({duration:2000,message:"long press,get dataURL"}); prompt.showToast({duration:2000,message:"long press,get dataURL"})
} }
} }
``` ```
![en-us_image_0000001276003513](figures/en-us_image_0000001276003513.gif) ![en-us_image_0000001276003513](figures/en-us_image_0000001276003513.gif)
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE:** > ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**<br/>
> The **&lt;canvas&gt;** component cannot be created in **onInit** or **onReady**. > The **&lt;canvas&gt;** component cannot be created in **onInit** or **onReady**.
## Samples
The following sample is provided to help you better understand how to develop the **\<canvas>** component:
[`JsCanvas`: \<canvas> (JavaScript, API 8)](https://gitee.com/openharmony/app_samples/tree/master/UI/JsCanvas)
...@@ -217,9 +217,8 @@ export default { ...@@ -217,9 +217,8 @@ export default {
![en-us_image_0000001275803181](figures/en-us_image_0000001275803181.gif) ![en-us_image_0000001275803181](figures/en-us_image_0000001275803181.gif)
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** > ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**<br/>The **&lt;chart&gt;** component does not display the value of each point.
> >
> The **&lt;chart&gt;** component does not display the value of each point.
## Setting the Chart Attributes ## Setting the Chart Attributes
...@@ -305,7 +304,7 @@ export default { ...@@ -305,7 +304,7 @@ export default {
} }
``` ```
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** > ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**<br/>
> - The **options** attribute supports the settings of bar charts and line charts but does not support those of gauge charts. > - The **options** attribute supports the settings of bar charts and line charts but does not support those of gauge charts.
> >
> - The **datasets** attribute supports the datasets for bar charts and line charts but does not support those of gauge charts. > - The **datasets** attribute supports the datasets for bar charts and line charts but does not support those of gauge charts.
...@@ -400,12 +399,7 @@ export default { ...@@ -400,12 +399,7 @@ export default {
} }
}, },
}, },
addData() { addData() { this.$refs.linechart.append({ serial: 0, data: [Math.floor(Math.random() * 400) + 200] }) }
this.$refs.linechart.append({
serial: 0,
data: [Math.floor(Math.random() * 400) + 200]
})
}
} }
``` ```
...@@ -624,6 +618,6 @@ export default { ...@@ -624,6 +618,6 @@ export default {
![en-us_image_0000001232162328](figures/en-us_image_0000001232162328.gif) ![en-us_image_0000001232162328](figures/en-us_image_0000001232162328.gif)
## Samples ## Samples
The following sample is provided to help you better understand how to develop the **&lt;chart&gt;** component: The following sample is provided to help you better understand how to develop the **&lt;chart&gt;** component:
[`Chart`: chart (JavaScript, API 7)](https://gitee.com/openharmony/app_samples/tree/master/UI/chart) [`Chart`: chart (JavaScript, API 8)](https://gitee.com/openharmony/app_samples/tree/master/UI/chart)
\ No newline at end of file \ No newline at end of file
...@@ -152,7 +152,7 @@ export default { ...@@ -152,7 +152,7 @@ export default {
![en-us_image_0000001223287720](figures/en-us_image_0000001223287720.gif) ![en-us_image_0000001223287720](figures/en-us_image_0000001223287720.gif)
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** > ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**<br/>
> - This component supports only one child component. > - This component supports only one child component.
> >
> - Attributes and styles of a **&lt;dialog&gt;** component cannot be dynamically updated. > - Attributes and styles of a **&lt;dialog&gt;** component cannot be dynamically updated.
...@@ -333,4 +333,4 @@ export default { ...@@ -333,4 +333,4 @@ export default {
The following sample is provided to help you better understand how to develop the **&lt;dialog&gt;** component: The following sample is provided to help you better understand how to develop the **&lt;dialog&gt;** component:
[`JsDialog`: JS Dialog Box (API 7)](https://gitee.com/openharmony/app_samples/tree/master/UI/JsDialog) [`JsDialog`: JS Dialog Box (API 8)](https://gitee.com/openharmony/app_samples/tree/master/UI/JsDialog)
\ No newline at end of file \ No newline at end of file
...@@ -242,3 +242,9 @@ export default { ...@@ -242,3 +242,9 @@ export default {
![en-us_image_0000001276003501](figures/en-us_image_0000001276003501.gif) ![en-us_image_0000001276003501](figures/en-us_image_0000001276003501.gif)
## Samples
The following sample is provided to help you better understand how to develop the **\<grid>** component:
[`JsGrid`: grid (JavaScript, API 8)](https://gitee.com/openharmony/app_samples/tree/master/UI/JsGrid)
\ No newline at end of file
...@@ -43,26 +43,26 @@ The setup procedure varies, depending on whether you need a GUI. If you need a G ...@@ -43,26 +43,26 @@ The setup procedure varies, depending on whether you need a GUI. If you need a G
3. Decompress the DevEco Device Tool software package and assign permission on the folder obtained from the decompression. 3. Decompress the DevEco Device Tool software package and assign permission on the folder obtained from the decompression.
1. Go to the directory where the DevEco Device Tool software package is stored and run the following command to decompress the software package. In the command, change **devicetool-linux-tool-3.0.0.400.zip** to the actual software package name. 1. Go to the directory where the DevEco Device Tool software package is stored and run the following command to decompress the software package. In the command, change **devicetool-linux-tool-3.0.0.401.zip** to the actual software package name.
``` ```
unzip devicetool-linux-tool-3.0.0.400.zip unzip devicetool-linux-tool-3.0.0.401.zip
``` ```
2. Open the folder of the decompressed software package and run the following command to grant the execute permission on the installation file. In the command, change **devicetool-linux-tool-3.0.0.400.sh** to the actual installation file name. 2. Open the folder of the decompressed software package and run the following command to grant the execute permission on the installation file. In the command, change **devicetool-linux-tool-3.0.0.401.sh** to the actual installation file name.
``` ```
chmod u+x devicetool-linux-tool-3.0.0.400.sh chmod u+x devicetool-linux-tool-3.0.0.401.sh
``` ```
4. Run the following command to install DevEco Device Tool, where **devicetool-linux-tool-3.0.0.400.sh** indicates the installation file name. 4. Run the following command to install DevEco Device Tool, where **devicetool-linux-tool-3.0.0.401.sh** indicates the installation file name.
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** > ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**<br>
> During the installation, the setup wizard automatically checks whether Python 3.8 or 3.9 is installed. If Python 3.8 or 3.9 is not installed, the setup wizard displays the "Do you want to continue?" message; enter **Y** to allow the setup wizard to automatically install Python. > During the installation, the setup wizard automatically checks whether Python 3.8 or 3.9 is installed. If Python 3.8 or 3.9 is not installed, the setup wizard displays the "Do you want to continue?" message; enter **Y** to allow the setup wizard to automatically install Python.
``` ```
sudo ./devicetool-linux-tool-3.0.0.400.sh sudo ./devicetool-linux-tool-3.0.0.401.sh
``` ```
Wait until the "Deveco Device Tool successfully installed." message is displayed. Wait until the "Deveco Device Tool successfully installed." message is displayed.
...@@ -91,14 +91,14 @@ To remotely access the Ubuntu environment through Windows and enjoy the benefits ...@@ -91,14 +91,14 @@ To remotely access the Ubuntu environment through Windows and enjoy the benefits
1. On the **VSCode installation confirm** page, select **Install VScode 1.62.2 automatically** and click **Next**. 1. On the **VSCode installation confirm** page, select **Install VScode 1.62.2 automatically** and click **Next**.
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** > ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**<br>
> If Visual Studio Code 1.62 or later has been installed, this step will be skipped. > If Visual Studio Code 1.62 or later has been installed, this step will be skipped.
![en-us_image_0000001237801283](figures/en-us_image_0000001237801283.png) ![en-us_image_0000001237801283](figures/en-us_image_0000001237801283.png)
2. On the displayed **Python select page**, select **Download from Huawei mirror** and click **Next**. 2. On the displayed **Python select page**, select **Download from Huawei mirror** and click **Next**.
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** > ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**<br>
> If Python 3.8 or 3.9 has been installed, select **Use one of compatible on your PC**. > If Python 3.8 or 3.9 has been installed, select **Use one of compatible on your PC**.
![en-us_image_0000001193983334](figures/en-us_image_0000001193983334.png) ![en-us_image_0000001193983334](figures/en-us_image_0000001193983334.png)
...@@ -123,7 +123,7 @@ To remotely access the Ubuntu environment through Windows and enjoy the benefits ...@@ -123,7 +123,7 @@ To remotely access the Ubuntu environment through Windows and enjoy the benefits
1. In Ubuntu, open the Terminal tool and run the following command to install the SSH service: 1. In Ubuntu, open the Terminal tool and run the following command to install the SSH service:
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** > ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**<br>
> If the command fails to be executed and the system displays a message indicating that the openssh-server and openssh-client depend on different versions, install the openssh-client of the required version (for example, **sudo apt-get install openssh-client=1:8.2p1-4**) as prompted on the command-line interface (CLI) and run the command again to install the openssh-server. > If the command fails to be executed and the system displays a message indicating that the openssh-server and openssh-client depend on different versions, install the openssh-client of the required version (for example, **sudo apt-get install openssh-client=1:8.2p1-4**) as prompted on the command-line interface (CLI) and run the command again to install the openssh-server.
......
...@@ -44,25 +44,25 @@ The setup procedure varies, depending on whether you need a GUI. If you need a G ...@@ -44,25 +44,25 @@ The setup procedure varies, depending on whether you need a GUI. If you need a G
3. Decompress the DevEco Device Tool software package and assign permission on the folder obtained from the decompression. 3. Decompress the DevEco Device Tool software package and assign permission on the folder obtained from the decompression.
1. Go to the directory where the DevEco Device Tool software package is stored and run the following command to decompress the software package. In the command, change **devicetool-linux-tool-3.0.0.400.zip** to the actual software package name. 1. Go to the directory where the DevEco Device Tool software package is stored and run the following command to decompress the software package. In the command, change **devicetool-linux-tool-3.0.0.401.zip** to the actual software package name.
``` ```
unzip devicetool-linux-tool-3.0.0.400.zip unzip devicetool-linux-tool-3.0.0.401.zip
``` ```
2. Open the folder of the decompressed software package and run the following command to grant the execute permission on the installation file. In the command, change **devicetool-linux-tool-3.0.0.400.sh** to the actual installation file name. 2. Open the folder of the decompressed software package and run the following command to grant the execute permission on the installation file. In the command, change **devicetool-linux-tool-3.0.0.401.sh** to the actual installation file name.
``` ```
chmod u+x devicetool-linux-tool-3.0.0.400.sh chmod u+x devicetool-linux-tool-3.0.0.401.sh
``` ```
4. Run the following command to install DevEco Device Tool, where **devicetool-linux-tool-3.0.0.400.sh** indicates the installation file name. 4. Run the following command to install DevEco Device Tool, where **devicetool-linux-tool-3.0.0.401.sh** indicates the installation file name.
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** > ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**<br>
> During the installation, the setup wizard automatically checks whether Python 3.8 or 3.9 is installed. If Python 3.8 or 3.9 is not installed, the setup wizard displays the "Do you want to continue?" message; enter **Y** to allow the setup wizard to automatically install Python. > During the installation, the setup wizard automatically checks whether Python 3.8 or 3.9 is installed. If Python 3.8 or 3.9 is not installed, the setup wizard displays the "Do you want to continue?" message; enter **Y** to allow the setup wizard to automatically install Python.
``` ```
sudo ./devicetool-linux-tool-3.0.0.400.sh sudo ./devicetool-linux-tool-3.0.0.401.sh
``` ```
Wait until the "Deveco Device Tool successfully installed." message is displayed. Wait until the "Deveco Device Tool successfully installed." message is displayed.
...@@ -80,7 +80,7 @@ To remotely access the Ubuntu environment through Windows and enjoy the benefits ...@@ -80,7 +80,7 @@ To remotely access the Ubuntu environment through Windows and enjoy the benefits
3. Set the installation path of DevEco Device Tool and click **Next**. You are advised to install DevEco Device Tool in a non-system drive. 3. Set the installation path of DevEco Device Tool and click **Next**. You are advised to install DevEco Device Tool in a non-system drive.
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** > ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**<br>
> If you have installed DevEco Device Tool 3.0 Beta2 or earlier, the earlier version will be uninstalled before you install a new version. If the following error message is displayed during the uninstallation, click **Ignore** to continue the installation. This error does not affect the installation of the new version. > If you have installed DevEco Device Tool 3.0 Beta2 or earlier, the earlier version will be uninstalled before you install a new version. If the following error message is displayed during the uninstallation, click **Ignore** to continue the installation. This error does not affect the installation of the new version.
> >
> ![en-us_image_0000001239275843](figures/en-us_image_0000001239275843.png) > ![en-us_image_0000001239275843](figures/en-us_image_0000001239275843.png)
...@@ -98,7 +98,7 @@ To remotely access the Ubuntu environment through Windows and enjoy the benefits ...@@ -98,7 +98,7 @@ To remotely access the Ubuntu environment through Windows and enjoy the benefits
2. On the displayed **Python select page**, select **Download from Huawei mirror** and click **Next**. 2. On the displayed **Python select page**, select **Download from Huawei mirror** and click **Next**.
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** > ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**<br>
> If Python 3.8 or 3.9 has been installed, select **Use one of compatible on your PC**. > If Python 3.8 or 3.9 has been installed, select **Use one of compatible on your PC**.
![en-us_image_0000001193983334](figures/en-us_image_0000001193983334.png) ![en-us_image_0000001193983334](figures/en-us_image_0000001193983334.png)
...@@ -123,7 +123,7 @@ To remotely access the Ubuntu environment through Windows and enjoy the benefits ...@@ -123,7 +123,7 @@ To remotely access the Ubuntu environment through Windows and enjoy the benefits
1. In Ubuntu, open the Terminal tool and run the following command to install the SSH service: 1. In Ubuntu, open the Terminal tool and run the following command to install the SSH service:
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** > ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**<br>
> If the command fails to be executed and the system displays a message indicating that the openssh-server and openssh-client depend on different versions, install the openssh-client of the required version (for example, **sudo apt-get install openssh-client=1:8.2p1-4**) as prompted on the command-line interface (CLI) and run the command again to install the openssh-server. > If the command fails to be executed and the system displays a message indicating that the openssh-server and openssh-client depend on different versions, install the openssh-client of the required version (for example, **sudo apt-get install openssh-client=1:8.2p1-4**) as prompted on the command-line interface (CLI) and run the command again to install the openssh-server.
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
1. [Download](https://gitee.com/hihope_iot/docs/blob/master/HiHope_DAYU200/%E7%83%A7%E5%86%99%E5%B7%A5%E5%85%B7%E5%8F%8A%E6%8C%87%E5%8D%97/windows/DriverAssitant_v5.1.1.zip) **DriverInstall.exe**. Double-click **DriverInstall.exe** to open the installer. Then click the install button to install the USB driver as prompted. 1. [Download](https://gitee.com/hihope_iot/docs/blob/master/HiHope_DAYU200/%E7%83%A7%E5%86%99%E5%B7%A5%E5%85%B7%E5%8F%8A%E6%8C%87%E5%8D%97/windows/DriverAssitant_v5.1.1.zip) **DriverInstall.exe**. Double-click **DriverInstall.exe** to open the installer. Then click the install button to install the USB driver as prompted.
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** > ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**<br>
> If the burning tool of an earlier version has been installed, uninstall it first. > If the burning tool of an earlier version has been installed, uninstall it first.
2. Connect the computer to the target development board through the USB port. 2. Connect the computer to the target development board through the USB port.
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
![en-us_image_0000001261395999](figures/en-us_image_0000001261395999.png) ![en-us_image_0000001261395999](figures/en-us_image_0000001261395999.png)
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** > ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**<br>
> This operation is required only in remote access mode (in the Windows+Ubuntu hybrid build environment). If the local access mode (Windows or Ubuntu build environment) is used, skip this step. > This operation is required only in remote access mode (in the Windows+Ubuntu hybrid build environment). If the local access mode (Windows or Ubuntu build environment) is used, skip this step.
4. In DevEco Device Tool, choose QUICK ACCESS > DevEco Home > Projects, and then click Settings. 4. In DevEco Device Tool, choose QUICK ACCESS > DevEco Home > Projects, and then click Settings.
...@@ -37,7 +37,7 @@ ...@@ -37,7 +37,7 @@
2. In **Partition Options**, modify the items selected in the preceding step. 2. In **Partition Options**, modify the items selected in the preceding step.
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** > ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**<br>
> Set the start address and length of the partition based on the size of the files to be burnt. Make sure the size of the partition is greater than that of the files to be burnt and the partition addresses of the files to be burnt do not overlap. > Set the start address and length of the partition based on the size of the files to be burnt. Make sure the size of the partition is greater than that of the files to be burnt and the partition addresses of the files to be burnt do not overlap.
![en-us_image_0000001268653461](figures/en-us_image_0000001268653461.png) ![en-us_image_0000001268653461](figures/en-us_image_0000001268653461.png)
...@@ -50,6 +50,11 @@ ...@@ -50,6 +50,11 @@
![en-us_image_0000001194821710](figures/en-us_image_0000001194821710.png) ![en-us_image_0000001194821710](figures/en-us_image_0000001194821710.png)
9. Wait until the burning is complete. If the following message is displayed, the burning is successful. 9. If the message "Operation paused, Please press Enter key to continue" is displayed, press **Enter**.
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**<br>
> If the message "The boad is not in Loader mode. Please Hold on the VOL+key..." is displayed, place the development board in Loader mode as follows: Press and hold the Volume+ key for 3 seconds, press the RESET key, wait for 3 seconds, and then release the Volume+ key.
10. Wait until the burning is complete. If the following message is displayed, the burning is successful.
![en-us_image_0000001194984912](figures/en-us_image_0000001194984912.png) ![en-us_image_0000001194984912](figures/en-us_image_0000001194984912.png)
...@@ -24,7 +24,7 @@ On Ubuntu: ...@@ -24,7 +24,7 @@ On Ubuntu:
sudo apt-get update && sudo apt-get install binutils binutils-dev git git-lfs gnupg flex bison gperf build-essential zip curl zlib1g-dev gcc-multilib g++-multilib gcc-arm-linux-gnueabi libc6-dev-i386 libc6-dev-amd64 lib32ncurses5-dev x11proto-core-dev libx11-dev lib32z1-dev ccache libgl1-mesa-dev libxml2-utils xsltproc unzip m4 bc gnutls-bin python3.8 python3-pip ruby genext2fs device-tree-compiler make libffi-dev e2fsprogs pkg-config perl openssl libssl-dev libelf-dev libdwarf-dev u-boot-tools mtd-utils cpio doxygen liblz4-tool openjdk-8-jre gcc g++ texinfo dosfstools mtools default-jre default-jdk libncurses5 apt-utils wget scons python3.8-distutils tar rsync git-core libxml2-dev lib32z-dev grsync xxd libglib2.0-dev libpixman-1-dev kmod jfsutils reiserfsprogs xfsprogs squashfs-tools pcmciautils quota ppp libtinfo-dev libtinfo5 libncurses5-dev libncursesw5 libstdc++6 gcc-arm-none-eabi vim ssh locales sudo apt-get update && sudo apt-get install binutils binutils-dev git git-lfs gnupg flex bison gperf build-essential zip curl zlib1g-dev gcc-multilib g++-multilib gcc-arm-linux-gnueabi libc6-dev-i386 libc6-dev-amd64 lib32ncurses5-dev x11proto-core-dev libx11-dev lib32z1-dev ccache libgl1-mesa-dev libxml2-utils xsltproc unzip m4 bc gnutls-bin python3.8 python3-pip ruby genext2fs device-tree-compiler make libffi-dev e2fsprogs pkg-config perl openssl libssl-dev libelf-dev libdwarf-dev u-boot-tools mtd-utils cpio doxygen liblz4-tool openjdk-8-jre gcc g++ texinfo dosfstools mtools default-jre default-jdk libncurses5 apt-utils wget scons python3.8-distutils tar rsync git-core libxml2-dev lib32z-dev grsync xxd libglib2.0-dev libpixman-1-dev kmod jfsutils reiserfsprogs xfsprogs squashfs-tools pcmciautils quota ppp libtinfo-dev libtinfo5 libncurses5-dev libncursesw5 libstdc++6 gcc-arm-none-eabi vim ssh locales
``` ```
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** > ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**<br>
> The preceding command is applicable to Ubuntu 18.04. For other Ubuntu versions, modify the preceding installation command based on the installation package name. Specifically: > The preceding command is applicable to Ubuntu 18.04. For other Ubuntu versions, modify the preceding installation command based on the installation package name. Specifically:
> >
> - Python 3.8 or a later version is required. This section uses Python 3.8 as an example. > - Python 3.8 or a later version is required. This section uses Python 3.8 as an example.
...@@ -52,7 +52,7 @@ On Ubuntu: ...@@ -52,7 +52,7 @@ On Ubuntu:
To remotely access the Ubuntu environment through Windows to perform operations such as burning, you need to install DevEco Device Tool on both Windows and Ubuntu. To remotely access the Ubuntu environment through Windows to perform operations such as burning, you need to install DevEco Device Tool on both Windows and Ubuntu.
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** > ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**<br>
> DevEco Device Tool is a one-stop integrated development environment (IDE) provided for developers of OpenHarmony-powered smart devices. It allows code editing, compiling, burning, and debugging. This document describes how to use DevEco Device Tool to remotely connect to the Ubuntu environment for burning and running. > DevEco Device Tool is a one-stop integrated development environment (IDE) provided for developers of OpenHarmony-powered smart devices. It allows code editing, compiling, burning, and debugging. This document describes how to use DevEco Device Tool to remotely connect to the Ubuntu environment for burning and running.
...@@ -64,7 +64,7 @@ To remotely access the Ubuntu environment through Windows to perform operations ...@@ -64,7 +64,7 @@ To remotely access the Ubuntu environment through Windows to perform operations
3. Set the installation path of DevEco Device Tool and click **Next**. You are advised to install DevEco Device Tool in a non-system drive. 3. Set the installation path of DevEco Device Tool and click **Next**. You are advised to install DevEco Device Tool in a non-system drive.
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** > ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**<br>
> If you have installed DevEco Device Tool 3.0 Beta2 or earlier, the earlier version will be uninstalled before you install a new version. If the following error message is displayed during the uninstallation, click **Ignore** to continue the installation. This error does not affect the installation of the new version. > If you have installed DevEco Device Tool 3.0 Beta2 or earlier, the earlier version will be uninstalled before you install a new version. If the following error message is displayed during the uninstallation, click **Ignore** to continue the installation. This error does not affect the installation of the new version.
> >
> ![en-us_image_0000001239275843](figures/en-us_image_0000001239275843.png) > ![en-us_image_0000001239275843](figures/en-us_image_0000001239275843.png)
...@@ -75,14 +75,14 @@ To remotely access the Ubuntu environment through Windows to perform operations ...@@ -75,14 +75,14 @@ To remotely access the Ubuntu environment through Windows to perform operations
1. On the **VSCode installation confirm** page, select **Install VScode 1.62.2 automatically** and click **Next**. 1. On the **VSCode installation confirm** page, select **Install VScode 1.62.2 automatically** and click **Next**.
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** > ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**<br>
> If Visual Studio Code 1.62 or later has been installed, this step will be skipped. > If Visual Studio Code 1.62 or later has been installed, this step will be skipped.
![en-us_image_0000001237801283](figures/en-us_image_0000001237801283.png) ![en-us_image_0000001237801283](figures/en-us_image_0000001237801283.png)
2. On the displayed **Python select page**, select **Download from Huawei mirror** and click **Next**. 2. On the displayed **Python select page**, select **Download from Huawei mirror** and click **Next**.
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** > ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**<br>
> If Python 3.8 or 3.9 has been installed, select **Use one of compatible on your PC**. > If Python 3.8 or 3.9 has been installed, select **Use one of compatible on your PC**.
![en-us_image_0000001193983334](figures/en-us_image_0000001193983334.png) ![en-us_image_0000001193983334](figures/en-us_image_0000001193983334.png)
...@@ -122,25 +122,25 @@ To remotely access the Ubuntu environment through Windows to perform operations ...@@ -122,25 +122,25 @@ To remotely access the Ubuntu environment through Windows to perform operations
3. Decompress the DevEco Device Tool software package and assign permission on the folder obtained from the decompression. 3. Decompress the DevEco Device Tool software package and assign permission on the folder obtained from the decompression.
1. Go to the directory where the DevEco Device Tool software package is stored and run the following command to decompress the software package. In the command, change **devicetool-linux-tool-3.0.0.400.zip** to the actual software package name. 1. Go to the directory where the DevEco Device Tool software package is stored and run the following command to decompress the software package. In the command, change **devicetool-linux-tool-3.0.0.401.zip** to the actual software package name.
``` ```
unzip devicetool-linux-tool-3.0.0.400.zip unzip devicetool-linux-tool-3.0.0.401.zip
``` ```
2. Open the folder of the decompressed software package and run the following command to grant the execute permission on the installation file. In the command, change **devicetool-linux-tool-3.0.0.400.sh** to the actual installation file name. 2. Open the folder of the decompressed software package and run the following command to grant the execute permission on the installation file. In the command, change **devicetool-linux-tool-3.0.0.401.sh** to the actual installation file name.
``` ```
chmod u+x devicetool-linux-tool-3.0.0.400.sh chmod u+x devicetool-linux-tool-3.0.0.401.sh
``` ```
4. Run the following command to install DevEco Device Tool, where **devicetool-linux-tool-3.0.0.400.sh** indicates the installation file name. 4. Run the following command to install DevEco Device Tool, where **devicetool-linux-tool-3.0.0.401.sh** indicates the installation file name.
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** > ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**<br>
> During the installation, the setup wizard automatically checks whether Python 3.8 or 3.9 is installed. If Python 3.8 or 3.9 is not installed, the setup wizard displays the "Do you want to continue?" message; enter **Y** to allow the setup wizard to automatically install Python. > During the installation, the setup wizard automatically checks whether Python 3.8 or 3.9 is installed. If Python 3.8 or 3.9 is not installed, the setup wizard displays the "Do you want to continue?" message; enter **Y** to allow the setup wizard to automatically install Python.
``` ```
sudo ./devicetool-linux-tool-3.0.0.400.sh sudo ./devicetool-linux-tool-3.0.0.401.sh
``` ```
Wait until the "Deveco Device Tool successfully installed." message is displayed. Wait until the "Deveco Device Tool successfully installed." message is displayed.
...@@ -155,7 +155,7 @@ To remotely access the Ubuntu environment through Windows to perform operations ...@@ -155,7 +155,7 @@ To remotely access the Ubuntu environment through Windows to perform operations
1. In Ubuntu, open the Terminal tool and run the following command to install the SSH service: 1. In Ubuntu, open the Terminal tool and run the following command to install the SSH service:
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** > ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**<br>
> If the command fails to be executed and the system displays a message indicating that the openssh-server and openssh-client depend on different versions, install the openssh-client of the required version (for example, **sudo apt-get install openssh-client=1:8.2p1-4**) as prompted on the command-line interface (CLI) and run the command again to install the openssh-server. > If the command fails to be executed and the system displays a message indicating that the openssh-server and openssh-client depend on different versions, install the openssh-client of the required version (for example, **sudo apt-get install openssh-client=1:8.2p1-4**) as prompted on the command-line interface (CLI) and run the command again to install the openssh-server.
...@@ -280,7 +280,7 @@ In the Ubuntu environment, perform the following steps to obtain the OpenHarmony ...@@ -280,7 +280,7 @@ In the Ubuntu environment, perform the following steps to obtain the OpenHarmony
### Obtaining Source Code ### Obtaining Source Code
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** > ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**<br>
> Download the master code if you want to get quick access to the latest features for your development. Download the release code, which is more stable, if you want to develop commercial functionalities. > Download the master code if you want to get quick access to the latest features for your development. Download the release code, which is more stable, if you want to develop commercial functionalities.
- **Obtaining OpenHarmony master code** - **Obtaining OpenHarmony master code**
...@@ -325,7 +325,7 @@ Perform the following steps in Ubuntu: ...@@ -325,7 +325,7 @@ Perform the following steps in Ubuntu:
### Install hb. ### Install hb.
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** > ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**<br>
> To install a proxy, see [Configuring the Proxy](../quick-start/quickstart-lite-reference.md#section6204129143010). > To install a proxy, see [Configuring the Proxy](../quick-start/quickstart-lite-reference.md#section6204129143010).
1. Run the following command to install hb and update it to the latest version: 1. Run the following command to install hb and update it to the latest version:
...@@ -370,7 +370,7 @@ Perform the following steps in Ubuntu: ...@@ -370,7 +370,7 @@ Perform the following steps in Ubuntu:
-h, --help show this help message and exit -h, --help show this help message and exit
``` ```
> ![icon-notice.gif](public_sys-resources/icon-notice.gif) **NOTICE** > ![icon-notice.gif](public_sys-resources/icon-notice.gif) **NOTICE**<br>
> - Run the following command to uninstall hb: > - Run the following command to uninstall hb:
> >
> ``` > ```
...@@ -382,7 +382,7 @@ Perform the following steps in Ubuntu: ...@@ -382,7 +382,7 @@ Perform the following steps in Ubuntu:
### Install LLVM. This step is only required for OpenHarmony_v1.x. ### Install LLVM. This step is only required for OpenHarmony_v1.x.
> ![icon-notice.gif](public_sys-resources/icon-notice.gif) **NOTICE** > ![icon-notice.gif](public_sys-resources/icon-notice.gif) **NOTICE**<br>
> When downloading source code under the OpenHarmony_v1.x branches or tags, perform the operation procedure described in this section to install LLVM 9.0.0. > When downloading source code under the OpenHarmony_v1.x branches or tags, perform the operation procedure described in this section to install LLVM 9.0.0.
> >
> When downloading source code under the Master or non-OpenHarmony_v1.x branches or tags, skip this section. hb will automatically download the latest version of LLVM. > When downloading source code under the Master or non-OpenHarmony_v1.x branches or tags, skip this section. hb will automatically download the latest version of LLVM.
......
...@@ -24,7 +24,7 @@ In Ubuntu: ...@@ -24,7 +24,7 @@ In Ubuntu:
sudo apt-get update && sudo apt-get install binutils binutils-dev git git-lfs gnupg flex bison gperf build-essential zip curl zlib1g-dev gcc-multilib g++-multilib gcc-arm-linux-gnueabi libc6-dev-i386 libc6-dev-amd64 lib32ncurses5-dev x11proto-core-dev libx11-dev lib32z1-dev ccache libgl1-mesa-dev libxml2-utils xsltproc unzip m4 bc gnutls-bin python3.8 python3-pip ruby genext2fs device-tree-compiler make libffi-dev e2fsprogs pkg-config perl openssl libssl-dev libelf-dev libdwarf-dev u-boot-tools mtd-utils cpio doxygen liblz4-tool openjdk-8-jre gcc g++ texinfo dosfstools mtools default-jre default-jdk libncurses5 apt-utils wget scons python3.8-distutils tar rsync git-core libxml2-dev lib32z-dev grsync xxd libglib2.0-dev libpixman-1-dev kmod jfsutils reiserfsprogs xfsprogs squashfs-tools pcmciautils quota ppp libtinfo-dev libtinfo5 libncurses5-dev libncursesw5 libstdc++6 gcc-arm-none-eabi vim ssh locales sudo apt-get update && sudo apt-get install binutils binutils-dev git git-lfs gnupg flex bison gperf build-essential zip curl zlib1g-dev gcc-multilib g++-multilib gcc-arm-linux-gnueabi libc6-dev-i386 libc6-dev-amd64 lib32ncurses5-dev x11proto-core-dev libx11-dev lib32z1-dev ccache libgl1-mesa-dev libxml2-utils xsltproc unzip m4 bc gnutls-bin python3.8 python3-pip ruby genext2fs device-tree-compiler make libffi-dev e2fsprogs pkg-config perl openssl libssl-dev libelf-dev libdwarf-dev u-boot-tools mtd-utils cpio doxygen liblz4-tool openjdk-8-jre gcc g++ texinfo dosfstools mtools default-jre default-jdk libncurses5 apt-utils wget scons python3.8-distutils tar rsync git-core libxml2-dev lib32z-dev grsync xxd libglib2.0-dev libpixman-1-dev kmod jfsutils reiserfsprogs xfsprogs squashfs-tools pcmciautils quota ppp libtinfo-dev libtinfo5 libncurses5-dev libncursesw5 libstdc++6 gcc-arm-none-eabi vim ssh locales
``` ```
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** > ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**<br>
> The preceding command is applicable to Ubuntu 18.04. For other Ubuntu versions, modify the preceding installation command based on the installation package name. Specifically: > The preceding command is applicable to Ubuntu 18.04. For other Ubuntu versions, modify the preceding installation command based on the installation package name. Specifically:
> >
> - Python 3.8 or a later version is required. This section uses Python 3.8 as an example. > - Python 3.8 or a later version is required. This section uses Python 3.8 as an example.
...@@ -51,7 +51,7 @@ In Ubuntu: ...@@ -51,7 +51,7 @@ In Ubuntu:
To remotely access the Ubuntu environment through Windows to perform operations such as burning, you need to install DevEco Device Tool on both Windows and Ubuntu. To remotely access the Ubuntu environment through Windows to perform operations such as burning, you need to install DevEco Device Tool on both Windows and Ubuntu.
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** > ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**<br>
> DevEco Device Tool is a one-stop integrated development environment (IDE) provided for developers of OpenHarmony-powered smart devices. It allows code editing, compiling, burning, and debugging. This document describes how to use DevEco Device Tool to remotely connect to the Ubuntu environment for burning and running. > DevEco Device Tool is a one-stop integrated development environment (IDE) provided for developers of OpenHarmony-powered smart devices. It allows code editing, compiling, burning, and debugging. This document describes how to use DevEco Device Tool to remotely connect to the Ubuntu environment for burning and running.
...@@ -62,7 +62,7 @@ To remotely access the Ubuntu environment through Windows to perform operations ...@@ -62,7 +62,7 @@ To remotely access the Ubuntu environment through Windows to perform operations
2. Decompress the DevEco Device Tool package, double-click the installer, and then click **Next**. 2. Decompress the DevEco Device Tool package, double-click the installer, and then click **Next**.
3. Set the installation path of DevEco Device Tool and click **Next**. You are advised to install DevEco Device Tool in a non-system drive. 3. Set the installation path of DevEco Device Tool and click **Next**. You are advised to install DevEco Device Tool in a non-system drive.
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** > ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**<br>
> If you have installed DevEco Device Tool 3.0 Beta2 or earlier, the earlier version will be uninstalled before you install a new version. If the following error message is displayed during the uninstallation, click **Ignore** to continue the installation. This error does not affect the installation of the new version. > If you have installed DevEco Device Tool 3.0 Beta2 or earlier, the earlier version will be uninstalled before you install a new version. If the following error message is displayed during the uninstallation, click **Ignore** to continue the installation. This error does not affect the installation of the new version.
> >
> ![en-us_image_0000001239275843](figures/en-us_image_0000001239275843.png) > ![en-us_image_0000001239275843](figures/en-us_image_0000001239275843.png)
...@@ -76,7 +76,7 @@ To remotely access the Ubuntu environment through Windows to perform operations ...@@ -76,7 +76,7 @@ To remotely access the Ubuntu environment through Windows to perform operations
![en-us_image_0000001237801283](figures/en-us_image_0000001237801283.png) ![en-us_image_0000001237801283](figures/en-us_image_0000001237801283.png)
2. On the displayed **Python select page**, select **Download from Huawei mirror** and click **Next**. 2. On the displayed **Python select page**, select **Download from Huawei mirror** and click **Next**.
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** > ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**<br>
> If Python 3.8 or 3.9 has been installed, select **Use one of compatible on your PC**. > If Python 3.8 or 3.9 has been installed, select **Use one of compatible on your PC**.
![en-us_image_0000001193983334](figures/en-us_image_0000001193983334.png) ![en-us_image_0000001193983334](figures/en-us_image_0000001193983334.png)
...@@ -115,24 +115,24 @@ To remotely access the Ubuntu environment through Windows to perform operations ...@@ -115,24 +115,24 @@ To remotely access the Ubuntu environment through Windows to perform operations
2. Download the [DevEco Device Tool 3.0 Release Linux version](https://device.harmonyos.com/cn/ide#download). 2. Download the [DevEco Device Tool 3.0 Release Linux version](https://device.harmonyos.com/cn/ide#download).
3. Decompress the DevEco Device Tool software package and assign permission on the folder obtained from the decompression. 3. Decompress the DevEco Device Tool software package and assign permission on the folder obtained from the decompression.
1. Go to the directory where the DevEco Device Tool software package is stored and run the following command to decompress the software package. In the command, change **devicetool-linux-tool-3.0.0.400.zip** to the actual software package name. 1. Go to the directory where the DevEco Device Tool software package is stored and run the following command to decompress the software package. In the command, change **devicetool-linux-tool-3.0.0.401.zip** to the actual software package name.
``` ```
unzip devicetool-linux-tool-3.0.0.400.zip unzip devicetool-linux-tool-3.0.0.401.zip
``` ```
2. Open the folder of the decompressed software package and run the following command to grant the execute permission on the installation file. In the command, change **devicetool-linux-tool-3.0.0.400.sh** to the actual installation file name. 2. Open the folder of the decompressed software package and run the following command to grant the execute permission on the installation file. In the command, change **devicetool-linux-tool-3.0.0.401.sh** to the actual installation file name.
``` ```
chmod u+x devicetool-linux-tool-3.0.0.400.sh chmod u+x devicetool-linux-tool-3.0.0.401.sh
``` ```
4. Run the following command to install DevEco Device Tool, where **devicetool-linux-tool-3.0.0.400.sh** indicates the installation file name. 4. Run the following command to install DevEco Device Tool, where **devicetool-linux-tool-3.0.0.401.sh** indicates the installation file name.
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** > ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**<br>
> During the installation, the setup wizard automatically checks whether Python 3.8 or 3.9 is installed. If Python 3.8 or 3.9 is not installed, the setup wizard displays the "Do you want to continue?" message; enter **Y** to allow the setup wizard to automatically install Python. > During the installation, the setup wizard automatically checks whether Python 3.8 or 3.9 is installed. If Python 3.8 or 3.9 is not installed, the setup wizard displays the "Do you want to continue?" message; enter **Y** to allow the setup wizard to automatically install Python.
``` ```
sudo ./devicetool-linux-tool-3.0.0.400.sh sudo ./devicetool-linux-tool-3.0.0.401.sh
``` ```
Wait until the "Deveco Device Tool successfully installed." message is displayed. Wait until the "Deveco Device Tool successfully installed." message is displayed.
...@@ -146,7 +146,7 @@ To remotely access the Ubuntu environment through Windows to perform operations ...@@ -146,7 +146,7 @@ To remotely access the Ubuntu environment through Windows to perform operations
### Installing the SSH Service and Obtaining the IP Address for Remote Access ### Installing the SSH Service and Obtaining the IP Address for Remote Access
1. In Ubuntu, open the Terminal tool and run the following command to install the SSH service: 1. In Ubuntu, open the Terminal tool and run the following command to install the SSH service:
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** > ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**<br>
> If the command fails to be executed and the system displays a message indicating that the openssh-server and openssh-client depend on different versions, install the openssh-client of the required version (for example, **sudo apt-get install openssh-client=1:8.2p1-4**) as prompted on the command-line interface (CLI) and run the command again to install the openssh-server. > If the command fails to be executed and the system displays a message indicating that the openssh-server and openssh-client depend on different versions, install the openssh-client of the required version (for example, **sudo apt-get install openssh-client=1:8.2p1-4**) as prompted on the command-line interface (CLI) and run the command again to install the openssh-server.
...@@ -269,7 +269,7 @@ In the Ubuntu environment, perform the following steps to obtain the OpenHarmony ...@@ -269,7 +269,7 @@ In the Ubuntu environment, perform the following steps to obtain the OpenHarmony
### Obtaining Source Code ### Obtaining Source Code
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** > ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**<br>
> Download the master code if you want to get quick access to the latest features for your development. Download the release code, which is more stable, if you want to develop commercial functionalities. > Download the master code if you want to get quick access to the latest features for your development. Download the release code, which is more stable, if you want to develop commercial functionalities.
- **Obtaining OpenHarmony master code** - **Obtaining OpenHarmony master code**
...@@ -310,7 +310,7 @@ bash build/prebuilts_download.sh ...@@ -310,7 +310,7 @@ bash build/prebuilts_download.sh
hb is a compilation tool of OpenHarmony. To install hb in Ubuntu, perform the following steps: For details about the functions of the OpenHarmony compilation and building module, see [Compilation and Building Guidelines](https://gitee.com/openharmony/docs/blob/master/en/device-dev/subsystems/subsys-build.md). hb is a compilation tool of OpenHarmony. To install hb in Ubuntu, perform the following steps: For details about the functions of the OpenHarmony compilation and building module, see [Compilation and Building Guidelines](https://gitee.com/openharmony/docs/blob/master/en/device-dev/subsystems/subsys-build.md).
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** > ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**<br>
> To install a proxy, see [Configuring the Proxy](../quick-start/quickstart-standard-reference.md#section6204129143012). > To install a proxy, see [Configuring the Proxy](../quick-start/quickstart-standard-reference.md#section6204129143012).
...@@ -357,7 +357,7 @@ hb is a compilation tool of OpenHarmony. To install hb in Ubuntu, perform the fo ...@@ -357,7 +357,7 @@ hb is a compilation tool of OpenHarmony. To install hb in Ubuntu, perform the fo
``` ```
> ![icon-notice.gif](public_sys-resources/icon-notice.gif) **NOTICE** > ![icon-notice.gif](public_sys-resources/icon-notice.gif) **NOTICE**<br>
> - Run the following command to uninstall hb: > - Run the following command to uninstall hb:
> >
> ``` > ```
......
...@@ -14,7 +14,7 @@ After the building is complete, ensure that you can [remotely access the Ubuntu ...@@ -14,7 +14,7 @@ After the building is complete, ensure that you can [remotely access the Ubuntu
2. Select the target directory (in the Ubuntu environment) and click **Import**. 2. Select the target directory (in the Ubuntu environment) and click **Import**.
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** > ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**<br>
> Make sure the selected directory does not contain Chinese characters or spaces. Otherwise, the building may fail. > Make sure the selected directory does not contain Chinese characters or spaces. Otherwise, the building may fail.
![en-us_image_0000001272032361](figures/en-us_image_0000001272032361.png) ![en-us_image_0000001272032361](figures/en-us_image_0000001272032361.png)
...@@ -39,7 +39,7 @@ After the building is complete, ensure that you can [remotely access the Ubuntu ...@@ -39,7 +39,7 @@ After the building is complete, ensure that you can [remotely access the Ubuntu
After the source code is imported, perform the following steps: After the source code is imported, perform the following steps:
1. [Download](https://gitee.com/hihope_iot/docs/blob/master/HiHope_DAYU200/%E7%83%A7%E5%86%99%E5%B7%A5%E5%85%B7%E5%8F%8A%E6%8C%87%E5%8D%97/windows/DriverAssitant_v5.1.1.zip) **DriverInstall.exe**. Double-click **DriverInstall.exe** to open the installer. Then click the install button to install the USB driver as prompted. 1. [Download](https://gitee.com/hihope_iot/docs/blob/master/HiHope_DAYU200/%E7%83%A7%E5%86%99%E5%B7%A5%E5%85%B7%E5%8F%8A%E6%8C%87%E5%8D%97/windows/DriverAssitant_v5.1.1.zip) **DriverInstall.exe**. Double-click **DriverInstall.exe** to open the installer. Then click the install button to install the USB driver as prompted.
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** > ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**<br>
> If the burning tool of an earlier version has been installed, uninstall it first. > If the burning tool of an earlier version has been installed, uninstall it first.
2. Connect the computer to the target development board through the USB port. 2. Connect the computer to the target development board through the USB port.
...@@ -51,7 +51,7 @@ After the source code is imported, perform the following steps: ...@@ -51,7 +51,7 @@ After the source code is imported, perform the following steps:
![en-us_image_0000001261395999](figures/en-us_image_0000001261395999.png) ![en-us_image_0000001261395999](figures/en-us_image_0000001261395999.png)
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** > ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**<br>
> This operation is required only in remote access mode (in the Windows+Ubuntu hybrid build environment). If the local access mode (Windows or Ubuntu build environment) is used, skip this step. > This operation is required only in remote access mode (in the Windows+Ubuntu hybrid build environment). If the local access mode (Windows or Ubuntu build environment) is used, skip this step.
4. In DevEco Device Tool, choose QUICK ACCESS > DevEco Home > Projects, and then click Settings. 4. In DevEco Device Tool, choose QUICK ACCESS > DevEco Home > Projects, and then click Settings.
...@@ -73,7 +73,7 @@ After the source code is imported, perform the following steps: ...@@ -73,7 +73,7 @@ After the source code is imported, perform the following steps:
2. In **Partition Options**, modify the items selected in the preceding step. 2. In **Partition Options**, modify the items selected in the preceding step.
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** > ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**<br>
> Set the start address and length of the partition based on the size of the files to be burnt. Make sure the size of the partition is greater than that of the files to be burnt and the partition addresses of the files to be burnt do not overlap. > Set the start address and length of the partition based on the size of the files to be burnt. Make sure the size of the partition is greater than that of the files to be burnt and the partition addresses of the files to be burnt do not overlap.
![en-us_image_0000001268653461](figures/en-us_image_0000001268653461.png) ![en-us_image_0000001268653461](figures/en-us_image_0000001268653461.png)
...@@ -86,6 +86,11 @@ After the source code is imported, perform the following steps: ...@@ -86,6 +86,11 @@ After the source code is imported, perform the following steps:
![en-us_image_0000001194821710](figures/en-us_image_0000001194821710.png) ![en-us_image_0000001194821710](figures/en-us_image_0000001194821710.png)
9. Wait until the burning is complete. If the following message is displayed, the burning is successful. 9. If the message "Operation paused, Please press Enter key to continue" is displayed, press **Enter**.
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**<br>
> If the message "The boad is not in Loader mode. Please Hold on the VOL+key..." is displayed, place the development board in Loader mode as follows: Press and hold the Volume+ key for 3 seconds, press the RESET key, wait for 3 seconds, and then release the Volume+ key.
10. Wait until the burning is complete. If the following message is displayed, the burning is successful.
![en-us_image_0000001194984912](figures/en-us_image_0000001194984912.png) ![en-us_image_0000001194984912](figures/en-us_image_0000001194984912.png)
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册