diff --git a/en/application-dev/quick-start/start-with-ets-low-code.md b/en/application-dev/quick-start/start-with-ets-low-code.md
index 7e0fd658f59ec68342dfa8b4fffdd82152a980ae..a2e41c66e918ccc33623ab6b746d1129fdedd7d3 100644
--- a/en/application-dev/quick-start/start-with-ets-low-code.md
+++ b/en/application-dev/quick-start/start-with-ets-low-code.md
@@ -1,10 +1,9 @@
# Getting Started with eTS in the Low-Code Approach
->  **Note:**
-> This feature is supported in DevEco Studio V3.0 Beta3 and later versions.
->
+>  **NOTE** 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.
->
+>
> 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.
@@ -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
-1. Open DevEco Studio, choose **File** > **New** > **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** > **New** > **Create Project**. Then, select **Empty Ability** and click **Next**.

@@ -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).
1. Delete the existing template components from the canvas.
- 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.
+
+ 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.
- 
+
2. Add a **Column** component and set its styles and attributes.
+
Drag the **Column** component from the **UI Control** area to the canvas. In the **Attributes & Styles** area on the right, click **General** and set **Height** to **100%** so that the component fills the entire screen. Click **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.

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 & Styles** area, click **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.

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 & Styles** area on the right, click **General** and set **Height** of the **Button** component to **40vp**. Click **Feature** and set **Label** to **Next** and **FontSize** to **25fp**. Below is an illustration of the operations.
- 
+
+
+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.

@@ -77,9 +82,10 @@ Add **Column**, **Text**, and **Button** components to the first page. A column
## Building the Second Page
1. Create the second page.
- In the **Project** window, choose **entry** > **src** > **main** > **ets** > **MainAbility**, right-click the **pages** folder, choose **New** > **Visual**, name the page **second**, and click **Finish**. Below is the structure of the **pages** folder.
+
+ In the **Project** window, choose **entry** > **src** > **main** > **ets** > **MainAbility**, right-click the **pages** folder, choose **New** > **Visual**, name the page **second**, and click **Finish**. Below, you can see the structure of the **pages** folder.
- 
+
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

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 & Styles** area on the right, click **General** and set **Height** of the **Button** component to **40vp**. Click **Feature** and set **Value** to **Back** and **FontSize** to **25fp**. Below is an illustration of the operations.

@@ -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:
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:
```
@@ -143,12 +152,13 @@ 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 & Styles** area, click **Events** and set **OnClick** to **this.onclick**.
- 
+ - In the **index.visual** file, select the **Button** component on the canvas. In the **Attributes & Styles** area, click **Events** and set **OnClick** to **this.onclick**.
+ 
+
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 **second.ets** file:
@@ -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 & Styles** area, click **Events** and set **OnClick** to **this.back**.
+ - In the **second.visual** file, select the **Button** component on the canvas. In the **Attributes & Styles** area, click **Events** and set **OnClick** to **this.back**.

diff --git a/en/application-dev/quick-start/start-with-ets.md b/en/application-dev/quick-start/start-with-ets.md
index 9ec3597755e23ba5172f24d1a72b1c9274a13cdc..53c1133bfb918ed07e1c6d81f90a2f46a85ca500 100644
--- a/en/application-dev/quick-start/start-with-ets.md
+++ b/en/application-dev/quick-start/start-with-ets.md
@@ -1,14 +1,13 @@
# Getting Started with eTS in the Traditional Coding Approach
->  **Note:**
-> To use eTS, your DevEco Studio must be V3.0.0.601 Beta1 or later.
->
+>  **NOTE** 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.
## Creating an eTS Project
-1. Open DevEco Studio, choose **File** > **New** > **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** > **New** > **Create Project**. Then, select **Empty Ability** and click **Next**.

@@ -21,14 +20,14 @@
## 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 > main > ets** : a collection of eTS source code.
- **src > main > ets > MainAbility** : entry to your application/service.
- **src > main > ets > MainAbility > pages** : pages contained in **MainAbility**.
- **src > main > ets > MainAbility > app.ets** : ability lifecycle file.
- **src > main > resources** : a collection of resource files used by your application/service, such as graphics, multimedia, character strings, and layout files.
- **src > main > 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.
- **build-profile.json5** : application-level configuration information, including the signature and product configuration.
- **hvigorfile.js** : application-level compilation and build task script.
@@ -37,9 +36,10 @@
## Building the First Page
1. Use the **Text** component.
+
After the project synchronization is complete, choose **entry** > **src** > **main** > **ets** > **MainAbility** > **pages** in the **Project** window and open the **index.ets** file. You can see that the file contains a **<Text>** component. The sample code in the **index.ets** file is shown below:
-
+
```
@Entry
@Component
@@ -61,9 +61,10 @@
```
2. Add a **<Button>** component.
+
On the default page, add a **<Button>** component to accept user clicks and implement redirection to another page. The sample code in the **index.ets** file is shown below:
-
+
```
@Entry
@Component
@@ -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.

@@ -105,14 +108,16 @@
## Building the Second Page
1. Create the second page.
- In the **Project** window, choose **entry** > **src** > **main** > **ets** > **MainAbility**, right-click the **pages** folder, choose **New** > **Page**, name the page **second**, and click **Finish**. Below is the structure of the **pages** folder:
+
+ In the **Project** window, choose **entry** > **src** > **main** > **ets** > **MainAbility**, right-click the **pages** folder, choose **New** > **Page**, name the page **second**, and click **Finish**. Below, you can see the structure of the **pages** folder.
- 
+
2. Add **<Text>** and **<Button>** components.
+
Add **<Text>** and **<Button>** components and set their styles, as you do for the first page. The sample code in the **second.ets** file is shown below:
-
+
```
@Entry
@Component
@@ -151,9 +156,10 @@
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.
+
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:
-
+
```
import router from '@ohos.router';
@@ -194,9 +200,10 @@ You can implement page redirection through the page router, which finds the targ
```
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:
-
+
```
import router from '@ohos.router';
diff --git a/en/application-dev/quick-start/start-with-js-low-code.md b/en/application-dev/quick-start/start-with-js-low-code.md
index 0dfb03c4930dc927bf7e2305ebcfc7503936d1d4..a20c01c2f459fc07b799ca847683f99350dd4829 100644
--- a/en/application-dev/quick-start/start-with-js-low-code.md
+++ b/en/application-dev/quick-start/start-with-js-low-code.md
@@ -1,8 +1,7 @@
# Getting Started with JavaScript in the Low-Code Approach
->  **Note:**
-> This feature will be available in DevEco Studio V2.2 Beta1 and later versions.
->
+>  **NOTE** 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.
@@ -19,15 +18,15 @@ You can develop applications or services in the low-code approach using either o
## Creating a Project That Supports Low-Code Development
->  **Note:**
-> This feature is available in DevEco Studio 3.0 Beta2 and later versions and works with compileSdkVersion 7 or later.
+>  **NOTE** 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** > **New** > **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** > **New** > **Create Project**. Then, select **Empty Ability** and click **Next**.

2. Go to the project configuration page, select **Enable Super Visual**, set **UI Syntax** to **JS**, and retain the default values for other parameters.
- 
+ 
3. Click **Finish**. DevEco Studio will automatically generate the sample code and resources that match your project type. Wait until the project is created.
@@ -39,8 +38,8 @@ After the project synchronization is complete, a low-code directory structure is

- **entry > src > main > js > MainAbility > pages > index > 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.
- >  **Note:**
- > 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** > **MainAbility** > **pages** > **index**.
+ >  **NOTE** 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** > **MainAbility** > **pages** > **index**.
+ >
- **entry > src > main > supervisual > MainAbility > pages > index > 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
Add **Div**, **Text**, and **Button** components to the first page.
1. Delete the existing template components from the canvas.
- 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.
+
+
+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.
- 
+
2. Add a **Div** component and set its styles and attributes.
+
Drag the **Div** component from the **UI Control** area to the canvas. In the **Attributes & Styles** area on the right, click **General** and set **Height** to **100%** so that the component fills the entire screen. Click **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.
- 
+
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 & Styles** area, click **Properties** and set **Content** of the **Text** component to **Hello World**. Click **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.

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 & Styles** area on the right, click **Properties** and set **Value** of the **Button** component to **Next**. Click **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.

-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.

@@ -78,20 +84,23 @@ Add **Div**, **Text**, and **Button** components to the first page.
## Building the Second Page
1. Create the second page.
- In the **Project** window, choose **entry** > **src** > **main** > **js** > **MainAbility**, right-click the **pages** folder, choose **New** > **Visual**, name the page **second**, and click **Finish**. Below is the structure of the **pages** folder:
+
+ In the **Project** window, choose **entry** > **src** > **main** > **js** > **MainAbility**, right-click the **pages** folder, choose **New** > **Visual**, name the page **second**, and click **Finish**. Below, you can see the structure of the **pages** folder.
- 
+
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)
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 & Styles** area, click **Properties** and set **Content** of the **Text** component to **Hi there**. Click **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.

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 & Styles** area on the right, click **Properties** and set **Value** of the **Button** component to **Back**. Click **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.

@@ -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:
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:
```js
@@ -118,10 +129,11 @@ You can implement page redirection through the [page router](../ui/ui-js-buildin
```
- In the index.visual file, select the **Button** component on the canvas. In the **Attributes & Styles** area, click **Events** and set **Click** to **onclick**.
-
- 
-
+
+ 
+
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 .js and .visual files.
@@ -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 & Styles** area, click **Events** and set **Click** to **back**.
+ - In the **second.visual** file, select the **Button** component on the canvas. In the **Attributes & Styles** area, click **Events** and set **Click** to **back**.

diff --git a/en/application-dev/quick-start/start-with-js.md b/en/application-dev/quick-start/start-with-js.md
index 1935fd67953ad414d7267275dabdabffd185ece3..60131768f2dd3727a4d1467ca92896abb0239752 100644
--- a/en/application-dev/quick-start/start-with-js.md
+++ b/en/application-dev/quick-start/start-with-js.md
@@ -1,12 +1,12 @@
# Getting Started with JavaScript in the Traditional Coding Approach
->  **Note:**
-> 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.
+>  **NOTE** 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
-1. Open DevEco Studio, choose **File** > **New** > **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** > **New** > **Create Project**. Then, select **Empty Ability** and click **Next**.

@@ -19,26 +19,27 @@
## JavaScript Project Files
-- **entry** : OpenHarmony project module, which can be built into an ability package (HAP).
- - **src > main > js** : a collection of JS source code.
- - **src > main > js > MainAbility** : entry to your application/service.
- - **src > main > js > MainAbility > i18n** : resources in different languages, for example, UI strings and image paths.
- - **src > main > js > MainAbility > pages** : pages contained in **MainAbility**.
- - **src > main > js > MainAbility > app.js** : ability lifecycle file.
- - **src > main > resources** : a collection of resource files used by your application/service, such as graphics, multimedia, character strings, and layout files.
- - **src > main > 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**.
- - **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.
-- **hvigorfile.js** : application-level compilation and build task script.
+- **entry** : OpenHarmony project module, which can be built into an ability package ([HAP](../../glossary.md#hap)).
+ - **src > main > js**: a collection of JS source code.
+ - **src > main > js > MainAbility**: entry to your application/service.
+ - **src > main > js > MainAbility > i18n**: resources in different languages, for example, UI strings and image paths.
+ - **src > main > js > MainAbility > pages**: pages contained in **MainAbility**.
+ - **src > main > js > MainAbility > app.js**: ability lifecycle file.
+ - **src > main > resources**: a collection of resource files used by your application/service, such as graphics, multimedia, character strings, and layout files.
+ - **src > main > 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**: 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.
+- **build-profile.json5**: application-level configuration information, including the signature and product configuration.
+- **hvigorfile.js**: application-level compilation and build task script.
## Building the First Page
1. Use the **Text** component.
+
After the project synchronization is complete, choose **entry** > **src** > **main** > **js** > **MainAbility** > **pages** > **index** in the **Project** window and open the **index.hml** file. You can see that the file contains a **<Text>** component. The sample code in the **index.hml** file is shown below:
-
+
```
@@ -48,9 +49,10 @@
```
2. Add a button and bind the **onclick** method to this button.
+
On the default page, add an **<input>** 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,9 +65,10 @@
```
3. Set the page style in the **index.css** file.
+
From the **Project** window, choose **entry** > **src** > **main** > **js** > **MainAbility** > **pages** > **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:
-
+
```
.container {
display: flex;
@@ -96,22 +99,26 @@
}
```
-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.
+

## Building the Second Page
1. Create the second page.
- In the **Project** window, choose **entry** > **src** > **main** > **js** > **MainAbility**, right-click the **pages** folder, choose **New** > **Page**, name the page **second**, and click **Finish**. Below is the structure of the **second** folder:
+
+ In the **Project** window, choose **entry** > **src** > **main** > **js** > **MainAbility**, right-click the **pages** folder, choose **New** > **Page**, name the page **second**, and click **Finish**. Below, you can see the structure of the **second** folder.
- 
+
2. Add **<Text>** and **<Button>** components.
+
Add **<Text>** and **<Button>** components and set their styles, as you do for the first page. The sample code in the **second.hml** file is shown below:
-
+
```
@@ -124,7 +131,7 @@
```
3. Set the page style in the **second.css** file. The sample code in the **second.css** file is shown below:
-
+
```
.container {
display: flex;
@@ -161,9 +168,10 @@
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.
+
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:
-
+
```
import router from '@ohos.router';
@@ -177,9 +185,10 @@ You can implement page redirection through the [page router](../ui/ui-js-buildin
```
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:
-
+
```
import router from '@ohos.router';
diff --git a/en/application-dev/reference/apis/js-apis-inputmethod.md b/en/application-dev/reference/apis/js-apis-inputmethod.md
index 6e5ef326d3bc6362f59ce7b6fffa2ea0214e94f4..deb605abe2bb17257c62c4e7004eabe97557e0cf 100644
--- a/en/application-dev/reference/apis/js-apis-inputmethod.md
+++ b/en/application-dev/reference/apis/js-apis-inputmethod.md
@@ -1,7 +1,7 @@
# Input Method Framework
->  **NOTE**
-> 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.
+>  **NOTE** 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
@@ -40,16 +40,18 @@ Obtains an [InputMethodController](#InputMethodController) instance.
**System capability**: SystemCapability.Miscservices.InputMethodFramework
-- Return value
+**Return value**
- | Type| Description|
- | -------- | -------- |
- | [InputMethodController](#InputMethodController) | Returns the current **InputMethodController** instance.|
+| Type| Description|
+| -------- | -------- |
+| [InputMethodController](#InputMethodController) | Returns the current **InputMethodController** instance.|
+
+**Example**
+
+```
+var InputMethodController = inputMethod.getInputMethodController();
+```
-- Example
- ```
- var InputMethodController = inputMethod.getInputMethodController();
- ```
## inputMethod.getInputMethodSetting8+
getInputMethodSetting(): InputMethodSetting
@@ -58,17 +60,17 @@ Obtains an [InputMethodSetting](#InputMethodSetting) instance.
**System capability**: SystemCapability.Miscservices.InputMethodFramework
-- Return value
+**Return value**
- | Type | Description |
- | ----------------------------------------- | ---------------------------- |
- | [InputMethodSetting](#InputMethodSetting) | Returns the current **InputMethodSetting** instance.|
+| Type | Description |
+| ----------------------------------------- | ---------------------------- |
+| [InputMethodSetting](#InputMethodSetting) | Returns the current **InputMethodSetting** instance.|
+**Example**
-- Example
- ```
- var InputMethodSetting = inputMethod.getInputMethodSetting();
- ```
+```js
+var InputMethodSetting = inputMethod.getInputMethodSetting();
+```
## InputMethodController
@@ -82,15 +84,15 @@ Hides the keyboard. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Miscservices.InputMethodFramework
-- Parameters
+**Parameters**
- | Name| Type| Mandatory| Description|
- | -------- | -------- | -------- | -------- |
- | callback | AsyncCallback<boolean> | Yes| Callback used to return whether the keyboard is successfully hidden.|
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| callback | AsyncCallback<boolean> | Yes| Callback used to return whether the keyboard is successfully hidden.|
-- Example
+**Example**
-```
+```js
InputMethodController.stopInput((error)=>{
console.info('stopInput');
});
@@ -104,16 +106,16 @@ Hides the keyboard. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Miscservices.InputMethodFramework
-- Return value
+**Return value**
- | Type| Description|
- | -------- | -------- |
- | Promise<boolean> | Promise used to return whether the keyboard is successfully hidden.|
+| Type| Description|
+| -------- | -------- |
+| Promise<boolean> | Promise used to return whether the keyboard is successfully hidden.|
-- Example
+**Example**
-```
+```js
var isSuccess = InputMethodController.stopInput();
console.info('stopInput isSuccess = ' + isSuccess);
```
@@ -130,20 +132,22 @@ Obtains the list of installed input methods. This API uses an asynchronous callb
**System capability**: SystemCapability.Miscservices.InputMethodFramework
-- Parameters
- | Name | Type | Mandatory| Description |
- | -------- | -------------------------------------------------- | ---- | ---------------------- |
- | callback | Array<[InputMethodProperty](#InputMethodProperty)> | Yes | Callback used to return the list of installed input methods.|
-
-- Example
- ```
- InputMethodSetting.listInputMethod((properties)=>{
- for (var i = 0;i < properties.length; i++) {
- var property = properties[i];
- console.info(property.packageName + "/" + property.methodId);
- }
- });
- ```
+**Parameters**
+
+| Name | Type | Mandatory| Description |
+| -------- | -------------------------------------------------- | ---- | ---------------------- |
+| callback | Array<[InputMethodProperty](#InputMethodProperty)> | Yes | Callback used to return the list of installed input methods.|
+
+**Example**
+
+```js
+ InputMethodSetting.listInputMethod((properties)=>{
+ for (var i = 0;i < properties.length; i++) {
+ var property = properties[i];
+ console.info(property.packageName + "/" + property.methodId);
+ }
+});
+```
### listInputMethod
@@ -153,19 +157,21 @@ Obtains the list of installed input methods. This API uses an asynchronous callb
**System capability**: SystemCapability.Miscservices.InputMethodFramework
-- Return value
- | Type | Description |
- | ----------------------------------------------------------- | ---------------------- |
- | Promise> | Promise used to return the list of installed input methods.|
+**Return value**
-- Example
- ```
- var properties = InputMethodSetting.listInputMethod();
- for (var i = 0;i < properties.length; i++) {
- var property = properties[i];
- console.info(property.packageName + "/" + property.methodId);
- }
- ```
+| Type | Description |
+| ----------------------------------------------------------- | ---------------------- |
+| Promise> | Promise used to return the list of installed input methods.|
+
+**Example**
+
+```js
+ var properties = InputMethodSetting.listInputMethod();
+ for (var i = 0;i < properties.length; i++) {
+ var property = properties[i];
+ console.info(property.packageName + "/" + property.methodId);
+ }
+```
### displayOptionalInputMethod
@@ -181,12 +187,12 @@ Displays a dialog box for selecting an input method. This API uses an asynchrono
| -------- | -------- | -------- | -------- |
| callback | AsyncCallback<void> | Yes| Callback used to return the execution result.|
-- Example
- ```
- InputMethodSetting.displayOptionalInputMethod(()=>{
- console.info('displayOptionalInputMethod is called');
- });
- ```
+**Example**
+```js
+ InputMethodSetting.displayOptionalInputMethod(()=>{
+ console.info('displayOptionalInputMethod is called');
+ });
+```
### displayOptionalInputMethod
@@ -194,15 +200,16 @@ displayOptionalInputMethod(): Promise<void>
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|
| -------- | -------- |
| Promise<void> | Promise used to return the execution result.|
- - Example
- ```
- InputMethodSetting.displayOptionalInputMethod();
- ```
+**Example**
+
+```js
+ InputMethodSetting.displayOptionalInputMethod();
+```
\ No newline at end of file
diff --git a/en/application-dev/reference/apis/js-apis-inputmethodengine.md b/en/application-dev/reference/apis/js-apis-inputmethodengine.md
index ba43211b4ae577be55718a6d32f50a565b2093b5..753992ebd71d29a5a2bc77b717ef0df6cd988125 100644
--- a/en/application-dev/reference/apis/js-apis-inputmethodengine.md
+++ b/en/application-dev/reference/apis/js-apis-inputmethodengine.md
@@ -1,7 +1,7 @@
# Input Method Engine
->  **NOTE**
-> 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.
+>  **NOTE** 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
@@ -52,17 +52,17 @@ Obtains an **InputMethodEngine** instance.
**System capability**: SystemCapability.Miscservices.InputMethodFramework
-- Return value
+**Return value**
- | Type | Description |
- | --------------------------------------- | ------------ |
- | [InputMethodEngine](#InputMethodEngine) | **InputMethodEngine** instance obtained.|
+| Type | Description |
+| --------------------------------------- | ------------ |
+| [InputMethodEngine](#InputMethodEngine) | **InputMethodEngine** instance obtained.|
-- Example
+**Example**
- ```
- var InputMethodEngine = inputMethodEngine.getInputMethodEngine();
- ```
+```js
+var InputMethodEngine = inputMethodEngine.getInputMethodEngine();
+```
## inputMethodEngine.createKeyboardDelegate
@@ -72,17 +72,17 @@ Obtains a **KeyboardDelegate** instance.
**System capability**: SystemCapability.Miscservices.InputMethodFramework
-- Return value
+**Return value**
- | Type | Description |
- | ------------------------------------- | ---------------- |
- | [KeyboardDelegate](#KeyboardDelegate) | **KeyboardDelegate** instance obtained.|
+| Type | Description |
+| ------------------------------------- | ---------------- |
+| [KeyboardDelegate](#KeyboardDelegate) | **KeyboardDelegate** instance obtained.|
-- Example
+**Example**
- ```
- var KeyboardDelegate = inputMethodEngine.createKeyboardDelegate();
- ```
+```js
+var KeyboardDelegate = inputMethodEngine.createKeyboardDelegate();
+```
## InputMethodEngine
@@ -96,21 +96,21 @@ Listens for the input method binding event. This API uses a callback to return t
**System capability**: SystemCapability.Miscservices.InputMethodFramework
-- Parameters
+**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ------------------------------- | ---- | ------------------------------------------------------------ |
| type | string | Yes | Listening type. 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.|
-- Example
+**Example**
- ```
- InputMethodEngine.on('inputStart', (kbController, textInputClient) => {
- KeyboardController = kbController;
- TextInputClient = textInputClient;
- });
- ```
+```js
+InputMethodEngine.on('inputStart', (kbController, textInputClient) => {
+ KeyboardController = kbController;
+ TextInputClient = textInputClient;
+});
+```
### off('inputStart')
@@ -120,20 +120,18 @@ Cancels listening for the input method binding event.
**System capability**: SystemCapability.Miscservices.InputMethodFramework
-- Parameters
-
- | Name | Type | Mandatory| Description |
- | -------- | -------------------- | ---- | ------------------------ |
- | type | string | Yes | Listening type. 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.|
-
+**Parameters**
+| Name | Type | Mandatory| Description |
+| -------- | -------------------- | ---- | ------------------------ |
+| type | string | Yes | Listening type. 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**
- ```
- InputMethodEngine.off('inputStart');
- ```
+```js
+InputMethodEngine.off('inputStart');
+```
### on('keyboardShow'|'keyboardHide')
@@ -143,20 +141,20 @@ Listens for an input method event.
**System capability**: SystemCapability.Miscservices.InputMethodFramework
-- Parameters
+**Parameters**
- | Name | Type | Mandatory| Description |
- | -------- | ------ | ---- | ------------------------------------------------------------ |
- | type | string | Yes | Listening type. - The value **'keyboardShow'** means to listen for displaying of the input method. - The value **'keyboardHide'** means to listen for hiding of the input method.|
- | callback | void | No | Callback used to return the result. |
+| Name | Type | Mandatory| Description |
+| -------- | ------ | ---- | ------------------------------------------------------------ |
+| type | string | Yes | Listening type. - The value **'keyboardShow'** means to listen for displaying of the input method. - The value **'keyboardHide'** means to listen for hiding of the input method.|
+| callback | void | No | Callback used to return the result. |
-- Example
+**Example**
- ```
- InputMethodEngine.on('keyboardShow', (err) => {
- console.info('keyboardShow');
- });
- ```
+```js
+InputMethodEngine.on('keyboardShow', (err) => {
+ console.info('keyboardShow');
+});
+```
### off('keyboardShow'|'keyboardHide')
@@ -166,19 +164,18 @@ Cancels listening for an input method event.
**System capability**: SystemCapability.Miscservices.InputMethodFramework
-- Parameters
+**Parameters**
- | Name | Type | Mandatory| Description |
- | -------- | ------ | ---- | ------------------------------------------------------------ |
- | type | string | Yes | Listening type. - The value **'keyboardShow'** means to listen for displaying of the input method. - The value **'keyboardHide'** means to listen for hiding of the input method.|
- | callback | void | No | Callback used to return the result. |
+| Name | Type | Mandatory| Description |
+| -------- | ------ | ---- | ------------------------------------------------------------ |
+| type | string | Yes | Listening type. - The value **'keyboardShow'** means to listen for displaying of the input method. - The value **'keyboardHide'** means to listen for hiding of the input method.|
+| callback | void | No | Callback used to return the result. |
-- Example
+**Example**
- ```
- InputMethodEngine.off('keyboardShow');
- ```
-
+```js
+InputMethodEngine.off('keyboardShow');
+```
## KeyboardDelegate
@@ -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
-- Parameters
-
- | Name | Type | Mandatory| Description |
- | -------- | ------------------------------- | ---- | ------------------------------------------------------------ |
- | type | string | Yes | Listening type. - The value **'keyDown'** means to listen for pressing of a key. - The value **'keyUp'** means to listen for releasing of a key.|
- | callback | [KeyEvent](#KeyEvent) | Yes| Callback used to return the key information.|
-
+**Parameters**
+| Name | Type | Mandatory| Description |
+| -------- | ------------------------------- | ---- | ------------------------------------------------------------ |
+| type | string | Yes | Listening type. - The value **'keyDown'** means to listen for pressing of a key. - The value **'keyUp'** means to listen for releasing of a key.|
+| callback | [KeyEvent](#KeyEvent) | Yes| Callback used to return the key information.|
-- Example
+**Example**
- ```
- KeyboardDelegate.on('keyDown', (event) => {
- console.info('keyDown');
- });
- ```
+```js
+KeyboardDelegate.on('keyDown', (event) => {
+ console.info('keyDown');
+});
+```
### off('keyDown'|'keyUp')
@@ -217,18 +212,18 @@ Cancels listening for a hard keyboard even.
**System capability**: SystemCapability.Miscservices.InputMethodFramework
-- Parameters
+**Parameters**
- | Name | Type | Mandatory| Description |
- | -------- | --------------------- | ---- | ------------------------------------------------------------ |
- | type | string | Yes | Listening type. - The value **'keyDown'** means to listen for pressing of a key. - The value **'keyUp'** means to listen for releasing of a key.|
- | callback | [KeyEvent](#KeyEvent) | No | Callback used to return the key information. |
+| Name | Type | Mandatory| Description |
+| -------- | --------------------- | ---- | ------------------------------------------------------------ |
+| type | string | Yes | Listening type. - The value **'keyDown'** means to listen for pressing of a key. - The value **'keyUp'** means to listen for releasing of a key.|
+| callback | [KeyEvent](#KeyEvent) | No | Callback used to return the key information. |
-- Example
+**Example**
- ```
- KeyboardDelegate.off('keyDown');
- ```
+```js
+KeyboardDelegate.off('keyDown');
+```
### on('cursorContextChange')
@@ -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.
- **System capability**: SystemCapability.Miscservices.InputMethodFramework
-
- - Parameters
+**System capability**: SystemCapability.Miscservices.InputMethodFramework
- | Name | Type | Mandatory| Description |
- | -------- | ------ | ---- | ------------------------------------------------------------ |
- | type | string | Yes | Listening type. 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. Set it to **'cursorContextChange'**, which indicates listening for cursor context changes.|
+| callback | number | Yes | Callback used to return the cursor information. |
+**Example**
- - Example
-
- ```
- KeyboardDelegate.on('cursorContextChange', (x, y, height) => {
- console.info('cursorContextChange');
- });
- ```
+```js
+KeyboardDelegate.on('cursorContextChange', (x, y, height) => {
+ console.info('cursorContextChange');
+});
+```
### off('cursorContextChange')
@@ -263,19 +256,19 @@ Cancels listening for cursor context changes.
**System capability**: SystemCapability.Miscservices.InputMethodFramework
- - Parameters
+**Parameters**
- | Name | Type | Mandatory| Description |
- | -------- | -------------------- | ---- | ------------------------ |
- | type | string | Yes | Listening type. Set it to **'cursorContextChange'**, which indicates listening for cursor context changes.|
- | callback | number | No| Callback used to return the cursor information.|
+| Name | Type | Mandatory| Description |
+| -------- | -------------------- | ---- | ------------------------ |
+| type | string | Yes | Listening type. Set it to **'cursorContextChange'**, which indicates listening for cursor context changes.|
+| callback | number | No| Callback used to return the cursor information.|
+**Example**
- - Example
+```js
+KeyboardDelegate.off('cursorContextChange');
+```
- ```
- KeyboardDelegate.off('cursorContextChange');
- ```
### on('selectionChange')
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
**System capability**: SystemCapability.Miscservices.InputMethodFramework
- - Parameters
+**Parameters**
+
+| Name | Type | Mandatory| Description |
+| -------- | ------ | ---- | ------------------------------------------------------------ |
+| type | string | Yes | Listening type. Set it to **'selectionChange'**, which indicates listening for text selection changes.|
+| callback | number | Yes | Callback used to return the text selection information. |
- | Name | Type | Mandatory| Description |
- | -------- | ------ | ---- | ------------------------------------------------------------ |
- | type | string | Yes | Listening type. Set it to **'selectionChange'**, which indicates listening for text selection changes.|
- | callback | number | Yes | Callback used to return the text selection information. |
+**Example**
- - Example
-
- ```
- KeyboardDelegate.on('selectionChange', (oldBegin, oldEnd, newBegin, newEnd) => {
- console.info('selectionChange');
- });
- ```
+```js
+KeyboardDelegate.on('selectionChange', (oldBegin, oldEnd, newBegin, newEnd) => {
+ console.info('selectionChange');
+});
+```
### off('selectionChange')
@@ -307,18 +300,18 @@ Cancels listening for text selection changes.
**System capability**: SystemCapability.Miscservices.InputMethodFramework
- - Parameters
+**Parameters**
- | Name | Type | Mandatory| Description |
- | -------- | -------------------- | ---- | ------------------------ |
- | type | string | Yes | Listening type. Set it to **'selectionChange'**, which indicates listening for text selection changes.|
- | callback | number | No| Callback used to return the text selection information.|
+| Name | Type | Mandatory| Description |
+| -------- | -------------------- | ---- | ------------------------ |
+| type | string | Yes | Listening type. Set it to **'selectionChange'**, which indicates listening for text selection changes.|
+| callback | number | No| Callback used to return the text selection information.|
- - Example
+**Example**
- ```
- KeyboardDelegate.off('selectionChange');
- ```
+```js
+KeyboardDelegate.off('selectionChange');
+```
### on('textChange')
@@ -329,20 +322,20 @@ Listens for text changes. This API uses a callback to return the current text co
**System capability**: SystemCapability.Miscservices.InputMethodFramework
- - Parameters
+**Parameters**
- | Name | Type | Mandatory| Description |
- | -------- | ------------------------------- | ---- | ------------------------------------------------------------ |
- | type | string | Yes | Listening type. Set it to **'textChange'**, which indicates listening for text changes.|
- | callback | string | Yes| Callback used to return the current text content.|
+| Name | Type | Mandatory| Description |
+| -------- | ------------------------------- | ---- | ------------------------------------------------------------ |
+| type | string | Yes | Listening type. Set it to **'textChange'**, which indicates listening for text changes.|
+| callback | string | Yes| Callback used to return the current text content.|
- - Example
+**Example**
- ```
- KeyboardDelegate.on('textChange', (text) => {
- console.info('textChange');
- });
- ```
+```js
+KeyboardDelegate.on('textChange', (text) => {
+ console.info('textChange');
+});
+```
### off('textChange')
@@ -352,18 +345,18 @@ Cancels listening for text changes.
**System capability**: SystemCapability.Miscservices.InputMethodFramework
- - Parameters
+**Parameters**
- | Name | Type | Mandatory| Description |
- | -------- | -------------------- | ---- | ------------------------ |
- | type | string | Yes | Listening type. Set it to **'textChange'**, which indicates listening for text changes.|
- | callback | string | No| Callback used to return the current text content.|
+| Name | Type | Mandatory| Description |
+| -------- | -------------------- | ---- | ------------------------ |
+| type | string | Yes | Listening type. Set it to **'textChange'**, which indicates listening for text changes.|
+| callback | string | No| Callback used to return the current text content.|
- - Example
+**Example**
- ```
- KeyboardDelegate.off('textChange');
- ```
+```js
+KeyboardDelegate.off('textChange');
+```
## KeyboardController
@@ -377,16 +370,16 @@ Hides the keyboard. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Miscservices.InputMethodFramework
-- Parameters
+**Parameters**
- | Name | Type | Mandatory| Description |
- | -------- | ---------------------- | ---- | -------- |
- | callback | AsyncCallback<void> | No | Callback used to return the result.|
+| Name | Type | Mandatory| Description |
+| -------- | ---------------------- | ---- | -------- |
+| callback | AsyncCallback<void> | No | Callback used to return the result.|
-- Example
+**Example**
-```
+```js
KeyboardController.hideKeyboard(()=>{
});
```
@@ -399,16 +392,16 @@ Hides the keyboard. This API uses a promise to return the result.
**System capability**: SystemCapability.Miscservices.InputMethodFramework
-- Return value
+**Return value**
- | Type | Description: |
- | ---------------- | -------- |
- | Promise<void> | Promise used to return the result.|
+| Type | Description: |
+| ---------------- | -------- |
+| Promise<void> | Promise used to return the result.|
-- Example
+**Example**
-```
+```js
KeyboardController.hideKeyboard();
```
@@ -424,19 +417,20 @@ Obtains the specific-length text before the cursor. This API uses an asynchronou
**System capability**: SystemCapability.Miscservices.InputMethodFramework
-- Parameters
+**Parameters**
+
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| length | number | Yes| Text length.|
+| callback | AsyncCallback<string> | Yes| Text returned.|
- | Name| Type| Mandatory| Description|
- | -------- | -------- | -------- | -------- |
- | length | number | Yes| Text length.|
- | callback | AsyncCallback<string> | Yes| Text returned.|
+**Example**
-- Example
- ```
- TextInputClient.getForward(5,(text) =>{
- console.info("text = " + text);
- });
- ```
+```js
+ TextInputClient.getForward(5,(text) =>{
+ console.info("text = " + text);
+ });
+```
### getForward
@@ -446,22 +440,24 @@ Obtains the specific-length text before the cursor. This API uses a promise to r
**System capability**: SystemCapability.Miscservices.InputMethodFramework
-- Parameters
+**Parameters**
- | Name| Type| Mandatory| Description|
- | -------- | -------- | -------- | -------- |
- | length | number | Yes| Text length.|
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| length | number | Yes| Text length.|
-- Return value
- | Type | Description |
- | ------------------------------- | ------------------------------------------------------------ |
- | Promise<string> | Text returned. |
+**Return value**
-- Example
- ```
- var text = TextInputClient.getForward(5);
- console.info("text = " + text);
- ```
+| Type | Description |
+| ------------------------------- | ------------------------------------------------------------ |
+| Promise<string> | Text returned. |
+
+**Example**
+
+```js
+ var text = TextInputClient.getForward(5);
+ console.info("text = " + text);
+```
### getBackward
@@ -471,19 +467,20 @@ Obtains the specific-length text after the cursor. This API uses an asynchronous
**System capability**: SystemCapability.Miscservices.InputMethodFramework
-- Parameters
+**Parameters**
- | Name| Type| Mandatory| Description|
- | -------- | -------- | -------- | -------- |
- | length | number | Yes| Text length.|
- | callback | AsyncCallback<string> | Yes| Text returned.|
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| length | number | Yes| Text length.|
+| callback | AsyncCallback<string> | Yes| Text returned.|
-- Example
- ```
- TextInputClient.getBackward(5,(text)=>{
- console.info("text = " + text);
- });
- ```
+**Example**
+
+```js
+ TextInputClient.getBackward(5,(text)=>{
+ console.info("text = " + text);
+});
+```
### getBackward
@@ -493,22 +490,24 @@ Obtains the specific-length text after the cursor. This API uses a promise to re
**System capability**: SystemCapability.Miscservices.InputMethodFramework
-- Parameters
+**Parameters**
- | Name| Type| Mandatory| Description|
- | -------- | -------- | -------- | -------- |
- | length | number | Yes| Text length.|
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| length | number | Yes| Text length.|
-- Return value
- | Type | Description |
- | ------------------------------- | ------------------------------------------------------------ |
- | Promise<string> | Text returned. |
+**Return value**
-- Example
- ```
- var text = TextInputClient.getBackward(5);
- console.info("text = " + text);
- ```
+| Type | Description |
+| ------------------------------- | ------------------------------------------------------------ |
+| Promise<string> | Text returned. |
+
+**Example**
+
+```js
+ var text = TextInputClient.getBackward(5);
+ console.info("text = " + text);
+```
### deleteForward
@@ -518,19 +517,21 @@ Deletes the fixed-length text before the cursor. This API uses an asynchronous c
**System capability**: SystemCapability.Miscservices.InputMethodFramework
-- Parameters
+**Parameters**
- | Name| Type| Mandatory| Description|
- | -------- | -------- | -------- | -------- |
- | length | number | Yes| Text length.|
- | callback | AsyncCallback<boolean> | Yes| Returns whether the operation is successful.|
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| length | number | Yes| Text length.|
+| callback | AsyncCallback<boolean> | Yes| Returns whether the operation is successful.|
+
+**Example**
+
+```js
+TextInputClient.deleteForward(5,(isSuccess)=>{
+ console.info("isSuccess = " + isSuccess);
+});
+```
-- Example
- ```
- TextInputClient.deleteForward(5,(isSuccess)=>{
- console.info("isSuccess = " + isSuccess);
- });
- ```
### deleteForward
deleteForward(length:number): Promise<boolean>
@@ -539,23 +540,25 @@ Deletes the fixed-length text before the cursor. This API uses a promise to retu
**System capability**: SystemCapability.Miscservices.InputMethodFramework
-- Parameters
-
- | Name| Type| Mandatory| Description|
- | -------- | -------- | -------- | -------- |
- | length | number | Yes| Text length.|
-
-- Return value
- | Type | Description |
- | ------------------------------- | ------------------------------------------------------------ |
- | Promise<boolean> | Returns whether the operation is successful. |
-
- - Example
- ```
- var isSuccess = TextInputClient.deleteForward(5);
- console.info("isSuccess = " + isSuccess);
- ```
-
+**Parameters**
+
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| length | number | Yes| Text length.|
+
+**Return value**
+
+| Type | Description |
+| ------------------------------- | ------------------------------------------------------------ |
+| Promise<boolean> | Returns whether the operation is successful. |
+
+**Example**
+
+```js
+ var isSuccess = TextInputClient.deleteForward(5);
+ console.info("isSuccess = " + isSuccess);
+```
+
### deleteBackward
deleteBackward(length:number, callback: AsyncCallback<boolean>): void
@@ -564,19 +567,20 @@ Deletes the fixed-length text after the cursor. This API uses an asynchronous ca
**System capability**: SystemCapability.Miscservices.InputMethodFramework
- - Parameters
+**Parameters**
- | Name| Type| Mandatory| Description|
- | -------- | -------- | -------- | -------- |
- | length | number | Yes| Text length.|
- | callback | AsyncCallback<boolean> | Yes| Returns whether the operation is successful.|
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| length | number | Yes| Text length.|
+| callback | AsyncCallback<boolean> | Yes| Returns whether the operation is successful.|
- - Example
- ```
- TextInputClient.deleteBackward(5, (isSuccess)=>{
- console.info("isSuccess = " + isSuccess);
- });
- ```
+**Example**
+
+```js
+ TextInputClient.deleteBackward(5, (isSuccess)=>{
+ console.info("isSuccess = " + isSuccess);
+});
+```
### deleteBackward
@@ -586,22 +590,25 @@ Deletes the fixed-length text after the cursor. This API uses a promise to retur
**System capability**: SystemCapability.Miscservices.InputMethodFramework
-- Parameters
- | Name| Type| Mandatory| Description|
- | -------- | -------- | -------- | -------- |
- | length | number | Yes| Text length.|
+**Parameters**
+
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| length | number | Yes| Text length.|
-- Return value
- | Type | Description |
- | ------------------------------- | ------------------------------------------------------------ |
- | Promise<boolean> | Returns whether the operation is successful. |
+**Return value**
-- Example
+| Type | Description |
+| ------------------------------- | ------------------------------------------------------------ |
+| Promise<boolean> | 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(action:number, callback: AsyncCallback<boolean>): void
@@ -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
- - Parameters
+**Parameters**
- | Name| Type| Mandatory| Description|
- | -------- | -------- | -------- | -------- |
- | action | number | Yes| Edit box attribute.|
- | callback | AsyncCallback<boolean> | Yes| Returns whether the operation is successful.|
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| action | number | Yes| Edit box attribute.|
+| callback | AsyncCallback<boolean> | Yes| Returns whether the operation is successful.|
- - Example
- ```
- TextInputClient.sendKeyFunction(inputMethod.ENTER_KEY_TYPE_NEXT,(isSuccess)=>{
- console.info("isSuccess = " + isSuccess);
- });
- ```
+**Example**
+
+```js
+ TextInputClient.sendKeyFunction(inputMethod.ENTER_KEY_TYPE_NEXT,(isSuccess)=>{
+ console.info("isSuccess = " + isSuccess);
+});
+```
### sendKeyFunction
@@ -632,23 +640,25 @@ Sets the Enter key to send the text to its target. This API uses a promise to re
**System capability**: SystemCapability.Miscservices.InputMethodFramework
-- Parameters
- | Name| Type| Mandatory| Description|
- | -------- | -------- | -------- | -------- |
- | action | number | Yes| Edit box attribute.|
+**Parameters**
-- Return value
- | Type | Description |
- | ------------------------------- | ------------------------------------------------------------ |
- | Promise<boolean> | Returns whether the operation is successful. |
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| action | number | Yes| Edit box attribute.|
-- Example
+**Return value**
+
+| Type | Description |
+| ------------------------------- | ------------------------------------------------------------ |
+| Promise<boolean> | Returns whether the operation is successful. |
+
+**Example**
+
+```js
+var isSuccess = TextInputClient.sendKeyFunction(inputMethod.ENTER_KEY_TYPE_NEXT);
+console.info("isSuccess = " + isSuccess);
+```
- ```
- var isSuccess = TextInputClient.sendKeyFunction(inputMethod.ENTER_KEY_TYPE_NEXT);
- console.info("isSuccess = " + isSuccess);
- ```
-
### insertText
insertText(text:string, callback: AsyncCallback<boolean>): void
@@ -657,19 +667,20 @@ Inserts text. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Miscservices.InputMethodFramework
-- Parameters
+**Parameters**
- | Name| Type| Mandatory| Description|
- | -------- | -------- | -------- | -------- |
- | text | string | Yes| Text to insert.|
- | callback | AsyncCallback<boolean> | Yes| Returns whether the operation is successful.|
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| text | string | Yes| Text to insert.|
+| callback | AsyncCallback<boolean> | Yes| Returns whether the operation is successful.|
-- Example
- ```
- TextInputClient.insertText("test", (isSuccess)=>{
- console.info("isSuccess = " + isSuccess);
- });
- ```
+**Example**
+
+```js
+TextInputClient.insertText("test", (isSuccess)=>{
+ console.info("isSuccess = " + isSuccess);
+});
+```
### insertText
@@ -679,23 +690,25 @@ Inserts text. This API uses a promise to return the result.
**System capability**: SystemCapability.Miscservices.InputMethodFramework
-- Parameters
- | Name| Type| Mandatory| Description|
- | -------- | -------- | -------- | -------- |
- | text | string | Yes| Text to insert.|
+**Parameters**
-- Return value
- | Type | Description |
- | ------------------------------- | ------------------------------------------------------------ |
- | Promise<boolean> | Returns whether the operation is successful. |
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| text | string | Yes| Text to insert.|
-- Example
+**Return value**
+
+| Type | Description |
+| ------------------------------- | ------------------------------------------------------------ |
+| Promise<boolean> | Returns whether the operation is successful. |
+
+**Example**
+
+```js
+var isSuccess = TextInputClient.insertText("test");
+console.info("isSuccess = " + isSuccess);
+```
- ```
- var isSuccess = TextInputClient.insertText("test");
- console.info("isSuccess = " + isSuccess);
- ```
-
### getEditorAttribute
getEditorAttribute(callback: AsyncCallback<EditorAttribute>): void
@@ -704,16 +717,18 @@ Obtains the attribute of the edit box. This API uses an asynchronous callback to
**System capability**: SystemCapability.Miscservices.InputMethodFramework
-- Parameters
- | Name | Type | Mandatory | Description |
- | ------------------------------- | ------------------------------------------------------------ | ------------------------------------------------------------ | ------------------------------------------------------------ |
- | callback | AsyncCallback<[EditorAttribute](#EditorAttribute)> | Yes| Attribute of the edit box. |
+**Parameters**
+
+| Name | Type | Mandatory | Description |
+| ------------------------------- | ------------------------------------------------------------ | ------------------------------------------------------------ | ------------------------------------------------------------ |
+| callback | AsyncCallback<[EditorAttribute](#EditorAttribute)> | Yes| Attribute of the edit box. |
+
+**Example**
-- Example
- ```
- TextInputClient.getEditorAttribute((EditorAttribute)=>{
- });
- ```
+```js
+ TextInputClient.getEditorAttribute((EditorAttribute)=>{
+ });
+```
### getEditorAttribute
@@ -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
-- Return value
- | Type | Description |
- | ------------------------------- | ------------------------------------------------------------ |
- | Promise<[EditorAttribute](#EditorAttribute)> | Returns the attribute of the edit box. |
+**Return value**
+
+| Type | Description |
+| ------------------------------- | ------------------------------------------------------------ |
+| Promise<[EditorAttribute](#EditorAttribute)> | Returns the attribute of the edit box. |
-- Example
- ```
- var EditorAttribute = TextInputClient.getEditorAttribute();
- ```
+**Example**
+
+```js
+var EditorAttribute = TextInputClient.getEditorAttribute();
+```
## EditorAttribute
diff --git a/en/application-dev/reference/apis/js-apis-pasteboard.md b/en/application-dev/reference/apis/js-apis-pasteboard.md
index f6bfa278469a5c930c2140078ceee5f0613ec56b..b12ac722319812d2682821495dffe35ebde1000c 100644
--- a/en/application-dev/reference/apis/js-apis-pasteboard.md
+++ b/en/application-dev/reference/apis/js-apis-pasteboard.md
@@ -1,8 +1,8 @@
# Pasteboard
->  **Note:**
-> 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.
+>  **NOTE** 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
@@ -19,11 +19,11 @@ import pasteboard from '@ohos.pasteboard';
| Name | Type | Readable | Writable | Description |
| -------- | -------- | -------- | -------- | -------- |
-| MAX_RECORD_NUM7+ | number | Yes | No | Maximum number of records allowed in a **PasteData** object. |
-| MIMETYPE_TEXT_HTML7+ | string | Yes | No | MIME type of the HTML text. |
-| MIMETYPE_TEXT_WANT7+ | string | Yes | No | MIME type of the Want text. |
-| MIMETYPE_TEXT_PLAIN7+ | string | Yes | No | MIME type of the plain text. |
-| MIMETYPE_TEXT_URI7+ | string | Yes | No | MIME type of the URI text. |
+| MAX_RECORD_NUM7+ | number | Yes | No | Maximum number of records allowed in a **PasteData** object. |
+| MIMETYPE_TEXT_HTML7+ | string | Yes | No | MIME type of the HTML text. |
+| MIMETYPE_TEXT_WANT7+ | string | Yes | No | MIME type of the Want text. |
+| MIMETYPE_TEXT_PLAIN7+ | string | Yes | No | MIME type of the plain text. |
+| MIMETYPE_TEXT_URI7+ | string | Yes | No | MIME type of the URI text. |
## pasteboard.createPlainTextData
@@ -34,21 +34,23 @@ Creates a **PasteData** object for plain text.
**System capability**: SystemCapability.MiscServices.Pasteboard
-- Parameters
- | Name | Type | Mandatory | Description |
- | -------- | -------- | -------- | -------- |
- | text | string | Yes | Plain text. |
+**Parameters**
-- Return values
- | Type | Description |
- | -------- | -------- |
- | [PasteData](#pastedata) | **PasteData** object with the specified content. |
+| Name | Type | Mandatory | Description |
+| -------- | -------- | -------- | -------- |
+| text | string | Yes | Plain text. |
-- Example
-
- ```
- var pasteData = pasteboard.createPlainTextData("content");
- ```
+**Return value**
+
+| Type | Description |
+| -------- | -------- |
+| [PasteData](#pastedata) | **PasteData** object with the specified content. |
+
+**Example**
+
+```js
+var pasteData = pasteboard.createPlainTextData("content");
+```
## pasteboard.createHtmlData7+
@@ -59,22 +61,24 @@ Creates a **PasteData** object for HTML text.
**System capability**: SystemCapability.MiscServices.Pasteboard
-- Parameters
- | Name | Type | Mandatory | Description |
- | -------- | -------- | -------- | -------- |
- | htmlText | string | Yes | HTML text. |
+**Parameters**
+
+| Name | Type | Mandatory | Description |
+| -------- | -------- | -------- | -------- |
+| htmlText | string | Yes | HTML text. |
-- Return values
- | Type | Description |
- | -------- | -------- |
- | [PasteData](#pastedata) | **PasteData** object with the specified content. |
+**Return value**
-- Example
-
- ```
- var html = "\n" + "\n" + "\n" + "\n" + "HTML-PASTEBOARD_HTML\n" + "\n" + "\n" + "
\n" + " \n" + "\n" + "";
+var record = pasteboard.createHtmlTextRecord(html);
+```
## pasteboard.createWantRecord7+
@@ -190,25 +202,27 @@ Creates a **PasteDataRecord** object of the Want text type.
**System capability**: SystemCapability.MiscServices.Pasteboard
-- Parameters
- | Name | Type | Mandatory | Description |
- | -------- | -------- | -------- | -------- |
- | want | [Want](js-apis-featureAbility.md#want) | Yes | Want text. |
+**Parameters**
-- Return values
- | Type | Description |
- | -------- | -------- |
- | [PasteDataRecord](#pastedatarecord7) | New Want record. |
+| Name | Type | Mandatory | Description |
+| -------- | -------- | -------- | -------- |
+| want | [Want](js-apis-application-Want.md) | Yes | Want text. |
-- Example
-
- ```
- var object = {
- bundleName: "com.example.aafwk.test",
- abilityName: "com.example.aafwk.test.TwoAbility"
- };
- var record = pasteboard.createWantRecord(object);
- ```
+**Return value**
+
+| Type | Description |
+| -------- | -------- |
+| [PasteDataRecord](#pastedatarecord7) | New Want record. |
+
+**Example**
+
+```js
+var object = {
+ bundleName: "com.example.aafwk.test",
+ abilityName: "com.example.aafwk.test.TwoAbility"
+};
+var record = pasteboard.createWantRecord(object);
+```
## pasteboard.createUriRecord7+
@@ -219,21 +233,23 @@ Creates a **PasteDataRecord** object of the URI text type.
**System capability**: SystemCapability.MiscServices.Pasteboard
-- Parameters
- | Name | Type | Mandatory | Description |
- | -------- | -------- | -------- | -------- |
- | uri | string | Yes | URI text. |
+**Parameters**
-- Return values
- | Type | Description |
- | -------- | -------- |
- | [PasteDataRecord](#pastedatarecord7) | New URI record. |
+| Name | Type | Mandatory | Description |
+| -------- | -------- | -------- | -------- |
+| uri | string | Yes | URI text. |
-- Example
-
- ```
- var record = pasteboard.createUriRecord("dataability:///com.example.myapplication1?user.txt");
- ```
+**Return value**
+
+| Type | Description |
+| -------- | -------- |
+| [PasteDataRecord](#pastedatarecord7) | New URI record. |
+
+**Example**
+
+```js
+var record = pasteboard.createUriRecord("dataability:///com.example.myapplication1?user.txt");
+```
## PasteDataProperty7+
@@ -244,11 +260,11 @@ Defines the properties of all data records on the pasteboard, including the time
| Name | Type | Readable | Writable | Description |
| -------- | -------- | -------- | -------- | -------- |
-| additions | {[key: string]: object} | Yes | Yes | Additional property data. |
-| mimeTypes | Array<string> | Yes | No | Non-repeating data types of the data records on the pasteboard. |
-| tag | string | Yes | Yes | User-defined tag. |
-| timestamp | number | Yes | No | Timestamp at which the data is written to the pasteboard, in milliseconds. |
-| localOnly | boolean | Yes | Yes | Whether local access only is set for the pasteboard. - The default value is **true**. - **true**: The **PasteData** is set for local access only. - **false**: The **PasteData** can be shared between devices. |
+| additions | {[key: string]: object} | Yes | Yes | Additional property data. |
+| mimeTypes | Array<string> | Yes | No | Non-repeating data types of the data records on the pasteboard. |
+| tag | string | Yes | Yes | User-defined tag. |
+| timestamp | number | Yes | No | Timestamp at which the data is written to the pasteboard, in milliseconds. |
+| localOnly | boolean | Yes | Yes | Whether local access only is set for the pasteboard. - The default value is **true**. - **true**: The **PasteData** is set for local access only. - **false**: The **PasteData** can be shared between devices. |
## PasteDataRecord7+
@@ -262,63 +278,65 @@ A data record is an abstract definition of the content on the pasteboard. The pa
| Name | Type | Readable | Writable | Description |
| -------- | -------- | -------- | -------- | -------- |
-| htmlText7+ | string | Yes | No | HTML text. |
-| want7+ | [Want](js-apis-featureAbility.md#want) | Yes | No | Want text. |
-| mimeType7+ | string | Yes | No | Data type. |
-| plainText7+ | string | Yes | No | Plain text. |
-| uri7+ | string | Yes | No | URI text. |
+| htmlText7+ | string | Yes | No | HTML text. |
+| want7+ | [Want](js-apis-featureAbility.md#want) | Yes | No | Want text. |
+| mimeType7+ | string | Yes | No | Data type. |
+| plainText7+ | string | Yes | No | Plain text. |
+| uri7+ | string | Yes | No | URI text. |
### convertToText7+
convertToText(): Promise<string>
-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
-- Return values
- | Type | Description |
- | -------- | -------- |
- | Promise<void> | Promise used to return the result. If the operation is successful, the plain text content after conversion is returned. Otherwise, error information is returned. |
+**Return value**
-- Example
-
- ```
- var record = pasteboard.createUriRecord("dataability:///com.example.myapplication1?user.txt");
- record.convertToText().then((data) => {
- console.info('convertToText success data : ' + JSON.stringify(data));
- }).catch((error) => {
- console.error('convertToText failed because ' + JSON.stringify(error));
- });
- ```
+| Type | Description |
+| -------- | -------- |
+| Promise<void> | 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**
+
+```js
+var record = pasteboard.createUriRecord("dataability:///com.example.myapplication1?user.txt");
+record.convertToText().then((data) => {
+ console.info('convertToText success data : ' + JSON.stringify(data));
+}).catch((error) => {
+ console.error('convertToText failed because ' + JSON.stringify(error));
+});
+```
### convertToText7+
convertToText(callback: AsyncCallback<string>): 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
-- Parameters
- | Name | Type | Mandatory | Description |
- | -------- | -------- | -------- | -------- |
- | callback | AsyncCallback<string> | 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
-
- ```
- var record = pasteboard.createUriRecord("dataability:///com.example.myapplication1?user.txt");
- record.convertToText((err, data) => {
- if (err) {
- console.error('convertToText failed because ' + JSON.stringify(err));
- return;
- }
- console.info('convertToText success data : ' + JSON.stringify(data));
- });
- ```
+**Parameters**
+
+| Name | Type | Mandatory | Description |
+| -------- | -------- | -------- | -------- |
+| callback | AsyncCallback<string> | 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**
+
+```js
+var record = pasteboard.createUriRecord("dataability:///com.example.myapplication1?user.txt");
+record.convertToText((err, data) => {
+ if (err) {
+ console.error('convertToText failed because ' + JSON.stringify(err));
+ return;
+ }
+ console.info('convertToText success data : ' + JSON.stringify(data));
+});
+```
## PasteData
@@ -339,22 +357,19 @@ Obtains the plain text of the primary record.
**System capability**: SystemCapability.MiscServices.Pasteboard
+**Return value**
-- Parameters
- None
+| Type | Description |
+| -------- | -------- |
+| string | Plain text. |
-- Return values
- | Type | Description |
- | -------- | -------- |
- | string | Plain text. |
+**Example**
-- Example
-
- ```
- var pasteData = pasteboard.createPlainTextData("hello");
- var plainText = pasteData.getPrimaryText();
- ```
+```js
+var pasteData = pasteboard.createPlainTextData("hello");
+var plainText = pasteData.getPrimaryText();
+```
### getPrimaryHtml7+
@@ -365,18 +380,19 @@ Obtains the HTML text of the primary record.
**System capability**: SystemCapability.MiscServices.Pasteboard
-- Return values
- | Type | Description |
- | -------- | -------- |
- | string | HTML text. |
+**Return value**
-- Example
-
- ```
- var html = "\n" + "\n" + "\n" + "\n" + "HTML-PASTEBOARD_HTML\n" + "\n" + "\n" + "
\n" + " \n" + "\n" + "";
+var htmlRecord = pasteboard.createHtmlTextRecord(html);
+pasteData.addRecord(textRecord);
+pasteData.addRecord(htmlRecord);
+```
### getMimeTypes7+
@@ -557,17 +580,18 @@ Obtains **mimeTypes** in [PasteDataProperty](#pastedataproperty7) from this past
**System capability**: SystemCapability.MiscServices.Pasteboard
-- Return values
- | Type | Description |
- | -------- | -------- |
- | Array<string> | List of non-duplicate MIME types. |
+**Return value**
+
+| Type | Description |
+| -------- | -------- |
+| Array<string> | List of non-duplicate MIME types. |
-- Example
-
- ```
- var pasteData = pasteboard.createPlainTextData("hello");
- var types = pasteData.getMimeTypes();
- ```
+**Example**
+
+```js
+var pasteData = pasteboard.createPlainTextData("hello");
+var types = pasteData.getMimeTypes();
+```
### getPrimaryMimeType7+
@@ -578,17 +602,18 @@ Obtains the data type of the primary record.
**System capability**: SystemCapability.MiscServices.Pasteboard
-- Return values
- | Type | Description |
- | -------- | -------- |
- | string | Data type of the primary record. |
+**Return value**
-- Example
-
- ```
- var pasteData = pasteboard.createPlainTextData("hello");
- var type = pasteData.getPrimaryMimeType();
- ```
+| Type | Description |
+| -------- | -------- |
+| string | Data type of the primary record. |
+
+**Example**
+
+```js
+var pasteData = pasteboard.createPlainTextData("hello");
+var type = pasteData.getPrimaryMimeType();
+```
### getProperty7+
@@ -599,17 +624,18 @@ Obtains the property description object.
**System capability**: SystemCapability.MiscServices.Pasteboard
-- Return values
- | Type | Description |
- | -------- | -------- |
- | [PasteDataProperty](#pastedataproperty7) | Property description object. |
+**Return value**
+
+| Type | Description |
+| -------- | -------- |
+| [PasteDataProperty](#pastedataproperty7) | Property description object. |
+
+**Example**
-- Example
-
- ```
- var pasteData = pasteboard.createPlainTextData("hello");
- var property = pasteData.getProperty();
- ```
+```js
+var pasteData = pasteboard.createPlainTextData("hello");
+var property = pasteData.getProperty();
+```
### getRecordAt7+
@@ -620,22 +646,24 @@ Obtains the record with the specified index.
**System capability**: SystemCapability.MiscServices.Pasteboard
-- Parameters
- | Name | Type | Mandatory | Description |
- | -------- | -------- | -------- | -------- |
- | index | number | Yes | Index of the specified record. |
+**Parameters**
+
+| Name | Type | Mandatory | Description |
+| -------- | -------- | -------- | -------- |
+| index | number | Yes | Index of the specified record. |
+
+**Return value**
-- Return values
- | Type | Description |
- | -------- | -------- |
- | [PasteDataRecord](#pastedatarecord7) | Record with the specified index. |
+| Type | Description |
+| -------- | -------- |
+| [PasteDataRecord](#pastedatarecord7) | Record with the specified index. |
-- Example
-
- ```
- var pasteData = pasteboard.createPlainTextData("hello");
- var record = pasteData.getRecordAt(0);
- ```
+**Example**
+
+```js
+var pasteData = pasteboard.createPlainTextData("hello");
+var record = pasteData.getRecordAt(0);
+```
### getRecordCount7+
@@ -646,17 +674,18 @@ Obtains the number of data records in this pasteboard.
**System capability**: SystemCapability.MiscServices.Pasteboard
-- Return values
- | Type | Description |
- | -------- | -------- |
- | number | Number of records. |
+**Return value**
-- Example
-
- ```
- var pasteData = pasteboard.createPlainTextData("hello");
- var count = pasteData.getRecordCount();
- ```
+| Type | Description |
+| -------- | -------- |
+| number | Number of records. |
+
+**Example**
+
+```js
+var pasteData = pasteboard.createPlainTextData("hello");
+var count = pasteData.getRecordCount();
+```
### getTag7+
@@ -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
-- Return values
- | Type | Description |
- | -------- | -------- |
- | string | User-defined tag content if obtained and null if no tag is set. |
+**Return value**
-- Example
-
- ```
- var pasteData = pasteboard.createPlainTextData("hello");
- var tag = pasteData.getTag();
- ```
+| Type | Description |
+| -------- | -------- |
+| string | User-defined tag content if obtained and null if no tag is set. |
+
+**Example**
+
+```js
+var pasteData = pasteboard.createPlainTextData("hello");
+var tag = pasteData.getTag();
+```
### hasMimeType7+
@@ -688,22 +718,24 @@ Checks whether the content of this pasteboard contains the specified data type.
**System capability**: SystemCapability.MiscServices.Pasteboard
-- Parameters
- | Name | Type | Mandatory | Description |
- | -------- | -------- | -------- | -------- |
- | mimeType | string | Yes | Type of the data to query. |
+**Parameters**
+
+| Name | Type | Mandatory | Description |
+| -------- | -------- | -------- | -------- |
+| mimeType | string | Yes | Type of the data to query. |
+
+**Return value**
-- Return values
- | Type | Description |
- | -------- | -------- |
- | boolean | Returns **true** if the specified data type exists; returns **false** otherwise. |
+| Type | Description |
+| -------- | -------- |
+| boolean | Returns **true** if the specified data type exists; returns **false** otherwise. |
-- Example
-
- ```
- var pasteData = pasteboard.createPlainTextData("hello");
- var hasType = pasteData.hasMimeType(pasteboard.MIMETYPE_TEXT_PLAIN);
- ```
+**Example**
+
+```js
+var pasteData = pasteboard.createPlainTextData("hello");
+var hasType = pasteData.hasMimeType(pasteboard.MIMETYPE_TEXT_PLAIN);
+```
### removeRecordAt7+
@@ -714,22 +746,24 @@ Removes the data record with a specified index from this pasteboard.
**System capability**: SystemCapability.MiscServices.Pasteboard
-- Parameters
- | Name | Type | Mandatory | Description |
- | -------- | -------- | -------- | -------- |
- | index | number | Yes | Specified index. |
+**Parameters**
-- Return values
- | Type | Description |
- | -------- | -------- |
- | boolean | Returns **true** if the operation is successful; returns **false** otherwise. |
+| Name | Type | Mandatory | Description |
+| -------- | -------- | -------- | -------- |
+| index | number | Yes | Specified index. |
-- Example
-
- ```
- var pasteData = pasteboard.createPlainTextData("hello");
- var isRemove = pasteData.removeRecordAt(0);
- ```
+**Return value**
+
+| Type | Description |
+| -------- | -------- |
+| boolean | Returns **true** if the operation is successful; returns **false** otherwise. |
+
+**Example**
+
+```js
+var pasteData = pasteboard.createPlainTextData("hello");
+var isRemove = pasteData.removeRecordAt(0);
+```
### replaceRecordAt7+
@@ -740,24 +774,26 @@ Replaces the data record with a specified index in this pasteboard.
**System capability**: SystemCapability.MiscServices.Pasteboard
-- Parameters
- | Name | Type | Mandatory | Description |
- | -------- | -------- | -------- | -------- |
- | index | number | Yes | Specified index. |
- | record | [PasteDataRecord](#pastedatarecord7) | Yes | New record. |
+**Parameters**
-- Return values
- | Type | Description |
- | -------- | -------- |
- | boolean | Returns **true** if the operation is successful; returns **false** otherwise. |
+| Name | Type | Mandatory | Description |
+| -------- | -------- | -------- | -------- |
+| index | number | Yes | Specified index. |
+| record | [PasteDataRecord](#pastedatarecord7) | Yes | New record. |
-- Example
-
- ```
- var pasteData = pasteboard.createPlainTextData("hello");
- var record = pasteboard.createUriRecord("dataability:///com.example.myapplication1?user.txt");
- var isReplace = pasteData.replaceRecordAt(0, record);
- ```
+**Return value**
+
+| Type | Description |
+| -------- | -------- |
+| boolean | Returns **true** if the operation is successful; returns **false** otherwise. |
+
+**Example**
+
+```js
+var pasteData = pasteboard.createPlainTextData("hello");
+var record = pasteboard.createUriRecord("dataability:///com.example.myapplication1?user.txt");
+var isReplace = pasteData.replaceRecordAt(0, record);
+```
## pasteboard.getSystemPasteboard
@@ -768,21 +804,22 @@ Obtains the system pasteboard.
**System capability**: SystemCapability.MiscServices.Pasteboard
-- Return values
- | Type | Description |
- | -------- | -------- |
- | [SystemPasteboard](#systempasteboard) | System pasteboard. |
+**Return value**
-- Example
-
- ```
- var systemPasteboard = pasteboard.getSystemPasteboard();
- ```
+| Type | Description |
+| -------- | -------- |
+| [SystemPasteboard](#systempasteboard) | System pasteboard. |
+
+**Example**
+
+```js
+var systemPasteboard = pasteboard.getSystemPasteboard();
+```
## 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();
@@ -793,112 +830,117 @@ var systemPasteboard = pasteboard.getSystemPasteboard();
setPasteData(data:PasteData, callback:AsyncCallback<void>): 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
-- Parameters
- | Name | Type | Mandatory | Description |
- | -------- | -------- | -------- | -------- |
- | data | [PasteData](#pastedata) | Yes | **PasteData** object. |
- | callback | AsyncCallback<void> | Yes | Callback used to return the data write result. |
-
-- Example
-
- ```
- var pasteData = pasteboard.createPlainTextData("content");
- var systemPasteboard = pasteboard.getSystemPasteboard();
- systemPasteboard.setPasteData(pasteData, (error, data) => {
- if (error) {
- console.error('Failed to setPasteData. Cause: ' + error.message);
- return;
- }
- console.info('setPasteData successfully.');
- });
- ```
+**Parameters**
+
+| Name | Type | Mandatory | Description |
+| -------- | -------- | -------- | -------- |
+| data | [PasteData](#pastedata) | Yes | **PasteData** object. |
+| callback | AsyncCallback<void> | Yes | Callback used to return the data write result. |
+
+**Example**
+
+```js
+var pasteData = pasteboard.createPlainTextData("content");
+var systemPasteboard = pasteboard.getSystemPasteboard();
+systemPasteboard.setPasteData(pasteData, (error, data) => {
+ if (error) {
+ console.error('Failed to setPasteData. Cause: ' + error.message);
+ return;
+ }
+ console.info('setPasteData successfully.');
+});
+```
### setPasteData
setPasteData(data:PasteData): Promise<void>
-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
-- Parameters
- | Name | Type | Description |
- | -------- | -------- | -------- |
- | data | [PasteData](#pastedata) | **PasteData** object. |
-
-- Return values
- | Type | Description |
- | -------- | -------- |
- | Promise<void> | Promise used to return the data write result. |
-
-- Example
-
- ```
- var pasteData = pasteboard.createPlainTextData("content");
- var systemPasteboard = pasteboard.getSystemPasteboard();
- systemPasteboard.setPasteData(pasteData).then((data) => {
- console.info('setPasteData success.');
- }).catch((error) => {
- console.error('Failed to setPasteData. Cause: ' + error.message);
- });
- ```
+**Parameters**
+
+| Name | Type | Description |
+| -------- | -------- | -------- |
+| data | [PasteData](#pastedata) | **PasteData** object. |
+
+**Return value**
+
+| Type | Description |
+| -------- | -------- |
+| Promise<void> | Promise used to return the data write result. |
+
+**Example**
+
+```js
+var pasteData = pasteboard.createPlainTextData("content");
+var systemPasteboard = pasteboard.getSystemPasteboard();
+systemPasteboard.setPasteData(pasteData).then((data) => {
+ console.info('setPasteData success.');
+}).catch((error) => {
+ console.error('Failed to setPasteData. Cause: ' + error.message);
+});
+```
### getPasteData
getPasteData( callback:AsyncCallback<PasteData>): 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
-- Parameters
- | Name | Type | Mandatory | Description |
- | -------- | -------- | -------- | -------- |
- | callback | AsyncCallback<[PasteData](#pastedata)> | Yes | Callback used to return the system pasteboard data. |
-
-- Example
-
- ```
- var systemPasteboard = pasteboard.getSystemPasteboard();
- systemPasteboard.getPasteData((error, pasteData) => {
- if (error) {
- console.error('Failed to getPasteData. Cause: ' + error.message);
- return;
- }
- var text = pasteData.getPrimaryText();
- });
- ```
+**Parameters**
+
+| Name | Type | Mandatory | Description |
+| -------- | -------- | -------- | -------- |
+| callback | AsyncCallback<[PasteData](#pastedata)> | Yes | Callback used to return the system pasteboard data. |
+
+**Example**
+
+```js
+var systemPasteboard = pasteboard.getSystemPasteboard();
+systemPasteboard.getPasteData((error, pasteData) => {
+ if (error) {
+ console.error('Failed to getPasteData. Cause: ' + error.message);
+ return;
+ }
+ var text = pasteData.getPrimaryText();
+});
+```
### getPasteData
getPasteData(): Promise<PasteData>
-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
-- Return values
- | Type | Description |
- | -------- | -------- |
- | Promise<[PasteData](#pastedata)> | Promise used to return the system pasteboard data. |
+**Return value**
-- Example
-
- ```
- var systemPasteboard = pasteboard.getSystemPasteboard();
- systemPasteboard.getPasteData().then((pasteData) => {
- var text = pasteData.getPrimaryText();
- }).catch((error) => {
- console.error('Failed to getPasteData. Cause: ' + error.message);
- })
- ```
+| Type | Description |
+| -------- | -------- |
+| Promise<[PasteData](#pastedata)> | Promise used to return the system pasteboard data. |
+
+**Example**
+
+```js
+var systemPasteboard = pasteboard.getSystemPasteboard();
+systemPasteboard.getPasteData().then((pasteData) => {
+ var text = pasteData.getPrimaryText();
+}).catch((error) => {
+ console.error('Failed to getPasteData. Cause: ' + error.message);
+})
+```
### on('update')7+
@@ -909,21 +951,22 @@ Subscribes to the content change event of the system pasteboard. If the pasteboa
**System capability**: SystemCapability.MiscServices.Pasteboard
-- Parameters
- | Name | Type | Mandatory | Description |
- | -------- | -------- | -------- | -------- |
- | type | string | Yes | Data type. The value **update** indicates the pasteboard content has changed. |
- | callback | function | Yes | Callback invoked when the pasteboard content changes. |
+**Parameters**
-- Example
-
- ```
- var systemPasteboard = pasteboard.getSystemPasteboard();
- var listener = ()=>{
- console.info('The system pasteboard has changed');
- };
- systemPasteboard.on('update', listener);
- ```
+| Name | Type | Mandatory | Description |
+| -------- | -------- | -------- | -------- |
+| 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**
+
+```js
+var systemPasteboard = pasteboard.getSystemPasteboard();
+var listener = ()=>{
+ console.info('The system pasteboard has changed');
+};
+systemPasteboard.on('update', listener);
+```
### off('update')7+
@@ -934,114 +977,119 @@ Unsubscribes from the system pasteboard content change event.
**System capability**: SystemCapability.MiscServices.Pasteboard
-- Parameters
- | Name | Type | Mandatory | Description |
- | -------- | -------- | -------- | -------- |
- | type | string | Yes | Data type. The value **update** indicates the pasteboard content has changed. |
- | callback | function | No | Callback invoked when the pasteboard content changes. |
+**Parameters**
+
+| Name | Type | Mandatory | Description |
+| -------- | -------- | -------- | -------- |
+| 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
-
- ```
- systemPasteboard.off('update', listener);
- ```
+**Example**
+
+```js
+systemPasteboard.off('update', listener);
+```
### hasPasteData7+
hasPasteData(callback: AsyncCallback<boolean>): 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
-- Parameters
- | Name | Type | Mandatory | Description |
- | -------- | -------- | -------- | -------- |
- | callback | AsyncCallback<boolean> | Yes | Returns **true** if the pasteboard contains content; returns **false** otherwise. |
-
-- Example
-
- ```
- systemPasteboard.hasPasteData((err, data) => {
- if (err) {
- console.error('failed to hasPasteData because ' + JSON.stringify(err));
- return;
- }
- console.info('success hasPasteData : ' + JSON.stringify(data));
- });
- ```
+**Parameters**
+
+| Name | Type | Mandatory | Description |
+| -------- | -------- | -------- | -------- |
+| callback | AsyncCallback<boolean> | Yes | Returns **true** if the pasteboard contains content; returns **false** otherwise. |
+
+**Example**
+
+```js
+systemPasteboard.hasPasteData((err, data) => {
+ if (err) {
+ console.error('failed to hasPasteData because ' + JSON.stringify(err));
+ return;
+ }
+ console.info('success hasPasteData : ' + JSON.stringify(data));
+});
+```
### hasPasteData7+
hasPasteData(): Promise<boolean>
-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
-- Return values
- | Type | Description |
- | -------- | -------- |
- | Promise<boolean> | Returns **true** if the pasteboard contains content; returns **false** otherwise. |
+**Return value**
+
+| Type | Description |
+| -------- | -------- |
+| Promise<boolean> | Returns **true** if the pasteboard contains content; returns **false** otherwise. |
+
+**Example**
-- Example
-
- ```
- systemPasteboard.hasPasteData().then((data) => {
- console.info('Operation succeeded. ' + JSON.stringify(data));
- }).catch((error) => {
- console.error('failed to hasPasteData because ' + JSON.stringify(error));
- });
- ```
+```js
+systemPasteboard.hasPasteData().then((data) => {
+ console.info('Operation succeeded. ' + JSON.stringify(data));
+}).catch((error) => {
+ console.error('failed to hasPasteData because ' + JSON.stringify(error));
+});
+```
### clear7+
clear(callback: AsyncCallback<void>): 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
-- Parameters
- | Name | Type | Mandatory | Description |
- | -------- | -------- | -------- | -------- |
- | callback | AsyncCallback<void> | Yes | Callback used to return the result. |
-
-- Example
-
- ```
- systemPasteboard.clear((err, data) => {
- if (err) {
- console.error('failed to clear because ' + JSON.stringify(err));
- return;
- }
- console.info('success clear');
- });
- ```
+**Parameters**
+
+| Name | Type | Mandatory | Description |
+| -------- | -------- | -------- | -------- |
+| callback | AsyncCallback<void> | Yes | Callback used to return the result. |
+
+**Example**
+
+```js
+systemPasteboard.clear((err, data) => {
+ if (err) {
+ console.error('failed to clear because ' + JSON.stringify(err));
+ return;
+ }
+ console.info('success clear');
+});
+```
### clear7+
clear(): Promise<void>
-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
-- Return values
- | Type | Description |
- | -------- | -------- |
- | Promise<void> | Promise used to return the result. |
-
-- Example
-
- ```
- systemPasteboard.clear().then((data) => {
- console.info('success clear');
- }).catch((error) => {
- console.error('failed to clear because ' + JSON.stringify(error));
- });
- ```
+**Return value**
+
+| Type | Description |
+| -------- | -------- |
+| Promise<void> | Promise used to return the result. |
+
+**Example**
+
+```js
+systemPasteboard.clear().then((data) => {
+ console.info('success clear');
+}).catch((error) => {
+ console.error('failed to clear because ' + JSON.stringify(error));
+});
+```
\ No newline at end of file
diff --git a/en/application-dev/reference/apis/js-apis-request.md b/en/application-dev/reference/apis/js-apis-request.md
index 0a8f08d0210217fcf972ce30e1bdabdcc8e1ac10..0a4b8c5ac6d2570ba34b5567322fef99e6b8bb1f 100644
--- a/en/application-dev/reference/apis/js-apis-request.md
+++ b/en/application-dev/reference/apis/js-apis-request.md
@@ -1,8 +1,8 @@
# Upload and Download
->  **Note:**
-> 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.
+>  **NOTE** 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
@@ -37,56 +37,58 @@ import request from '@ohos.request';
| Name | Type | Readable | Writable | Description |
| -------- | -------- | -------- | -------- | -------- |
-| NETWORK_MOBILE | number | Yes | No | Whether download is allowed when the cellular network is used. |
-| NETWORK_WIFI | number | Yes | No | Whether download is allowed when the WLAN is used. |
-| ERROR_CANNOT_RESUME7+ | number | Yes | No | Failure to resume the download due to an error. |
-| ERROR_DEVICE_NOT_FOUND7+ | number | Yes | No | Failure to find a storage device such as an SD card. |
-| ERROR_FILE_ALREADY_EXISTS7+ | number | Yes | No | Failure to download the file because it already exists. |
-| ERROR_FILE_ERROR7+ | number | Yes | No | File operation failure. |
-| ERROR_HTTP_DATA_ERROR7+ | number | Yes | No | HTTP transmission failure. |
-| ERROR_INSUFFICIENT_SPACE7+ | number | Yes | No | Insufficient storage space. |
-| ERROR_TOO_MANY_REDIRECTS7+ | number | Yes | No | Error caused by too many network redirections. |
-| ERROR_UNHANDLED_HTTP_CODE7+ | number | Yes | No | Unidentified HTTP code. |
-| ERROR_UNKNOWN7+ | number | Yes | No | Unknown error. |
-| PAUSED_QUEUED_FOR_WIFI7+ | 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_UNKNOWN7+ | number | Yes | No | Download paused due to unknown reasons. |
-| PAUSED_WAITING_FOR_NETWORK7+ | number | Yes | No | Download paused due to a network connection problem, for example, network disconnection. |
-| PAUSED_WAITING_TO_RETRY7+ | number | Yes | No | Download paused and then retried. |
-| SESSION_FAILED7+ | number | Yes | No | Download failure without retry. |
-| SESSION_PAUSED7+ | number | Yes | No | Download paused. |
-| SESSION_PENDING7+ | number | Yes | No | Download pending. |
-| SESSION_RUNNING7+ | number | Yes | No | Download in progress. |
-| SESSION_SUCCESSFUL7+ | number | Yes | No | Successful download. |
+| NETWORK_MOBILE | number | Yes | No | Whether download is allowed when the cellular network is used. |
+| NETWORK_WIFI | number | Yes | No | Whether download is allowed when the WLAN is used. |
+| ERROR_CANNOT_RESUME7+ | number | Yes | No | Failure to resume the download due to an error. |
+| ERROR_DEVICE_NOT_FOUND7+ | number | Yes | No | Failure to find a storage device such as an SD card. |
+| ERROR_FILE_ALREADY_EXISTS7+ | number | Yes | No | Failure to download the file because it already exists. |
+| ERROR_FILE_ERROR7+ | number | Yes | No | File operation failure. |
+| ERROR_HTTP_DATA_ERROR7+ | number | Yes | No | HTTP transmission failure. |
+| ERROR_INSUFFICIENT_SPACE7+ | number | Yes | No | Insufficient storage space. |
+| ERROR_TOO_MANY_REDIRECTS7+ | number | Yes | No | Error caused by too many network redirections. |
+| ERROR_UNHANDLED_HTTP_CODE7+ | number | Yes | No | Unidentified HTTP code. |
+| ERROR_UNKNOWN7+ | number | Yes | No | Unknown error. |
+| PAUSED_QUEUED_FOR_WIFI7+ | 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_UNKNOWN7+ | number | Yes | No | Download paused due to unknown reasons. |
+| PAUSED_WAITING_FOR_NETWORK7+ | number | Yes | No | Download paused due to a network connection problem, for example, network disconnection. |
+| PAUSED_WAITING_TO_RETRY7+ | number | Yes | No | Download paused and then retried. |
+| SESSION_FAILED7+ | number | Yes | No | Download failure without retry. |
+| SESSION_PAUSED7+ | number | Yes | No | Download paused. |
+| SESSION_PENDING7+ | number | Yes | No | Download pending. |
+| SESSION_RUNNING7+ | number | Yes | No | Download in progress. |
+| SESSION_SUCCESSFUL7+ | number | Yes | No | Successful download. |
## request.upload
upload(config: UploadConfig): Promise<UploadTask>
-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
**System capability**: SystemCapability.MiscServices.Upload
-- Parameters
- | Name | Type | Mandatory | Description |
- | -------- | -------- | -------- | -------- |
- | config | [UploadConfig](#uploadconfig) | Yes | Configurations of the upload. |
+**Parameters**
-- Return values
- | Type | Description |
- | -------- | -------- |
- | Promise<[UploadTask](#uploadtask)> | Promise used to return the **UploadTask** object. |
+| Name | Type | Mandatory | Description |
+| -------- | -------- | -------- | -------- |
+| config | [UploadConfig](#uploadconfig) | Yes | Configurations of the upload. |
-- Example
-
- ```
- request.upload({ url: 'https://patch' }).then((data) => {
- uploadTask = data;
- }).catch((err) => {
- console.error('Failed to request the upload. Cause: ' + JSON.stringify(err));
- })
+**Return value**
+
+| Type | Description |
+| -------- | -------- |
+| Promise<[UploadTask](#uploadtask)> | Promise used to return the **UploadTask** object. |
+
+**Example**
+
+ ```js
+request.upload({ url: 'https://patch' }).then((data) => {
+ uploadTask = data;
+}).catch((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.
upload(config: UploadConfig, callback: AsyncCallback<UploadTask>): 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
**System capability**: SystemCapability.MiscServices.Upload
-- Parameters
- | Name | Type | Mandatory | Description |
- | -------- | -------- | -------- | -------- |
- | config | [UploadConfig](#uploadconfig) | Yes | Configurations of the upload. |
- | callback | AsyncCallback<[UploadTask](#uploadtask)> | No | Callback used to return the **UploadTask** object. |
+**Parameters**
-- Example
-
- ```
- request.upload({ url: 'https://patch' }, (err, data) => {
- if (err) {
- console.error('Failed to request the upload. Cause: ' + JSON.stringify(err));
- return;
- }
- uploadTask = data;
- });
+| Name | Type | Mandatory | Description |
+| -------- | -------- | -------- | -------- |
+| config | [UploadConfig](#uploadconfig) | Yes | Configurations of the upload. |
+| callback | AsyncCallback<[UploadTask](#uploadtask)> | No | Callback used to return the **UploadTask** object. |
+
+**Example**
+
+ ```js
+request.upload({ url: 'https://patch' }, (err, data) => {
+ if (err) {
+ console.error('Failed to request the upload. Cause: ' + JSON.stringify(err));
+ return;
+ }
+ uploadTask = data;
+});
```
@@ -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) => 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
**System capability**: SystemCapability.MiscServices.Upload
-- Parameters
- | 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. |
+**Parameters**
- 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 |
- | -------- | -------- | -------- | -------- |
- | uploadedSize | number | Yes | Size of the uploaded files, in KB. |
- | totalSize | number | Yes | Total size of the files to upload, in KB. |
+Parameters of the callback function
-- Example
-
- ```
- uploadTask.on('progress', function callback(uploadedSize, totalSize) {
- console.info("upload totalSize:" + totalSize + " uploadedSize:" + uploadedSize);
- }
- );
+| 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**
+
+ ```js
+uploadTask.on('progress', function callback(uploadedSize, totalSize) {
+ console.info("upload totalSize:" + totalSize + " uploadedSize:" + uploadedSize);
+}
+);
```
@@ -161,31 +165,32 @@ Subscribes to the upload progress event. This method uses an asynchronous callba
on(type: 'headerReceive', callback: (header: object) => 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
**System capability**: SystemCapability.MiscServices.Upload
-- Parameters
- | 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. |
+**Parameters**
- 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 |
- | -------- | -------- | -------- | -------- |
- | header | object | Yes | HTTP Response Header. |
+Parameters of the callback function
-- Example
-
- ```
- uploadTask.on('headerReceive', function callback(headers){
- console.info("upOnHeader headers:" + JSON.stringify(headers));
- }
- );
+| Name | Type | Mandatory | Description |
+| -------- | -------- | -------- | -------- |
+| header | object | Yes | HTTP Response Header. |
+
+**Example**
+
+ ```js
+uploadTask.on('headerReceive', function callback(headers){
+ console.info("upOnHeader headers:" + JSON.stringify(headers));
+}
+);
```
@@ -193,32 +198,33 @@ Subscribes to the **headerReceive** event, which is triggered when an HTTP respo
off(type: 'progress', callback?: (uploadedSize: number, totalSize: number) => 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
**System capability**: SystemCapability.MiscServices.Upload
-- Parameters
- | Name | Type | Mandatory | Description |
- | -------- | -------- | -------- | -------- |
- | 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**
- Parameters of the callback function
+| Name | Type | Mandatory | Description |
+| -------- | -------- | -------- | -------- |
+| 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. |
- | 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. |
+Parameters of the callback function
-- Example
-
- ```
- uploadTask.off('progress', function callback(uploadedSize, totalSize) {
- console.info('uploadedSize: ' + uploadedSize, 'totalSize: ' + totalSize);
- }
- );
+| 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**
+
+ ```js
+uploadTask.off('progress', function callback(uploadedSize, totalSize) {
+ console.info('uploadedSize: ' + uploadedSize, 'totalSize: ' + totalSize);
+}
+);
```
@@ -226,31 +232,32 @@ Unsubscribes from the upload progress event. This method uses an asynchronous ca
off(type: 'headerReceive', callback?: (header: object) => 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
**System capability**: SystemCapability.MiscServices.Upload
-- Parameters
- | 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. |
+**Parameters**
- 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 |
- | -------- | -------- | -------- | -------- |
- | header | object | Yes | HTTP Response Header. |
+Parameters of the callback function
-- Example
-
- ```
- uploadTask.off('headerReceive', function callback(headers) {
- console.info("upOnHeader headers:" + JSON.stringify(headers));
- }
- );
+| Name | Type | Mandatory | Description |
+| -------- | -------- | -------- | -------- |
+| header | object | Yes | HTTP Response Header. |
+
+**Example**
+
+ ```js
+uploadTask.off('headerReceive', function callback(headers) {
+ console.info("upOnHeader headers:" + JSON.stringify(headers));
+}
+);
```
@@ -258,29 +265,30 @@ Unsubscribes from the **headerReceive** event. This method uses an asynchronous
remove(): Promise<boolean>
-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
**System capability**: SystemCapability.MiscServices.Upload
-- Return values
- | Type | Description |
- | -------- | -------- |
- | Promise<boolean> | 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. |
+**Return value**
-- Example
-
- ```
- uploadTask.remove().then((result) => {
- if (result) {
- console.info('Upload task removed successfully. ');
- } else {
- console.error('Failed to remove the upload task. ');
- }
- }).catch((err) => {
- console.error('Failed to remove the upload task. Cause: ' + JSON.stringify(err));
- });
+| Type | Description |
+| -------- | -------- |
+| Promise<boolean> | 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**
+
+ ```js
+uploadTask.remove().then((result) => {
+ if (result) {
+ console.info('Upload task removed successfully. ');
+ } else {
+ console.error('Failed to remove the upload task. ');
+ }
+}).catch((err) => {
+ console.error('Failed to remove the upload task. Cause: ' + JSON.stringify(err));
+});
```
@@ -288,31 +296,32 @@ Removes this upload task. This method uses a promise to return the result.
remove(callback: AsyncCallback<boolean>): 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
**System capability**: SystemCapability.MiscServices.Upload
-- Parameters
- | Name | Type | Mandatory | Description |
- | -------- | -------- | -------- | -------- |
- | callback | AsyncCallback<boolean> | Yes | Callback used to return the result. |
+**Parameters**
-- Example
-
- ```
- uploadTask.remove((err, result) => {
- if (err) {
- console.error('Failed to remove the upload task. Cause: ' + JSON.stringify(err));
- return;
- }
- if (result) {
- console.info('Upload task removed successfully.');
- } else {
- console.error('Failed to remove the upload task.');
- }
- });
+| Name | Type | Mandatory | Description |
+| -------- | -------- | -------- | -------- |
+| callback | AsyncCallback<boolean> | Yes | Callback used to return the result. |
+
+**Example**
+
+ ```js
+uploadTask.remove((err, result) => {
+ if (err) {
+ console.error('Failed to remove the upload task. Cause: ' + JSON.stringify(err));
+ return;
+ }
+ if (result) {
+ console.info('Upload task removed successfully.');
+ } else {
+ 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
| Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- |
-| url | string | Yes | Resource URL. |
-| header | object | No | HTTP or HTTPS header added to an upload request. |
-| method | string | No | Request methods available: **POST** and **PUT**. The default value is **POST**. |
-| files | Array<[File](#file)> | Yes | List of files to upload, which is submitted through **multipart/form-data**. |
-| data | Array<[RequestData](#requestdata)> | No | Form data in the request body. |
+| url | string | Yes | Resource URL. |
+| header | object | No | HTTP or HTTPS header added to an upload request. |
+| method | string | No | Request methods available: **POST** and **PUT**. The default value is **POST**. |
+| files | Array<[File](#file)> | Yes | List of files to upload, which is submitted through **multipart/form-data**. |
+| data | Array<[RequestData](#requestdata)> | No | Form data in the request body. |
## File
@@ -335,10 +344,10 @@ Removes this upload task. This method uses an asynchronous callback to return th
| Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- |
-| filename | string | No | File name in the header when **multipart** is used. |
-| name | string | No | Name of a form item when **multipart** is used. The default value is **file**. |
-| uri | string | Yes | Local path for storing files. The **dataability** and **internal** protocol types are supported. However, the **internal** protocol type supports only temporary directories. The following is an example: dataability:///com.domainname.dataability.persondata/person/10/file.txt internal://cache/path/to/file.txt |
-| type | string | No | Type of the file content. By default, the type is obtained based on the extension of the file name or URI. |
+| filename | string | No | File name in the header when **multipart** is used. |
+| name | string | No | Name of a form item when **multipart** is used. The default value is **file**. |
+| uri | string | Yes | Local path for storing files. The **dataability** and **internal** protocol types are supported. However, the **internal** protocol type supports only temporary directories. The following is an example: dataability:///com.domainname.dataability.persondata/person/10/file.txt internal://cache/path/to/file.txt |
+| 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
@@ -347,68 +356,71 @@ Removes this upload task. This method uses an asynchronous callback to return th
| Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- |
-| name | string | Yes | Name of a form element. |
-| value | string | Yes | Value of a form element. |
+| name | string | Yes | Name of a form element. |
+| value | string | Yes | Value of a form element. |
## request.download
download(config: DownloadConfig): Promise<DownloadTask>
-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
**System capability**: SystemCapability.MiscServices.Download
-- Parameters
- | Name | Type | Mandatory | Description |
- | -------- | -------- | -------- | -------- |
- | config | [DownloadConfig](#downloadconfig) | Yes | Configurations of the download. |
+**Parameters**
-- Return values
- | Type | Description |
- | -------- | -------- |
- | Promise<[DownloadTask](#downloadtask)> | Promise used to return the result. |
+| Name | Type | Mandatory | Description |
+| -------- | -------- | -------- | -------- |
+| config | [DownloadConfig](#downloadconfig) | Yes | Configurations of the download. |
-- Example
-
- ```
- request.download({ url: 'https://xxxx/xxxx.hap' }).then((data) => {
- downloadTask = data;
- }).catch((err) => {
- console.error('Failed to request the download. Cause: ' + JSON.stringify(err));
- })
- ```
+**Return value**
+
+| Type | Description |
+| -------- | -------- |
+| Promise<[DownloadTask](#downloadtask)> | Promise used to return the result. |
+
+**Example**
+
+```js
+request.download({ url: 'https://xxxx/xxxx.hap' }).then((data) => {
+ downloadTask = data;
+}).catch((err) => {
+ console.error('Failed to request the download. Cause: ' + JSON.stringify(err));
+})
+```
## request.download
download(config: DownloadConfig, callback: AsyncCallback<DownloadTask>): 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
**System capability**: SystemCapability.MiscServices.Download
-- Parameters
- | Name | Type | Mandatory | Description |
- | -------- | -------- | -------- | -------- |
- | config | [DownloadConfig](#downloadconfig) | Yes | Configurations of the download. |
- | callback | AsyncCallback<[DownloadTask](#downloadtask)> | No | Callback used to return the result. |
+**Parameters**
-- Example
-
- ```
- request.download({ url: 'https://xxxx/xxxxx.hap',
- filePath: 'xxx/xxxxx.hap'}, (err, data) => {
- if (err) {
- console.error('Failed to request the download. Cause: ' + JSON.stringify(err));
- return;
- }
- downloadTask = data;
- });
+| Name | Type | Mandatory | Description |
+| -------- | -------- | -------- | -------- |
+| config | [DownloadConfig](#downloadconfig) | Yes | Configurations of the download. |
+| callback | AsyncCallback<[DownloadTask](#downloadtask)> | No | Callback used to return the result. |
+
+**Example**
+
+ ```js
+request.download({ url: 'https://xxxx/xxxxx.hap',
+filePath: 'xxx/xxxxx.hap'}, (err, data) => {
+ if (err) {
+ console.error('Failed to request the download. Cause: ' + JSON.stringify(err));
+ return;
+ }
+ downloadTask = data;
+});
```
@@ -421,28 +433,29 @@ Implements file downloads.
on(type: 'progress', callback:(receivedSize: number, totalSize: number) => 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
**System capability**: SystemCapability.MiscServices.Download
-- Parameters
- | Name | Type | Mandatory | Description |
- | -------- | -------- | -------- | -------- |
- | 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**
+
+| Name | Type | Mandatory | Description |
+| -------- | -------- | -------- | -------- |
+| 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 |
- | -------- | -------- | -------- | -------- |
- | receivedSize | number | Yes | Size of the downloaded files, in KB. |
- | totalSize | number | Yes | Total size of the files to download, in KB. |
+| 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
-
- ```
+**Example**
+
+ ```js
request.download({ url: 'https://xxxx/xxxx.hap' }, (err, data)=> {
if (err) {
console.error('Failed to request download. Cause:' + err);
@@ -461,39 +474,40 @@ Subscribes to the download progress event. This method uses an asynchronous call
off(type: 'progress', callback?: (receivedSize: number, totalSize: number) => 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
**System capability**: SystemCapability.MiscServices.Download
-- Parameters
- | 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. |
+**Parameters**
- 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 |
- | -------- | -------- | -------- | -------- |
- | receivedSize | number | Yes | Size of the downloaded files, in KB. |
- | totalSize | number | Yes | Total size of the files to download, in KB. |
+Parameters of the callback function
-- Example
-
- ```
- request.download({ url: 'https://xxxx/xxxx.hap' }, (err, data)=> {
- if (err) {
- console.error('Failed to request download. Cause:' + err);
- return;
- }
- downloadTask = data;
- downloadTask .off('progress', function download_callback(receivedSize, totalSize) {
- console.info("download receivedSize:" + receivedSize + " totalSize:" + totalSize);
- }
- );
- });
+| 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**
+
+ ```js
+request.download({ url: 'https://xxxx/xxxx.hap' }, (err, data)=> {
+ if (err) {
+ console.error('Failed to request download. Cause:' + err);
+ return;
+ }
+ downloadTask = data;
+ downloadTask .off('progress', function download_callback(receivedSize, totalSize) {
+ console.info("download receivedSize:" + receivedSize + " totalSize:" + totalSize);
+ }
+);
+});
```
@@ -501,32 +515,33 @@ Unsubscribes from the download progress event. This method uses an asynchronous
on(type: 'complete'|'pause'|'remove', callback:() => 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
**System capability**: SystemCapability.MiscServices.Download
-- Parameters
- | Name | Type | Mandatory | Description |
- | -------- | -------- | -------- | -------- |
- | type | string | Yes | Event type. - **complete**: download task completion event. - **pause**: download task pause event. - **remove**: download task removal event. |
- | callback | function | Yes | Callback used to return the result. |
+**Parameters**
-- Example
-
- ```
- request.download({ url: 'https://xxxx/xxxx.hap' }, (err, data)=> {
- if (err) {
- console.error('Failed to request download. Cause:' + err);
- return;
- }
- downloadTask= data;
- downloadTask.on('complete', function callback() {
- console.info('Download task completed.');
- }
- );
- });
+| Name | Type | Mandatory | Description |
+| -------- | -------- | -------- | -------- |
+| type | string | Yes | Event type. - **complete**: download task completion event. - **pause**: download task pause event. - **remove**: download task removal event. |
+| callback | function | Yes | Callback used to return the result. |
+
+**Example**
+
+ ```js
+request.download({ url: 'https://xxxx/xxxx.hap' }, (err, data)=> {
+ if (err) {
+ console.error('Failed to request download. Cause:' + err);
+ return;
+ }
+ downloadTask= data;
+ downloadTask.on('complete', function callback() {
+ console.info('Download task completed.');
+ }
+);
+});
```
@@ -534,32 +549,33 @@ Subscribes to a download event. This method uses an asynchronous callback to ret
off(type: 'complete'|'pause'|'remove', callback?:() => 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
**System capability**: SystemCapability.MiscServices.Download
-- Parameters
- | Name | Type | Mandatory | Description |
- | -------- | -------- | -------- | -------- |
- | type | string | Yes | Event type. - **complete**: download task completion event. - **pause**: download task pause event. - **remove**: download task removal event. |
- | callback | function | No | Callback used to return the result. |
+**Parameters**
-- Example
-
- ```
- request.download({ url: 'https://xxxx/xxxx.hap' }, (err, data)=> {
- if (err) {
- console.error('Failed to request download. Cause:' + JSON.stringify(err));
- return;
- }
- downloadTask = data;
- downloadTask.off('complete', function callback() {
- console.info('Download task completed.');
- }
- );
- });
+| Name | Type | Mandatory | Description |
+| -------- | -------- | -------- | -------- |
+| type | string | Yes | Event type. - **complete**: download task completion event. - **pause**: download task pause event. - **remove**: download task removal event. |
+| callback | function | No | Callback used to return the result. |
+
+**Example**
+
+ ```js
+request.download({ url: 'https://xxxx/xxxx.hap' }, (err, data)=> {
+ if (err) {
+ console.error('Failed to request download. Cause:' + JSON.stringify(err));
+ return;
+ }
+ downloadTask = data;
+ downloadTask.off('complete', function callback() {
+ console.info('Download task completed.');
+ }
+);
+});
```
@@ -567,38 +583,39 @@ Unsubscribes from the download event. This method uses an asynchronous callback
on(type: 'fail', callback: (err: number) => 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
**System capability**: SystemCapability.MiscServices.Download
-- Parameters
- | 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. |
+**Parameters**
- 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 |
- | -------- | -------- | -------- | -------- |
- | err | number | Yes | Error code of the download failure. For details about the error cause, see [ERROR_*](#constants). |
+Parameters of the callback function
-- Example
-
- ```
- request.download({ url: 'https://xxxx/xxxx.hap' }, (err, data)=> {
- if (err) {
- console.error('Failed to request download. Cause:' + err);
- return;
- }
- downloadTask = data;
- downloadTask.on('fail', function callBack(err) {
- console.info('Download task failed. Cause:' + err);
- }
- );
- });
+| 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)=> {
+ if (err) {
+ console.error('Failed to request download. Cause:' + err);
+ return;
+ }
+ downloadTask = data;
+ downloadTask.on('fail', function callBack(err) {
+ console.info('Download task failed. Cause:' + err);
+ }
+);
+});
```
@@ -606,27 +623,28 @@ Subscribes to the download task failure event. This method uses an asynchronous
off(type: 'fail', callback?: (err: number) => 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
**System capability**: SystemCapability.MiscServices.Download
-- Parameters
- | 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. |
+**Parameters**
+
+| 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. |
- Parameters of the callback function
+Parameters of the callback function
- | Name | Type | Mandatory | Description |
- | -------- | -------- | -------- | -------- |
- | err | number | Yes | Error code of the download failure. For details about the error cause, see [ERROR_*](#constants). |
+| Name | Type | Mandatory | Description |
+| -------- | -------- | -------- | -------- |
+| err | number | Yes | Error code of the download failure. For details about the error cause, see [ERROR_*](#constants). |
-- Example
-
- ```
+**Example**
+
+ ```js
request.download({ url: 'https://xxxx/xxxx.hap' }, (err, data)=> {
if (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
remove(): Promise<boolean>
-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
**System capability**: SystemCapability.MiscServices.Download
-- Return values
- | Type | Description |
- | -------- | -------- |
- | Promise<boolean> | Promise used to return the task removal result. |
+**Return value**
-- Example
-
- ```
+| Type | Description |
+| -------- | -------- |
+| Promise<boolean> | Promise used to return the task removal result. |
+
+**Example**
+
+ ```js
downloadTask.remove().then((result) => {
if (result) {
console.info('Download task removed.');
@@ -675,31 +694,32 @@ Removes this download task. This method uses a promise to return the result.
remove(callback: AsyncCallback<boolean>): 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
**System capability**: SystemCapability.MiscServices.Download
-- Parameters
- | Name | Type | Mandatory | Description |
- | -------- | -------- | -------- | -------- |
- | callback | AsyncCallback<boolean> | Yes | Callback used to return the task removal result. |
+**Parameters**
-- Example
-
- ```
- downloadTask.remove((err, result)=>{
- if(err) {
- console.error('Failed to remove the download task.');
- return;
- }
- if (result) {
- console.info('Download task removed.');
- } else {
- console.error('Failed to remove the download task.');
- }
- });
+| Name | Type | Mandatory | Description |
+| -------- | -------- | -------- | -------- |
+| callback | AsyncCallback<boolean> | Yes | Callback used to return the task removal result. |
+
+**Example**
+
+ ```js
+downloadTask.remove((err, result)=>{
+ if(err) {
+ console.error('Failed to remove the download task.');
+ return;
+ }
+ if (result) {
+ console.info('Download task removed.');
+ } else {
+ console.error('Failed to remove the download task.');
+ }
+});
```
@@ -707,25 +727,26 @@ Removes this download task. This method uses an asynchronous callback to return
query(): Promise<DownloadInfo>
-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
**System capability**: SystemCapability.MiscServices.Download
-- Parameters
- | Type | Description |
- | -------- | -------- |
- | Promise<[DownloadInfo](#downloadinfo7)> | Promise used to return the download task information. |
+**Parameters**
-- Example
-
- ```
- downloadTask.query().then((downloadInfo) => {
- console.info('Download task queried. Data:' + JSON.stringify(downloadInfo))
- }) .catch((err) => {
- console.error('Failed to query the download task. Cause:' + err)
- });
+| Type | Description |
+| -------- | -------- |
+| Promise<[DownloadInfo](#downloadinfo7)> | Promise used to return the download task information. |
+
+**Example**
+
+ ```js
+downloadTask.query().then((downloadInfo) => {
+ console.info('Download task queried. Data:' + JSON.stringify(downloadInfo))
+}) .catch((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.
query(callback: AsyncCallback<DownloadInfo>): 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
**System capability**: SystemCapability.MiscServices.Download
-- Parameters
- | Name | Type | Mandatory | Description |
- | -------- | -------- | -------- | -------- |
- | callback | AsyncCallback<[DownloadInfo](#downloadinfo7)> | Yes | Callback used to return the download task information. |
+**Parameters**
-- Example
-
- ```
- downloadTask.query((err, downloadInfo)=>{
- if(err) {
- console.error('Failed to query the download mimeType. Cause:' + JSON.stringify(err));
- } else {
- console.info('download query success. data:'+ JSON.stringify(downloadInfo));
- }
- });
+| Name | Type | Mandatory | Description |
+| -------- | -------- | -------- | -------- |
+| callback | AsyncCallback<[DownloadInfo](#downloadinfo7)> | Yes | Callback used to return the download task information. |
+
+**Example**
+
+ ```js
+downloadTask.query((err, downloadInfo)=>{
+ if(err) {
+ console.error('Failed to query the download mimeType. Cause:' + JSON.stringify(err));
+ } else {
+ 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
queryMimeType(): Promise<string>
-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
**System capability**: SystemCapability.MiscServices.Download
-- Return values
- | Type | Description |
- | -------- | -------- |
- | Promise<string> | Promise used to return **MimeType** of the download task. |
+**Return value**
-- Example
-
- ```
- downloadTask.queryMimeType().then((data) => {
- console.info('Download task queried. Data:' + JSON.stringify(data));
- }).catch((err) => {
- console.error('Failed to query the download MimeType. Cause:' + JSON.stringify(err))
- });
+| Type | Description |
+| -------- | -------- |
+| Promise<string> | Promise used to return **MimeType** of the download task. |
+
+**Example**
+
+ ```js
+downloadTask.queryMimeType().then((data) => {
+ console.info('Download task queried. Data:' + JSON.stringify(data));
+}).catch((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
queryMimeType(callback: AsyncCallback<string>): 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
**System capability**: SystemCapability.MiscServices.Download
-- Parameters
- | Name | Type | Mandatory | Description |
- | -------- | -------- | -------- | -------- |
- | callback | AsyncCallback<string> | Yes | Callback used to return **MimeType** of the download task. |
+**Parameters**
-- Example
-
- ```
- downloadTask.queryMimeType((err, data)=>{
- if(err) {
- console.error('Failed to query the download mimeType. Cause:' + JSON.stringify(err));
- } else {
- console.info('Download task queried. data:' + JSON.stringify(data));
- }
- });
+| Name | Type | Mandatory | Description |
+| -------- | -------- | -------- | -------- |
+| callback | AsyncCallback<string> | Yes | Callback used to return **MimeType** of the download task. |
+
+**Example**
+
+ ```js
+downloadTask.queryMimeType((err, data)=>{
+ if(err) {
+ console.error('Failed to query the download mimeType. Cause:' + JSON.stringify(err));
+ } else {
+ 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
pause(): Promise<void>
-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
**System capability**: SystemCapability.MiscServices.Download
-- Return values
- | Type | Description |
- | -------- | -------- |
- | Promise<void> | Promise used to return the download task pause result. |
+**Return value**
-- Example
-
- ```
- downloadTask.pause().then((result) => {
- if (result) {
- console.info('Download task paused. ');
- } else {
- console.error('Failed to pause the download task. Cause:' + JSON.stringify(result));
- }
- }).catch((err) => {
- console.error('Failed to pause the download task. Cause:' + JSON.stringify(err));
- });
+| Type | Description |
+| -------- | -------- |
+| Promise<void> | Promise used to return the download task pause result. |
+
+**Example**
+
+ ```js
+downloadTask.pause().then((result) => {
+ if (result) {
+ console.info('Download task paused. ');
+ } else {
+ console.error('Failed to pause the download task. Cause:' + JSON.stringify(result));
+ }
+}).catch((err) => {
+ console.error('Failed to pause the download task. Cause:' + JSON.stringify(err));
+});
```
@@ -845,31 +870,32 @@ Pauses this download task. This method uses a promise to return the result.
pause(callback: AsyncCallback<void>): 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
**System capability**: SystemCapability.MiscServices.Download
-- Parameters
- | Name | Type | Mandatory | Description |
- | -------- | -------- | -------- | -------- |
- | callback | AsyncCallback<void> | Yes | Callback used to return the result. |
+**Parameters**
-- Example
-
- ```
- downloadTask.pause((err, result)=>{
- if(err) {
- console.error('Failed to pause the download task. Cause:' + JSON.stringify(err));
- return;
- }
- if (result) {
- console.info('Download task paused. ');
- } else {
- console.error('Failed to pause the download task. Cause:' + JSON.stringify(result));
- }
- });
+| Name | Type | Mandatory | Description |
+| -------- | -------- | -------- | -------- |
+| callback | AsyncCallback<void> | Yes | Callback used to return the result. |
+
+**Example**
+
+ ```js
+downloadTask.pause((err, result)=>{
+ if(err) {
+ console.error('Failed to pause the download task. Cause:' + JSON.stringify(err));
+ return;
+ }
+ if (result) {
+ console.info('Download task paused. ');
+ } else {
+ 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
resume(): Promise<void>
-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
**System capability**: SystemCapability.MiscServices.Download
-- Parameters
- | Type | Description |
- | -------- | -------- |
- | Promise<void> | Promise used to return the result. |
+**Parameters**
-- Example
-
- ```
- downloadTask.resume().then((result) => {
- if (result) {
- console.info('Download task resumed.')
- } else {
- console.error('Failed to resume the download task. ');
- }
- console.info('Download task resumed.')
- }).catch((err) => {
- console.error('Failed to resume the download task. Cause:' + err);
- });
+| Type | Description |
+| -------- | -------- |
+| Promise<void> | Promise used to return the result. |
+
+**Example**
+
+ ```js
+downloadTask.resume().then((result) => {
+ if (result) {
+ console.info('Download task resumed.')
+ } else {
+ console.error('Failed to resume the download task. ');
+ }
+ console.info('Download task resumed.')
+}).catch((err) => {
+ console.error('Failed to resume the download task. Cause:' + err);
+});
```
@@ -908,31 +935,32 @@ Resumes this download task. This method uses a promise to return the result.
resume(callback: AsyncCallback<void>): 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
**System capability**: SystemCapability.MiscServices.Download
-- Parameters
- | Name | Type | Mandatory | Description |
- | -------- | -------- | -------- | -------- |
- | callback | AsyncCallback<void> | Yes | Callback used to return the result. |
+**Parameters**
-- Example
-
- ```
- downloadTask.resume((err, result)=>{
- if (err) {
- console.error('Failed to resume the download task. Cause:' + err);
- return;
- }
- if (result) {
- console.info('Download task resumed.');
- } else {
- console.error('Failed to resume the download task.');
- }
- });
+| Name | Type | Mandatory | Description |
+| -------- | -------- | -------- | -------- |
+| callback | AsyncCallback<void> | Yes | Callback used to return the result. |
+
+**Example**
+
+ ```js
+downloadTask.resume((err, result)=>{
+ if (err) {
+ console.error('Failed to resume the download task. Cause:' + err);
+ return;
+ }
+ if (result) {
+ console.info('Download task resumed.');
+ } else {
+ console.error('Failed to resume the download task.');
+ }
+});
```
@@ -942,14 +970,14 @@ Resumes this download task. This method uses an asynchronous callback to return
| Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- |
-| url | string | Yes | Resource URL. |
-| header | object | No | HTTP or HTTPS header added to a download request. |
-| enableMetered | boolean | No | Download allowed in metered connections. |
-| enableRoaming | boolean | No | Download allowed on a roaming network. |
-| description | string | No | Description of the download session. |
-| filePath7+ | 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)). - filePath:'workspace/test.txt': The **workspace** directory is created in the default path to store files. - filePath:'test.txt': Files are stored in the default path. - filePath:'workspace/': The **workspace** directory is created in the default path to store files. |
-| networkType | number | No | Network type allowed for download. |
-| title | string | No | Title of the download session. |
+| url | string | Yes | Resource URL. |
+| header | object | No | HTTP or HTTPS header added to a download request. |
+| enableMetered | boolean | No | Download allowed in metered connections. |
+| enableRoaming | boolean | No | Download allowed on a roaming network. |
+| description | string | No | Description of the download session. |
+| filePath7+ | 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)). - filePath:'workspace/test.txt': The **workspace** directory is created in the default path to store files. - filePath:'test.txt': Files are stored in the default path. - filePath:'workspace/': The **workspace** directory is created in the default path to store files. |
+| networkType | number | No | Network type allowed for download. |
+| title | string | No | Title of the download session. |
## DownloadInfo7+
@@ -958,14 +986,14 @@ Resumes this download task. This method uses an asynchronous callback to return
| Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- |
-| downloadId | number | Yes | ID of the downloaded file. |
-| failedReason | number | No | Download failure cause, which can be any constant of [ERROR_*](#constants). |
-| fileName | string | Yes | Name of the downloaded file. |
-| filePath | string | Yes | URI of the saved file. |
-| pausedReason | number | No | Reason for session pause, which can be any constant of [PAUSED_*](#constants). |
-| status | number | Yes | Download status code, which can be any constant of [SESSION_*](#constants). |
-| targetURI | string | Yes | URI of the downloaded file. |
-| downloadTitle | string | Yes | Title of the downloaded file. |
-| downloadTotalBytes | number | Yes | Total size of the downloaded file (int bytes). |
-| description | string | Yes | Description of the file to download. |
-| downloadedBytes | number | Yes | Size of the files downloaded (int bytes). |
+| downloadId | number | Yes | ID of the downloaded file. |
+| failedReason | number | No | Download failure cause, which can be any constant of [ERROR_*](#constants). |
+| fileName | string | Yes | Name of the downloaded file. |
+| filePath | string | Yes | URI of the saved file. |
+| pausedReason | number | No | Reason for session pause, which can be any constant of [PAUSED_*](#constants). |
+| status | number | Yes | Download status code, which can be any constant of [SESSION_*](#constants). |
+| targetURI | string | Yes | URI of the downloaded file. |
+| downloadTitle | string | Yes | Title of the downloaded file. |
+| downloadTotalBytes | number | Yes | Total size of the downloaded file (int bytes). |
+| description | string | Yes | Description of the file to download. |
+| downloadedBytes | number | Yes | Size of the files downloaded (int bytes). |
diff --git a/en/application-dev/reference/apis/js-apis-system-time.md b/en/application-dev/reference/apis/js-apis-system-time.md
index 35096fe9a772de7ef95ea21d4e7660f850db366d..74beca3c0aacbabd628f99f7987b96caf5988f61 100644
--- a/en/application-dev/reference/apis/js-apis-system-time.md
+++ b/en/application-dev/reference/apis/js-apis-system-time.md
@@ -1,12 +1,12 @@
# Setting the System Time
->  **NOTE**
-> 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.
+>  **NOTE** 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
-
+
```
import systemTime from '@ohos.systemTime';
```
@@ -22,16 +22,17 @@ Sets the system time. This API uses an asynchronous callback to return the resul
**System capability**: SystemCapability.MiscServices.Time
-- **Parameters**
- | Name| Type| Mandatory| Description|
- | -------- | -------- | -------- | -------- |
- | time | number | Yes| Timestamp to set, in milliseconds.|
- | callback | AsyncCallback<void> | Yes| Callback used to process the received return value.|
+**Parameters**
-- Example
-
- ```
- // Set the system time to 2021-01-20 02:36:25.
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| time | number | Yes| Timestamp to set, in milliseconds.|
+| callback | AsyncCallback<void> | Yes| Callback used to process the received return value.|
+
+**Example**
+
+ ```js
+// Set the system time to 2021-01-20 02:36:25.
var time = 1611081385000;
systemTime.setTime(time, (error, data) => {
if (error) {
@@ -53,26 +54,28 @@ Sets the system time. This API uses a promise to return the result.
**System capability**: SystemCapability.MiscServices.Time
-- **Parameters**
- | Name| Type| Mandatory| Description|
- | -------- | -------- | -------- | -------- |
- | time | number | Yes| Timestamp to set, in milliseconds.|
+**Parameters**
-- Return value
- | Type| Description|
- | -------- | -------- |
- | Promise<void> | Promise used to return the result.|
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| time | number | Yes| Timestamp to set, in milliseconds.|
-- Example
-
- ```
- // 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));
- }).catch((error) => {
- console.error(`failed to systemTime.setTime because ` + JSON.stringify(error));
- });
+**Return value**
+
+| Type| Description|
+| -------- | -------- |
+| Promise<void> | Promise used to return the result.|
+
+**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));
+}).catch((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
**System capability**: SystemCapability.MiscServices.Time
-- **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<number> | Yes| Callback used to return the time.|
+**Parameters**
-- 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<number> | Yes| Callback used to return the time.|
+
+**Example**
+
+ ```js
systemTime.getCurrentTime(true, (error, data) => {
if (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
**System capability**: SystemCapability.MiscServices.Time
-- **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.|
+**Parameters**
-- Return value
- | Type| Description|
- | -------- | -------- |
- | Promise<number> | Promise used to return the time.|
+| 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.|
-- Example
-
- ```
+**Return value**
+
+| Type| Description|
+| -------- | -------- |
+| Promise<number> | Promise used to return the time.|
+
+**Example**
+
+ ```js
systemTime.getCurrentTime().then((data) => {
console.log(`systemTime.getCurrentTime success data : ` + JSON.stringify(data));
}).catch((error) => {
@@ -140,15 +146,16 @@ Obtains the time elapsed since system start, excluding the deep sleep time. This
**System capability**: SystemCapability.MiscServices.Time
-- **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<number> | Yes| Callback used to return the time.|
+**Parameters**
-- 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<number> | Yes| Callback used to return the time.|
+
+**Example**
+
+ ```js
systemTime.getRealActiveTime(true, (error, data) => {
if (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
**System capability**: SystemCapability.MiscServices.Time
-- **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.|
+**Parameters**
-- Return value
- | Type| Description|
- | -------- | -------- |
- | Promise<number> | Promise used to return the time.|
+| 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.|
-- Example
-
- ```
+**Return value**
+
+| Type| Description|
+| -------- | -------- |
+| Promise<number> | Promise used to return the time.|
+
+**Example**
+
+ ```js
systemTime.getCurrentTime().then((data) => {
console.log(`systemTime.getRealActiveTime success data : ` + JSON.stringify(data));
}).catch((error) => {
@@ -196,15 +205,16 @@ Obtains the time elapsed since system start, including the deep sleep time. This
**System capability**: SystemCapability.MiscServices.Time
-- **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<number> | Yes| Callback used to return the time.|
+**Parameters**
-- 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<number> | Yes| Callback used to return the time.|
+
+**Example**
+
+ ```js
systemTime.getRealTime(true, (error, data) => {
if (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
**System capability**: SystemCapability.MiscServices.Time
-- **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.|
+**Parameters**
-- Return value
- | Type| Description|
- | -------- | -------- |
- | Promise<number> | Promise used to return the time.|
+| 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.|
-- Example
-
- ```
+**Return value**
+
+| Type| Description|
+| -------- | -------- |
+| Promise<number> | Promise used to return the time.|
+
+**Example**
+
+ ```js
systemTime.getRealTime().then((data) => {
console.log(`systemTime.getRealTime success data: ` + JSON.stringify(data));
}).catch((error) => {
@@ -254,15 +266,16 @@ Sets the system date. This API uses an asynchronous callback to return the resul
**System capability**: SystemCapability.MiscServices.Time
-- **Parameters**
- | Name| Type| Mandatory| Description|
- | -------- | -------- | -------- | -------- |
- | date | Date | Yes| Target date to set.|
- | callback | AsyncCallback<void> | Yes| Callback used to process the received return value.|
+**Parameters**
-- Example
-
- ```
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| date | Date | Yes| Target date to set.|
+| callback | AsyncCallback<void> | Yes| Callback used to process the received return value.|
+
+**Example**
+
+ ```js
var data = new Date("October 13, 2020 11:13:00");
systemTime.setDate(data,(error, data) => {
if (error) {
@@ -284,19 +297,21 @@ Sets the system date. This API uses a promise to return the result.
**System capability**: SystemCapability.MiscServices.Time
-- **Parameters**
- | Name| Type| Mandatory| Description|
- | -------- | -------- | -------- | -------- |
- | date | Date | Yes| Target date to set.|
+**Parameters**
-- Return value
- | Type| Description|
- | -------- | -------- |
- | Promise<void> | Promise used to return the result.|
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| date | Date | Yes| Target date to set.|
-- Example
-
- ```
+**Return value**
+
+| Type| Description|
+| -------- | -------- |
+| Promise<void> | Promise used to return the result.|
+
+**Example**
+
+ ```js
var data = new Date("October 13, 2020 11:13:00");
systemTime.setDate(data).then((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
**System capability**: SystemCapability.MiscServices.Time
-- **Parameters**
- | Name| Type| Mandatory| Description|
- | -------- | -------- | -------- | -------- |
- | callback | AsyncCallback<Date> | Yes| Callback used to return the current system date.|
+**Parameters**
-- Example
-
- ```
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| callback | AsyncCallback<Date> | Yes| Callback used to return the current system date.|
+
+**Example**
+
+ ```js
systemTime.getDate((error, data) => {
if (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.
**System capability**: SystemCapability.MiscServices.Time
-- Return value
- | Type| Description|
- | -------- | -------- |
- | Promise<Date> | Promise used to return the current system date.|
+**Return value**
-- Example
-
- ```
+| Type| Description|
+| -------- | -------- |
+| Promise<Date> | Promise used to return the current system date.|
+
+**Example**
+
+ ```js
systemTime.getDate().then((data) => {
console.log(`systemTime.getDate success data : ` + JSON.stringify(data));
}).catch((error) => {
@@ -366,15 +383,16 @@ Sets the system time zone. This API uses an asynchronous callback to return the
**System capability**: SystemCapability.MiscServices.Time
-- **Parameters**
- | Name| Type| Mandatory| Description|
- | -------- | -------- | -------- | -------- |
- | timezone | string | Yes| System time zone to set.|
- | callback | AsyncCallback<void> | Yes| Callback used to process the received return value.|
+**Parameters**
-- Example
-
- ```
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| timezone | string | Yes| System time zone to set.|
+| callback | AsyncCallback<void> | Yes| Callback used to process the received return value.|
+
+**Example**
+
+ ```js
systemTime.setTimezone('Asia/Shanghai', (error, data) => {
if (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.
**System capability**: SystemCapability.MiscServices.Time
-- **Parameters**
- | Name| Type| Mandatory| Description|
- | -------- | -------- | -------- | -------- |
- | timezone | string | Yes| System time zone to set.|
+**Parameters**
-- Return value
- | Type| Description|
- | -------- | -------- |
- | Promise<void> | Promise used to return the result.|
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| timezone | string | Yes| System time zone to set.|
-- Example
-
- ```
+**Return value**
+
+| Type| Description|
+| -------- | -------- |
+| Promise<void> | Promise used to return the result.|
+
+**Example**
+
+ ```js
systemTime.setTimezone('Asia/Shanghai').then((data) => {
console.log(`systemTime.setTimezone success data : ` + JSON.stringify(data));
}).catch((error) => {
@@ -424,14 +444,15 @@ Obtains the system time zone. This API uses an asynchronous callback to return t
**System capability**: SystemCapability.MiscServices.Time
-- **Parameters**
- | Name| Type| Mandatory| Description|
- | -------- | -------- | -------- | -------- |
- | callback | AsyncCallback<string> | Yes| Callback used to return the system time zone.|
+**Parameters**
-- Example
-
- ```
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| callback | AsyncCallback<string> | Yes| Callback used to return the system time zone.|
+
+**Example**
+
+ ```js
systemTime.getTimezone((error, data) => {
if (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.
**System capability**: SystemCapability.MiscServices.Time
-- Return value
- | Type| Description|
- | -------- | -------- |
- | Promise<string> | Promise used to return the system time zone.|
+**Return value**
-- Example
-
- ```
+| Type| Description|
+| -------- | -------- |
+| Promise<string> | Promise used to return the system time zone.|
+
+**Example**
+
+ ```js
systemTime.getTimezone().then((data) => {
console.log(`systemTime.getTimezone success data : ` + JSON.stringify(data));
}).catch((error) => {
diff --git a/en/application-dev/reference/apis/js-apis-wallpaper.md b/en/application-dev/reference/apis/js-apis-wallpaper.md
index 8f0d4aaae67090bf9335b223e6882852397a4a23..8e0038daacc3d195b5642c2518dfa926afaff517 100644
--- a/en/application-dev/reference/apis/js-apis-wallpaper.md
+++ b/en/application-dev/reference/apis/js-apis-wallpaper.md
@@ -1,8 +1,8 @@
# Wallpaper
->  **Note:**
-> 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.
+>  **NOTE** 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
@@ -21,8 +21,8 @@ Defines the wallpaper type.
| Name | Description |
| -------- | -------- |
-| WALLPAPER_LOCKSCREEN | Lock screen wallpaper. |
-| WALLPAPER_SYSTEM | Home screen wallpaper. |
+| WALLPAPER_LOCKSCREEN | Lock screen wallpaper. |
+| WALLPAPER_SYSTEM | Home screen wallpaper. |
## wallpaper.getColors
@@ -36,12 +36,12 @@ Obtains the main color information of the wallpaper of a specified type.
- Parameters
| Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- |
- | wallpaperType | [WallpaperType](#wallpapertype) | Yes | Wallpaper type. |
- | callback | AsyncCallback<Array<[RgbaColor](#rgbacolor)>> | Yes | Callback used to return the main color information of the wallpaper. |
+ | wallpaperType | [WallpaperType](#wallpapertype) | Yes | Wallpaper type. |
+ | callback | AsyncCallback<Array<[RgbaColor](#rgbacolor)>> | Yes | Callback used to return the main color information of the wallpaper. |
- Example
- ```
+ ```js
wallpaper.getColors(wallpaper.WallpaperType.WALLPAPER_SYSTEM, (error, data) => {
if (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.
**System capability**: SystemCapability.MiscServices.Wallpaper
-- Parameters
- | Name | Type | Mandatory | Description |
- | -------- | -------- | -------- | -------- |
- | wallpaperType | [WallpaperType](#wallpapertype) | Yes | Wallpaper type. |
+**Parameters**
-- Return values
- | Type | Description |
- | -------- | -------- |
- | Promise<Array<[RgbaColor](#rgbacolor)>> | Promise used to return the main color information of the wallpaper. |
+| Name | Type | Mandatory | Description |
+| -------- | -------- | -------- | -------- |
+| wallpaperType | [WallpaperType](#wallpapertype) | Yes | Wallpaper type. |
-- Example
-
- ```
- wallpaper.getColors(wallpaper.WallpaperType.WALLPAPER_SYSTEM).then((data) => {
- console.log(`success to getColors.`);
- }).catch((error) => {
- console.error(`failed to getColors because: ` + JSON.stringify(error));
- });
- ```
+**Return value**
+
+| Type | Description |
+| -------- | -------- |
+| Promise<Array<[RgbaColor](#rgbacolor)>> | 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.`);
+}).catch((error) => {
+ console.error(`failed to getColors because: ` + JSON.stringify(error));
+});
+```
## wallpaper.getId
@@ -89,23 +91,24 @@ Obtains the ID of the wallpaper of the specified type.
**System capability**: SystemCapability.MiscServices.Wallpaper
-- Parameters
- | Name | Type | Mandatory | Description |
- | -------- | -------- | -------- | -------- |
- | wallpaperType | [WallpaperType](#wallpapertype) | Yes | Wallpaper type. |
- | callback | AsyncCallback<number> | 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. |
+**Parameters**
-- Example
-
- ```
- wallpaper.getId(wallpaper.WallpaperType.WALLPAPER_SYSTEM, (error, data) => {
- if (error) {
- console.error(`failed to getId because: ` + JSON.stringify(error));
- return;
- }
- console.log(`success to getId: ` + JSON.stringify(data));
- });
- ```
+| Name | Type | Mandatory | Description |
+| -------- | -------- | -------- | -------- |
+| wallpaperType | [WallpaperType](#wallpapertype) | Yes | Wallpaper type. |
+| callback | AsyncCallback<number> | 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**
+
+```js
+wallpaper.getId(wallpaper.WallpaperType.WALLPAPER_SYSTEM, (error, data) => {
+ if (error) {
+ console.error(`failed to getId because: ` + JSON.stringify(error));
+ return;
+ }
+ console.log(`success to getId: ` + JSON.stringify(data));
+});
+```
## wallpaper.getId
@@ -116,26 +119,27 @@ Obtains the ID of the wallpaper of the specified type.
**System capability**: SystemCapability.MiscServices.Wallpaper
+**Parameters**
-- Parameters
- | Name | Type | Mandatory | Description |
- | -------- | -------- | -------- | -------- |
- | wallpaperType | [WallpaperType](#wallpapertype) | Yes | Wallpaper type. |
+| Name | Type | Mandatory | Description |
+| -------- | -------- | -------- | -------- |
+| wallpaperType | [WallpaperType](#wallpapertype) | Yes | Wallpaper type. |
-- Return values
- | Type | Description |
- | -------- | -------- |
- | Promise<number> | 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. |
+**Return value**
-- Example
-
- ```
- wallpaper.getId(wallpaper.WallpaperType.WALLPAPER_SYSTEM).then((data) => {
- console.log(`success to getId: ` + JSON.stringify(data));
- }).catch((error) => {
- console.error(`failed to getId because: ` + JSON.stringify(error));
- });
- ```
+| Type | Description |
+| -------- | -------- |
+| Promise<number> | 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**
+
+```js
+wallpaper.getId(wallpaper.WallpaperType.WALLPAPER_SYSTEM).then((data) => {
+ console.log(`success to getId: ` + JSON.stringify(data));
+}).catch((error) => {
+ console.error(`failed to getId because: ` + JSON.stringify(error));
+});
+```
## wallpaper.getMinHeight
@@ -146,22 +150,23 @@ Obtains the minimum height of the wallpaper.
**System capability**: SystemCapability.MiscServices.Wallpaper
-- Parameters
- | Name | Type | Mandatory | Description |
- | -------- | -------- | -------- | -------- |
- | callback | AsyncCallback<number> | 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. |
+**Parameters**
-- Example
-
- ```
- wallpaper.getMinHeight((error, data) => {
- if (error) {
- console.error(`failed to getMinHeight because: ` + JSON.stringify(error));
- return;
- }
- console.log(`success to getMinHeight: ` + JSON.stringify(data));
- });
- ```
+| Name | Type | Mandatory | Description |
+| -------- | -------- | -------- | -------- |
+| callback | AsyncCallback<number> | 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**
+
+```js
+wallpaper.getMinHeight((error, data) => {
+ if (error) {
+ console.error(`failed to getMinHeight because: ` + JSON.stringify(error));
+ return;
+ }
+ console.log(`success to getMinHeight: ` + JSON.stringify(data));
+});
+```
## wallpaper.getMinHeight
@@ -172,21 +177,21 @@ Obtains the minimum height of the wallpaper.
**System capability**: SystemCapability.MiscServices.Wallpaper
+**Return value**
-- Return values
- | Type | Description |
- | -------- | -------- |
- | Promise<number> | 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. |
+| Type | Description |
+| -------- | -------- |
+| Promise<number> | 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. |
-- Example
-
- ```
- wallpaper.getMinHeight().then((data) => {
- console.log(`success to getMinHeight: ` + JSON.stringify(data));
- }).catch((error) => {
- console.error(`failed to getMinHeight because: ` + JSON.stringify(error));
- });
- ```
+**Example**
+
+```js
+wallpaper.getMinHeight().then((data) => {
+ console.log(`success to getMinHeight: ` + JSON.stringify(data));
+}).catch((error) => {
+ console.error(`failed to getMinHeight because: ` + JSON.stringify(error));
+});
+```
## wallpaper.getMinWidth
@@ -197,23 +202,23 @@ Obtains the minimum width of the wallpaper.
**System capability**: SystemCapability.MiscServices.Wallpaper
+**Parameters**
-- Parameters
- | Name | Type | Mandatory | Description |
- | -------- | -------- | -------- | -------- |
- | callback | AsyncCallback<number> | 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. |
+| Name | Type | Mandatory | Description |
+| -------- | -------- | -------- | -------- |
+| callback | AsyncCallback<number> | 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. |
-- Example
-
- ```
- wallpaper.getMinWidth((error, data) => {
- if (error) {
- console.error(`failed to getMinWidth because: ` + JSON.stringify(error));
- return;
- }
- console.log(`success to getMinWidth: ` + JSON.stringify(data));
- });
- ```
+**Example**
+
+```js
+wallpaper.getMinWidth((error, data) => {
+ if (error) {
+ console.error(`failed to getMinWidth because: ` + JSON.stringify(error));
+ return;
+ }
+ console.log(`success to getMinWidth: ` + JSON.stringify(data));
+});
+```
## wallpaper.getMinWidth
@@ -224,20 +229,21 @@ Obtains the minimum width of the wallpaper.
**System capability**: SystemCapability.MiscServices.Wallpaper
-- Return values
- | Type | Description |
- | -------- | -------- |
- | Promise<number> | 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. |
+**Return value**
-- Example
-
- ```
- wallpaper.getMinWidth().then((data) => {
- console.log(`success to getMinWidth: ` + JSON.stringify(data));
- }).catch((error) => {
- console.error(`failed to getMinWidth because: ` + JSON.stringify(error));
- });
- ```
+| Type | Description |
+| -------- | -------- |
+| Promise<number> | 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**
+
+```js
+wallpaper.getMinWidth().then((data) => {
+ console.log(`success to getMinWidth: ` + JSON.stringify(data));
+}).catch((error) => {
+ console.error(`failed to getMinWidth because: ` + JSON.stringify(error));
+});
+```
## wallpaper.isChangePermitted
@@ -248,22 +254,23 @@ Checks whether to allow the application to change the wallpaper for the current
**System capability**: SystemCapability.MiscServices.Wallpaper
-- Parameters
- | Name | Type | Mandatory | Description |
- | -------- | -------- | -------- | -------- |
- | callback | AsyncCallback<boolean> | Yes | Callback used to return the queried result. Returns **true** if it is allowed; returns **false** otherwise. |
+**Parameters**
-- Example
-
- ```
- wallpaper.isChangePermitted((error, data) => {
- if (error) {
- console.error(`failed to isChangePermitted because: ` + JSON.stringify(error));
- return;
- }
- console.log(`success to isChangePermitted: ` + JSON.stringify(data));
- });
- ```
+| Name | Type | Mandatory | Description |
+| -------- | -------- | -------- | -------- |
+| callback | AsyncCallback<boolean> | Yes | Callback used to return the queried result. Returns **true** if it is allowed; returns **false** otherwise. |
+
+**Example**
+
+```js
+wallpaper.isChangePermitted((error, data) => {
+ if (error) {
+ console.error(`failed to isChangePermitted because: ` + JSON.stringify(error));
+ return;
+ }
+ console.log(`success to isChangePermitted: ` + JSON.stringify(data));
+});
+```
## wallpaper.isChangePermitted
@@ -274,20 +281,21 @@ Checks whether to allow the application to change the wallpaper for the current
**System capability**: SystemCapability.MiscServices.Wallpaper
-- Return values
- | Type | Description |
- | -------- | -------- |
- | Promise<boolean> | 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. |
+**Return value**
-- Example
-
- ```
- wallpaper.isChangePermitted().then((data) => {
- console.log(`success to isChangePermitted: ` + JSON.stringify(data));
- }).catch((error) => {
- console.error(`failed to isChangePermitted because: ` + JSON.stringify(error));
- });
- ```
+| Type | Description |
+| -------- | -------- |
+| Promise<boolean> | 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**
+
+```js
+wallpaper.isChangePermitted().then((data) => {
+ console.log(`success to isChangePermitted: ` + JSON.stringify(data));
+}).catch((error) => {
+ console.error(`failed to isChangePermitted because: ` + JSON.stringify(error));
+});
+```
## wallpaper.isOperationAllowed
@@ -298,22 +306,23 @@ Checks whether the user is allowed to set wallpapers.
**System capability**: SystemCapability.MiscServices.Wallpaper
-- Parameters
- | Name | Type | Mandatory | Description |
- | -------- | -------- | -------- | -------- |
- | callback | AsyncCallback<boolean> | Yes | Callback used to return whether the user is allowed to set wallpapers. Returns **true** if it is allowed; returns **false** otherwise. |
+**Parameters**
-- Example
-
- ```
- wallpaper.isOperationAllowed((error, data) => {
- if (error) {
- console.error(`failed to isOperationAllowed because: ` + JSON.stringify(error));
- return;
- }
- console.log(`success to isOperationAllowed: ` + JSON.stringify(data));
- });
- ```
+| Name | Type | Mandatory | Description |
+| -------- | -------- | -------- | -------- |
+| callback | AsyncCallback<boolean> | Yes | Callback used to return whether the user is allowed to set wallpapers. Returns **true** if it is allowed; returns **false** otherwise. |
+
+**Example**
+
+```js
+wallpaper.isOperationAllowed((error, data) => {
+ if (error) {
+ console.error(`failed to isOperationAllowed because: ` + JSON.stringify(error));
+ return;
+ }
+ console.log(`success to isOperationAllowed: ` + JSON.stringify(data));
+});
+```
## wallpaper.isOperationAllowed
@@ -324,20 +333,21 @@ Checks whether the user is allowed to set wallpapers.
**System capability**: SystemCapability.MiscServices.Wallpaper
-- Return values
- | Type | Description |
- | -------- | -------- |
- | Promise<boolean> | Promise used to return whether the user is allowed to set wallpapers. Returns **true** if it is allowed; returns **false** otherwise. |
+**Return value**
-- Example
-
- ```
- wallpaper.isOperationAllowed().then((data) => {
- console.log(`success to isOperationAllowed: ` + JSON.stringify(data));
- }).catch((error) => {
- console.error(`failed to isOperationAllowed because: ` + JSON.stringify(error));
- });
- ```
+| Type | Description |
+| -------- | -------- |
+| Promise<boolean> | Promise used to return whether the user is allowed to set wallpapers. Returns **true** if it is allowed; returns **false** otherwise. |
+
+**Example**
+
+```js
+wallpaper.isOperationAllowed().then((data) => {
+ console.log(`success to isOperationAllowed: ` + JSON.stringify(data));
+}).catch((error) => {
+ console.error(`failed to isOperationAllowed because: ` + JSON.stringify(error));
+});
+```
## wallpaper.reset
@@ -350,23 +360,24 @@ Removes a wallpaper of the specified type and restores the default one.
**System capability**: SystemCapability.MiscServices.Wallpaper
-- Parameters
- | Name | Type | Mandatory | Description |
- | -------- | -------- | -------- | -------- |
- | wallpaperType | [WallpaperType](#wallpapertype) | Yes | Wallpaper type. |
- | callback | AsyncCallback<void> | Yes | Callback used to return the result. If the operation is successful, the result of removal is returned. Otherwise, error information is returned. |
+**Parameters**
-- Example
-
- ```
- wallpaper.reset(wallpaper.WallpaperType.WALLPAPER_SYSTEM, (error, data) => {
- if (error) {
- console.error(`failed to reset because: ` + JSON.stringify(error));
- return;
- }
- console.log(`success to reset.`);
- });
- ```
+| Name | Type | Mandatory | Description |
+| -------- | -------- | -------- | -------- |
+| wallpaperType | [WallpaperType](#wallpapertype) | Yes | Wallpaper type. |
+| callback | AsyncCallback<void> | Yes | Callback 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, (error, data) => {
+ if (error) {
+ console.error(`failed to reset because: ` + JSON.stringify(error));
+ return;
+ }
+ console.log(`success to reset.`);
+});
+```
## wallpaper.reset
@@ -379,25 +390,27 @@ Removes a wallpaper of the specified type and restores the default one.
**System capability**: SystemCapability.MiscServices.Wallpaper
-- Parameters
- | Name | Type | Mandatory | Description |
- | -------- | -------- | -------- | -------- |
- | wallpaperType | [WallpaperType](#wallpapertype) | Yes | Wallpaper type. |
+**Parameters**
-- Return values
- | Type | Description |
- | -------- | -------- |
- | Promise<void> | Promise used to return the result. If the operation is successful, the result of removal is returned. Otherwise, error information is returned. |
+| Name | Type | Mandatory | Description |
+| -------- | -------- | -------- | -------- |
+| wallpaperType | [WallpaperType](#wallpapertype) | Yes | Wallpaper type. |
-- Example
-
- ```
- wallpaper.reset(wallpaper.WallpaperType.WALLPAPER_SYSTEM).then((data) => {
- console.log(`success to reset.`);
- }).catch((error) => {
- console.error(`failed to reset because: ` + JSON.stringify(error));
- });
- ```
+**Return value**
+
+| Type | Description |
+| -------- | -------- |
+| Promise<void> | 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.`);
+}).catch((error) => {
+ console.error(`failed to reset because: ` + JSON.stringify(error));
+});
+```
## wallpaper.setWallpaper
@@ -410,47 +423,48 @@ Sets a specified source as the wallpaper of a specified type.
**System capability**: SystemCapability.MiscServices.Wallpaper
-- Parameters
- | 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<void> | 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";
- wallpaper.setWallpaper(wallpaperPath, wallpaper.WallpaperType.WALLPAPER_SYSTEM, (error, data) => {
- if (error) {
- console.error(`failed to setWallpaper because: ` + JSON.stringify(error));
- return;
- }
- console.log(`success to setWallpaper.`);
- });
-
- //The source type is image.PixelMap.
- import image from '@ohos.multimedia.image';
- let imageSource = image.createImageSource("file://" + wallpaperPath);
- let opts = {
- "desiredSize": {
- "height": 3648,
- "width": 2736
- }
- };
- imageSource.createPixelMap(opts).then((pixelMap) => {
- wallpaper.setWallpaper(pixelMap, wallpaper.WallpaperType.WALLPAPER_SYSTEM, (error, data) => {
- if (error) {
- console.error(`failed to setWallpaper because: ` + JSON.stringify(error));
- return;
- }
- console.log(`success to setWallpaper.`);
- });
- }).catch((error) => {
- console.error(`failed to createPixelMap because: ` + JSON.stringify(error));
- });
- ```
+**Parameters**
+
+| 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<void> | Yes | Callback used to return the result. If the operation is successful, the setting result is returned. Otherwise, error information is returned. |
+
+**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, (error, data) => {
+ if (error) {
+ console.error(`failed to setWallpaper because: ` + JSON.stringify(error));
+ return;
+ }
+ console.log(`success to setWallpaper.`);
+});
+
+// The source type is image.PixelMap.
+import image from '@ohos.multimedia.image';
+let imageSource = image.createImageSource("file://" + wallpaperPath);
+let opts = {
+ "desiredSize": {
+ "height": 3648,
+ "width": 2736
+ }
+};
+imageSource.createPixelMap(opts).then((pixelMap) => {
+ wallpaper.setWallpaper(pixelMap, wallpaper.WallpaperType.WALLPAPER_SYSTEM, (error, data) => {
+ if (error) {
+ console.error(`failed to setWallpaper because: ` + JSON.stringify(error));
+ return;
+ }
+ console.log(`success to setWallpaper.`);
+ });
+}).catch((error) => {
+ console.error(`failed to createPixelMap because: ` + JSON.stringify(error));
+});
+```
## wallpaper.setWallpaper
@@ -463,47 +477,49 @@ Sets a specified source as the wallpaper of a specified type.
**System capability**: SystemCapability.MiscServices.Wallpaper
-- Parameters
- | 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. |
+**Parameters**
-- Return values
- | Type | Description |
- | -------- | -------- |
- | Promise<void> | Promise used to return the result. If the operation is successful, the setting result is returned. Otherwise, error information is returned. |
+| 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. |
-- Example
-
- ```
- //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.`);
- }).catch((error) => {
- console.error(`failed to setWallpaper because: ` + JSON.stringify(error));
- });
-
- //The source type is image.PixelMap.
- import image from '@ohos.multimedia.image';
- let imageSource = image.createImageSource("file://" + wallpaperPath);
- let opts = {
- "desiredSize": {
- "height": 3648,
- "width": 2736
- }
- };
- imageSource.createPixelMap(opts).then((pixelMap) => {
- wallpaper.setWallpaper(pixelMap, wallpaper.WallpaperType.WALLPAPER_SYSTEM).then((data) => {
- console.log(`success to setWallpaper.`);
- }).catch((error) => {
- console.error(`failed to setWallpaper because: ` + JSON.stringify(error));
- });
- }).catch((error) => {
- console.error(`failed to createPixelMap because: ` + JSON.stringify(error));
- });
- ```
+**Return value**
+
+| Type | Description |
+| -------- | -------- |
+| Promise<void> | Promise used to return the result. If the operation is successful, the setting result is returned. Otherwise, error information is returned. |
+
+**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.`);
+}).catch((error) => {
+ console.error(`failed to setWallpaper because: ` + JSON.stringify(error));
+});
+
+// The source type is image.PixelMap.
+import image from '@ohos.multimedia.image';
+let imageSource = image.createImageSource("file://" + wallpaperPath);
+let opts = {
+ "desiredSize": {
+ "height": 3648,
+ "width": 2736
+ }
+};
+imageSource.createPixelMap(opts).then((pixelMap) => {
+ wallpaper.setWallpaper(pixelMap, wallpaper.WallpaperType.WALLPAPER_SYSTEM).then((data) => {
+ console.log(`success to setWallpaper.`);
+ }).catch((error) => {
+ console.error(`failed to setWallpaper because: ` + JSON.stringify(error));
+ });
+}).catch((error) => {
+ console.error(`failed to createPixelMap because: ` + JSON.stringify(error));
+});
+```
## wallpaper.getFile8+
@@ -511,27 +527,28 @@ getFile(wallpaperType: WallpaperType, callback: AsyncCallback<number>): vo
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
-- Parameters
- | Name | Type | Mandatory | Description |
- | -------- | -------- | -------- | -------- |
- | wallpaperType | [WallpaperType](#wallpapertype) | Yes | Wallpaper type. |
- | callback | AsyncCallback<number> | 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. |
+**Parameters**
-- Example
-
- ```
- wallpaper.getFile(wallpaper.WallpaperType.WALLPAPER_SYSTEM, (error, data) => {
- if (error) {
- console.error(`failed to getFile because: ` + JSON.stringify(error));
- return;
- }
- console.log(`success to getFile: ` + JSON.stringify(data));
- });
- ```
+| Name | Type | Mandatory | Description |
+| -------- | -------- | -------- | -------- |
+| wallpaperType | [WallpaperType](#wallpapertype) | Yes | Wallpaper type. |
+| callback | AsyncCallback<number> | 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**
+
+```js
+wallpaper.getFile(wallpaper.WallpaperType.WALLPAPER_SYSTEM, (error, data) => {
+ if (error) {
+ console.error(`failed to getFile because: ` + JSON.stringify(error));
+ return;
+ }
+ console.log(`success to getFile: ` + JSON.stringify(data));
+});
+```
## wallpaper.getFile8+
@@ -543,25 +560,27 @@ Obtains the wallpaper of the specified type.
**System capability**: SystemCapability.MiscServices.Wallpaper
-- Parameters
- | Name | Type | Mandatory | Description |
- | -------- | -------- | -------- | -------- |
- | wallpaperType | [WallpaperType](#wallpapertype) | Yes | Wallpaper type. |
+**Parameters**
-- Return values
- | Type | Description |
- | -------- | -------- |
- | Promise<number> | 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. |
+| Name | Type | Mandatory | Description |
+| -------- | -------- | -------- | -------- |
+| wallpaperType | [WallpaperType](#wallpapertype) | Yes | Wallpaper type. |
-- Example
-
- ```
- wallpaper.getFile(wallpaper.WallpaperType.WALLPAPER_SYSTEM).then((data) => {
- console.log(`success to getFile: ` + JSON.stringify(data));
- }).catch((error) => {
- console.error(`failed to getFile because: ` + JSON.stringify(error));
- });
- ```
+**Return value**
+
+| Type | Description |
+| -------- | -------- |
+| Promise<number> | 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));
+}).catch((error) => {
+ console.error(`failed to getFile because: ` + JSON.stringify(error));
+});
+```
## wallpaper.on('colorChange')
@@ -572,20 +591,21 @@ Subscribes to the wallpaper color change event.
**System capability**: SystemCapability.MiscServices.Wallpaper
-- Parameters
- | 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. - colors Main color information of the wallpaper. For details, see [RgbaColor](#rgbacolor). - wallpaperType Wallpaper type. |
+**Parameters**
-- Example
-
- ```
- let listener = (colors, wallpaperType) => {
- console.log(`wallpaper color changed.`);
- };
- wallpaper.on('colorChange', listener);
- ```
+| 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. - colors Main color information of the wallpaper. For details, see [RgbaColor](#rgbacolor). - wallpaperType Wallpaper type. |
+
+**Example**
+
+```js
+let listener = (colors, wallpaperType) => {
+ console.log(`wallpaper color changed.`);
+};
+wallpaper.on('colorChange', listener);
+```
## wallpaper.off('colorChange')
@@ -596,24 +616,25 @@ Unsubscribes from the wallpaper color change event.
**System capability**: SystemCapability.MiscServices.Wallpaper
-- Parameters
- | 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. - colors Main color information of the wallpaper. For details, see [RgbaColor](#rgbacolor). - wallpaperType Wallpaper type. |
+**Parameters**
-- Example
-
- ```
- let listener = (colors, wallpaperType) => {
- console.log(`wallpaper color changed.`);
- };
- wallpaper.on('colorChange', listener);
- // Unsubscribe from the listener.
- wallpaper.off('colorChange', listener);
- //Unsubscribe from all subscriptions of the colorChange type.
- wallpaper.off('colorChange');
- ```
+| 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. - colors Main color information of the wallpaper. For details, see [RgbaColor](#rgbacolor). - wallpaperType Wallpaper type. |
+
+**Example**
+
+```js
+let listener = (colors, wallpaperType) => {
+ console.log(`wallpaper color changed.`);
+};
+wallpaper.on('colorChange', listener);
+// Unsubscribe from the listener.
+wallpaper.off('colorChange', listener);
+//Unsubscribe from all subscriptions of the colorChange type.
+wallpaper.off('colorChange');
+```
## RgbaColor
@@ -622,7 +643,7 @@ Unsubscribes from the wallpaper color change event.
| Name | Type | Readable | Writable | Description |
| -------- | -------- | -------- | -------- | -------- |
-| red | number | Yes | Yes | Red color. The value ranges from 0 to 255. |
-| green | number | Yes | Yes | Green color. The value ranges from 0 to 255. |
-| blue | number | Yes | Yes | Blue color. The value ranges from 0 to 255. |
-| alpha | number | Yes | Yes | Alpha value. The value ranges from 0 to 255. |
+| red | number | Yes | Yes | Red color. The value ranges from 0 to 255. |
+| green | number | Yes | Yes | Green color. The value ranges from 0 to 255. |
+| blue | number | Yes | Yes | Blue color. The value ranges from 0 to 255. |
+| alpha | number | Yes | Yes | Alpha value. The value ranges from 0 to 255. |
diff --git a/en/application-dev/ui/Readme-EN.md b/en/application-dev/ui/Readme-EN.md
index d657b40cc0baf31ba295a7bc56164d2a64858171..acc4bd0613c1741db03277fffecce33195c592df 100644
--- a/en/application-dev/ui/Readme-EN.md
+++ b/en/application-dev/ui/Readme-EN.md
@@ -51,11 +51,11 @@
- [Qrcode Development](ui-js-components-qrcode.md)
- [Search Development](ui-js-components-search.md)
- Canvas Development
- - [Canvas](ui-js-components-canvas.md)
- - [CanvasRenderingContext2D](ui-js-components-canvasrenderingcontext2d.md)
- - [Path2D](ui-js-components-path2d.md)
- - [OffscreenCanvas](ui-js-components-offscreencanvas.md)
- - [Grid-container Development](ui-js-components-calendar.md)
+ - [Canvas](ui-js-components-canvas.md)
+ - [CanvasRenderingContext2D](ui-js-components-canvasrenderingcontext2d.md)
+ - [Path2D](ui-js-components-path2d.md)
+ - [OffscreenCanvas](ui-js-components-offscreencanvas.md)
+ - [Grid-container Development](ui-js-components-grid.md)
- Svg
- [Basics](ui-js-components-svg-overview.md)
- [Graph Drawing](ui-js-components-svg-graphics.md)
diff --git a/en/application-dev/ui/ui-js-animate-transform.md b/en/application-dev/ui/ui-js-animate-transform.md
index c8d5c6b233b5b263e6614fa836386441486eb870..3b6fe35a82a50468f5321d3d97eb98a55a3c87ff 100644
--- a/en/application-dev/ui/ui-js-animate-transform.md
+++ b/en/application-dev/ui/ui-js-animate-transform.md
@@ -8,7 +8,7 @@ Set the transform attribute for component rotation, scaling, translation, and sk
Create a square and rotate it by 90 degrees to form a rhombus. Cover the lower part of the rhombus with a rectangle to form a roof. Set the translate attribute of the rectangle to the coordinate (150px, -150px) to form a door, use the position attribute to translate the horizontal and vertical axes to the specified coordinates of the parent component (square), set the scale attribute to scale up the parent and child components together to determine the window size, and use the skewX attribute to skew the component and set the coordinate translate(200px,-830px) to form a chimney.
-
+
```
@@ -24,10 +24,12 @@ Create a square and rotate it by 90 degrees to form a rhombus. Cover the lower p
```
-
+
```
/* xxx.css */
.container {
+ width:100%;
+ height:100%;
background-color:#F1F3F5;
align-items: center;
flex-direction: column;
@@ -97,7 +99,7 @@ Create a square and rotate it by 90 degrees to form a rhombus. Cover the lower p
Decrease the y-coordinate over a time frame to make the ball bounce back. Gradually decrease the bounce height until it drops to 0. An animation where the ball falls is hereby created.
-
+
```
@@ -106,10 +108,12 @@ Decrease the y-coordinate over a time frame to make the ball bounce back. Gradua
```
-
+
```
/* xxx.css */
.container {
+ width:100%;
+ height:100%;
background-color:#F1F3F5;
display: flex;
justify-content: center;
@@ -176,7 +180,7 @@ Decrease the y-coordinate over a time frame to make the ball bounce back. Gradua
Set the rotation center around an element in different transform-origin positions. Of the rotate3d values, the first three values are the rotation vectors of the x-axis, y-axis, and z-axis, respectively; the fourth value is the rotation angle, which can be a negative value to indicate that the rotation is performed counterclockwise.
-
+
```
@@ -196,7 +200,7 @@ Set the rotation center around an element in different transform-origin position
```
-
+
```
/* xxx.css */
.container {
@@ -304,7 +308,7 @@ Set the rotation center around an element in different transform-origin position

->  **NOTE**:
+>  **NOTE**
> 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.
@@ -314,7 +318,7 @@ This example implements a ripple animation with the scale attribute. Here is the
Set the scaling values for the x-axis, y-axis, and z-axis in scale3d to implement the animation.
-
+
```
@@ -330,7 +334,7 @@ Set the scaling values for the x-axis, y-axis, and z-axis in scale3d to implemen
```
-
+
```
/* xxx.css */
.container {
@@ -419,7 +423,7 @@ text{

->  **NOTE**:
+>  **NOTE**
> 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.
@@ -427,7 +431,7 @@ text{
The matrix attribute defines a transformation matrix with six input parameters: scaleX, skewY, skewX, scaleY, translateX, and translateY. In the following example, matrix is set to matrix(1,0,0,1,0,200) to skew and translate the component.
-
+
```
@@ -435,7 +439,7 @@ The matrix attribute defines a transformation matrix with six input parameters:
```
-
+
```
/* xxx.css */
.container{
@@ -472,7 +476,7 @@ The matrix attribute defines a transformation matrix with six input parameters:
You can set multiple transform attributes at the same time to apply different transformations to a component. The following example applies the scale, translate, and rotate attributes simultaneously.
-
+
```
@@ -484,7 +488,7 @@ You can set multiple transform attributes at the same time to apply different tr
```
-
+
```
/* xxx.css */
.container{
@@ -577,9 +581,21 @@ You can set multiple transform attributes at the same time to apply different tr

->  **NOTE**:
-> 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).
+>  **NOTE**
+> - 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
diff --git a/en/application-dev/ui/ui-js-building-ui-component.md b/en/application-dev/ui/ui-js-building-ui-component.md
index 50b3fccf7a613a43117c879be4005c98ba822c92..752b8c4e4d527c9ffa0357fa9474aa1430bca6d9 100644
--- a/en/application-dev/ui/ui-js-building-ui-component.md
+++ b/en/application-dev/ui/ui-js-building-ui-component.md
@@ -11,11 +11,26 @@ You can also customize a new component through proper combination of components
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 |
-| 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 |
-| Media | video |
-| Canvas | canvas |
-| Grid | grid-container, grid-row, grid-col |
+| 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 |
+| Media | video |
+| Canvas | canvas |
+| Grid | grid-container, grid-row, grid-col |
| 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)
diff --git a/en/application-dev/ui/ui-js-building-ui-routes.md b/en/application-dev/ui/ui-js-building-ui-routes.md
index 4fcdb531fd87488f639df54d3d8aef5a016d799c..c4fccae121e30d9c2c2aa6ea4cbf3c707421cc29 100644
--- a/en/application-dev/ui/ui-js-building-ui-routes.md
+++ b/en/application-dev/ui/ui-js-building-ui-routes.md
@@ -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:
-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
-The index and detail pages each contains a <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:
+The index and detail pages each contains a <text> component that specifies the current page, and a **\
-
+
```
@@ -56,7 +56,7 @@ By default, the active tab of a **<tabs>** component is the one with the s
```
-
+ item1item2
@@ -149,7 +149,7 @@ Set the **mode** attribute to enable the child components of the **<tab-bar&g
margin-top: 10px;
height: 300px;
color: blue;
- justify-content: center;
+ justify-content: center;
align-items: center;
}
```
@@ -165,7 +165,7 @@ Add the **change** event for the **<tabs>** component to display the index
```
-
+ item1item2
@@ -324,6 +324,6 @@ export default {
## Samples
- The following sample is provided to help you better understand how to develop the **<tabs>** component:
+The following sample is provided to help you better understand how to develop the **<tabs>** component:
-[`Tabs`: Tabs (JavaScript, API 7)](https://gitee.com/openharmony/app_samples/tree/master/UI/Tabs)
\ No newline at end of file
+[`Tabs`: Tabs (JavaScript, API 8)](https://gitee.com/openharmony/app_samples/tree/master/UI/Tabs)
\ No newline at end of file
diff --git a/en/application-dev/ui/ui-js-components-canvas.md b/en/application-dev/ui/ui-js-components-canvas.md
index 87b813cca0bae6f27a417f43b81f03f098350a35..f1d935f866c29f06ee98109bbea1adf659003995 100644
--- a/en/application-dev/ui/ui-js-components-canvas.md
+++ b/en/application-dev/ui/ui-js-components-canvas.md
@@ -32,7 +32,7 @@ canvas{

->  **NOTE:**
+>  **NOTE**
> - The default background color of the **<canvas>** component is the same as that of the parent component.
>
> - The default width and height of **<canvas>** are 300 px and 150 px, respectively.
@@ -61,8 +61,8 @@ Set **width**, **height**, **background-color**, and **border** of the **<can
}
canvas{
width: 500px;
- height: 500px;
- background-color: #fdfdfd;
+ height: 500px;
+ background-color: #fdfdfd;
border: 5px solid red;
}
```
@@ -86,9 +86,29 @@ Add the long press event to the **<canvas>** 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;
- margin-bottom: 50px;
-}.content{ border: 5px solid blue; padding: 10px; width: 90%; height: 400px; overflow: scroll;}
+/* 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;
+}
+.content{
+ border: 5px solid blue;
+ padding: 10px;
+ width: 90%;
+ height: 400px;
+ overflow: scroll;
+}
```
@@ -103,19 +123,26 @@ export default {
},
onShow(){
let el = this.$refs.canvas1;
- let ctx = el.getContext("2d");
+ let ctx = el.getContext("2d");
ctx.strokeRect(100,100,300,300);
},
getUrl(){
- let el = this.$refs.canvas1;
- let dataUrl = el.toDataURL();
+ let el = this.$refs.canvas1
+ let dataUrl = el.toDataURL()
this.dataURL = dataUrl;
- prompt.showToast({duration:2000,message:"long press,get dataURL"});
+ prompt.showToast({duration:2000,message:"long press,get dataURL"})
}
}
```

->  **NOTE:**
+>  **NOTE**
> The **<canvas>** component cannot be created in **onInit** or **onReady**.
+
+## Samples
+
+The following sample is provided to help you better understand how to develop the **\