diff --git a/en/application-dev/ability/stage-ability.md b/en/application-dev/ability/stage-ability.md index 6d436a445638346dcdc616ac967e0b6d10a00b81..4dfe6cf0e1ef001bdd72d4ae362baadc5d155d63 100644 --- a/en/application-dev/ability/stage-ability.md +++ b/en/application-dev/ability/stage-ability.md @@ -1,18 +1,14 @@ # Ability Development ## When to Use -The stage model is an application development model introduced in API version 9. For details about this model, see [Stage Model Overview](stage-brief.md). To develop an ability based on the stage model, you must implement the following logic: -- Create Page abilities for an application that needs to be browsed on the screen and supports man-machine interaction, such as video playback and news browsing. -- Obtain ability configuration information, such as **ApplicationInfo**, **AbilityInfo**, and **HapModuleInfo**. -- Start an ability, start an ability with start options, start an ability with the returned result, or start an ability with an account ID. -- Request certain permissions from end users. -- Notify the ability stage and ability of environment configuration changes. -- Call common components. For details, see [Call Development](stage-call.md). -- Connect to and disconnect from the Service Extension ability. For details, see [Service Extension Ability Development](stage-serviceextension.md). -- Continue the application on another device. For details, see [Ability Continuation Development](stage-ability-continuation.md). +Unlike the FA model, the [stage model](stage-brief.md) requires you to declare the application package structure in the `module.json` and `app.json` files during application development. For details about the configuration file, see [Application Package Structure Configuration File](../quick-start/stage-structure.md). To develop abilities based on the stage model, implement the following logic: +- Create abilities for an application that involves screen viewing and human-machine interaction. You must implement the following scenarios: ability lifecycle callbacks, obtaining ability configuration, requesting permissions, and notifying environment changes. +- Start an ability. You need to implement ability startup on the same device, on a remote device, or with a specified UI page. +- Call abilities. For details, see [Call Development](stage-call.md). +- Connect to and disconnect from a Service Extension ability. For details, see [Service Extension Ability Development](stage-serviceextension.md). +- Continue the ability on another device. For details, see [Ability Continuation Development](stage-ability-continuation.md). ### Launch Type -The ability supports three launch types: singleton, multi-instance, and instance-specific. -The **launchType** item in the **module.json** file is used to specify the launch type. +The ability supports three launch types: singleton, multi-instance, and instance-specific. Each launch type, specified by `launchType` in the `module.json` file, specifies the action that can be performed when the ability is started. | Launch Type | Description |Description | | ----------- | ------- |---------------- | @@ -20,56 +16,49 @@ The **launchType** item in the **module.json** file is used to specify the launc | singleton | Singleton | Only one instance exists in the system. If an instance already exists when an ability is started, that instance is reused.| | specified | Instance-specific| The internal service of an ability determines whether to create multiple instances during running.| -By default, **singleton** is used. - -## Available APIs -The table below describes the APIs provided by the **AbilityStage** class, which has the **context** attribute. For details about the APIs, see [AbilityStage](../reference/apis/js-apis-application-abilitystage.md). +By default, the singleton mode is used. The following is an example of the `module.json` file: +```json +{ + "module": { + "abilities": [ + { + "launchType": "singleton", + } + ] + } +} +``` +## Creating an Ability +### Available APIs +The table below describes the APIs provided by the `AbilityStage` class, which has the `context` attribute. For details about the APIs, see [AbilityStage](../reference/apis/js-apis-application-abilitystage.md). **Table 1** AbilityStage APIs |API|Description| |:------|:------| -|void onCreate()|Called when an ability stage is created.| -|string onAcceptWant(want: Want)|Called when a specified ability is started.| -|void onConfigurationUpdated(config: Configuration)|Called when the global configuration is updated.| +|onCreate(): void|Called when an ability stage is created.| +|onAcceptWant(want: Want): string|Called when a specified ability is started.| +|onConfigurationUpdated(config: Configuration): void|Called when the global configuration is updated.| -The table below describes the APIs provided by the **Ability** class. For details about the APIs, see [Ability](../reference/apis/js-apis-application-ability.md). +The table below describes the APIs provided by the `Ability` class. For details about the APIs, see [Ability](../reference/apis/js-apis-application-ability.md). **Table 2** Ability APIs |API|Description| |:------|:------| -|void onCreate(want: Want, param: AbilityConstant.LaunchParam)|Called when an ability is created.| -|void onDestroy()|Called when the ability is destroyed.| -|void onWindowStageCreate(windowStage: window.WindowStage)|Called when a **WindowStage** is created for the ability. You can use the **window.WindowStage** APIs to implement operations such as page loading.| -|void onWindowStageDestroy()|Called when the **WindowStage** is destroyed for the ability.| -|void onForeground()|Called when the ability is running in the foreground.| -|void onBackground()|Called when the ability is switched to the background.| -|void onNewWant(want: Want)|Called when the ability startup mode is set to singleton.| -|void onConfigurationUpdated(config: Configuration)|Called when the configuration of the environment where the ability is running is updated.| - -The **Ability** class has the **context** attribute, which belongs to the **AbilityContext** class. The **AbilityContext** class has attributes such as **abilityInfo** and **currentHapModuleInfo**. For details about the APIs, see [AbilityContext](../reference/apis/js-apis-ability-context.md). - -**Table 3** AbilityContext APIs -|API|Description| -|:------|:------| -|void startAbility(want: Want, callback: AsyncCallback)|Starts an ability.| -|void startAbility(want: Want, options: StartOptions, callback: AsyncCallback)|Starts an ability with start options.| -|void startAbilityWithAccount(want: Want, accountId: number, callback: AsyncCallback)|Starts an ability with the account ID.| -|void startAbilityWithAccount(want: Want, accountId: number, options: StartOptions, callback: AsyncCallback)|Starts an ability with the account ID and start options.| -|void startAbilityForResult(want: Want, callback: AsyncCallback)|Starts an ability with the returned result.| -|void startAbilityForResult(want: Want, options: StartOptions, callback: AsyncCallback)|Starts an ability with the returned result and start options.| -|void startAbilityForResultWithAccount(want: Want, accountId: number, callback: AsyncCallback)|Starts an ability with the returned result and account ID.| -|void startAbilityForResultWithAccount(want: Want, accountId: number, options: StartOptions, callback: AsyncCallback)|Starts an ability with the returned result, account ID, and start options.| -|void terminateSelf(callback: AsyncCallback)|Destroys the Page ability.| -|void terminateSelfWithResult(parameter: AbilityResult, callback: AsyncCallback)|Destroys the Page ability with the returned result.| - -## How to Develop -### Creating Page Abilities for an Application -To create Page abilities for an application on the stage model, you must implement the **AbilityStage** class and ability lifecycle callbacks, and use the **Window** APIs to set the pages. The sample code is as follows: -1. Import the **AbilityStage** module. +|onCreate(want: Want, param: AbilityConstant.LaunchParam): void|Called when an ability is created.| +|onDestroy(): void|Called when the ability is destroyed.| +|onWindowStageCreate(windowStage: window.WindowStage): void|Called when a `WindowStage` is created for the ability. You can use the `window.WindowStage` APIs to implement operations such as page loading.| +|onWindowStageDestroy(): void|Called when the `WindowStage` is destroyed for the ability.| +|onForeground(): void|Called when the ability is switched to the foreground.| +|onBackground(): void|Called when the ability is switched to the background.| +|onNewWant(want: Want): void|Called when the ability launch type is set to `singleton`.| +|onConfigurationUpdated(config: Configuration): void|Called when the configuration of the environment where the ability is running is updated.| +### Implementing AbilityStage and Ability Lifecycle Callbacks +To create Page abilities for an application in the stage model, you must implement the `AbilityStage` class and ability lifecycle callbacks, and use the `Window` APIs to set the pages. The sample code is as follows: +1. Import the `AbilityStage` module. ``` import AbilityStage from "@ohos.application.AbilityStage" ``` -2. Implement the **AbilityStage** class. +2. Implement the `AbilityStage` class. ```ts export default class MyAbilityStage extends AbilityStage { onCreate() { @@ -77,13 +66,13 @@ To create Page abilities for an application on the stage model, you must impleme } } ``` -3. Import the **Ability** module. +3. Import the `Ability` module. ```js import Ability from '@ohos.application.Ability' ``` -4. Implement the lifecycle callbacks of the **Ability** class. +4. Implement the lifecycle callbacks of the `Ability` class. - In the **onWindowStageCreate(windowStage)** API, use **loadContent** to set the pages to be loaded by the application. For details about how to use the **Window** APIs, see [Window Development](../windowmanager/window-guidelines.md). + In the `onWindowStageCreate(windowStage)` API, use `loadContent` to set the application page to be loaded. For details about how to use the `Window` APIs, see [Window Development](../windowmanager/window-guidelines.md). ```ts export default class MainAbility extends Ability { onCreate(want, launchParam) { @@ -117,8 +106,8 @@ To create Page abilities for an application on the stage model, you must impleme } } ``` -### Obtaining AbilityStage and Ability Configuration Information -Both the **AbilityStage** and **Ability** classes have the **context** attribute. An application can obtain the context of the **Ability** instance through **this.context** to obtain detailed configuration information. The following example shows how the ability stage obtains the bundle code directory, HAP file name, ability name, and system language through the **context** attribute. The sample code is as follows: +### Obtaining AbilityStage and Ability Configurations +Both the `AbilityStage` and `Ability` classes have the `context` attribute. An application can obtain the context of an `Ability` instance through `this.context` to obtain the configuration details. The following example shows how an application obtains the bundle code directory, HAP file name, ability name, and system language through the `context` attribute in the `AbilityStage` class. The sample code is as follows: ```ts import AbilityStage from "@ohos.application.AbilityStage" export default class MyAbilityStage extends AbilityStage { @@ -137,7 +126,7 @@ export default class MyAbilityStage extends AbilityStage { } ``` -The following example shows how the ability obtains the bundle code directory, HAP file name, ability name, and system language through the **context** attribute. The sample code is as follows: +The following example shows how an application obtains the bundle code directory, HAP file name, ability name, and system language through the `context` attribute in the `Ability` class. The sample code is as follows: ```ts import Ability from '@ohos.application.Ability' export default class MainAbility extends Ability { @@ -155,9 +144,83 @@ export default class MainAbility extends Ability { } } ``` +### Requesting Permissions +If an application needs to obtain user privacy information or use system capabilities, for example, obtaining location information or using the camera to take photos or record videos, it must request the permission from consumers. During application development, you need to specify the involved sensitive permissions, declare the required permissions in `module.json`, and use the `requestPermissionsFromUser` API to request the permission from consumers in the form of a dialog box. The following uses the permissions for calendar access as an example. -### Starting an Ability -An application can obtain the context of an **Ability** instance through **this.context** and then use the **StartAbility** API in the **AbilityContext** class to start the ability. The ability can be started by specifying **Want**, **StartOptions**, and **accountId**, and the operation result can be returned using a callback or **Promise** instance. The sample code is as follows: +Declare the required permissions in the `module.json` file. +```json +"requestPermissions": [ + { + "name": "ohos.permission.READ_CALENDAR" + } +] +``` +Request the permissions from consumers in the form of a dialog box: +```ts +let context = this.context +let permissions: Array = ['ohos.permission.READ_CALENDAR'] +context.requestPermissionsFromUser(permissions).then((data) => { + console.log("Succeed to request permission from user with data: " + JSON.stringify(data)) +}).catch((error) => { + console.log("Failed to request permission from user with error: " + JSON.stringify(error)) +}) +``` +### Notifying of Environment Changes +Environment changes include changes of global configurations and ability configurations. Currently, the global configurations include the system language and color mode. The change of global configurations is generally triggered by the configuration item in **Settings** or the icon in **Control Panel**. The ability configuration is specific to a single `Ability` instance, including the display ID, screen resolution, and screen orientation. The configuration is related to the display where the ability is located, and the change is generally triggered by the window. For details on the configuration, see [Configuration](../reference/apis/js-apis-configuration.md). + +For an application in the stage model, when the configuration changes, its abilities are not restarted, but the `onConfigurationUpdated(config: Configuration)` callback is triggered. If the application needs to perform processing based on the change, you can overwrite `onConfigurationUpdated`. Note that the `Configuration` object in the callback contains all the configurations of the current ability, not only the changed configurations. + +The following example shows the implement of the `onConfigurationUpdated` callback in the `AbilityStage` class. The callback is triggered when the system language and color mode are changed. +```ts +import Ability from '@ohos.application.Ability' +import ConfigurationConstant from '@ohos.application.ConfigurationConstant' + +export default class MyAbilityStage extends AbilityStage { + onConfigurationUpdated(config) { + if (config.colorMode === ConfigurationConstant.ColorMode.COLOR_MODE_DARK) { + console.log('colorMode changed to dark') + } + } +} +``` + +The following example shows the implement of the `onConfigurationUpdated` callback in the `Ability` class. The callback is triggered when the system language, color mode, or display parameters (such as the direction and density) change. +```ts +import Ability from '@ohos.application.Ability' +import ConfigurationConstant from '@ohos.application.ConfigurationConstant' + +export default class MainAbility extends Ability { + direction : number; + + onCreate(want, launchParam) { + this.direction = this.context.config.direction + } + + onConfigurationUpdated(config) { + if (this.direction !== config.direction) { + console.log(`direction changed to ${config.direction}`) + } + } +} +``` +## Starting an Ability +### Available APIs +The `Ability` class has the `context` attribute, which belongs to the `AbilityContext` class. The `AbilityContext` class has the `abilityInfo`, `currentHapModuleInfo`, and other attributes and the APIs used for starting abilities. For details, see [AbilityContext](../reference/apis/js-apis-ability-context.md). + +**Table 3** AbilityContext APIs + +|API|Description| +|:------|:------| +|startAbility(want: Want, callback: AsyncCallback\): void|Starts an ability.| +|startAbility(want: Want, options?: StartOptions): Promise\|Starts an ability.| +|startAbilityWithAccount(want: Want, accountId: number, callback: AsyncCallback\): void|Starts an ability with the account ID.| +|startAbilityWithAccount(want: Want, accountId: number, options?: StartOptions): Promise\|Starts an ability with the account ID.| +|startAbilityForResult(want: Want, callback: AsyncCallback\): void|Starts an ability with the returned result.| +|startAbilityForResult(want: Want, options?: StartOptions): Promise\|Starts an ability with the returned result.| +|startAbilityForResultWithAccount(want: Want, accountId: number, callback: AsyncCallback\): void|Starts an ability with the execution result and account ID.| +|startAbilityForResultWithAccount(want: Want, accountId: number, options?: StartOptions): Promise\|Starts an ability with the execution result and account ID.| +### Starting an Ability on the Same Device +An application can obtain the context of an `Ability` instance through `this.context` and then use the `startAbility` API in the `AbilityContext` class to start the ability. The ability can be started by specifying `Want`, `StartOptions`, and `accountId`, and the operation result can be returned using a callback or `Promise` instance. The sample code is as follows: ```ts let context = this.context var want = { @@ -165,20 +228,17 @@ var want = { "bundleName": "com.example.MyApplication", "abilityName": "MainAbility" }; -var options = { - windowMode: 0, - displayId: 2 -}; -context.startAbility(want, options).then((data) => { +context.startAbility(want).then((data) => { console.log("Succeed to start ability with data: " + JSON.stringify(data)) }).catch((error) => { console.error("Failed to start ability with error: "+ JSON.stringify(error)) }) ``` -### Starting an Ability on a Remote Device (Available only to System Applications) ->Note: The **getTrustedDeviceListSync** API of the **DeviceManager** class is open only to system applications. Therefore, cross-device ability startup applies only to system applications. +### Starting an Ability on a Remote Device +This feature applies only to system applications, since the `getTrustedDeviceListSync` API of the `DeviceManager` class is open only to system applications. In the cross-device scenario, you must specify the ID of the remote device. The sample code is as follows: + ```ts let context = this.context var want = { @@ -192,7 +252,7 @@ context.startAbility(want).then((data) => { console.error("Failed to start remote ability with error: "+ JSON.stringify(error)) }) ``` -Obtain the ID of a specified device from **DeviceManager**. The sample code is as follows: +Obtain the ID of a specified device from `DeviceManager`. The sample code is as follows: ```ts import deviceManager from '@ohos.distributedHardware.deviceManager'; function getRemoteDeviceId() { @@ -209,68 +269,57 @@ function getRemoteDeviceId() { } } ``` +Request the permission `ohos.permission.DISTRIBUTED_DATASYNC ` from consumers. This permission is used for data synchronization. For details about the sample code for requesting the permission, see [Requesting Permissions](##requesting-permissions). +### Starting an Ability with the Specified Page +If the launch type of an ability is set to `singleton` and the ability has been started, the `onNewWant` callback is triggered when the ability is started again. You can pass start options through the `want`. For example, to start an ability with the specified page, use the `uri` or `parameters` parameter in the `want` to pass the page information. Currently, the ability in the stage model cannot directly use the `router` capability. You must pass the start options to the custom component and invoke the `router` method to display the specified page during the custom component lifecycle management. The sample code is as follows: -### Requesting Permissions -If an application requires certain permissions, such as storage, location information, and log access, the application must request the permissions from end users. After determining the required permissions, add the permissions in the **module.json** file and use **requestPermissionsFromUser** to request the permissions from end users in the form of a dialog box. The following uses the permissions for calendar access as an example. -Modify the **module.json** file as follows: -```json -"requestPermissions": [ - { - "name": "ohos.permission.READ_CALENDAR" - } -] -``` -Request the permissions from end users in the form of a dialog box: +When using `startAbility` to start an ability again, use the `uri` parameter in the `want` to pass the page information. ```ts -let context = this.context -let permissions: Array = ['ohos.permission.READ_CALENDAR'] -context.requestPermissionsFromUser(permissions).then((data) => { - console.log("Succeed to request permission from user with data: "+ JSON.stringify(data)) -}).catch((error) => { - console.log("Failed to request permission from user with error: "+ JSON.stringify(error)) -}) -``` -In the cross-device scenario, the application must also apply for the data synchronization permission from end users. The sample code is as follows: -```ts -let context = this.context -let permissions: Array = ['ohos.permission.DISTRIBUTED_DATASYNC'] -context.requestPermissionsFromUser(permissions).then((data) => { - console.log("Succeed to request permission from user with data: "+ JSON.stringify(data)) -}).catch((error) => { - console.log("Failed to request permission from user with error: "+ JSON.stringify(error)) -}) +async function reStartAbility() { + try { + await this.context.startAbility({ + bundleName: "com.sample.MyApplication", + abilityName: "MainAbility", + uri: "pages/second" + }) + console.log('start ability succeed') + } catch (error) { + console.error(`start ability failed with ${error.code}`) + } +} ``` -### Notifying of Environment Configuration Changes -When the global configuration, for example, system language and color mode, changes, the **onConfigurationUpdated** API is called to notify the ability stage and ability. System applications can update the system language and color mode through the **updateConfiguration** API. The following example shows the implement of the **onConfigurationUpdated** callback in the **AbilityStage** class. The callback is triggered when the system language and color mode change. The sample code is as follows: +Obtain the `want` parameter that contains the page information from the `onNewWant` callback of the ability. ```ts import Ability from '@ohos.application.Ability' -import ConfigurationConstant from '@ohos.application.ConfigurationConstant' -export default class MyAbilityStage extends AbilityStage { - onConfigurationUpdated(config) { - console.log("MyAbilityStage onConfigurationUpdated") - console.log("MyAbilityStage config language" + config.language) - console.log("MyAbilityStage config colorMode" + config.colorMode) - } + +export default class MainAbility extends Ability { + onNewWant(want) { + globalThis.newWant = want + } } ``` -The following example shows the implement of the **onConfigurationUpdated** callback in the **Ability** class. The callback is triggered when the system language, color mode, and display parameters (such as the direction and density) change. The sample code is as follows: +Obtain the `want` parameter that contains the page information from the custom component and process the route based on the URI. ```ts -import Ability from '@ohos.application.Ability' -import ConfigurationConstant from '@ohos.application.ConfigurationConstant' -export default class MainAbility extends Ability { { - onConfigurationUpdated(config) { - console.log("MainAbility onConfigurationUpdated") - console.log("MainAbility config language" + config.language) - console.log("MainAbility config colorMode" + config.colorMode) - console.log("MainAbility config direction" + config.direction) - console.log("MainAbility config screenDensity" + config.screenDensity) - console.log("MainAbility config displayId" + config.displayId) +import router from '@system.router' + +@Entry +@Component +struct Index { + newWant = undefined + + onPageShow() { + console.info('Index onPageShow') + let newWant = globalThis.newWant + if (newWant.hasOwnProperty("uri")) { + router.push({ uri: newWant.uri }); + globalThis.newWant = undefined } + } } ``` ## Samples The following sample is provided to help you better understand how to develop an ability on the stage model: -- [`StageCallAbility`: Stage Ability Creation and Usage (eTS) (API9)](https://gitee.com/openharmony/app_samples/tree/master/ability/StageCallAbility) +- [`StageCallAbility`: Stage Call Ability Creation and Usage (eTS, API version 9)](https://gitee.com/openharmony/app_samples/tree/master/ability/StageCallAbility) diff --git a/en/application-dev/ability/stage-call.md b/en/application-dev/ability/stage-call.md index 9f7216de316df0e4d786e8e25b770dea45be7f6d..e402454ddf6afd1b1aab71601e52b19d8010b425 100644 --- a/en/application-dev/ability/stage-call.md +++ b/en/application-dev/ability/stage-call.md @@ -18,15 +18,17 @@ The table below describes the ability call APIs. For details, see [Ability](../r **Table 1** Ability call APIs |API|Description| |:------|:------| -|Promise startAbilityByCall(want: Want)|Obtains the caller interface of the specified ability and, if the specified ability is not running, starts the ability in the background.| -|void on(method: string, callback: CalleeCallBack)|Callee.on: callback invoked when the callee registers a method.| -|void off(method: string)|Callee.off: callback invoked when the callee deregisters a method.| -|Promise call(method: string, data: rpc.Sequenceable)|Caller.call: sends agreed sequenceable data to the callee.| -|Promise callWithResult(method: string, data: rpc.Sequenceable)|Caller.callWithResult: sends agreed sequenceable data to the callee and returns the agreed sequenceable data.| -|void release()|Caller.release: releases the caller interface.| -|void onRelease(callback: OnReleaseCallBack)|Caller.onRelease: registers a callback that is invoked when the caller is disconnected.| +|startAbilityByCall(want: Want): Promise\|Obtains the caller interface of the specified ability and, if the specified ability is not running, starts the ability in the background.| +|on(method: string, callback: CaleeCallBack): void|Callback invoked when the callee registers a method.| +|off(method: string): void|Callback invoked when the callee deregisters a method.| +|call(method: string, data: rpc.Sequenceable): Promise\|Sends agreed sequenceable data to the callee.| +|callWithResult(method: string, data: rpc.Sequenceable): Promise\|Sends agreed sequenceable data to the callee and returns the agreed sequenceable data.| +|release(): void|Releases the caller interface.| +|onRelease(callback: OnReleaseCallBack): void|Registers a callback that is invoked when the caller is disconnected.| ## How to Develop +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**
+> The sample code snippets provided in the **How to Develop** section are used to show specific development steps. They may not be able to run independently. For details about the complete project code, see [Samples](#samples). ### Creating a Callee For the callee, implement the callback to receive data and the methods to marshal and unmarshal data. When data needs to be received, use the **on** API to register a listener. When data does not need to be received, use the **off** API to deregister the listener. 1. Configure the ability startup mode. @@ -55,7 +57,7 @@ import Ability from '@ohos.application.Ability' ``` 3. Define the agreed sequenceable data. - The data formats sent and received by the caller and callee must be consistent. In the following example, the data consists of numbers and strings. The sample code is as follows: + The data formats sent and received by the caller and callee must be consistent. In the following example, the data consists of numbers and strings. The sample code snippet is as follows: ```ts export default class MySequenceable { num: number = 0 @@ -81,7 +83,7 @@ export default class MySequenceable { ``` 4. Implement **Callee.on** and **Callee.off**. - The time to register a listener for the callee depends on your application. The data sent and received before the listener is registered and that after the listener is deregistered are not processed. In the following example, the **CalleeSortMethod** listener is registered in **onCreate** of the ability and deregistered in **onDestroy**. After receiving sequenceable data, the application processes the data and returns the data result. You need to implement processing based on service requirements. The sample code is as follows: + The time to register a listener for the callee depends on your application. The data sent and received before the listener is registered and that after the listener is deregistered are not processed. In the following example, the **MSG_SEND_METHOD** listener is registered in **onCreate** of the ability and deregistered in **onDestroy**. After receiving sequenceable data, the application processes the data and returns the data result. You need to implement processing based on service requirements. The sample code snippet is as follows: ```ts const TAG: string = '[CalleeAbility]' const MSG_SEND_METHOD: string = 'CallSendMsg' @@ -125,7 +127,7 @@ import Ability from '@ohos.application.Ability' ``` 2. Obtain the caller interface. - The **context** attribute of the ability implements **startAbilityByCall** to obtain the caller interface of the ability. The following example uses **this.context** to obtain the **context** attribute of the **Ability** instance, uses **startAbilityByCall** to start the callee, obtain the caller interface, and register the **onRelease** listener of the caller. You need to implement processing based on service requirements. The sample code is as follows: + The **context** attribute of the ability implements **startAbilityByCall** to obtain the caller interface of the ability. The following example uses **this.context** to obtain the **context** attribute of the **Ability** instance, uses **startAbilityByCall** to start the callee, obtain the caller interface, and register the **onRelease** listener of the caller. You need to implement processing based on service requirements. The sample code snippet is as follows: ```ts async onButtonGetCaller() { try { @@ -146,7 +148,7 @@ async onButtonGetCaller() { console.error(TAG + 'get caller failed with ' + error) }) ``` -In the cross-device scenario, you need to specify the ID of the peer device. The sample code is as follows: + In the cross-device scenario, you need to specify the ID of the peer device. The sample code snippet is as follows: ```ts let TAG = '[MainAbility] ' var caller = undefined @@ -170,7 +172,7 @@ context.startAbilityByCall({ console.error(TAG + 'get remote caller failed with ' + error) }) ``` -Obtain the ID of the peer device from **DeviceManager**. Note that the **getTrustedDeviceListSync** API is open only to system applications. The sample code is as follows: + Obtain the ID of the peer device from **DeviceManager**. Note that the **getTrustedDeviceListSync** API is open only to system applications. The sample code snippet is as follows: ```ts import deviceManager from '@ohos.distributedHardware.deviceManager'; var dmClass; @@ -188,7 +190,7 @@ function getRemoteDeviceId() { } } ``` -In the cross-device scenario, the application must also apply for the data synchronization permission from end users. The sample code is as follows: + In the cross-device scenario, the application must also apply for the data synchronization permission from end users. The sample code snippet is as follows: ```ts let context = this.context let permissions: Array = ['ohos.permission.DISTRIBUTED_DATASYNC'] @@ -200,7 +202,7 @@ context.requestPermissionsFromUser(permissions).then((data) => { ``` 3. Send agreed sequenceable data. -The sequenceable data can be sent to the callee with or without a return value. The method and sequenceable data must be consistent with those of the callee. The following example describes how to invoke the **Call** API to send data to the callee. The sample code is as follows: + The sequenceable data can be sent to the callee with or without a return value. The method and sequenceable data must be consistent with those of the callee. The following example describes how to invoke the **Call** API to send data to the callee. The sample code snippet is as follows: ```ts const MSG_SEND_METHOD: string = 'CallSendMsg' async onButtonCall() { @@ -213,7 +215,7 @@ async onButtonCall() { } ``` -In the following, **CallWithResult** is used to send data **originMsg** to the callee and assign the data processed by the **CallSendMsg** method to **backMsg**. The sample code is as follows: + In the following, **CallWithResult** is used to send data **originMsg** to the callee and assign the data processed by the **CallSendMsg** method to **backMsg**. The sample code snippet is as follows: ```ts const MSG_SEND_METHOD: string = 'CallSendMsg' originMsg: string = '' @@ -235,7 +237,7 @@ async onButtonCallWithResult(originMsg, backMsg) { ``` 4. Release the caller interface. -When the caller interface is no longer required, call the **release** API to release it. The sample code is as follows: + When the caller interface is no longer required, call the **release** API to release it. The sample code snippet is as follows: ```ts try { this.caller.release() @@ -248,4 +250,4 @@ try { ## Samples The following sample is provided to help you better understand how to develop an ability call in the stage model: -- [`StageCallAbility`: Stage Ability Creation and Usage (eTS, API version 9)](https://gitee.com/openharmony/app_samples/tree/master/ability/StageCallAbility) +- [`StageCallAbility`: Stage Call Ability Creation and Usage (eTS, API version 9)](https://gitee.com/openharmony/app_samples/tree/master/ability/StageCallAbility) diff --git a/en/application-dev/database/database-relational-guidelines.md b/en/application-dev/database/database-relational-guidelines.md index 3905580f4f44de8b541e9650916f281011839bf5..fe70b837c085a2309cdbc26a5365dfcce29d6b5c 100644 --- a/en/application-dev/database/database-relational-guidelines.md +++ b/en/application-dev/database/database-relational-guidelines.md @@ -204,7 +204,7 @@ You can obtain the distributed table name for a remote device based on the local const CREATE_TABLE_TEST = "CREATE TABLE IF NOT EXISTS test (" + "id INTEGER PRIMARY KEY AUTOINCREMENT, " + "name TEXT NOT NULL, " + "age INTEGER, " + "salary REAL, " + "blobType BLOB)"; const STORE_CONFIG = {name: "rdbstore.db",} data_rdb.getRdbStore(STORE_CONFIG, 1, function (err, rdbStore) { - rdbStore.executeSql(SQL_CREATE_TABLE) + rdbStore.executeSql(CREATE_TABLE_TEST) console.info('create table done.') }) ``` diff --git a/en/application-dev/device/device-location-info.md b/en/application-dev/device/device-location-info.md index 25d539a79c431159bd0e2816ace8f658d29c8ead..e3d2e4155798eb69904ec7c819ef3702604dd1bf 100644 --- a/en/application-dev/device/device-location-info.md +++ b/en/application-dev/device/device-location-info.md @@ -12,44 +12,44 @@ Real-time location of the device is recommended for location-sensitive services. The following table describes APIs available for obtaining device location information. - **Table1** APIs for obtaining device location information + **Table 1** APIs for obtaining device location information -| API | Description | +| API| Description| | -------- | -------- | -| on(type: 'locationChange', request: LocationRequest, callback: Callback<Location>) : void | Registers a listener for location changes with a location request initiated. | -| off(type: 'locationChange', callback?: Callback<Location>) : void | Unregisters the listener for location changes with the corresponding location request deleted. | -| on(type: 'locationServiceState', callback: Callback<boolean>) : void | Registers a listener for location service status change events. | -| off(type: 'locationServiceState', callback: Callback<boolean>) : void | Unregisters the listener for location service status change events. | -| on(type: 'cachedGnssLocationsReporting', request: CachedGnssLoactionsRequest, callback: Callback<Array<Location>>) : void; | Registers a listener for cached GNSS location reports. | -| off(type: 'cachedGnssLocationsReporting', callback?: Callback<Array<Location>>) : void; | Unregisters the listener for cached GNSS location reports. | -| on(type: 'gnssStatusChange', callback: Callback<SatelliteStatusInfo>) : void; | Registers a listener for satellite status change events. | -| off(type: 'gnssStatusChange', callback?: Callback<SatelliteStatusInfo>) : void; | Unregisters the listener for satellite status change events. | -| on(type: 'nmeaMessageChange', callback: Callback<string>) : void; | Registers a listener for GNSS NMEA message change events. | -| off(type: 'nmeaMessageChange', callback?: Callback<string>) : void; | Unregisters the listener for GNSS NMEA message change events. | -| on(type: 'fenceStatusChange', request: GeofenceRequest, want: WantAgent) : void; | Registers a listener for status change events of the specified geofence. | -| off(type: 'fenceStatusChange', request: GeofenceRequest, want: WantAgent) : void; | Unregisters the listener for status change events of the specified geofence. | -| getCurrentLocation(request: CurrentLocationRequest, callback: AsyncCallback<Location>) : void | Obtains the current location. This function uses an asynchronous callback to return the result. | -| getCurrentLocation(request?: CurrentLocationRequest) : Promise<Location> | Obtains the current location. This function uses a promise to return the result. | -| getLastLocation(callback: AsyncCallback<Location>) : void | Obtains the previous location. This function uses an asynchronous callback to return the result. | -| getLastLocation() : Promise<Location> | Obtains the previous location. This function uses a promise to return the result. | -| isLocationEnabled(callback: AsyncCallback<boolean>) : void | Checks whether the location service is enabled. This function uses an asynchronous callback to return the result. | -| isLocationEnabled() : Promise<boolean> | Checks whether the location service is enabled. This function uses a promise to return the result. | -| requestEnableLocation(callback: AsyncCallback<boolean>) : void | Requests to enable the location service. This function uses an asynchronous callback to return the result. | -| requestEnableLocation() : Promise<boolean> | Requests to enable the location service. This function uses a promise to return the result. | -| enableLocation(callback: AsyncCallback<boolean>) : void | Enables the location service. This function uses an asynchronous callback to return the result. | -| enableLocation() : Promise<boolean> | Enables the location service. This function uses a promise to return the result. | -| disableLocation(callback: AsyncCallback<boolean>) : void | Disables the location service. This function uses an asynchronous callback to return the result. | -| disableLocation() : Promise<boolean> | Disables the location service. This function uses a promise to return the result. | -| getCachedGnssLocationsSize(callback: AsyncCallback<number>) : void; | Obtains the number of cached GNSS locations. This function uses an asynchronous callback to return the result. | -| getCachedGnssLocationsSize() : Promise<number>; | Obtains the number of cached GNSS locations. This function uses a promise to return the result. | -| flushCachedGnssLocations(callback: AsyncCallback<boolean>) : void; | Obtains all cached GNSS locations and clears the GNSS cache queue. This function uses an asynchronous callback to return the result. | -| flushCachedGnssLocations() : Promise<boolean>; | Obtains all cached GNSS locations and clears the GNSS cache queue. This function uses a promise to return the result. | -| sendCommand(command: LocationCommand, callback: AsyncCallback<boolean>) : void; | Sends extended commands to the location subsystem. This function uses an asynchronous callback to return the result. | -| sendCommand(command: LocationCommand) : Promise<boolean>; | Sends extended commands to the location subsystem. This function uses a promise to return the result. | -| isLocationPrivacyConfirmed(type : LocationPrivacyType, callback: AsyncCallback<boolean>) : void; | Checks whether a user agrees with the privacy statement of the location service. This function uses an asynchronous callback to return the result. | -| isLocationPrivacyConfirmed(type : LocationPrivacyType,) : Promise<boolean>; | Checks whether a user agrees with the privacy statement of the location service. This function uses a promise to return the result. | -| setLocationPrivacyConfirmStatus(type : LocationPrivacyType, isConfirmed : boolean, callback: AsyncCallback<boolean>) : void; | Sets the user confirmation status for the privacy statement of the location service. This function uses an asynchronous callback to return the result. | -| setLocationPrivacyConfirmStatus(type : LocationPrivacyType, isConfirmed : boolean) : Promise<boolean>; | Sets the user confirmation status for the privacy statement of the location service. This function uses a promise to return the result. | +| on(type: 'locationChange', request: LocationRequest, callback: Callback<Location>) : void | Registers a listener for location changes with a location request initiated.| +| off(type: 'locationChange', callback?: Callback<Location>) : void | Unregisters the listener for location changes with the corresponding location request deleted.| +| on(type: 'locationServiceState', callback: Callback<boolean>) : void | Registers a listener for location service status change events.| +| off(type: 'locationServiceState', callback: Callback<boolean>) : void | Unregisters the listener for location service status change events.| +| on(type: 'cachedGnssLocationsReporting', request: CachedGnssLoactionsRequest, callback: Callback<Array<Location>>) : void; | Registers a listener for cached GNSS location reports.| +| off(type: 'cachedGnssLocationsReporting', callback?: Callback<Array<Location>>) : void; | Unregisters the listener for cached GNSS location reports.| +| on(type: 'gnssStatusChange', callback: Callback<SatelliteStatusInfo>) : void; | Registers a listener for satellite status change events.| +| off(type: 'gnssStatusChange', callback?: Callback<SatelliteStatusInfo>) : void; | Unregisters the listener for satellite status change events.| +| on(type: 'nmeaMessageChange', callback: Callback<string>) : void; | Registers a listener for GNSS NMEA message change events.| +| off(type: 'nmeaMessageChange', callback?: Callback<string>) : void; | Unregisters the listener for GNSS NMEA message change events.| +| on(type: 'fenceStatusChange', request: GeofenceRequest, want: WantAgent) : void; | Registers a listener for status change events of the specified geofence.| +| off(type: 'fenceStatusChange', request: GeofenceRequest, want: WantAgent) : void; | Unregisters the listener for status change events of the specified geofence.| +| getCurrentLocation(request: CurrentLocationRequest, callback: AsyncCallback<Location>) : void | Obtains the current location. This API uses an asynchronous callback to return the result. | +| getCurrentLocation(request?: CurrentLocationRequest) : Promise<Location> | Obtains the current location. This API uses a promise to return the result. | +| getLastLocation(callback: AsyncCallback<Location>) : void | Obtains the previous location. This API uses an asynchronous callback to return the result.| +| getLastLocation() : Promise<Location> | Obtains the previous location. This API uses a promise to return the result. | +| isLocationEnabled(callback: AsyncCallback<boolean>) : void | Checks whether the location service is enabled. This API uses an asynchronous callback to return the result.| +| isLocationEnabled() : Promise<boolean> | Checks whether the location service is enabled. This API uses a promise to return the result.| +| requestEnableLocation(callback: AsyncCallback<boolean>) : void | Requests to enable the location service. This API uses an asynchronous callback to return the result.| +| requestEnableLocation() : Promise<boolean> | Requests to enable the location service. This API uses a promise to return the result.| +| enableLocation(callback: AsyncCallback<boolean>) : void | Enables the location service. This API uses an asynchronous callback to return the result.| +| enableLocation() : Promise<boolean> | Enables the location service. This API uses a promise to return the result.| +| disableLocation(callback: AsyncCallback<boolean>) : void | Disables the location service. This function uses an asynchronous callback to return the result.| +| disableLocation() : Promise<boolean> | Disables the location service. This function uses a promise to return the result.| +| getCachedGnssLocationsSize(callback: AsyncCallback<number>) : void; | Obtains the number of cached GNSS locations. This function uses an asynchronous callback to return the result.| +| getCachedGnssLocationsSize() : Promise<number>; | Obtains the number of cached GNSS locations. This function uses a promise to return the result.| +| flushCachedGnssLocations(callback: AsyncCallback<boolean>) : void; | Obtains all cached GNSS locations and clears the GNSS cache queue. This function uses an asynchronous callback to return the result.| +| flushCachedGnssLocations() : Promise<boolean>; | Obtains all cached GNSS locations and clears the GNSS cache queue. This function uses a promise to return the result.| +| sendCommand(command: LocationCommand, callback: AsyncCallback<boolean>) : void; | Sends extended commands to the location subsystem. This function uses an asynchronous callback to return the result.| +| sendCommand(command: LocationCommand) : Promise<boolean>; | Sends extended commands to the location subsystem. This function uses a promise to return the result.| +| isLocationPrivacyConfirmed(type : LocationPrivacyType, callback: AsyncCallback<boolean>) : void; | Checks whether a user agrees with the privacy statement of the location service. This function uses an asynchronous callback to return the result.| +| isLocationPrivacyConfirmed(type : LocationPrivacyType,) : Promise<boolean>; | Checks whether a user agrees with the privacy statement of the location service. This function uses a promise to return the result.| +| setLocationPrivacyConfirmStatus(type : LocationPrivacyType, isConfirmed : boolean, callback: AsyncCallback<boolean>) : void; | Sets the user confirmation status for the privacy statement of the location service. This function uses an asynchronous callback to return the result.| +| setLocationPrivacyConfirmStatus(type : LocationPrivacyType, isConfirmed : boolean) : Promise<boolean>; | Sets the user confirmation status for the privacy statement of the location service. This function uses a promise to return the result.| ## How to Develop @@ -64,9 +64,9 @@ The following table describes APIs available for obtaining device location infor If your application needs to access the device location information when running on the background, it must be allowed to run on the background in the configuration file and also granted the **ohos.permission.LOCATION_IN_BACKGROUND** permission. In this way, the system continues to report device location information even when your application moves to the background. - To allow your application to access device location information, you can declare the required permissions in the **config.json** file of your application. The sample code is as follows: + To allow your application to access device location information, declare the required permissions in the **module.json** file of your application. The sample code is as follows: - + ``` { "module": { @@ -81,21 +81,21 @@ The following table describes APIs available for obtaining device location infor } } ``` - - For details about the fields, see . + + For details about the configuration fields, see the description of the **module.json** file. 2. Import the **geolocation** module by which you can implement all APIs related to the basic location capabilities. - + ``` import geolocation from '@ohos.geolocation'; ``` -3. Instantiate the **LocationRequest** object. This object provides APIs to notify the system of the location service type and the interval of reporting location information. +3. Instantiate the **LocationRequest** object. This object provides APIs to notify the system of the location service type and the interval of reporting location information.
**Method 1:** To better serve your needs for using APIs, the system has categorized APIs into different packages to match your common use cases of the location function. In this way, you can directly use the APIs specific to a certain use case, making application development much easier. The following table lists the use cases currently supported. - + ``` export enum LocationRequestScenario { UNSET = 0x300, @@ -107,19 +107,19 @@ The following table describes APIs available for obtaining device location infor } ``` + + **Table 2** Common use cases of the location function - **Table2** Common use cases of the location function - - | Use Case | Constant | Description | + | Use Case| Constant| Description| | -------- | -------- | -------- | - | Navigation | NAVIGATION | Applicable when your application needs to obtain the real-time location of a mobile device outdoors, such as navigation for driving or walking. In this scenario, the GNSS positioning technology is mainly used to ensure the location accuracy. However, due to its limitations, the technology may be unable to provide the location service when navigation is just started or when the user moves into a shielded environment such as indoors or a garage. To resolve this issue, the system uses the network positioning technology as an alternative to provide the location service for your application until the GNSS can provide stable location results. This helps achieve a smooth navigation experience for users.
By default, the system reports location results at a minimal interval of 1s. To adopt this use case, you must declare the **ohos.permission.LOCATION** permission and obtain users' authorization. | - | Trajectory tracking | TRAJECTORY_TRACKING | Applicable when your application needs to record user trajectories, for example, the track recording function of sports applications. In this scenario, the GNSS positioning technology is mainly used to ensure the location accuracy.
By default, the system reports location results at a minimal interval of 1s. To adopt this use case, you must declare the **ohos.permission.LOCATION** permission and obtain users' authorization. | - | Ride hailing | CAR_HAILING | Applicable when your application needs to obtain the current location of a user who is hailing a taxi.
By default, the system reports location results at a minimal interval of 1s. To adopt this use case, you must declare the **ohos.permission.LOCATION** permission and obtain users' authorization. | - | Life service | DAILY_LIFE_SERVICE | Applicable when your application only needs the approximate user location for recommendations and push notifications in scenarios such as when the user is browsing news, shopping online, and ordering food.
By default, the system reports location results at a minimal interval of 1s. To adopt this use case, you must declare the **ohos.permission.LOCATION** permission and obtain users' authorization. | - | Power efficiency | NO_POWER | Applicable when your application does not proactively start the location service for a higher battery efficiency. When responding to another application requesting the same location service, the system marks a copy of the location result to your application. In this way, your application will not consume extra power for obtaining the user location.
By default, the system reports location results at a minimal interval of 1s. To adopt this use case, you must declare the **ohos.permission.LOCATION** permission and obtain users' authorization. | + | Navigation| NAVIGATION | Applicable when your application needs to obtain the real-time location of a mobile device outdoors, such as navigation for driving or walking. In this scenario, the GNSS positioning technology is mainly used to ensure the location accuracy. However, due to its limitations, the technology may be unable to provide the location service when navigation is just started or when the user moves into a shielded environment such as indoors or a garage. To resolve this issue, the system uses the network positioning technology as an alternative to provide the location service for your application until the GNSS can provide stable location results. This helps achieve a smooth navigation experience for users.
By default, the system reports location results at a minimal interval of 1s. To adopt this use case, you must declare the **ohos.permission.LOCATION** permission and obtain users' authorization.| + | Trajectory tracking| TRAJECTORY_TRACKING | Applicable when your application needs to record user trajectories, for example, the track recording function of sports applications. In this scenario, the GNSS positioning technology is mainly used to ensure the location accuracy.
By default, the system reports location results at a minimal interval of 1s. To adopt this use case, you must declare the **ohos.permission.LOCATION** permission and obtain users' authorization.| + | Ride hailing| CAR_HAILING | Applicable when your application needs to obtain the current location of a user who is hailing a taxi.
By default, the system reports location results at a minimal interval of 1s. To adopt this use case, you must declare the **ohos.permission.LOCATION** permission and obtain users' authorization.| + | Life service| DAILY_LIFE_SERVICE | Applicable when your application only needs the approximate user location for recommendations and push notifications in scenarios such as when the user is browsing news, shopping online, and ordering food.
By default, the system reports location results at a minimal interval of 1s. To adopt this use case, you must declare the **ohos.permission.LOCATION** permission and obtain users' authorization.| + | Power efficiency| NO_POWER | Applicable when your application does not proactively start the location service for a higher battery efficiency. When responding to another application requesting the same location service, the system marks a copy of the location result to your application. In this way, your application will not consume extra power for obtaining the user location.
By default, the system reports location results at a minimal interval of 1s. To adopt this use case, you must declare the **ohos.permission.LOCATION** permission and obtain users' authorization.| The following example instantiates the **RequestParam** object for navigation: - + ``` var requestInfo = {'scenario': 0x301, 'timeInterval': 0, 'distanceInterval': 0, 'maxAccuracy': 0}; ``` @@ -128,7 +128,7 @@ The following table describes APIs available for obtaining device location infor If the predefined use cases do not meet your needs, you can also use the basic location priority policies provided by the system. - + ``` export enum LocationRequestPriority { UNSET = 0x200, @@ -138,23 +138,23 @@ The following table describes APIs available for obtaining device location infor } ``` + + **Table 3** Location priority policies - **Table3** Location priority policies - - | Policy | Constant | Description | + | Policy| Constant| Description| | -------- | -------- | -------- | - | Location accuracy priority | ACCURACY | This policy mainly uses the GNSS positioning technology. In an open area, the technology can achieve the meter-level location accuracy, depending on the hardware performance of the device. However, in a shielded environment, the location accuracy may significantly decrease.
To use this policy, you must declare the **ohos.permission.LOCATION** permission and obtain users' authorization. | - | Fast location priority | FAST_FIRST_FIX | This policy uses the GNSS positioning, base station positioning, WLAN positioning, and Bluetooth positioning technologies simultaneously to obtain the device location in both the indoor and outdoor scenarios. When all positioning technologies provide a location result, the system provides the most accurate location result for your application. This policy can lead to significant hardware resource consumption and power consumption.
To use this policy, you must declare the **ohos.permission.LOCATION** permission and obtain users' authorization. | - | Power efficiency priority | LOW_POWER | This policy mainly uses the base station positioning, WLAN positioning, and Bluetooth positioning technologies to obtain device location in both indoor and outdoor scenarios. The location accuracy depends on the distribution of surrounding base stations, visible WLANs, and Bluetooth devices and therefore may fluctuate greatly. This policy is recommended and can reduce power consumption when your application does not require high location accuracy or when base stations, visible WLANs, and Bluetooth devices are densely distributed.
To use this policy, you must declare at least the **ohos.permission.LOCATION** permission and obtain users' authorization. | + | Location accuracy priority| ACCURACY | This policy mainly uses the GNSS positioning technology. In an open area, the technology can achieve the meter-level location accuracy, depending on the hardware performance of the device. However, in a shielded environment, the location accuracy may significantly decrease.
To use this policy, you must declare the **ohos.permission.LOCATION** permission and obtain users' authorization.| + | Fast location priority| FAST_FIRST_FIX | This policy uses the GNSS positioning, base station positioning, WLAN positioning, and Bluetooth positioning technologies simultaneously to obtain the device location in both the indoor and outdoor scenarios. When all positioning technologies provide a location result, the system provides the most accurate location result for your application. This policy can lead to significant hardware resource consumption and power consumption.
To use this policy, you must declare the **ohos.permission.LOCATION** permission and obtain users' authorization.| + | Power efficiency priority| LOW_POWER | This policy mainly uses the base station positioning, WLAN positioning, and Bluetooth positioning technologies to obtain device location in both indoor and outdoor scenarios. The location accuracy depends on the distribution of surrounding base stations, visible WLANs, and Bluetooth devices and therefore may fluctuate greatly. This policy is recommended and can reduce power consumption when your application does not require high location accuracy or when base stations, visible WLANs, and Bluetooth devices are densely distributed.
To use this policy, you must declare at least the **ohos.permission.LOCATION** permission and obtain users' authorization.| The following example instantiates the **RequestParam** object for the location accuracy priority policy: - + ``` var requestInfo = {'priority': 0x201, 'timeInterval': 0, 'distanceInterval': 0, 'maxAccuracy': 0}; ``` 4. Instantiate the **Callback** object for the system to report location results. - Your application needs to implement the callback interface defined by the system. When the system successfully obtains the real-time location of a device, it will report the location result to your application through the callback interface. Your application can implement the callback interface in such a way to complete your own service logic. + Your application needs to implement the callback defined by the system. When the system successfully obtains the real-time location of a device, it will report the location result to your application through the callback interface. Your application can implement the callback interface in such a way to complete your own service logic. ``` var locationChange = (location) => { @@ -163,19 +163,19 @@ The following table describes APIs available for obtaining device location infor ``` 5. Start device location. - + ``` geolocation.on('locationChange', requestInfo, locationChange); ``` 6. (Optional) Stop device location. - + ``` geolocation.off('locationChange', locationChange); ``` If your application does not need the real-time device location, it can use the last known device location cached in the system instead. - + ``` geolocation.getLastLocation((data) => { console.log('getLastLocation: data: ' + JSON.stringify(data)); 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 de3c11c9bcef2c6ef3ecd4e77db051de55844359..1dd03af96c2064b5b6b0baa89e7295decb4cf1fd 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 @@ -15,7 +15,7 @@ You can develop applications or services in the low-code approach using either o - Create a project that supports low-code development. This method is used as an example in this topic. -- In an existing project, create a .visual file for development. +- In an existing project, create a .visual file for development. For details, see [Creating a .visual File That Supports Low-Code Development](#building-the-second-page). ## Creating a Project That Supports Low-Code Development @@ -52,7 +52,7 @@ Add **Column**, **Text**, and **Button** components to the first page. A column Open the **index.visual** file, right-click the existing template components on the canvas, and choose **Delete** from the shortcut menu to delete them. Below is an illustration of the operations. -![en-us_image_0000001233208980](figures/en-us_image_0000001233208980.gif) + ![en-us_image_0000001233208980](figures/en-us_image_0000001233208980.gif) 2. Add a **Column** component and set its styles and attributes. @@ -70,7 +70,7 @@ Add **Column**, **Text**, and **Button** components to the first page. A column 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 ![en-us_image_0000001277728577](figures/en-us_image_0000001277728577.png)**General** and set **Height** of the **Button** component to **40vp**. Click ![en-us_image_0000001277809337](figures/en-us_image_0000001277809337.png)**Feature** and set **Label** to **Next** and **FontSize** to **25fp**. Below is an illustration of the operations. -![en-us_image_0000001235732402](figures/en-us_image_0000001235732402.gif) + ![en-us_image_0000001235732402](figures/en-us_image_0000001235732402.gif) 5. On the toolbar in the upper right corner of the editing window, click **Previewer** to open the Previewer. @@ -85,7 +85,7 @@ Add **Column**, **Text**, and **Button** components to the first page. A column 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. -![en-us_image_0000001233368868](figures/en-us_image_0000001233368868.png) + ![en-us_image_0000001233368868](figures/en-us_image_0000001233368868.png) 2. [Delete the existing template components from the canvas.](#delete_origin_content) 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 865f2b69847412f626c47d8228d1a3dc344a3b7a..9d551aea76026a1d089d6853bce1aabdc1533192 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 @@ -13,7 +13,7 @@ You can develop applications or services in the low-code approach using either o - Create a project that supports low-code development. This method is used as an example in this topic. -- In an existing project, create a Visual file for development. +- In an existing project, create a Visual file for development. For details, see [Creating a .visual File That Supports Low-Code Development](#building-the-second-page). ## Creating a Project That Supports Low-Code Development @@ -53,15 +53,15 @@ 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. -![en-us_image_0000001216600980](figures/en-us_image_0000001216600980.gif) + ![en-us_image_0000001216600980](figures/en-us_image_0000001216600980.gif) 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 ![en-us_image_0000001260226691](figures/en-us_image_0000001260226691.png)**General** and set **Height** to **100%** so that the component fills the entire screen. Click ![en-us_image_0000001215226858](figures/en-us_image_0000001215226858.png)**Flex**, set **FlexDirection** to **column** so that the main axis of the component is vertical, and set both **JustifyContent** and **AlignItems** to **center** so that the child components of the **Div** component are centered along the main axis and cross axis. Below is an illustration of the operations. -![en-us_image_0000001216448880](figures/en-us_image_0000001216448880.gif) + ![en-us_image_0000001216448880](figures/en-us_image_0000001216448880.gif) 3. Add a **Text** component. @@ -88,7 +88,7 @@ Open the index.visual file, right-click the existing template components on the 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. -![en-us_image_0000001223882030](figures/en-us_image_0000001223882030.png) + ![en-us_image_0000001223882030](figures/en-us_image_0000001223882030.png) 2. [Delete the existing template components from the canvas.](#delete_origin_content) diff --git a/en/application-dev/reference/apis/js-apis-appAccount.md b/en/application-dev/reference/apis/js-apis-appAccount.md index 3577652546daea30400c7eadafd7e6771a55db77..f7671c4f66025887a62622df895c14b04325eff9 100644 --- a/en/application-dev/reference/apis/js-apis-appAccount.md +++ b/en/application-dev/reference/apis/js-apis-appAccount.md @@ -1,6 +1,6 @@ -# App Account Management +# App Account Management -> **NOTE**
+> ![icon-note.gif](public_sys-resources/icon-note.gif) **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. @@ -20,13 +20,13 @@ Creates an **AppAccountManager** instance. **System capability**: SystemCapability.Account.AppAccount **Return Value** - | Type | Description | - | ----------------- | ------------ | - | AppAccountManager | **AppAccountManager** instance created. | +| Type | Description | +| ----------------- | ------------ | +| AppAccountManager | **AppAccountManager** instance created.| **Example** ```js - var appAccountManager = account.createAppAccountManager(); + const appAccountManager = account_appAccount.createAppAccountManager(); ``` ## AppAccountManager @@ -37,16 +37,16 @@ Provides methods to manage app accounts. addAccount(name: string, callback: AsyncCallback<void>): void -Adds an app account to the account management service. This method uses an asynchronous callback to return the result. +Adds an app account to the account management service. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.Account.AppAccount **Parameters** - | Name | Type | Mandatory | Description | - | -------- | ------------------------- | ---- | --------------------- | - | name | string | Yes | Name of the app account to add. | - | callback | AsyncCallback<void> | Yes | Callback invoked when the app account is added. | +| Name | Type | Mandatory | Description | +| -------- | ------------------------- | ---- | --------------------- | +| name | string | Yes | Name of the app account to add. | +| callback | AsyncCallback<void> | Yes | Callback invoked when the app account is added.| **Example** @@ -61,17 +61,17 @@ Adds an app account to the account management service. This method uses an async addAccount(name: string, extraInfo: string, callback: AsyncCallback<void>): void -Adds an app account and its additional information to the account management service. This method uses an asynchronous callback to return the result. +Adds an app account and its additional information to the account management service. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.Account.AppAccount **Parameters** - | Name | Type | Mandatory | Description | - | --------- | ------------------------- | ---- | ---------------------------------------- | - | name | string | Yes | Name of the app account to add. | - | extraInfo | string | Yes | Additional information (for example, token) of the app account to add. The additional information cannot contain sensitive information about the app account. | - | callback | AsyncCallback<void> | Yes | Callback invoked when the app account and its additional information are added. | +| Name | Type | Mandatory | Description | +| --------- | ------------------------- | ---- | ---------------------------------------- | +| name | string | Yes | Name of the app account to add. | +| extraInfo | string | Yes | Additional information (for example, token) of the app account to add. The additional information cannot contain sensitive information about the app account.| +| callback | AsyncCallback<void> | Yes | Callback invoked when the app account and its additional information are added. | **Example** @@ -88,22 +88,22 @@ Adds an app account and its additional information to the account management ser addAccount(name: string, extraInfo?: string): Promise<void> -Adds an app account and its additional information to the account management service. This method uses a promise to return the result. +Adds an app account and its additional information to the account management service. This API uses a promise to return the result. **System capability**: SystemCapability.Account.AppAccount **Parameters** - | Name | Type | Mandatory | Description | - | --------- | ------ | ---- | -------------------------------- | - | name | string | Yes | Name of the app account to add. | - | extraInfo | string | Yes | Additional information of the app account to add. The additional information cannot contain sensitive information about the app account. | +| Name | Type | Mandatory | Description | +| --------- | ------ | ---- | -------------------------------- | +| name | string | Yes | Name of the app account to add. | +| extraInfo | string | Yes | Additional information of the app account to add. The additional information cannot contain sensitive information about the app account.| **Return Value** - | Type | Description | - | ------------------- | --------------------- | - | Promise<void> | Promise used to return the result. | +| Type | Description | +| ------------------- | --------------------- | +| Promise<void> | Promise used to return the result.| **Example** @@ -120,18 +120,18 @@ Adds an app account and its additional information to the account management ser addAccountImplicitly(owner: string, authType: string, options: {[key: string]: any}, callback: AuthenticatorCallback): void -Implicitly adds an app account based on the specified account owner, authentication type, and options. This method uses an asynchronous callback to return the result. +Implicitly adds an app account based on the specified account owner, authentication type, and options. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.Account.AppAccount **Parameters** - | Name | Type | Mandatory | Description | - | -------- | --------------------- | ---- | --------------- | - | owner | string | Yes | Bundle name of the app account to add. | - | authType | string | Yes | Authentication type of the app account to add. | - | options | {[key: string]: any} | Yes | Options for the authentication. | - | callback | AuthenticatorCallback | Yes | Authenticator callback invoked to return the authentication result. | +| Name | Type | Mandatory | Description | +| -------- | --------------------- | ---- | --------------- | +| owner | string | Yes | Bundle name of the app account to add.| +| authType | string | Yes | Authentication type of the app account to add. | +| options | {[key: string]: any} | Yes | Options for the authentication. | +| callback | AuthenticatorCallback | Yes | Authenticator callback invoked to return the authentication result.| **Example** @@ -161,16 +161,16 @@ Implicitly adds an app account based on the specified account owner, authenticat deleteAccount(name: string, callback: AsyncCallback<void>): void -Deletes an app account from the account management service. This method uses an asynchronous callback to return the result. +Deletes an app account from the account management service. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.Account.AppAccount **Parameters** - | Name | Type | Mandatory | Description | - | -------- | ------------------------- | ---- | ----------------- | - | name | string | Yes | Name of the app account to delete. | - | callback | AsyncCallback<void> | Yes | Callback invoked when the app account is deleted. | +| Name | Type | Mandatory | Description | +| -------- | ------------------------- | ---- | ----------------- | +| name | string | Yes | Name of the app account to delete. | +| callback | AsyncCallback<void> | Yes | Callback invoked when the app account is deleted.| **Example** @@ -185,21 +185,21 @@ Deletes an app account from the account management service. This method uses an deleteAccount(name: string): Promise<void> -Deletes an app account from the account management service. This method uses a promise to return the result. +Deletes an app account from the account management service. This API uses a promise to return the result. **System capability**: SystemCapability.Account.AppAccount **Parameters** - | Name | Type | Mandatory | Description | - | ---- | ------ | ---- | ------------ | - | name | string | Yes | Name of the app account to delete. | +| Name | Type | Mandatory | Description | +| ---- | ------ | ---- | ------------ | +| name | string | Yes | Name of the app account to delete.| **Return Value** - | Type | Description | - | :------------------ | :-------------------- | - | Promise<void> | Promise used to return the result. | +| Type | Description | +| :------------------ | :-------------------- | +| Promise<void> | Promise used to return the result.| **Example** @@ -216,17 +216,17 @@ Deletes an app account from the account management service. This method uses a p disableAppAccess(name: string, bundleName: string, callback: AsyncCallback<void>): void -Disables an app account from accessing an application with the given bundle name. This method uses an asynchronous callback to return the result. +Disables an app account from accessing an application with the given bundle name. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.Account.AppAccount **Parameters** - | Name | Type | Mandatory | Description | - | ---------- | ------------------------- | ---- | ------------------------------- | - | name | string | Yes | App account name. | - | bundleName | string | Yes | Bundle name of an app. | - | callback | AsyncCallback<void> | Yes | Callback invoked when the app account is disabled from accessing the application with the given bundle name. | +| Name | Type | Mandatory | Description | +| ---------- | ------------------------- | ---- | ------------------------------- | +| name | string | Yes | App account name. | +| bundleName | string | Yes | Bundle name of an app. | +| callback | AsyncCallback<void> | Yes | Callback invoked when the app account is disabled from accessing the application with the given bundle name.| **Example** @@ -241,22 +241,22 @@ Disables an app account from accessing an application with the given bundle name disableAppAccess(name: string, bundleName: string): Promise<void> -Disables an app account from accessing an application with the given bundle name. This method uses a promise to return the result. +Disables an app account from accessing an application with the given bundle name. This API uses a promise to return the result. **System capability**: SystemCapability.Account.AppAccount **Parameters** - | Name | Type | Mandatory | Description | - | ---------- | ------ | ---- | ----------------- | - | name | string | Yes | App account name. | - | bundleName | string | Yes | Bundle name of an app. | +| Name | Type | Mandatory | Description | +| ---------- | ------ | ---- | ----------------- | +| name | string | Yes | App account name.| +| bundleName | string | Yes | Bundle name of an app. | **Return Value** - | Type | Description | - | :------------------ | :-------------------- | - | Promise<void> | Promise used to return the result. | +| Type | Description | +| :------------------ | :-------------------- | +| Promise<void> | Promise used to return the result.| **Example** @@ -273,17 +273,17 @@ Disables an app account from accessing an application with the given bundle name enableAppAccess(name: string, bundleName: string, callback: AsyncCallback<void>): void -Enables an app account to access an application with the given bundle name. This method uses an asynchronous callback to return the result. +Enables an app account to access an application with the given bundle name. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.Account.AppAccount **Parameters** - | Name | Type | Mandatory | Description | - | ---------- | ------------------------- | ---- | ------------------------------- | - | name | string | Yes | App account name. | - | bundleName | string | Yes | Bundle name of an app. | - | callback | AsyncCallback<void> | Yes | Callback invoked when the app account is enabled to access the application with the given bundle name. | +| Name | Type | Mandatory | Description | +| ---------- | ------------------------- | ---- | ------------------------------- | +| name | string | Yes | App account name. | +| bundleName | string | Yes | Bundle name of an app. | +| callback | AsyncCallback<void> | Yes | Callback invoked when the app account is enabled to access the application with the given bundle name.| **Example** @@ -298,22 +298,22 @@ Enables an app account to access an application with the given bundle name. This enableAppAccess(name: string, bundleName: string): Promise<void> -Enables an app account to access an application with the given bundle name. This method uses a promise to return the result. +Enables an app account to access an application with the given bundle name. This API uses a promise to return the result. **System capability**: SystemCapability.Account.AppAccount **Parameters** - | Name | Type | Mandatory | Description | - | ---------- | ------ | ---- | --------- | - | name | string | Yes | App account name. | - | bundleName | string | Yes | Bundle name of an app. | +| Name | Type | Mandatory | Description | +| ---------- | ------ | ---- | --------- | +| name | string | Yes | App account name. | +| bundleName | string | Yes | Bundle name of an app.| **Return Value** - | Type | Description | - | :------------------ | :-------------------- | - | Promise<void> | Promise used to return the result. | +| Type | Description | +| :------------------ | :-------------------- | +| Promise<void> | Promise used to return the result.| **Example** @@ -329,7 +329,7 @@ Enables an app account to access an application with the given bundle name. This checkAppAccountSyncEnable(name: string, callback: AsyncCallback<boolean>): void -Checks whether an app account allows application data synchronization. This method uses an asynchronous callback to return the result. +Checks whether an app account allows application data synchronization. This API uses an asynchronous callback to return the result. **Required permissions**: ohos.permission.DISTRIBUTED_DATASYNC (available only to system applications) @@ -337,10 +337,10 @@ Checks whether an app account allows application data synchronization. This meth **Parameters** - | Name | Type | Mandatory | Description | - | -------- | ---------------------------- | ---- | ---------------------- | - | name | string | Yes | App account name. | - | callback | AsyncCallback<boolean> | Yes | Callback used to return whether the app account allows application data synchronization. | +| Name | Type | Mandatory | Description | +| -------- | ---------------------------- | ---- | ---------------------- | +| name | string | Yes | App account name. | +| callback | AsyncCallback<boolean> | Yes | Callback used to return whether the app account allows application data synchronization.| **Example** @@ -356,7 +356,7 @@ Checks whether an app account allows application data synchronization. This meth checkAppAccountSyncEnable(name: string): Promise<boolean> -Checks whether an app account allows application data synchronization. This method uses a promise to return the result. +Checks whether an app account allows application data synchronization. This API uses a promise to return the result. **Required permissions**: ohos.permission.DISTRIBUTED_DATASYNC (available only to system applications) @@ -364,15 +364,15 @@ Checks whether an app account allows application data synchronization. This meth **Parameters** - | Name | Type | Mandatory | Description | - | ---- | ------ | ---- | ------- | - | name | string | Yes | App account name. | +| Name | Type | Mandatory | Description | +| ---- | ------ | ---- | ------- | +| name | string | Yes | App account name.| **Return Value** - | Type | Description | - | :--------------------- | :-------------------- | - | Promise<boolean> | Promise used to return the result. | +| Type | Description | +| :--------------------- | :-------------------- | +| Promise<boolean> | Promise used to return the result.| **Example** @@ -387,20 +387,20 @@ Checks whether an app account allows application data synchronization. This meth ### setAccountCredential -setAccountCredential(name: string, credentialType: string, credential: string, callback: AsyncCallback<void>): void +setAccountCredential(name: string, credentialType: string, credential: string,callback: AsyncCallback<void>): void -Sets a credential for an app account. This method uses an asynchronous callback to return the result. +Sets a credential for an app account. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.Account.AppAccount **Parameters** - | Name | Type | Mandatory | Description | - | -------------- | ------------------------- | ---- | -------------- | - | name | string | Yes | App account name. | - | credentialType | string | Yes | Type of the credential to set. | - | credential | string | Yes | Credential to set. | - | callback | AsyncCallback<void> | Yes | Callback invoked when a credential is set for the specified app account. | +| Name | Type | Mandatory | Description | +| -------------- | ------------------------- | ---- | -------------- | +| name | string | Yes | App account name. | +| credentialType | string | Yes | Type of the credential to set. | +| credential | string | Yes | Credential to set. | +| callback | AsyncCallback<void> | Yes | Callback invoked when a credential is set for the specified app account.| **Example** @@ -415,23 +415,23 @@ Sets a credential for an app account. This method uses an asynchronous callback setAccountCredential(name: string, credentialType: string, credential: string): Promise<void> -Sets a credential for an app account. This method uses a promise to return the result asynchronously. +Sets a credential for an app account. This API uses a promise to return the result asynchronously. **System capability**: SystemCapability.Account.AppAccount **Parameters** - | Name | Type | Mandatory | Description | - | -------------- | ------ | ---- | ---------- | - | name | string | Yes | App account name. | - | credentialType | string | Yes | Type of the credential to set. | - | credential | string | Yes | Credential to set. | +| Name | Type | Mandatory | Description | +| -------------- | ------ | ---- | ---------- | +| name | string | Yes | App account name. | +| credentialType | string | Yes | Type of the credential to set.| +| credential | string | Yes | Credential to set. | **Return Value** - | Type | Description | - | :------------------ | :-------------------- | - | Promise<void> | Promise used to return the result. | +| Type | Description | +| :------------------ | :-------------------- | +| Promise<void> | Promise used to return the result.| **Example** @@ -448,17 +448,17 @@ Sets a credential for an app account. This method uses a promise to return the r setAccountExtraInfo(name: string, extraInfo: string, callback: AsyncCallback<void>): void -Sets additional information for an app account. This method uses an asynchronous callback to return the result. +Sets additional information for an app account. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.Account.AppAccount **Parameters** - | Name | Type | Mandatory | Description | - | --------- | ------------------------- | ---- | ---------------- | - | name | string | Yes | App account name. | - | extraInfo | string | Yes | Additional information to set. | - | callback | AsyncCallback<void> | Yes | Callback invoked when additional information is set for the specified app account. | +| Name | Type | Mandatory | Description | +| --------- | ------------------------- | ---- | ---------------- | +| name | string | Yes | App account name. | +| extraInfo | string | Yes | Additional information to set. | +| callback | AsyncCallback<void> | Yes | Callback invoked when additional information is set for the specified app account.| **Example** @@ -473,22 +473,22 @@ Sets additional information for an app account. This method uses an asynchronous setAccountExtraInfo(name: string, extraInfo: string): Promise<void> -Sets additional information for an app account. This method uses a promise to return the result asynchronously. +Sets additional information for an app account. This API uses a promise to return the result asynchronously. **System capability**: SystemCapability.Account.AppAccount **Parameters** - | Name | Type | Mandatory | Description | - | --------- | ------ | ---- | --------- | - | name | string | Yes | App account name. | - | extraInfo | string | Yes | Additional information to set. | +| Name | Type | Mandatory | Description | +| --------- | ------ | ---- | --------- | +| name | string | Yes | App account name. | +| extraInfo | string | Yes | Additional information to set.| **Return Value** - | Type | Description | - | :------------------ | :-------------------- | - | Promise<void> | Promise used to return the result. | +| Type | Description | +| :------------------ | :-------------------- | +| Promise<void> | Promise used to return the result.| **Example** @@ -505,7 +505,7 @@ Sets additional information for an app account. This method uses a promise to re setAppAccountSyncEnable(name: string, isEnable: boolean, callback: AsyncCallback<void>): void -Sets whether to enable application data synchronization for an app account. This method uses an asynchronous callback to return the result. +Sets whether to enable application data synchronization for an app account. This API uses an asynchronous callback to return the result. **Required permissions**: ohos.permission.DISTRIBUTED_DATASYNC (available only to system applications) @@ -513,11 +513,11 @@ Sets whether to enable application data synchronization for an app account. This **Parameters** - | Name | Type | Mandatory | Description | - | -------- | ------------------------- | ---- | ------------------------- | - | name | string | Yes | App account name. | - | isEnable | boolean | Yes | Whether to enable app data synchronization. | - | callback | AsyncCallback<void> | Yes | Callback invoked when application data synchronization is enabled or disabled for the app account. | +| Name | Type | Mandatory | Description | +| -------- | ------------------------- | ---- | ------------------------- | +| name | string | Yes | App account name. | +| isEnable | boolean | Yes | Whether to enable app data synchronization. | +| callback | AsyncCallback<void> | Yes | Callback invoked when application data synchronization is enabled or disabled for the app account.| **Example** @@ -532,7 +532,7 @@ Sets whether to enable application data synchronization for an app account. This setAppAccountSyncEnable(name: string, isEnable: boolean): Promise<void> -Sets whether to enable application data synchronization for an app account. This method uses a promise to return the result asynchronously. +Sets whether to enable application data synchronization for an app account. This API uses a promise to return the result asynchronously. **Required permissions**: ohos.permission.DISTRIBUTED_DATASYNC (available only to system applications) @@ -540,16 +540,16 @@ Sets whether to enable application data synchronization for an app account. This **Parameters** - | Name | Type | Mandatory | Description | - | -------- | ------- | ---- | ----------- | - | name | string | Yes | App account name. | - | isEnable | boolean | Yes | Whether to enable app data synchronization. | +| Name | Type | Mandatory | Description | +| -------- | ------- | ---- | ----------- | +| name | string | Yes | App account name. | +| isEnable | boolean | Yes | Whether to enable app data synchronization.| **Return Value** - | Type | Description | - | :------------------ | :-------------------- | - | Promise<void> | Promise used to return the result. | +| Type | Description | +| :------------------ | :-------------------- | +| Promise<void> | Promise used to return the result.| **Example** @@ -566,18 +566,18 @@ Sets whether to enable application data synchronization for an app account. This setAssociatedData(name: string, key: string, value: string, callback: AsyncCallback<void>): void -Sets data to be associated with an app account. This method uses an asynchronous callback to return the result. +Sets data to be associated with an app account. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.Account.AppAccount **Parameters** - | Name | Type | Mandatory | Description | - | -------- | ------------------------- | ---- | ----------------- | - | name | string | Yes | App account name. | - | key | string | Yes | Key of the data to set. The private key can be customized. | - | value | string | Yes | Value of the data to be set. | - | callback | AsyncCallback<void> | Yes | Callback invoked when the data associated with the specified app account is set. | +| Name | Type | Mandatory | Description | +| -------- | ------------------------- | ---- | ----------------- | +| name | string | Yes | App account name. | +| key | string | Yes | Key of the data to set. The private key can be customized.| +| value | string | Yes | Value of the data to be set. | +| callback | AsyncCallback<void> | Yes | Callback invoked when the data associated with the specified app account is set.| **Example** @@ -591,23 +591,23 @@ Sets data to be associated with an app account. This method uses an asynchronous setAssociatedData(name: string, key: string, value: string): Promise<void> -Sets data to be associated with an app account. This method uses a promise to return the result asynchronously. +Sets data to be associated with an app account. This API uses a promise to return the result asynchronously. **System capability**: SystemCapability.Account.AppAccount **Parameters** - | Name | Type | Mandatory | Description | - | ----- | ------ | ---- | ----------------- | - | name | string | Yes | App account name. | - | key | string | Yes | Key of the data to set. The private key can be customized. | - | value | string | Yes | Value of the data to be set. | +| Name | Type | Mandatory | Description | +| ----- | ------ | ---- | ----------------- | +| name | string | Yes | App account name. | +| key | string | Yes | Key of the data to set. The private key can be customized.| +| value | string | Yes | Value of the data to be set. | **Return Value** - | Type | Description | - | :------------------ | :-------------------- | - | Promise<void> | Promise used to return the result. | +| Type | Description | +| :------------------ | :-------------------- | +| Promise<void> | Promise used to return the result.| **Example** @@ -624,17 +624,17 @@ Sets data to be associated with an app account. This method uses a promise to re getAccountCredential(name: string, credentialType: string, callback: AsyncCallback<string>): void -Obtains the credential of an app account. This method uses an asynchronous callback to return the result. +Obtains the credential of an app account. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.Account.AppAccount **Parameters** - | Name | Type | Mandatory | Description | - | -------------- | --------------------------- | ---- | -------------- | - | name | string | Yes | App account name. | - | credentialType | string | Yes | Type of the credential to obtain. | - | callback | AsyncCallback<string> | Yes | Callback invoked to return the credential of the specified app account. | +| Name | Type | Mandatory | Description | +| -------------- | --------------------------- | ---- | -------------- | +| name | string | Yes | App account name. | +| credentialType | string | Yes | Type of the credential to obtain. | +| callback | AsyncCallback<string> | Yes | Callback invoked to return the credential of the specified app account.| **Example** @@ -650,22 +650,22 @@ Obtains the credential of an app account. This method uses an asynchronous callb getAccountCredential(name: string, credentialType: string): Promise<string> -Obtains the credential of an app account. This method uses a promise to return the result asynchronously. +Obtains the credential of an app account. This API uses a promise to return the result asynchronously. **System capability**: SystemCapability.Account.AppAccount **Parameters** - | Name | Type | Mandatory | Description | - | -------------- | ------ | ---- | ---------- | - | name | string | Yes | App account name. | - | credentialType | string | Yes | Type of the credential to obtain. | +| Name | Type | Mandatory | Description | +| -------------- | ------ | ---- | ---------- | +| name | string | Yes | App account name. | +| credentialType | string | Yes | Type of the credential to obtain.| **Return Value** - | Type | Description | - | :-------------------- | :-------------------- | - | Promise<string> | Promise used to return the result. | +| Type | Description | +| :-------------------- | :-------------------- | +| Promise<string> | Promise used to return the result.| **Example** @@ -682,16 +682,16 @@ Obtains the credential of an app account. This method uses a promise to return t getAccountExtraInfo(name: string, callback: AsyncCallback<string>): void -Obtains additional information of an app account. This method uses an asynchronous callback to return the result. +Obtains additional information of an app account. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.Account.AppAccount **Parameters** - | Name | Type | Mandatory | Description | - | -------- | --------------------------- | ---- | ---------------- | - | name | string | Yes | App account name. | - | callback | AsyncCallback<string> | Yes | Callback invoked to return the additional information of the specified app account. | +| Name | Type | Mandatory | Description | +| -------- | --------------------------- | ---- | ---------------- | +| name | string | Yes | App account name. | +| callback | AsyncCallback<string> | Yes | Callback invoked to return the additional information of the specified app account.| **Example** @@ -707,21 +707,21 @@ Obtains additional information of an app account. This method uses an asynchrono getAccountExtraInfo(name: string): Promise<string> -Obtains additional information of an app account. This method uses a promise to return the result asynchronously. +Obtains additional information of an app account. This API uses a promise to return the result asynchronously. **System capability**: SystemCapability.Account.AppAccount **Parameters** - | Name | Type | Mandatory | Description | - | ---- | ------ | ---- | ------- | - | name | string | Yes | App account name. | +| Name | Type | Mandatory | Description | +| ---- | ------ | ---- | ------- | +| name | string | Yes | App account name.| **Return Value** - | Type | Description | - | :-------------------- | :-------------------- | - | Promise<string> | Promise used to return the result. | +| Type | Description | +| :-------------------- | :-------------------- | +| Promise<string> | Promise used to return the result.| **Example** @@ -738,17 +738,17 @@ Obtains additional information of an app account. This method uses a promise to getAssociatedData(name: string, key: string, callback: AsyncCallback<string>): void -Obtains data associated with an app account. This method uses an asynchronous callback to return the result. +Obtains data associated with an app account. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.Account.AppAccount **Parameters** - | Name | Type | Mandatory | Description | - | -------- | --------------------------- | ---- | ----------------- | - | name | string | Yes | App account name. | - | key | string | Yes | Key of the data to obtain. | - | callback | AsyncCallback<string> | Yes | Callback invoked to return the data associated with the specified app account. | +| Name | Type | Mandatory | Description | +| -------- | --------------------------- | ---- | ----------------- | +| name | string | Yes | App account name. | +| key | string | Yes | Key of the data to obtain. | +| callback | AsyncCallback<string> | Yes | Callback invoked to return the data associated with the specified app account.| **Example** @@ -764,22 +764,22 @@ Obtains data associated with an app account. This method uses an asynchronous ca getAssociatedData(name: string, key: string): Promise<string> -Obtains data associated with an app account. This method uses a promise to return the result asynchronously. +Obtains data associated with an app account. This API uses a promise to return the result asynchronously. **System capability**: SystemCapability.Account.AppAccount **Parameters** - | Name | Type | Mandatory | Description | - | ---- | ------ | ---- | ----------- | - | name | string | Yes | App account name. | - | key | string | Yes | Key of the data to obtain. | +| Name | Type | Mandatory | Description | +| ---- | ------ | ---- | ----------- | +| name | string | Yes | App account name. | +| key | string | Yes | Key of the data to obtain.| **Return Value** - | Type | Description | - | :-------------------- | :-------------------- | - | Promise<string> | Promise used to return the result. | +| Type | Description | +| :-------------------- | :-------------------- | +| Promise<string> | Promise used to return the result.| **Example** @@ -796,7 +796,7 @@ Obtains data associated with an app account. This method uses a promise to retur getAllAccessibleAccounts(callback: AsyncCallback<Array<AppAccountInfo>>): void -Obtains information about all accessible app accounts. This method uses an asynchronous callback to return the result. +Obtains information about all accessible app accounts. This API uses an asynchronous callback to return the result. **Required permissions**: ohos.permission.GET_ALL_APP_ACCOUNTS (available only to system applications) @@ -804,9 +804,9 @@ Obtains information about all accessible app accounts. This method uses an async **Parameters** - | Name | Type | Mandatory | Description | - | -------- | ---------------------------------------- | ---- | -------- | - | callback | AsyncCallback<Array<AppAccountInfo>> | Yes | Callback invoked to return information about all accessible app accounts. | +| Name | Type | Mandatory | Description | +| -------- | ---------------------------------------- | ---- | -------- | +| callback | AsyncCallback<Array<AppAccountInfo>> | Yes | Callback invoked to return information about all accessible app accounts.| **Example** @@ -822,7 +822,7 @@ Obtains information about all accessible app accounts. This method uses an async getAllAccessibleAccounts(): Promise<Array<AppAccountInfo>> -Obtains information about all accessible app accounts. This method uses an asynchronous callback to return the result. +Obtains information about all accessible app accounts. This API uses a promise to return the result. **Required permissions**: ohos.permission.GET_ALL_APP_ACCOUNTS (available only to system applications) @@ -830,9 +830,9 @@ Obtains information about all accessible app accounts. This method uses an async **Parameters** - | Type | Description | - | ---------------------------------------- | --------------------- | - | Promise<Array<AppAccountInfo>> | Promise used to return the result. | +| Type | Description | +| ---------------------------------------- | --------------------- | +| Promise<Array<AppAccountInfo>> | Promise used to return the result.| **Example** @@ -849,7 +849,7 @@ Obtains information about all accessible app accounts. This method uses an async getAllAccounts(owner: string, callback: AsyncCallback<Array<AppAccountInfo>>): void -Obtains information about all app accounts of the specified app. This method uses an asynchronous callback to return the result. +Obtains information about all app accounts of the specified app. This API uses an asynchronous callback to return the result. **Required permissions**: ohos.permission.GET_ALL_APP_ACCOUNTS (available only to system applications) @@ -857,10 +857,10 @@ Obtains information about all app accounts of the specified app. This method use **Parameters** - | Name | Type | Mandatory | Description | - | -------- | ---------------------------------------- | ---- | -------- | - | owner | string | Yes | Bundle name of the app. | - | callback | AsyncCallback<Array<AppAccountInfo>> | Yes | Callback invoked to return information about all accessible app accounts. | +| Name | Type | Mandatory | Description | +| -------- | ---------------------------------------- | ---- | -------- | +| owner | string | Yes | Bundle name of the app. | +| callback | AsyncCallback<Array<AppAccountInfo>> | Yes | Callback invoked to return information about all accessible app accounts.| **Example** @@ -877,7 +877,7 @@ Obtains information about all app accounts of the specified app. This method use getAllAccounts(owner: string): Promise<Array<AppAccountInfo>> -Obtains information about all app accounts of the specified app. This method uses an asynchronous callback to return the result. +Obtains information about all app accounts of the specified app. This API uses a promise to return the result. **Required permissions**: ohos.permission.GET_ALL_APP_ACCOUNTS (available only to system applications) @@ -885,15 +885,15 @@ Obtains information about all app accounts of the specified app. This method use **Parameters** - | Name | Type | Mandatory | Description | - | ----- | ------ | ---- | ----- | - | owner | string | Yes | Bundle name of the app. | +| Name | Type | Mandatory | Description | +| ----- | ------ | ---- | ----- | +| owner | string | Yes | Bundle name of the app.| **Parameters** - | Type | Description | - | ---------------------------------------- | --------------------- | - | Promise<Array<AppAccountInfo>> | Promise used to return the result. | +| Type | Description | +| ---------------------------------------- | --------------------- | +| Promise<Array<AppAccountInfo>> | Promise used to return the result.| **Example** @@ -911,17 +911,17 @@ Obtains information about all app accounts of the specified app. This method use on(type: 'change', owners: Array<string>, callback: Callback<Array<AppAccountInfo>>): void -Subscribes to the account change event of the specified account owners. This method uses an asynchronous callback to return the result. +Subscribes to the account change event of the specified account owners. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.Account.AppAccount **Parameters** - | Name | Type | Mandatory | Description | - | -------- | ---------------------------------------- | ---- | ------------------------------ | - | type | 'change' | Yes | Type of the event to subscribe to. The subscriber will receive a notification when the account owners update their accounts. | - | owners | Array<string> | Yes | Owners of the accounts. | - | callback | Callback<Array<AppAccountInfo>> | Yes | Callback invoked to return the account change. | +| Name | Type | Mandatory | Description | +| -------- | ---------------------------------------- | ---- | ------------------------------ | +| type | 'change' | Yes | Type of the event to subscribe to. The subscriber will receive a notification when the account owners update their accounts.| +| owners | Array<string> | Yes | Owners of the accounts. | +| callback | Callback<Array<AppAccountInfo>> | Yes | Callback invoked to return the account change. | **Example** @@ -942,16 +942,16 @@ Subscribes to the account change event of the specified account owners. This met off(type: 'change', callback?: Callback>): void -Unsubscribes from the account change event. This method uses an asynchronous callback to return the result. +Unsubscribes from the account change event. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.Account.AppAccount **Parameters** - | Name | Type | Mandatory | Description | - | -------- | -------------------------------- | ---- | ------------ | - | type | 'change' | Yes | Account change event to unsubscribe from. | - | callback | Callback> | No | Callback used to report the account change. | +| Name | Type | Mandatory | Description | +| -------- | -------------------------------- | ---- | ------------ | +| type | 'change' | Yes | Account change event to unsubscribe from. | +| callback | Callback> | No | Callback used to report the account change.| **Example** @@ -975,19 +975,19 @@ Unsubscribes from the account change event. This method uses an asynchronous cal authenticate(name: string, owner: string, authType: string, options: {[key: string]: any}, callback: AuthenticatorCallback): void -Authenticates an app account to obtain the Open Authorization (OAuth) access token. This method uses an asynchronous callback to return the result. +Authenticates an app account to obtain the Open Authorization (OAuth) access token. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.Account.AppAccount **Parameters** - | Name | Type | Mandatory | Description | - | -------- | --------------------- | ---- | --------------- | - | name | string | Yes | Name of the app account to authenticate. | - | owner | string | Yes | Bundle name of the app. | - | authType | string | Yes | Authentication type. | - | options | {[key: string]: any} | Yes | Options for the authentication. | - | callback | AuthenticatorCallback | Yes | Authenticator callback invoked to return the authentication result. | +| Name | Type | Mandatory | Description | +| -------- | --------------------- | ---- | --------------- | +| name | string | Yes | Name of the app account to authenticate. | +| owner | string | Yes | Bundle name of the app.| +| authType | string | Yes | Authentication type. | +| options | {[key: string]: any} | Yes | Options for the authentication. | +| callback | AuthenticatorCallback | Yes | Authenticator callback invoked to return the authentication result.| **Example** @@ -1017,18 +1017,18 @@ Authenticates an app account to obtain the Open Authorization (OAuth) access tok getOAuthToken(name: string, owner: string, authType: string, callback: AsyncCallback<string>): void -Obtains the OAuth access token of an app account based on the specified authentication type. This method uses an asynchronous callback to return the result. +Obtains the OAuth access token of an app account based on the specified authentication type. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.Account.AppAccount **Parameters** - | Name | Type | Mandatory | Description | - | -------- | --------------------------- | ---- | ----------- | - | name | string | Yes | App account name. | - | owner | string | Yes | Bundle name of the app. | - | authType | string | Yes | Authentication type. | - | callback | AsyncCallback<string> | Yes | Callback invoked to return the result. | +| Name | Type | Mandatory | Description | +| -------- | --------------------------- | ---- | ----------- | +| name | string | Yes | App account name. | +| owner | string | Yes | Bundle name of the app.| +| authType | string | Yes | Authentication type. | +| callback | AsyncCallback<string> | Yes | Callback invoked to return the result. | **Example** @@ -1044,23 +1044,23 @@ Obtains the OAuth access token of an app account based on the specified authenti getOAuthToken(name: string, owner: string, authType: string): Promise<string> -Obtains the OAuth access token of an app account based on the specified authentication type. This method uses a promise to return the result. +Obtains the OAuth access token of an app account based on the specified authentication type. This API uses a promise to return the result. **System capability**: SystemCapability.Account.AppAccount **Parameters** - | Name | Type | Mandatory | Description | - | -------- | ------ | ---- | ----------- | - | name | string | Yes | App account name. | - | owner | string | Yes | Bundle name of the app. | - | authType | string | Yes | Authentication type. | +| Name | Type | Mandatory | Description | +| -------- | ------ | ---- | ----------- | +| name | string | Yes | App account name. | +| owner | string | Yes | Bundle name of the app.| +| authType | string | Yes | Authentication type. | **Parameters** - | Type | Description | - | --------------------- | --------------------- | - | Promise<string> | Promise used to return the result. | +| Type | Description | +| --------------------- | --------------------- | +| Promise<string> | Promise used to return the result.| **Example** @@ -1077,18 +1077,18 @@ Obtains the OAuth access token of an app account based on the specified authenti setOAuthToken(name: string, authType: string, token: string, callback: AsyncCallback<void>): void -Sets an OAuth access token for an app account. This method uses an asynchronous callback to return the result. +Sets an OAuth access token for an app account. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.Account.AppAccount **Parameters** - | Name | Type | Mandatory | Description | - | -------- | ------------------------- | ---- | -------- | - | name | string | Yes | App account name. | - | authType | string | Yes | Authentication type. | - | token | string | Yes | OAuth access token to set. | - | callback | AsyncCallback<void> | Yes | Callback invoked to return the result. | +| Name | Type | Mandatory | Description | +| -------- | ------------------------- | ---- | -------- | +| name | string | Yes | App account name.| +| authType | string | Yes | Authentication type. | +| token | string | Yes | OAuth access token to set.| +| callback | AsyncCallback<void> | Yes | Callback invoked to return the result.| **Example** @@ -1103,23 +1103,23 @@ Sets an OAuth access token for an app account. This method uses an asynchronous setOAuthToken(name: string, authType: string, token: string): Promise<void> -Sets an OAuth access token for an app account. This method uses a promise to return the result. +Sets an OAuth access token for an app account. This API uses a promise to return the result. **System capability**: SystemCapability.Account.AppAccount **Parameters** - | Name | Type | Mandatory | Description | - | -------- | ------ | ---- | -------- | - | name | string | Yes | App account name. | - | authType | string | Yes | Authentication type. | - | token | string | Yes | OAuth access token to set. | +| Name | Type | Mandatory | Description | +| -------- | ------ | ---- | -------- | +| name | string | Yes | App account name.| +| authType | string | Yes | Authentication type. | +| token | string | Yes | OAuth access token to set.| **Parameters** - | Type | Description | - | ------------------- | --------------------- | - | Promise<void> | Promise used to return the result. | +| Type | Description | +| ------------------- | --------------------- | +| Promise<void> | Promise used to return the result.| **Example** @@ -1136,19 +1136,19 @@ Sets an OAuth access token for an app account. This method uses a promise to ret deleteOAuthToken(name: string, owner: string, authType: string, token: string, callback: AsyncCallback<void>): void -Deletes the specified OAuth access token for an app account. This method uses an asynchronous callback to return the result. +Deletes the specified OAuth access token for an app account. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.Account.AppAccount **Parameters** - | Name | Type | Mandatory | Description | - | -------- | ------------------------- | ---- | ------------ | - | name | string | Yes | App account name. | - | owner | string | Yes | Bundle name of the app. | - | authType | string | Yes | Authentication type. | - | token | string | Yes | OAuth access token to delete. | - | callback | AsyncCallback<void> | Yes | Callback invoked to return the result. | +| Name | Type | Mandatory | Description | +| -------- | ------------------------- | ---- | ------------ | +| name | string | Yes | App account name. | +| owner | string | Yes | Bundle name of the app. | +| authType | string | Yes | Authentication type. | +| token | string | Yes | OAuth access token to delete.| +| callback | AsyncCallback<void> | Yes | Callback invoked to return the result. | **Example** @@ -1163,24 +1163,24 @@ Deletes the specified OAuth access token for an app account. This method uses an deleteOAuthToken(name: string, owner: string, authType: string, token: string): Promise<void> -Deletes the specified OAuth access token for an app account. This method uses a promise to return the result. +Deletes the specified OAuth access token for an app account. This API uses a promise to return the result. **System capability**: SystemCapability.Account.AppAccount **Parameters** - | Name | Type | Mandatory | Description | - | -------- | ------ | ---- | ------------ | - | name | string | Yes | App account name. | - | owner | string | Yes | Bundle name of the app. | - | authType | string | Yes | Authentication type. | - | token | string | Yes | OAuth access token to delete. | +| Name | Type | Mandatory | Description | +| -------- | ------ | ---- | ------------ | +| name | string | Yes | App account name. | +| owner | string | Yes | Bundle name of the app. | +| authType | string | Yes | Authentication type. | +| token | string | Yes | OAuth access token to delete.| **Parameters** - | Type | Description | - | ------------------- | --------------------- | - | Promise<void> | Promise used to return the result. | +| Type | Description | +| ------------------- | --------------------- | +| Promise<void> | Promise used to return the result.| **Example** @@ -1197,19 +1197,19 @@ Deletes the specified OAuth access token for an app account. This method uses a setOAuthTokenVisibility(name: string, authType: string, bundleName: string, isVisible: boolean, callback: AsyncCallback<void>): void -Sets the visibility of an OAuth access token to the specified app. This method uses an asynchronous callback to return the result. +Sets the visibility of an OAuth access token to the specified app. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.Account.AppAccount **Parameters** - | Name | Type | Mandatory | Description | - | ---------- | ------------------------- | ---- | ------------ | - | name | string | Yes | App account name. | - | authType | string | Yes | Authentication type. | - | bundleName | string | Yes | Bundle name of the app. | - | isVisible | boolean | Yes | Whether the OAuth access token is visible to the app. | - | callback | AsyncCallback<void> | Yes | Callback invoked to return the result. | +| Name | Type | Mandatory | Description | +| ---------- | ------------------------- | ---- | ------------ | +| name | string | Yes | App account name. | +| authType | string | Yes | Authentication type. | +| bundleName | string | Yes | Bundle name of the app.| +| isVisible | boolean | Yes | Whether the OAuth access token is visible to the app. | +| callback | AsyncCallback<void> | Yes | Callback invoked to return the result. | **Example** @@ -1224,24 +1224,24 @@ Sets the visibility of an OAuth access token to the specified app. This method u setOAuthTokenVisibility(name: string, authType: string, bundleName: string, isVisible: boolean): Promise<void> -Sets the visibility of an OAuth access token to the specified app. This method uses a promise to return the result. +Sets the visibility of an OAuth access token to the specified app. This API uses a promise to return the result. **System capability**: SystemCapability.Account.AppAccount **Parameters** - | Name | Type | Mandatory | Description | - | ---------- | ------- | ---- | ------------ | - | name | string | Yes | App account name. | - | authType | string | Yes | Authentication type. | - | bundleName | string | Yes | Bundle name of the app. | - | isVisible | boolean | Yes | Whether the OAuth access token is visible to the app. | +| Name | Type | Mandatory | Description | +| ---------- | ------- | ---- | ------------ | +| name | string | Yes | App account name. | +| authType | string | Yes | Authentication type. | +| bundleName | string | Yes | Bundle name of the app.| +| isVisible | boolean | Yes | Whether the OAuth access token is visible to the app. | **Parameters** - | Type | Description | - | ------------------- | --------------------- | - | Promise<void> | Promise used to return the result. | +| Type | Description | +| ------------------- | --------------------- | +| Promise<void> | Promise used to return the result.| **Example** @@ -1258,18 +1258,18 @@ Sets the visibility of an OAuth access token to the specified app. This method u checkOAuthTokenVisibility(name: string, authType: string, bundleName: string, callback: AsyncCallback<boolean>): void -Checks whether an OAuth token is visible to the specified app. This method uses an asynchronous callback to return the result. +Checks whether an OAuth token is visible to the specified app. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.Account.AppAccount **Parameters** - | Name | Type | Mandatory | Description | - | ---------- | ---------------------------- | ---- | ------------- | - | name | string | Yes | App account name. | - | authType | string | Yes | Authentication type. | - | bundleName | string | Yes | Bundle name of the app. | - | callback | AsyncCallback<boolean> | Yes | Callback invoked to return the result. | +| Name | Type | Mandatory | Description | +| ---------- | ---------------------------- | ---- | ------------- | +| name | string | Yes | App account name. | +| authType | string | Yes | Authentication type. | +| bundleName | string | Yes | Bundle name of the app.| +| callback | AsyncCallback<boolean> | Yes | Callback invoked to return the result. | **Example** @@ -1285,23 +1285,23 @@ Checks whether an OAuth token is visible to the specified app. This method uses checkOAuthTokenVisibility(name: string, authType: string, bundleName: string): Promise<boolean> -Checks whether an OAuth token is visible to the specified app. This method uses a promise to return the result. +Checks whether an OAuth token is visible to the specified app. This API uses a promise to return the result. **System capability**: SystemCapability.Account.AppAccount **Parameters** - | Name | Type | Mandatory | Description | - | ---------- | ------ | ---- | ------------- | - | name | string | Yes | App account name. | - | authType | string | Yes | Authentication type. | - | bundleName | string | Yes | Bundle name of the app. | +| Name | Type | Mandatory | Description | +| ---------- | ------ | ---- | ------------- | +| name | string | Yes | App account name. | +| authType | string | Yes | Authentication type. | +| bundleName | string | Yes | Bundle name of the app.| **Parameters** - | Type | Description | - | ---------------------- | --------------------- | - | Promise<boolean> | Promise used to return the result. | +| Type | Description | +| ---------------------- | --------------------- | +| Promise<boolean> | Promise used to return the result.| **Example** @@ -1318,17 +1318,17 @@ Checks whether an OAuth token is visible to the specified app. This method uses getAllOAuthTokens(name: string, owner: string, callback: AsyncCallback<Array<OAuthTokenInfo>>): void -Obtains information about all OAuth access tokens of an app account visible to the specified app. This method uses an asynchronous callback to return the result. +Obtains information about all OAuth access tokens of an app account visible to the specified app. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.Account.AppAccount **Parameters** - | Name | Type | Mandatory | Description | - | -------- | ---------------------------------------- | ---- | ----------- | - | name | string | Yes | App account name. | - | owner | string | Yes | Bundle name of the app. | - | callback | AsyncCallback<Array<OAuthTokenInfo>> | Yes | Callback invoked to return the result. | +| Name | Type | Mandatory | Description | +| -------- | ---------------------------------------- | ---- | ----------- | +| name | string | Yes | App account name. | +| owner | string | Yes | Bundle name of the app.| +| callback | AsyncCallback<Array<OAuthTokenInfo>> | Yes | Callback invoked to return the result. | **Example** @@ -1344,22 +1344,22 @@ Obtains information about all OAuth access tokens of an app account visible to t getAllOAuthTokens(name: string, owner: string): Promise<Array<OAuthTokenInfo>> -Obtains information about all OAuth access tokens of an app account visible to the specified app. This method uses a promise to return the result. +Obtains information about all OAuth access tokens of an app account visible to the specified app. This API uses a promise to return the result. **System capability**: SystemCapability.Account.AppAccount **Parameters** - | Name | Type | Mandatory | Description | - | ----- | ------ | ---- | ----------- | - | name | string | Yes | App account name. | - | owner | string | Yes | Bundle name of the app. | +| Name | Type | Mandatory | Description | +| ----- | ------ | ---- | ----------- | +| name | string | Yes | App account name. | +| owner | string | Yes | Bundle name of the app.| **Parameters** - | Type | Description | - | ---------------------------------------- | --------------------- | - | Promise<Array<OAuthTokenInfo>> | Promise used to return the result. | +| Type | Description | +| ---------------------------------------- | --------------------- | +| Promise<Array<OAuthTokenInfo>> | Promise used to return the result.| **Example** @@ -1376,17 +1376,17 @@ Obtains information about all OAuth access tokens of an app account visible to t getOAuthList(name: string, authType: string, callback: AsyncCallback<Array<string>>): void -Obtains the authorization list of OAuth access tokens of an app account. This method uses an asynchronous callback to return the result. +Obtains the authorization list of OAuth access tokens of an app account. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.Account.AppAccount **Parameters** - | Name | Type | Mandatory | Description | - | -------- | ---------------------------------------- | ---- | ----------- | - | name | string | Yes | App account name. | - | owner | string | Yes | Bundle name of the app. | - | callback | AsyncCallback<Array<string>> | Yes | Callback invoked to return the result. | +| Name | Type | Mandatory | Description | +| -------- | ---------------------------------------- | ---- | ----------- | +| name | string | Yes | App account name. | +| owner | string | Yes | Bundle name of the app.| +| callback | AsyncCallback<Array<string>> | Yes | Callback invoked to return the result. | **Example** @@ -1402,22 +1402,22 @@ Obtains the authorization list of OAuth access tokens of an app account. This me getOAuthList(name: string, authType: string): Promise<Array<string>> -Obtains the authorization list of OAuth access tokens of an app account. This method uses a promise to return the result. +Obtains the authorization list of OAuth access tokens of an app account. This API uses a promise to return the result. **System capability**: SystemCapability.Account.AppAccount **Parameters** - | Name | Type | Mandatory | Description | - | ----- | ------ | ---- | ----------- | - | name | string | Yes | App account name. | - | owner | string | Yes | Bundle name of the app. | +| Name | Type | Mandatory | Description | +| ----- | ------ | ---- | ----------- | +| name | string | Yes | App account name. | +| owner | string | Yes | Bundle name of the app.| **Parameters** - | Type | Description | - | ---------------------------------- | --------------------- | - | Promise<Array<string>> | Promise used to return the result. | +| Type | Description | +| ---------------------------------- | --------------------- | +| Promise<Array<string>> | Promise used to return the result.| **Example** @@ -1434,16 +1434,16 @@ Obtains the authorization list of OAuth access tokens of an app account. This me getAuthenticatorCallback(sessionId: string, callback: AsyncCallback<AuthenticatorCallback>): void -Obtains the authenticator callback for a session. This method uses an asynchronous callback to return the result. +Obtains the authenticator callback for a session. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.Account.AppAccount **Parameters** - | Name | Type | Mandatory | Description | - | --------- | ---------------------------------------- | ---- | -------- | - | sessionId | string | Yes | ID of the session to authenticate. | - | callback | AsyncCallback<AuthenticatorCallback> | Yes | Callback invoked to return the result. | +| Name | Type | Mandatory | Description | +| --------- | ---------------------------------------- | ---- | -------- | +| sessionId | string | Yes | ID of the session to authenticate.| +| callback | AsyncCallback<AuthenticatorCallback> | Yes | Callback invoked to return the result.| **Example** @@ -1469,21 +1469,21 @@ Obtains the authenticator callback for a session. This method uses an asynchrono getAuthenticatorCallback(sessionId: string): Promise<AuthenticatorCallback> -Obtains the authenticator callback for a session. This method uses a promise to return the result. +Obtains the authenticator callback for a session. This API uses a promise to return the result. **System capability**: SystemCapability.Account.AppAccount **Parameters** - | Name | Type | Mandatory | Description | - | --------- | ------ | ---- | -------- | - | sessionId | string | Yes | ID of the session to authenticate. | +| Name | Type | Mandatory | Description | +| --------- | ------ | ---- | -------- | +| sessionId | string | Yes | ID of the session to authenticate.| **Parameters** - | Type | Description | - | ------------------------------------ | --------------------- | - | Promise<AuthenticatorCallback> | Promise used to return the result. | +| Type | Description | +| ------------------------------------ | --------------------- | +| Promise<AuthenticatorCallback> | Promise used to return the result.| **Example** @@ -1509,16 +1509,16 @@ Obtains the authenticator callback for a session. This method uses a promise to getAuthenticatorInfo(owner: string, callback: AsyncCallback<AuthenticatorInfo>): void -Obtains authenticator information of an app account. This method uses an asynchronous callback to return the result. +Obtains authenticator information of an app account. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.Account.AppAccount **Parameters** - | Name | Type | Mandatory | Description | - | -------- | -------------------------------------- | ---- | ----------- | - | owner | string | Yes | Bundle name of the app. | - | callback | AsyncCallback<AuthenticatorInfo> | Yes | Callback invoked to return the result. | +| Name | Type | Mandatory | Description | +| -------- | -------------------------------------- | ---- | ----------- | +| owner | string | Yes | Bundle name of the app.| +| callback | AsyncCallback<AuthenticatorInfo> | Yes | Callback invoked to return the result. | **Example** @@ -1534,21 +1534,21 @@ Obtains authenticator information of an app account. This method uses an asynchr getAuthenticatorInfo(owner: string): Promise<AuthenticatorInfo> -Obtains authenticator information of an app account. This method uses a promise to return the result. +Obtains authenticator information of an app account. This API uses a promise to return the result. **System capability**: SystemCapability.Account.AppAccount **Parameters** - | Name | Type | Mandatory | Description | - | ----- | ------ | ---- | ----------- | - | owner | string | Yes | Bundle name of the app. | +| Name | Type | Mandatory | Description | +| ----- | ------ | ---- | ----------- | +| owner | string | Yes | Bundle name of the app.| **Parameters** - | Type | Description | - | -------------------------------- | --------------------- | - | Promise<AuthenticatorInfo> | Promise used to return the result. | +| Type | Description | +| -------------------------------- | --------------------- | +| Promise<AuthenticatorInfo> | Promise used to return the result.| **Example** @@ -1567,10 +1567,10 @@ Defines app account information. **System capability**: SystemCapability.Account.AppAccount - | Name | Type | Mandatory | Description | - | ----- | ------ | ---- | ----------- | - | owner | string | Yes | Bundle name of the app. | - | name | string | Yes | App account name. | +| Name | Type | Mandatory | Description | +| ----- | ------ | ---- | ----------- | +| owner | string | Yes | Bundle name of the app.| +| name | string | Yes | App account name. | ## OAuthTokenInfo8+ @@ -1578,10 +1578,10 @@ Defines OAuth access token information. **System capability**: SystemCapability.Account.AppAccount - | Name | Type | Mandatory | Description | - | -------- | ------ | ---- | -------- | - | authType | string | Yes | Authentication type. | - | token | string | Yes | Value of the access token. | +| Name | Type | Mandatory | Description | +| -------- | ------ | ---- | -------- | +| authType | string | Yes | Authentication type.| +| token | string | Yes | Value of the access token. | ## AuthenticatorInfo8+ @@ -1589,11 +1589,11 @@ Defines OAuth authenticator information. **System capability**: SystemCapability.Account.AppAccount - | Name | Type | Mandatory | Description | - | ------- | ------ | ---- | ---------- | - | owner | string | Yes | Bundle name of the authenticator owner. | - | iconId | string | Yes | ID of the authenticator icon. | - | labelId | string | Yes | ID of the authenticator label. | +| Name | Type | Mandatory | Description | +| ------- | ------ | ---- | ---------- | +| owner | string | Yes | Bundle name of the authenticator owner.| +| iconId | string | Yes | ID of the authenticator icon. | +| labelId | string | Yes | ID of the authenticator label. | ## Constants8+ @@ -1601,19 +1601,19 @@ Enumerates the constants. **System capability**: SystemCapability.Account.AppAccount - | Name | Default Value | Description | - | ----------------------------- | ---------------------- | ------------- | - | ACTION_ADD_ACCOUNT_IMPLICITLY | "addAccountImplicitly" | Operation for implicitly adding an account. | - | ACTION_AUTHENTICATE | "authenticate" | Authentication operation. | - | KEY_NAME | "name" | App account name. | - | KEY_OWNER | "owner" | App account owner. | - | KEY_TOKEN | "token" | OAuth access token. | - | KEY_ACTION | "action" | Action. | - | KEY_AUTH_TYPE | "authType" | Authentication type. | - | KEY_SESSION_ID | "sessionId" | Session ID. | - | KEY_CALLER_PID | "callerPid" | Caller process ID (PID). | - | KEY_CALLER_UID | "callerUid" | Caller user ID (UID). | - | KEY_CALLER_BUNDLE_NAME | "callerBundleName" | Caller bundle name. | +| Name | Default Value | Description | +| ----------------------------- | ---------------------- | ------------- | +| ACTION_ADD_ACCOUNT_IMPLICITLY | "addAccountImplicitly" | Operation for implicitly adding an account. | +| ACTION_AUTHENTICATE | "authenticate" | Authentication operation. | +| KEY_NAME | "name" | App account name. | +| KEY_OWNER | "owner" | App account owner.| +| KEY_TOKEN | "token" | OAuth access token. | +| KEY_ACTION | "action" | Action. | +| KEY_AUTH_TYPE | "authType" | Authentication type. | +| KEY_SESSION_ID | "sessionId" | Session ID. | +| KEY_CALLER_PID | "callerPid" | Caller process ID (PID). | +| KEY_CALLER_UID | "callerUid" | Caller user ID (UID). | +| KEY_CALLER_BUNDLE_NAME | "callerBundleName" | Caller bundle name. | ## ResultCode8+ @@ -1621,27 +1621,27 @@ Enumerates the result codes. **System capability**: SystemCapability.Account.AppAccount - | Name | Default Value | Description | - | ----------------------------------- | ----- | ------------ | - | SUCCESS | 0 | The operation is successful. | - | ERROR_ACCOUNT_NOT_EXIST | 10001 | The app account does not exist. | - | ERROR_APP_ACCOUNT_SERVICE_EXCEPTION | 10002 | The app account service is abnormal. | - | ERROR_INVALID_PASSWORD | 10003 | The password is invalid. | - | ERROR_INVALID_REQUEST | 10004 | The request is invalid. | - | ERROR_INVALID_RESPONSE | 10005 | The response is invalid. | - | ERROR_NETWORK_EXCEPTION | 10006 | The network is abnormal. | - | ERROR_OAUTH_AUTHENTICATOR_NOT_EXIST | 10007 | The authenticator does not exist. | - | ERROR_OAUTH_CANCELED | 10008 | The authentication is canceled. | - | ERROR_OAUTH_LIST_TOO_LARGE | 10009 | The size of the OAuth list exceeds the limit. | - | ERROR_OAUTH_SERVICE_BUSY | 10010 | The OAuth service is busy. | - | ERROR_OAUTH_SERVICE_EXCEPTION | 10011 | The OAuth service is abnormal. | - | ERROR_OAUTH_SESSION_NOT_EXIST | 10012 | The session to be authenticated does not exist. | - | ERROR_OAUTH_TIMEOUT | 10013 | The authentication timed out. | - | ERROR_OAUTH_TOKEN_NOT_EXIST | 10014 | The OAuth access token does not exist. | - | ERROR_OAUTH_TOKEN_TOO_MANY | 10015 | The number of OAuth access tokens reaches the limit. | - | ERROR_OAUTH_UNSUPPORT_ACTION | 10016 | The authentication operation is not supported. | - | ERROR_OAUTH_UNSUPPORT_AUTH_TYPE | 10017 | The authentication type is not supported. | - | ERROR_PERMISSION_DENIED | 10018 | The required permission is missing. | +| Name | Default Value | Description | +| ----------------------------------- | ----- | ------------ | +| SUCCESS | 0 | The operation is successful. | +| ERROR_ACCOUNT_NOT_EXIST | 10001 | The app account does not exist. | +| ERROR_APP_ACCOUNT_SERVICE_EXCEPTION | 10002 | The app account service is abnormal. | +| ERROR_INVALID_PASSWORD | 10003 | The password is invalid. | +| ERROR_INVALID_REQUEST | 10004 | The request is invalid. | +| ERROR_INVALID_RESPONSE | 10005 | The response is invalid. | +| ERROR_NETWORK_EXCEPTION | 10006 | The network is abnormal. | +| ERROR_OAUTH_AUTHENTICATOR_NOT_EXIST | 10007 | The authenticator does not exist. | +| ERROR_OAUTH_CANCELED | 10008 | The authentication is canceled. | +| ERROR_OAUTH_LIST_TOO_LARGE | 10009 | The size of the OAuth list exceeds the limit. | +| ERROR_OAUTH_SERVICE_BUSY | 10010 | The OAuth service is busy. | +| ERROR_OAUTH_SERVICE_EXCEPTION | 10011 | The OAuth service is abnormal. | +| ERROR_OAUTH_SESSION_NOT_EXIST | 10012 | The session to be authenticated does not exist. | +| ERROR_OAUTH_TIMEOUT | 10013 | The authentication timed out. | +| ERROR_OAUTH_TOKEN_NOT_EXIST | 10014 | The OAuth access token does not exist.| +| ERROR_OAUTH_TOKEN_TOO_MANY | 10015 | The number of OAuth access tokens reaches the limit. | +| ERROR_OAUTH_UNSUPPORT_ACTION | 10016 | The authentication operation is not supported. | +| ERROR_OAUTH_UNSUPPORT_AUTH_TYPE | 10017 | The authentication type is not supported. | +| ERROR_PERMISSION_DENIED | 10018 | The required permission is missing. | ## AuthenticatorCallback8+ @@ -1656,10 +1656,10 @@ Called back to send the authentication result. **System capability**: SystemCapability.Account.AppAccount **Parameters** - | Name | Type | Mandatory | Description | - | ------ | -------------------- | ---- | ------ | - | code | number | Yes | Authentication result code. | - | result | {[key: string]: any} | Yes | Authentication result. | +| Name | Type | Mandatory | Description | +| ------ | -------------------- | ---- | ------ | +| code | number | Yes | Authentication result code.| +| result | {[key: string]: any} | Yes | Authentication result. | **Example** @@ -1686,9 +1686,9 @@ Called back to redirect an authentication request. **System capability**: SystemCapability.Account.AppAccount **Parameters** - | Name | Type | Mandatory | Description | - | ------- | ---- | ---- | ---------- | - | request | Want | Yes | Request to be redirected. | +| Name | Type | Mandatory | Description | +| ------- | ---- | ---- | ---------- | +| request | Want | Yes | Request to be redirected.| **Example** @@ -1718,34 +1718,34 @@ Defines the OAuth authenticator base class. addAccountImplicitly(authType: string, callerBundleName: string, options: {[key: string]: any}, callback: AuthenticatorCallback): void -Implicitly adds an app account based on the specified authentication type and options. This method uses an asynchronous callback to return the result. +Implicitly adds an app account based on the specified authentication type and options. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.Account.AppAccount **Parameters** - | Name | Type | Mandatory | Description | - | ---------------- | --------------------- | ---- | --------------- | - | authType | string | Yes | Authentication type. | - | callerBundleName | string | Yes | Bundle name of the authentication requester. | - | options | {[key: string]: any} | Yes | Options for the authentication. | - | callback | AuthenticatorCallback | Yes | Authenticator callback invoked to return the authentication result. | +| Name | Type | Mandatory | Description | +| ---------------- | --------------------- | ---- | --------------- | +| authType | string | Yes | Authentication type. | +| callerBundleName | string | Yes | Bundle name of the authentication requester. | +| options | {[key: string]: any} | Yes | Options for the authentication. | +| callback | AuthenticatorCallback | Yes | Authenticator callback invoked to return the authentication result.| ### authenticate8+ authenticate(name: string, authType: string, callerBundleName: string, options: {[key: string]: any}, callback: AuthenticatorCallback): void -Authenticates an app account to obtain the OAuth access token. This method uses an asynchronous callback to return the result. +Authenticates an app account to obtain the OAuth access token. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.Account.AppAccount **Parameters** - | Name | Type | Mandatory | Description | - | ---------------- | --------------------- | ---- | --------------- | - | name | string | Yes | App account name. | - | authType | string | Yes | Authentication type. | - | callerBundleName | string | Yes | Bundle name of the authentication requester. | - | options | {[key: string]: any} | Yes | Options for the authentication. | - | callback | AuthenticatorCallback | Yes | Authenticator callback invoked to return the authentication result. | +| Name | Type | Mandatory | Description | +| ---------------- | --------------------- | ---- | --------------- | +| name | string | Yes | App account name. | +| authType | string | Yes | Authentication type. | +| callerBundleName | string | Yes | Bundle name of the authentication requester. | +| options | {[key: string]: any} | Yes | Options for the authentication. | +| callback | AuthenticatorCallback | Yes | Authenticator callback invoked to return the authentication result.| **Example** @@ -1771,4 +1771,4 @@ Authenticates an app account to obtain the OAuth access token. This method uses return new MyAuthenticator(); } } - ``` \ No newline at end of file + ``` diff --git a/en/application-dev/reference/apis/js-apis-arraylist.md b/en/application-dev/reference/apis/js-apis-arraylist.md index a887e9a02b24275e2574ea5fac7ecee0ac49f723..341295a167878f6c3696efe01f15a29415f91cd8 100644 --- a/en/application-dev/reference/apis/js-apis-arraylist.md +++ b/en/application-dev/reference/apis/js-apis-arraylist.md @@ -320,10 +320,10 @@ arrayList.add(2); arrayList.add(4); arrayList.add(5); arrayList.add(4); -arrayList.replaceAllElements((value, index) => { +arrayList.replaceAllElements((value: number, index: number)=> { return value = 2 * value; }); -arrayList.replaceAllElements((value, index) => { +arrayList.replaceAllElements((value: number, index: number) => { return value = value - 2; }); ``` @@ -394,8 +394,8 @@ arrayList.add(2); arrayList.add(4); arrayList.add(5); arrayList.add(4); -arrayList.sort((a, b) => a - b); -arrayList.sort((a, b) => b - a); +arrayList.sort((a: number, b: number) => a - b); +arrayList.sort((a: number, b: number) => b - a); arrayList.sort(); ``` diff --git a/en/application-dev/reference/apis/js-apis-audio.md b/en/application-dev/reference/apis/js-apis-audio.md index 3e1071581b34df1b3896b8605bab5f00732f588d..bd47176d4680b7a72b3b834dce75d96039b4c810 100644 --- a/en/application-dev/reference/apis/js-apis-audio.md +++ b/en/application-dev/reference/apis/js-apis-audio.md @@ -1322,7 +1322,7 @@ Sets a device to the active state. This API uses an asynchronous callback to ret **Example** ``` -audioManager.setDeviceActive(audio.DeviceType.SPEAKER, true, (err) => { +audioManager.setDeviceActive(audio.ActiveDeviceType.SPEAKER, true, (err) => { if (err) { console.error('Failed to set the active status of the device. ${err.message}'); return; @@ -1356,7 +1356,7 @@ Sets a device to the active state. This API uses a promise to return the result. ``` -audioManager.setDeviceActive(audio.DeviceType.SPEAKER, true).then(() => { +audioManager.setDeviceActive(audio.ActiveDeviceType.SPEAKER, true).then(() => { console.log('Promise returned to indicate that the device is set to the active status.'); }); ``` @@ -1379,7 +1379,7 @@ Checks whether a device is active. This API uses an asynchronous callback to ret **Example** ``` -audioManager.isDeviceActive(audio.DeviceType.SPEAKER, (err, value) => { +audioManager.isDeviceActive(audio.ActiveDeviceType.SPEAKER, (err, value) => { if (err) { console.error('Failed to obtain the active status of the device. ${err.message}'); return; @@ -1412,7 +1412,7 @@ Checks whether a device is active. This API uses a promise to return the result. **Example** ``` -audioManager.isDeviceActive(audio.DeviceType.SPEAKER).then((value) => { +audioManager.isDeviceActive(audio.ActiveDeviceType.SPEAKER).then((value) => { console.log('Promise returned to indicate that the active status of the device is obtained.' + value); }); ``` @@ -1646,7 +1646,7 @@ var interAudioInterrupt = { contentType:0, pauseWhenDucked:true }; -this.audioManager.on('interrupt', interAudioInterrupt, (InterruptAction) => { +audioManager.on('interrupt', interAudioInterrupt, (InterruptAction) => { if (InterruptAction.actionType === 0) { console.log("An event to gain the audio focus starts."); console.log("Focus gain event:" + JSON.stringify(InterruptAction)); @@ -1682,7 +1682,7 @@ var interAudioInterrupt = { contentType:0, pauseWhenDucked:true }; -this.audioManager.off('interrupt', interAudioInterrupt, (InterruptAction) => { +audioManager.off('interrupt', interAudioInterrupt, (InterruptAction) => { if (InterruptAction.actionType === 0) { console.log("An event to release the audio focus starts."); console.log("Focus release event:" + JSON.stringify(InterruptAction)); @@ -1744,7 +1744,7 @@ This is a system API and cannot be called by third-party applications. **Example** ``` -audioManager.setAudioScene(audio.AudioSceneMode.AUDIO_SCENE_PHONE_CALL).then(() => { +audioManager.setAudioScene(audio.AudioScene.AUDIO_SCENE_PHONE_CALL).then(() => { console.log('Promise returned to indicate a successful setting of the audio scene mode.'); }).catch ((err) => { console.log('Failed to set the audio scene mode'); @@ -1903,6 +1903,7 @@ Obtains the renderer information of this **AudioRenderer** instance. This API us **Example** ``` +var resultFlag = true; audioRenderer.getRendererInfo().then((rendererInfo) => { console.log('Renderer GetRendererInfo:'); console.log('Renderer content:' + rendererInfo.content); @@ -2349,13 +2350,11 @@ Obtains a reasonable minimum buffer size in bytes for rendering. This API uses a **Example** ``` -audioRenderer.getBufferSize((err, bufferSize) => { +var bufferSize = audioRenderer.getBufferSize(async(err, bufferSize) => { if (err) { console.error('getBufferSize error'); } }); -let buf = new ArrayBuffer(bufferSize); -ss.readSync(buf); ``` ### getBufferSize8+ @@ -2375,11 +2374,12 @@ Obtains a reasonable minimum buffer size in bytes for rendering. This API uses a **Example** ``` -audioRenderer.getBufferSize().then((bufferSize) => { - let buf = new ArrayBuffer(bufferSize); - ss.readSync(buf); +var bufferSize; +await audioRenderer.getBufferSize().then(async function (data) => { + console.info('AudioFrameworkRenderLog: getBufferSize :SUCCESS '+data); + bufferSize=data; }).catch((err) => { - console.log('ERROR: '+err.message); + console.info('AudioFrameworkRenderLog: getBufferSize :ERROR : '+err.message); }); ``` @@ -2504,7 +2504,9 @@ Subscribes to audio interruption events. This API uses a callback to get interru **Example** ``` -audioRenderer.on('interrupt', (interruptEvent) => { +var isPlay; +var started; +audioRenderer.on('interrupt', async(interruptEvent) => { if (interruptEvent.forceType == audio.InterruptForceType.INTERRUPT_FORCE) { switch (interruptEvent.hintType) { case audio.InterruptHint.INTERRUPT_HINT_PAUSE: @@ -2517,14 +2519,33 @@ audioRenderer.on('interrupt', (interruptEvent) => { break; } } else if (interruptEvent.forceType == audio.InterruptForceType.INTERRUPT_SHARE) { - switch (interruptEvent.hintType) { + switch (interruptEvent.hintType) { case audio.InterruptHint.INTERRUPT_HINT_RESUME: console.log('Resume force paused renderer or ignore'); - startRenderer(); + await audioRenderer.start().then(async function () { + console.info('AudioInterruptMusic: renderInstant started :SUCCESS '); + started = true; + }).catch((err) => { + console.info('AudioInterruptMusic: renderInstant start :ERROR : '+err.message); + started = false; + }); + if (started) { + isPlay = true; + console.info('AudioInterruptMusic Renderer started : isPlay : '+isPlay); + } else { + console.error('AudioInterruptMusic Renderer start failed'); + } break; case audio.InterruptHint.INTERRUPT_HINT_PAUSE: console.log('Choose to pause or ignore'); - pauseRenderer(); + if (isPlay == true) { + isPlay == false; + console.info('AudioInterruptMusic: Media PAUSE : TRUE'); + } + else { + isPlay = true; + console.info('AudioInterruptMusic: Media PLAY : TRUE'); + } break; } } @@ -2985,7 +3006,7 @@ audioCapturer.read(bufferSize, true, async(err, buffer) => { if (!err) { console.log("Success in reading the buffer data"); } -}; +}); ``` diff --git a/en/application-dev/reference/apis/js-apis-backgroundTaskManager.md b/en/application-dev/reference/apis/js-apis-backgroundTaskManager.md index 7ffa13920f46c4e9fb71a46ddf85025d0385dcad..cbb0ff47c767fd26e499913f44ba88d7e6187f17 100644 --- a/en/application-dev/reference/apis/js-apis-backgroundTaskManager.md +++ b/en/application-dev/reference/apis/js-apis-backgroundTaskManager.md @@ -128,6 +128,7 @@ Cancels the suspension delay. **Example** ```js + let id = 1; backgroundTaskManager.cancelSuspendDelay(id); ``` @@ -313,14 +314,14 @@ Provides the information about the suspension delay. **System capability**: SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask -| Name | Value| Description | -| ----------------------- | ------ | ---------------------------- | -| DATA_TRANSFER | 1 | Data transfer. | -| AUDIO_PLAYBACK | 2 | Audio playback. | -| AUDIO_RECORDING | 3 | Audio recording. | -| LOCATION | 4 | Positioning and navigation. | -| BLUETOOTH_INTERACTION | 5 | Bluetooth-related task. | -| MULTI_DEVICE_CONNECTION | 6 | Multi-device connection. | -| WIFI_INTERACTION | 7 | WLAN-related (reserved). | -| VOIP | 8 | Voice and video call (reserved). | -| TASK_KEEPING | 9 | Computing task (effective only for specific devices).| +| Name | Value| Description | +| ----------------------- | ------ | ------------------------------------------------------------ | +| DATA_TRANSFER | 1 | Data transfer. | +| AUDIO_PLAYBACK | 2 | Audio playback. | +| AUDIO_RECORDING | 3 | Audio recording. | +| LOCATION | 4 | Positioning and navigation. | +| BLUETOOTH_INTERACTION | 5 | Bluetooth-related task. | +| MULTI_DEVICE_CONNECTION | 6 | Multi-device connection. | +| WIFI_INTERACTION | 7 | WLAN-related.
This is a system API and cannot be called by third-party applications.| +| VOIP | 8 | Audio and video calls.
This is a system API and cannot be called by third-party applications.| +| TASK_KEEPING | 9 | Computing task (effective only for specific devices). | diff --git a/en/application-dev/reference/apis/js-apis-bluetooth.md b/en/application-dev/reference/apis/js-apis-bluetooth.md index 8c2e4f41606e44f93d872427c2c81b1ecf70cb4f..c4cee6859f5efc72dab04aed89d23651c26bbff7 100644 --- a/en/application-dev/reference/apis/js-apis-bluetooth.md +++ b/en/application-dev/reference/apis/js-apis-bluetooth.md @@ -1,9 +1,9 @@ # Bluetooth -> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**
+> **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. -> -> The Bluetooth module provides Classic Bluetooth capabilities and Bluetooth Low Energy (BLE) scan and advertising. + +Provides classic Bluetooth capabilities and Bluetooth Low Energy (BLE) scan and advertising. ## Modules to Import @@ -201,7 +201,7 @@ Obtains the connection state of a profile. | Name | Type | Mandatory | Description | | --------- | --------- | ---- | ------------------------------------- | -| ProfileId | profileId | Yes | ID of the target profile, for example, **PROFILE_A2DP_SOURCE**.| +| ProfileId | profileId | Yes | ID of the profile to obtain, for example, **PROFILE_A2DP_SOURCE**.| **Return value** @@ -212,7 +212,7 @@ Obtains the connection state of a profile. **Example** ```js -let result = bluetooth.getProfileConnState(PROFILE_A2DP_SOURCE); +let result = bluetooth.getProfileConnState(bluetooth.ProfileId.PROFILE_A2DP_SOURCE); ``` @@ -355,7 +355,7 @@ Sets the Bluetooth scan mode so that the device can be discovered by a remote de ```js // The device can be discovered and connected only when the discoverable and connectable mode is used. -let result = bluetooth.setBluetoothScanMode(ScanMode.SCAN_MODE_CONNECTABLE_GENERAL_DISCOVERABLE, 100); +let result = bluetooth.setBluetoothScanMode(bluetooth.ScanMode.SCAN_MODE_CONNECTABLE_GENERAL_DISCOVERABLE, 100); ``` @@ -720,7 +720,7 @@ bluetooth.off('stateChange', onReceiveEvent); ``` -## bluetooth.sppListen8+ +## bluetooth.sppListen8+ sppListen(name: string, option: SppOption, callback: AsyncCallback<number>): void @@ -773,6 +773,14 @@ Listens for a connection to be made to this socket from the client and accepts i **Example** ```js +let serverNumber = -1; +function serverSocket(code, number) { + console.log('bluetooth error code: ' + code.code); + if (code.code == 0) { + console.log('bluetooth serverSocket Number: ' + number); + serverNumber = number; + } +} let clientNumber = -1; function acceptClientSocket(code, number) { console.log('bluetooth error code: ' + code.code); @@ -807,6 +815,7 @@ Initiates an SPP connection to a remote device from the client. **Example** ```js + let clientNumber = -1; function clientSocket(code, number) { if (code.code != 0) { @@ -838,6 +847,14 @@ Closes the listening socket of the server. **Example** ```js +let serverNumber = -1; +function serverSocket(code, number) { + console.log('bluetooth error code: ' + code.code); + if (code.code == 0) { + console.log('bluetooth serverSocket Number: ' + number); + serverNumber = number; + } +} bluetooth.sppCloseServerSocket(serverNumber); ``` @@ -860,6 +877,15 @@ Closes the client socket. **Example** ```js +let clientNumber = -1; +function clientSocket(code, number) { + if (code.code != 0) { + return; + } + console.log('bluetooth serverSocket Number: ' + number); + // The obtained clientNumber is used as the socket ID for subsequent read/write operations on the client. + clientNumber = number; +} bluetooth.sppCloseClientSocket(clientNumber); ``` @@ -888,6 +914,15 @@ Writes data to the remote device through the socket. **Example** ```js +let clientNumber = -1; +function clientSocket(code, number) { + if (code.code != 0) { + return; + } + console.log('bluetooth serverSocket Number: ' + number); + // The obtained clientNumber is used as the socket ID for subsequent read/write operations on the client. + clientNumber = number; +} let arrayBuffer = new ArrayBuffer(8); let data = new Uint8Array(arrayBuffer); data[0] = 123; @@ -923,6 +958,15 @@ No value is returned. **Example** ```js +let clientNumber = -1; +function clientSocket(code, number) { + if (code.code != 0) { + return; + } + console.log('bluetooth serverSocket Number: ' + number); + // The obtained clientNumber is used as the socket ID for subsequent read/write operations on the client. + clientNumber = number; +} function dataRead(dataBuffer) { let data = new Uint8Array(dataBuffer); console.log('bluetooth data is: ' + data[0]); @@ -954,6 +998,15 @@ No value is returned. **Example** ```js +let clientNumber = -1; +function clientSocket(code, number) { + if (code.code != 0) { + return; + } + console.log('bluetooth serverSocket Number: ' + number); + // The obtained clientNumber is used as the socket ID for subsequent read/write operations on the client. + clientNumber = number; +} bluetooth.off('sppRead', clientNumber); ``` @@ -981,14 +1034,14 @@ Obtains a profile object. **Example** ```js -let a2dpSrc = bluetooth.getProfile(PROFILE_A2DP_SOURCE); +let a2dpSrc = bluetooth.getProfile(bluetooth.ProfileId.PROFILE_A2DP_SOURCE); ``` ## bluetooth.getProfile9+ getProfile(profileId: ProfileId): A2dpSourceProfile | HandsFreeAudioGatewayProfile | HidHostProfile -Obtains the profile object instance based on **ProfileId**. API version 9 is added with **HidHostProfile**. +Obtains a profile instance. **HidHostProfile** is added in API version 9. **System capability**: SystemCapability.Communication.Bluetooth.Core @@ -996,7 +1049,7 @@ Obtains the profile object instance based on **ProfileId**. API version 9 is add | Name | Type | Mandatory | Description | | --------- | --------- | ---- | ------------------------------------- | -| profileId | [ProfileId](#ProfileId) | Yes | ID of the target profile, for example, **PROFILE_A2DP_SOURCE**.| +| profileId | [ProfileId](#ProfileId) | Yes | ID of the profile to obtain, for example, **PROFILE_A2DP_SOURCE**.| **Return value** @@ -1007,7 +1060,7 @@ Obtains the profile object instance based on **ProfileId**. API version 9 is add **Example** ```js -let hidHost = bluetooth.getProfile(PROFILE_HID_HOST); +let hidHost = bluetooth.getProfile(bluetooth.ProfileId.PROFILE_HID_HOST); ``` @@ -1239,7 +1292,7 @@ No value is returned. **Example** ```js -let a2dpSrc = bluetooth.getProfile(PROFILE_A2DP_SOURCE) +let a2dpSrc = bluetooth.getProfile(bluetooth.ProfileId.PROFILE_A2DP_SOURCE) let retArray = a2dpSrc.getConnectionDevices(); ``` @@ -1257,7 +1310,7 @@ Obtains the connection state of the profile. | Name | Type | Mandatory | Description | | ------ | ------ | ---- | ------- | -| device | string | Yes | Address of the remote device.| +| device | string | Yes | Address of the target device.| **Return value** @@ -1268,7 +1321,7 @@ Obtains the connection state of the profile. **Example** ```js -let a2dpSrc = bluetooth.getProfile(PROFILE_A2DP_SOURCE) +let a2dpSrc = bluetooth.getProfile(bluetooth.ProfileId.PROFILE_A2DP_SOURCE) let ret = a2dpSrc.getDeviceState('XX:XX:XX:XX:XX:XX'); ``` @@ -1302,7 +1355,7 @@ Sets up an Advanced Audio Distribution Profile (A2DP) connection. **Example** ```js -let a2dpSrc = bluetooth.getProfile(PROFILE_A2DP_SOURCE) +let a2dpSrc = bluetooth.getProfile(bluetooth.ProfileId.PROFILE_A2DP_SOURCE) let ret = a2dpSrc.connect('XX:XX:XX:XX:XX:XX'); ``` @@ -1332,7 +1385,7 @@ Disconnects an A2DP connection. **Example** ```js -let a2dpSrc = bluetooth.getProfile(PROFILE_A2DP_SOURCE); +let a2dpSrc = bluetooth.getProfile(bluetooth.ProfileId.PROFILE_A2DP_SOURCE); let ret = a2dpSrc.disconnect('XX:XX:XX:XX:XX:XX'); ``` @@ -1362,7 +1415,7 @@ No value is returned. function onReceiveEvent(data) { console.info('a2dp state = '+ JSON.stringify(data)); } -let a2dpSrc = bluetooth.getProfile(PROFILE_A2DP_SOURCE); +let a2dpSrc = bluetooth.getProfile(bluetooth.ProfileId.PROFILE_A2DP_SOURCE); a2dpSrc.on('connectionStateChange', onReceiveEvent); ``` @@ -1392,7 +1445,7 @@ No value is returned. function onReceiveEvent(data) { console.info('a2dp state = '+ JSON.stringify(data)); } -let a2dpSrc = bluetooth.getProfile(PROFILE_A2DP_SOURCE); +let a2dpSrc = bluetooth.getProfile(bluetooth.ProfileId.PROFILE_A2DP_SOURCE); a2dpSrc.on('connectionStateChange', onReceiveEvent); a2dpSrc.off('connectionStateChange', onReceiveEvent); ``` @@ -1410,7 +1463,7 @@ Obtains the playing state of a device. | Name | Type | Mandatory | Description | | ------ | ------ | ---- | ------- | -| device | string | Yes | Address of the remote device.| +| device | string | Yes | Address of the target device.| **Return value** @@ -1421,7 +1474,7 @@ Obtains the playing state of a device. **Example** ```js -let a2dpSrc = bluetooth.getProfile(PROFILE_A2DP_SOURCE); +let a2dpSrc = bluetooth.getProfile(bluetooth.ProfileId.PROFILE_A2DP_SOURCE); let state = a2dpSrc.getPlayingState('XX:XX:XX:XX:XX:XX'); ``` @@ -1445,7 +1498,7 @@ Sets up a Hands-free Profile (HFP) connection of a device. | Name | Type | Mandatory | Description | | ------ | ------ | ---- | ------- | -| device | string | Yes | Address of the remote device.| +| device | string | Yes | Address of the target device.| **Return value** @@ -1456,7 +1509,7 @@ Sets up a Hands-free Profile (HFP) connection of a device. **Example** ```js -let hfpAg = bluetooth.getProfile(PROFILE_HANDS_FREE_AUDIO_GATEWAY); +let hfpAg = bluetooth.getProfile(bluetooth.ProfileId.PROFILE_HANDS_FREE_AUDIO_GATEWAY); let ret = hfpAg.connect('XX:XX:XX:XX:XX:XX'); ``` @@ -1475,7 +1528,7 @@ Disconnects the HFP connection of a device. | Name | Type | Mandatory | Description | | ------ | ------ | ---- | ------- | -| device | string | Yes | Address of the remote device.| +| device | string | Yes | Address of the target device.| **Return value** @@ -1486,7 +1539,7 @@ Disconnects the HFP connection of a device. **Example** ```js -let hfpAg = bluetooth.getProfile(PROFILE_HANDS_FREE_AUDIO_GATEWAY); +let hfpAg = bluetooth.getProfile(bluetooth.ProfileId.PROFILE_HANDS_FREE_AUDIO_GATEWAY); let ret = hfpAg.disconnect('XX:XX:XX:XX:XX:XX'); ``` @@ -1516,7 +1569,7 @@ No value is returned. function onReceiveEvent(data) { console.info('hfp state = '+ JSON.stringify(data)); } -let hfpAg = bluetooth.getProfile(PROFILE_HANDS_FREE_AUDIO_GATEWAY); +let hfpAg = bluetooth.getProfile(bluetooth.ProfileId.PROFILE_HANDS_FREE_AUDIO_GATEWAY); hfpAg.on('connectionStateChange', onReceiveEvent); ``` @@ -1546,7 +1599,7 @@ No value is returned. function onReceiveEvent(data) { console.info('hfp state = '+ JSON.stringify(data)); } -let hfpAg = bluetooth.getProfile(PROFILE_HANDS_FREE_AUDIO_GATEWAY); +let hfpAg = bluetooth.getProfile(bluetooth.ProfileId.PROFILE_HANDS_FREE_AUDIO_GATEWAY); hfpAg.on('connectionStateChange', onReceiveEvent); hfpAg.off('connectionStateChange', onReceiveEvent); ``` @@ -1573,7 +1626,7 @@ Connects to the HidHost service of a device. | Name | Type | Mandatory | Description | | ------ | ------ | ---- | ------- | -| device | string | Yes | Address of the remote device.| +| device | string | Yes | Address of the target device.| **Return value** @@ -1584,7 +1637,7 @@ Connects to the HidHost service of a device. **Example** ```js -let hidHostProfile = bluetooth.getProfile(PROFILE_HID_HOST); +let hidHostProfile = bluetooth.getProfile(bluetooth.ProfileId.PROFILE_HID_HOST); let ret = hidHostProfile.connect('XX:XX:XX:XX:XX:XX'); ``` @@ -1605,7 +1658,7 @@ Disconnects from the HidHost service of a device. | Name | Type | Mandatory | Description | | ------ | ------ | ---- | ------- | -| device | string | Yes | Address of the remote device.| +| device | string | Yes | Address of the target device.| **Return value** @@ -1616,7 +1669,7 @@ Disconnects from the HidHost service of a device. **Example** ```js -let hidHostProfile = bluetooth.getProfile(PROFILE_HID_HOST); +let hidHostProfile = bluetooth.getProfile(bluetooth.ProfileId.PROFILE_HID_HOST); let ret = hidHostProfile.disconnect('XX:XX:XX:XX:XX:XX'); ``` @@ -1646,7 +1699,7 @@ No value is returned. function onReceiveEvent(data) { console.info('hidHost state = '+ JSON.stringify(data)); } -let hidHost = bluetooth.getProfile(PROFILE_HID_HOST); +let hidHost = bluetooth.getProfile(bluetooth.ProfileId.PROFILE_HID_HOST); hidHost.on('connectionStateChange', onReceiveEvent); ``` @@ -1676,7 +1729,7 @@ No value is returned. function onReceiveEvent(data) { console.info('hidHost state = '+ JSON.stringify(data)); } -let hidHost = bluetooth.getProfile(PROFILE_HID_HOST); +let hidHost = bluetooth.getProfile(bluetooth.ProfileId.PROFILE_HID_HOST); hidHost.on('connectionStateChange', onReceiveEvent); hidHost.off('connectionStateChange', onReceiveEvent); ``` @@ -1819,7 +1872,7 @@ cccV[0] = 1; let characteristic = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB', characteristicUuid: '00001820-0000-1000-8000-00805F9B34FB', characteristicValue: arrayBufferC, descriptors:descriptors}; let characteristicN = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB', - characteristicUuid: '00001821-0000-1000-8000-00805F9B34FB', characteristicValue: arrayBufferC, descriptors:descriptorsN}; + characteristicUuid: '00001821-0000-1000-8000-00805F9B34FB', characteristicValue: arrayBufferC, descriptors:descriptors}; characteristics[0] = characteristic; // Create a gattService instance. @@ -1911,8 +1964,11 @@ Notifies the connected client device when a characteristic value changes. **Example** ```js +let arrayBufferC = new ArrayBuffer(8); +let characteristic = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB', + characteristicUuid: '00001820-0000-1000-8000-00805F9B34FB', characteristicValue: arrayBufferC, descriptors:descriptors}; let notifyCharacteristic = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB', - characteristicUuid: '00001821-0000-1000-8000-00805F9B34FB', characteristicValue: notifyCcc.characteristicValue, confirm: false}; + characteristicUuid: '00001821-0000-1000-8000-00805F9B34FB', characteristicValue: characteristic.characteristicValue, confirm: false}; let server = bluetooth.BLE.createGattServer(); server.notifyCharacteristicChanged('XX:XX:XX:XX:XX:XX', notifyCharacteristic); ``` @@ -2138,7 +2194,7 @@ Subscribes to the descriptor read request events. | Name | Type | Mandatory | Description | | -------- | ---------------------------------------- | ---- | --------------------------------- | | type | string | Yes | Event type. The value **descriptorRead** indicates a descriptor read request event.| -| callback | Callback<[DescriptorReadReq](#descriptorreadreq)> | Yes | Callback invoked to return a descriptor read request from the GATT client. | +| callback | Callback<[DescriptorReadReq](#descriptorreadreq)> | Yes | Callback invoked to return a descriptor read request event from the GATT client. | **Return value** @@ -2279,7 +2335,6 @@ let gattServer = bluetooth.BLE.createGattServer(); gattServer.off("descriptorWrite"); ``` - ### on('connectStateChange') on(type: "connectStateChange", callback: Callback<BLEConnectChangedState>): void @@ -2488,7 +2543,7 @@ Obtains all services of the remote BLE device. This API uses a promise to return // Promise let device = bluetooth.BLE.createGattClientDevice('XX:XX:XX:XX:XX:XX'); device.connect(); -let services = device.getServices(); +var services = device.getServices(); console.log("bluetooth services size is ", services.length); for (let i = 0; i < services.length; i++) { @@ -2826,8 +2881,11 @@ Sets the function of notifying the GATT client when the characteristic value of **Example** ```js +let arrayBufferC = new ArrayBuffer(8); +let characteristic = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB', + characteristicUuid: '00001820-0000-1000-8000-00805F9B34FB', characteristicValue: arrayBufferC, descriptors:descriptors}; let device = bluetooth.BLE.createGattClientDevice('XX:XX:XX:XX:XX:XX'); -device.setNotifyCharacteristicChanged(notifyCcc, false); +device.setNotifyCharacteristicChanged(characteristic, false); ``` @@ -3296,11 +3354,11 @@ Defines the scan filter parameters. **System capability**: SystemCapability.Communication.Bluetooth.Core -| Name | Type | Readable | Writable | Description | -| ----------- | ------ | ---- | ---- | ---------------------------------------- | -| deviceId | string | Yes | Yes | Address of the BLE device to filter, for example, XX:XX:XX:XX:XX:XX. | -| name | string | Yes | Yes | Name of the BLE device to filter. | -| serviceUuid | string | Yes | Yes | UUID of the service, for example, **00001888-0000-1000-8000-00805f9b34fb**.| +| Name | Type | Readable| Writable| Description | +| ---------------------------------------- | ----------- | ---- | ---- | ------------------------------------------------------------ | +| deviceId | string | Yes | Yes | Address of the BLE device to filter, for example, XX:XX:XX:XX:XX:XX. | +| name | string | Yes | Yes | Name of the BLE device to filter. | +| serviceUuid | string | Yes | Yes | Service UUID of the device to filter, for example, **00001888-0000-1000-8000-00805f9b34fb**.| ## ScanOptions diff --git a/en/application-dev/reference/apis/js-apis-data-ability.md b/en/application-dev/reference/apis/js-apis-data-ability.md index 5e13507952dec34e32f7a4e49a75669ccc16fd82..b801f7038e84713dd3096a7c7c63f3a03314e2a5 100644 --- a/en/application-dev/reference/apis/js-apis-data-ability.md +++ b/en/application-dev/reference/apis/js-apis-data-ability.md @@ -1,6 +1,6 @@ # DataAbilityPredicates -> **NOTE**
+> **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. @@ -24,15 +24,15 @@ Creates an **RdbPredicates** object from a **DataAbilityPredicates** object. **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | name | string | Yes| Table name in the RDB store.| - | dataAbilityPredicates | [DataAbilityPredicates](#dataabilitypredicates) | Yes| **DataAbilityPredicates** object. | +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| name | string | Yes| Table name in the RDB store.| +| dataAbilityPredicates | [DataAbilityPredicates](#dataabilitypredicates) | Yes| **DataAbilityPredicates** object. | **Return value** - | Type| Description| - | -------- | -------- | - | rdb.[RdbPredicates](js-apis-data-rdb.md#rdbpredicates) | **RdbPredicates** object created.| +| Type| Description| +| -------- | -------- | +| rdb.[RdbPredicates](js-apis-data-rdb.md#rdbpredicates) | **RdbPredicates** object created.| **Example** ```js @@ -58,15 +58,15 @@ Sets a **DataAbilityPredicates** object to match the field with data type **Valu **System capability**: SystemCapability.DistributedDataManager.DataShare.Core **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | field | string | Yes| Column name in the table.| - | value | [ValueType](#valuetype) | Yes| Value to match the **DataAbilityPredicates**.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| field | string | Yes| Column name in the table.| +| value | [ValueType](#valuetype) | Yes| Value to match the **DataAbilityPredicates**.| **Return value** - | Type| Description| - | -------- | -------- | - | [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object that matches the specified field.| +| Type| Description| +| -------- | -------- | +| [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object that matches the specified field.| **Example** ```js @@ -85,15 +85,15 @@ Sets a **DataAbilityPredicates** object to match the field with data type **Valu **System capability**: SystemCapability.DistributedDataManager.DataShare.Core **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | field | string | Yes| Column name in the table.| - | value | [ValueType](#valuetype) | Yes| Value to match the **DataAbilityPredicates**.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| field | string | Yes| Column name in the table.| +| value | [ValueType](#valuetype) | Yes| Value to match the **DataAbilityPredicates**.| **Return value** - | Type| Description| - | -------- | -------- | - | [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object that matches the specified field.| +| Type| Description| +| -------- | -------- | +| [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object that matches the specified field.| **Example** ```js @@ -112,9 +112,9 @@ Adds a left parenthesis to this **DataAbilityPredicates**. **System capability**: SystemCapability.DistributedDataManager.DataShare.Core **Return value** - | Type| Description| - | -------- | -------- | - | [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object with a left parenthesis.| +| Type| Description| +| -------- | -------- | +| [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object with a left parenthesis.| **Example** ```js @@ -138,9 +138,9 @@ Adds a right parenthesis to this **DataAbilityPredicates**. **System capability**: SystemCapability.DistributedDataManager.DataShare.Core **Return value** - | Type| Description| - | -------- | -------- | - | [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object with a right parenthesis.| +| Type| Description| +| -------- | -------- | +| [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object with a right parenthesis.| **Example** ```js @@ -164,9 +164,9 @@ Adds the OR condition to this **DataAbilityPredicates**. **System capability**: SystemCapability.DistributedDataManager.DataShare.Core **Return value** - | Type| Description| - | -------- | -------- | - | [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object with the OR condition.| +| Type| Description| +| -------- | -------- | +| [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object with the OR condition.| **Example** ```js @@ -187,9 +187,9 @@ Adds the AND condition to this **DataAbilityPredicates**. **System capability**: SystemCapability.DistributedDataManager.DataShare.Core **Return value** - | Type| Description| - | -------- | -------- | - | [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object with the AND condition.| +| Type| Description| +| -------- | -------- | +| [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object with the AND condition.| **Example** ```js @@ -210,15 +210,15 @@ Sets a **DataAbilityPredicates** object to match a string containing the specifi **System capability**: SystemCapability.DistributedDataManager.DataShare.Core **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | field | string | Yes| Column name in the table.| - | value | string | Yes| Value to match the **DataAbilityPredicates**.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| field | string | Yes| Column name in the table.| +| value | string | Yes| Value to match the **DataAbilityPredicates**.| **Return value** - | Type| Description| - | -------- | -------- | - | [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object that matches the specified field.| +| Type| Description| +| -------- | -------- | +| [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object that matches the specified field.| **Example** ```js @@ -237,15 +237,15 @@ Sets a **DataAbilityPredicates** object to match a string that starts with the s **System capability**: SystemCapability.DistributedDataManager.DataShare.Core **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | field | string | Yes| Column name in the table.| - | value | string | Yes| Value to match the **DataAbilityPredicates**.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| field | string | Yes| Column name in the table.| +| value | string | Yes| Value to match the **DataAbilityPredicates**.| **Return value** - | Type| Description| - | -------- | -------- | - | [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object that matches the specified field.| +| Type| Description| +| -------- | -------- | +| [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object that matches the specified field.| **Example** ```js @@ -264,15 +264,15 @@ Sets a **DataAbilityPredicates** object to match a string that ends with the spe **System capability**: SystemCapability.DistributedDataManager.DataShare.Core **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | field | string | Yes| Column name in the table.| - | value | string | Yes| Value to match the **DataAbilityPredicates**.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| field | string | Yes| Column name in the table.| +| value | string | Yes| Value to match the **DataAbilityPredicates**.| **Return value** - | Type| Description| - | -------- | -------- | - | [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object that matches the specified field.| +| Type| Description| +| -------- | -------- | +| [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object that matches the specified field.| **Example** ``` @@ -291,14 +291,14 @@ Sets a **DataAbilityPredicates** object to match the field whose value is null. **System capability**: SystemCapability.DistributedDataManager.DataShare.Core **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | field | string | Yes| Column name in the table.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| field | string | Yes| Column name in the table.| **Return value** - | Type| Description| - | -------- | -------- | - | [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object that matches the specified field.| +| Type| Description| +| -------- | -------- | +| [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object that matches the specified field.| **Example** ```js @@ -317,14 +317,14 @@ Sets a **DataAbilityPredicates** object to match the field whose value is not nu **System capability**: SystemCapability.DistributedDataManager.DataShare.Core **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | field | string | Yes| Column name in the table.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| field | string | Yes| Column name in the table.| **Return value** - | Type| Description| - | -------- | -------- | - | [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object that matches the specified field.| +| Type| Description| +| -------- | -------- | +| [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object that matches the specified field.| **Example** ```js @@ -343,15 +343,15 @@ Sets a **DataAbilityPredicates** object to match a string that is similar to the **System capability**: SystemCapability.DistributedDataManager.DataShare.Core **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | field | string | Yes| Column name in the table.| - | value | string | Yes| Value to match the **DataAbilityPredicates**.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| field | string | Yes| Column name in the table.| +| value | string | Yes| Value to match the **DataAbilityPredicates**.| **Return value** - | Type| Description| - | -------- | -------- | - | [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object that matches the specified field.| +| Type| Description| +| -------- | -------- | +| [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object that matches the specified field.| **Example** ```js @@ -370,15 +370,15 @@ Sets a **DataAbilityPredicates** object to match the specified string. **System capability**: SystemCapability.DistributedDataManager.DataShare.Core **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | field | string | Yes| Column name in the table.| - | value | string | Yes| Value to match the **DataAbilityPredicates**.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| field | string | Yes| Column name in the table.| +| value | string | Yes| Value to match the **DataAbilityPredicates**.| **Return value** - | Type| Description| - | -------- | -------- | - | [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object that matches the specified field.| +| Type| Description| +| -------- | -------- | +| [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object that matches the specified field.| **Example** ```js @@ -397,16 +397,16 @@ Sets a **DataAbilityPredicates** object to match the field with data type **Valu **System capability**: SystemCapability.DistributedDataManager.DataShare.Core **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | field | string | Yes| Column name in the table.| - | low | [ValueType](#valuetype) | Yes| Minimum value to match the **DataAbilityPredicates**.| - | high | [ValueType](#valuetype) | Yes| Maximum value to match the **DataAbilityPredicates**.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| field | string | Yes| Column name in the table.| +| low | [ValueType](#valuetype) | Yes| Minimum value to match the **DataAbilityPredicates**.| +| high | [ValueType](#valuetype) | Yes| Maximum value to match the **DataAbilityPredicates**.| **Return value** - | Type| Description| - | -------- | -------- | - | [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object that matches the specified field.| +| Type| Description| +| -------- | -------- | +| [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object that matches the specified field.| **Example** ```js @@ -425,16 +425,16 @@ Sets a **DataAbilityPredicates** object to match the field with data type **Valu **System capability**: SystemCapability.DistributedDataManager.DataShare.Core **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | field | string | Yes| Column name in the table.| - | low | [ValueType](#valuetype) | Yes| Minimum value to match the **DataAbilityPredicates**.| - | high | [ValueType](#valuetype) | Yes| Maximum value to match the **DataAbilityPredicates**.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| field | string | Yes| Column name in the table.| +| low | [ValueType](#valuetype) | Yes| Minimum value to match the **DataAbilityPredicates**.| +| high | [ValueType](#valuetype) | Yes| Maximum value to match the **DataAbilityPredicates**.| **Return value** - | Type| Description| - | -------- | -------- | - | [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object that matches the specified field.| +| Type| Description| +| -------- | -------- | +| [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object that matches the specified field.| **Example** ```js @@ -453,15 +453,15 @@ Sets a **DataAbilityPredicates** object to match the field with data type **Valu **System capability**: SystemCapability.DistributedDataManager.DataShare.Core **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | field | string | Yes| Column name in the table.| - | value | [ValueType](#valuetype) | Yes| Value to match the **DataAbilityPredicates**.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| field | string | Yes| Column name in the table.| +| value | [ValueType](#valuetype) | Yes| Value to match the **DataAbilityPredicates**.| **Return value** - | Type| Description| - | -------- | -------- | - | [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object that matches the specified field.| +| Type| Description| +| -------- | -------- | +| [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object that matches the specified field.| **Example** ```js @@ -480,15 +480,15 @@ Sets a **DataAbilityPredicates** object to match the field with data type **Valu **System capability**: SystemCapability.DistributedDataManager.DataShare.Core **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | field | string | Yes| Column name in the table.| - | value | [ValueType](#valuetype) | Yes| Value to match the **DataAbilityPredicates**.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| field | string | Yes| Column name in the table.| +| value | [ValueType](#valuetype) | Yes| Value to match the **DataAbilityPredicates**.| **Return value** - | Type| Description| - | -------- | -------- | - | [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object that matches the specified field.| +| Type| Description| +| -------- | -------- | +| [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object that matches the specified field.| **Example** ```js @@ -507,15 +507,15 @@ Sets a **DataAbilityPredicates** object to match the field with data type **Valu **System capability**: SystemCapability.DistributedDataManager.DataShare.Core **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | field | string | Yes| Column name in the table.| - | value | [ValueType](#valuetype) | Yes| Value to match the **DataAbilityPredicates**.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| field | string | Yes| Column name in the table.| +| value | [ValueType](#valuetype) | Yes| Value to match the **DataAbilityPredicates**.| **Return value** - | Type| Description| - | -------- | -------- | - | [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object that matches the specified field.| +| Type| Description| +| -------- | -------- | +| [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object that matches the specified field.| **Example** ```js @@ -534,15 +534,15 @@ Sets a **DataAbilityPredicates** object to match the field with data type **Valu **System capability**: SystemCapability.DistributedDataManager.DataShare.Core **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | field | string | Yes| Column name in the table.| - | value | [ValueType](#valuetype) | Yes| Value to match the **DataAbilityPredicates**.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| field | string | Yes| Column name in the table.| +| value | [ValueType](#valuetype) | Yes| Value to match the **DataAbilityPredicates**.| **Return value** - | Type| Description| - | -------- | -------- | - | [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object that matches the specified field.| +| Type| Description| +| -------- | -------- | +| [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object that matches the specified field.| **Example** ```js @@ -561,14 +561,14 @@ Sets a **DataAbilityPredicates** object to match the column with values sorted i **System capability**: SystemCapability.DistributedDataManager.DataShare.Core **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | field | string | Yes| Column name in the table.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| field | string | Yes| Column name in the table.| **Return value** - | Type| Description| - | -------- | -------- | - | [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object that matches the specified field.| +| Type| Description| +| -------- | -------- | +| [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object that matches the specified field.| **Example** ```js @@ -587,14 +587,14 @@ Sets a **DataAbilityPredicates** object to match the column with values sorted i **System capability**: SystemCapability.DistributedDataManager.DataShare.Core **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | field | string | Yes| Column name in the table.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| field | string | Yes| Column name in the table.| **Return value** - | Type| Description| - | -------- | -------- | - | [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object that matches the specified field.| +| Type| Description| +| -------- | -------- | +| [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object that matches the specified field.| **Example** ```js @@ -613,9 +613,9 @@ Sets a **DataAbilityPredicates** object to filter out duplicate records. **System capability**: SystemCapability.DistributedDataManager.DataShare.Core **Return value** - | Type| Description| - | -------- | -------- | - | [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object that can filter out duplicate records.| +| Type| Description| +| -------- | -------- | +| [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object that can filter out duplicate records.| **Example** ```js @@ -634,14 +634,14 @@ Set a **DataAbilityPredicates** object to specify the maximum number of records. **System capability**: SystemCapability.DistributedDataManager.DataShare.Core **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | value | number | Yes| Maximum number of records.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| value | number | Yes| Maximum number of records.| **Return value** - | Type| Description| - | -------- | -------- | - | [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object that specifies the maximum number of records.| +| Type| Description| +| -------- | -------- | +| [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object that specifies the maximum number of records.| **Example** ```js @@ -660,14 +660,14 @@ Sets a **DataAbilityPredicates** object to specify the start position of the ret **System capability**: SystemCapability.DistributedDataManager.DataShare.Core **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | rowOffset | number | Yes| Number of rows to offset from the beginning. The value is a positive integer.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| rowOffset | number | Yes| Number of rows to offset from the beginning. The value is a positive integer.| **Return value** - | Type| Description| - | -------- | -------- | - | [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object that specifies the start position of the returned result.| +| Type| Description| +| -------- | -------- | +| [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object that specifies the start position of the returned result.| **Example** ```js @@ -686,14 +686,14 @@ Sets a **DataAbilityPredicates** object to group rows that have the same value i **System capability**: SystemCapability.DistributedDataManager.DataShare.Core **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | fields | Array<string> | Yes| Names of columns to group.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| fields | Array<string> | Yes| Names of columns to group.| **Return value** - | Type| Description| - | -------- | -------- | - | [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object that groups rows with the same value.| +| Type| Description| +| -------- | -------- | +| [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object that groups rows with the same value.| **Example** ```js @@ -705,19 +705,20 @@ Sets a **DataAbilityPredicates** object to group rows that have the same value i indexedBy(field: string): DataAbilityPredicates - Sets a **DataAbilityPredicates** object to specify the index column. +**System capability**: SystemCapability.DistributedDataManager.DataShare.Core + **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | indexName | string | Yes| Name of the index column.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| indexName | string | Yes| Name of the index column.| **Return value** - | Type| Description| - | -------- | -------- | - | [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object that specifies the index column.| +| Type| Description| +| -------- | -------- | +| [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object that specifies the index column.| **Example** ```js @@ -736,16 +737,16 @@ Sets a **DataAbilityPredicates** object to match the field with data type Array< **System capability**: SystemCapability.DistributedDataManager.DataShare.Core **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | field | string | Yes| Column name in the table.| - | value | Array<[ValueType](#valuetype)> | Yes| Array of **ValueType**s to match.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| field | string | Yes| Column name in the table.| +| value | Array<[ValueType](#valuetype)> | Yes| Array of **ValueType**s to match.| **Return value** - | Type| Description| - | -------- | -------- | - | [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object that matches the specified field.| +| Type| Description| +| -------- | -------- | +| [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object that matches the specified field.| **Example** ```js @@ -764,16 +765,16 @@ Sets a **DataAbilityPredicates** object to match the field with data type Array< **System capability**: SystemCapability.DistributedDataManager.DataShare.Core **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | field | string | Yes| Column name in the table.| - | value | Array<[ValueType](#valuetype)> | Yes| Array of **ValueType**s to match.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| field | string | Yes| Column name in the table.| +| value | Array<[ValueType](#valuetype)> | Yes| Array of **ValueType**s to match.| **Return value** - | Type| Description| - | -------- | -------- | - | [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object that matches the specified field.| +| Type| Description| +| -------- | -------- | +| [DataAbilityPredicates](#dataabilitypredicates) | **DataAbilityPredicates** object that matches the specified field.| **Example** ```js diff --git a/en/application-dev/reference/apis/js-apis-display.md b/en/application-dev/reference/apis/js-apis-display.md index 994fe3a673ca9d505c0a6f96df6f007fe6d027d4..ffbc73ff530a4d8f9ec39fd6e824760df9448644 100644 --- a/en/application-dev/reference/apis/js-apis-display.md +++ b/en/application-dev/reference/apis/js-apis-display.md @@ -1,6 +1,8 @@ # Display +Provides APIs for managing displays, such as obtaining information about the default display, obtaining information about all displays, and listening for the addition and removal of displays. -> **NOTE**
+> **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 @@ -139,7 +141,7 @@ Obtains all the display objects. | Type | Description | | ----------------------------------------------- | ------------------------------------------------------- | - | Promise<Array<[Display](#display)>> | Promise used to return an array containing all the display objects.| + | Promise<Array<[Display](#display)>> | Promise used to return all the display objects.| **Example** @@ -163,7 +165,7 @@ Enables listening. **Parameters** | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | - | type | string | Yes| Listening type. The available values are as follows:
- **add**: listening for whether a display is added
- **remove**: listening for whether a display is removed
- **change**: listening for whether a display is changed| + | type | string | Yes| Listening type. The available values are as follows:
- **add**: listening for whether a display is added
- **remove**: listening for whether a display is removed
- **change**: listening for whether a display is changed| | callback | Callback<number> | Yes| Callback used to return the ID of the display.| **Example** @@ -186,7 +188,7 @@ Disables listening. **Parameters** | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | - | type | string | Yes| Listening type. The available values are as follows:
- **add**: listening for whether a display is added
- **remove**: listening for whether a display is removed
- **change**: listening for whether a display is changed| + | type | string | Yes| Listening type. The available values are as follows:
- **add**: listening for whether a display is added
- **remove**: listening for whether a display is removed
- **change**: listening for whether a display is changed| | callback | Callback<number> | No| Callback used to return the ID of the display.| **Example** diff --git a/en/application-dev/reference/apis/js-apis-distributed-data.md b/en/application-dev/reference/apis/js-apis-distributed-data.md index 6bbe4a0111f7fa6d409457e705af60cf6d0376c7..480a528124da0305fb8235893f9b0d78b8d2eb15 100644 --- a/en/application-dev/reference/apis/js-apis-distributed-data.md +++ b/en/application-dev/reference/apis/js-apis-distributed-data.md @@ -575,13 +575,12 @@ Provides KV store configuration. Defines the KV store types. -**System capability**: SystemCapability.DistributedDataManager.KVStore.Core | Name | Default Value| Description | | --- | ---- | ----------------------- | -| DEVICE_COLLABORATION | 0 | Device KV store. | -| SINGLE_VERSION | 1 | Single KV store. | -| MULTI_VERSION | 2 | Multi-version KV store. This type is not supported currently. | +| DEVICE_COLLABORATION | 0 | Device KV store.
**System capability**: SystemCapability.DistributedDataManager.KVStore.DistributedKVStore | +| SINGLE_VERSION | 1 | Single KV store.
**System capability**: SystemCapability.DistributedDataManager.KVStore.Core | +| MULTI_VERSION | 2 | Multi-version KV store. This type is not supported currently.
**System capability**: SystemCapability.DistributedDataManager.KVStore.DistributedKVStore| ## SecurityLevel diff --git a/en/application-dev/reference/apis/js-apis-enterprise-device-manager.md b/en/application-dev/reference/apis/js-apis-enterprise-device-manager.md index 869472d43c046a68cd3d50cfe262b424b660dd0d..3ae18cfdf93fcaa47553aa6f160d7b0f52e5ff2b 100644 --- a/en/application-dev/reference/apis/js-apis-enterprise-device-manager.md +++ b/en/application-dev/reference/apis/js-apis-enterprise-device-manager.md @@ -6,7 +6,7 @@ ## Modules to Import -``` +```js import enterpriseDeviceManager from '@ohos.enterpriseDeviceManager'; ``` @@ -36,7 +36,7 @@ SystemCapability.Customation.EnterpriseDeviceManager **Example** -``` +```js let wantTemp = { bundleName: "com.example.myapplication", abilityName: "com.example.myapplication.MainAbility", @@ -50,7 +50,7 @@ enterpriseDeviceManager.activateAdmin(wantTemp, enterpriseInfo, enterpriseDevice console.log("error occurs" + error); return; } - console.log(result); + console.log("result is " + result); }); ``` @@ -84,7 +84,7 @@ SystemCapability.Customation.EnterpriseDeviceManager **Example** -``` +```js let wantTemp = { bundleName: "com.example.myapplication", abilityName: "com.example.myapplication.MainAbility", @@ -95,7 +95,7 @@ let enterpriseInfo = { } enterpriseDeviceManager.activateAdmin(wantTemp, enterpriseInfo, enterpriseDeviceManager.AdminType.ADMIN_TYPE_NORMAL) .then((result) => { - console.log(result); + console.log("result is " + result); }).catch(error => { console.log("error occurs" + error); }); @@ -124,17 +124,17 @@ SystemCapability.Customation.EnterpriseDeviceManager **Example** -``` +```js let wantTemp = { - bundleName: elementName.bundleName, - abilityName: elementName.abilityName, + bundleName: "bundleName", + abilityName: "abilityName", }; enterpriseDeviceManager.deactivateAdmin(wantTemp, (error, result) => { if (error != null) { console.log("error occurs" + error); return; } - console.log(result); + console.log("result is " + result); }); ``` @@ -168,13 +168,13 @@ SystemCapability.Customation.EnterpriseDeviceManager **Example** -``` +```js let wantTemp = { bundleName: "bundleName", abilityName: "abilityName", }; enterpriseDeviceManager.deactivateAdmin(wantTemp).then((result) => { - console.log(result); + console.log("result is " + result); }).catch(error => { console.log("error occurs" + error); }); @@ -199,14 +199,14 @@ SystemCapability.Customation.EnterpriseDeviceManager **Example** -``` +```js let bundleName = "com.example.myapplication"; enterpriseDeviceManager.deactivateSuperAdmin(bundleName, (error, result) => { if (error != null) { console.log("error occurs" + error); return; } - console.log(result); + console.log("result is " + result); }); ``` @@ -234,10 +234,10 @@ SystemCapability.Customation.EnterpriseDeviceManager **Example** -``` +```js let bundleName = "com.example.myapplication"; enterpriseDeviceManager.deactivateSuperAdmin(bundleName).then((result) => { - console.log(result); + console.log("result is " + result); }).catch(error => { console.log("error occurs" + error); }); @@ -262,17 +262,17 @@ SystemCapability.Customation.EnterpriseDeviceManager **Example** -``` +```js let wantTemp = { - bundleName: elementName.bundleName, - abilityName: elementName.abilityName, + bundleName: "bundleName", + abilityName: "abilityName", }; enterpriseDeviceManager.isAdminAppActive(wantTemp, (error, result) => { if (error != null) { console.log("error occurs" + error); return; } - console.log(result); + console.log("result is " + result); }); ``` @@ -302,13 +302,13 @@ SystemCapability.Customation.EnterpriseDeviceManager **Example** -``` +```js let wantTemp = { bundleName: "bundleName", abilityName: "abilityName", }; enterpriseDeviceManager.isAdminAppActive(wantTemp).then((result) => { - console.log(result); + console.log("result is " + result); }).catch(error => { console.log("error occurs" + error); }); @@ -333,14 +333,14 @@ SystemCapability.Customation.EnterpriseDeviceManager **Example** -``` +```js let bundleName = "com.example.myapplication"; enterpriseDeviceManager.isSuperAdmin(bundleName, (error, result) => { if (error != null) { console.log("error occurs" + error); return; } - console.log(result); + console.log("result is " + result); }); ``` @@ -370,10 +370,10 @@ SystemCapability.Customation.EnterpriseDeviceManager **Example** -``` +```js let bundleName = "com.example.myapplication"; enterpriseDeviceManager.isSuperAdmin(bundleName).then((result) => { - console.log(result); + console.log("result is " + result); }).catch(error => { console.log("error occurs" + error); }); @@ -397,7 +397,7 @@ SystemCapability.Customation.EnterpriseDeviceManager **Example** -``` +```js let wantTemp = { bundleName: "bundleName", abilityName: "abilityName", @@ -436,7 +436,7 @@ SystemCapability.Customation.EnterpriseDeviceManager **Example** -``` +```js let wantTemp = { bundleName: "bundleName", abilityName: "abilityName", @@ -472,7 +472,7 @@ SystemCapability.Customation.EnterpriseDeviceManager **Example** -``` +```js let wantTemp = { bundleName: "com.example.myapplication", abilityName: "com.example.myapplication.MainAbility", @@ -483,7 +483,7 @@ let enterpriseInfo = { } enterpriseDeviceManager.setEnterpriseInfo(wantTemp, enterpriseInfo) .then((result) => { - console.log(result); + console.log("result is " + result); }).catch(error => { console.log("error occurs" + error); }); @@ -515,7 +515,7 @@ SystemCapability.Customation.EnterpriseDeviceManager **Example** -``` +```js let wantTemp = { bundleName: "com.example.myapplication", abilityName: "com.example.myapplication.MainAbility", @@ -526,7 +526,7 @@ let enterpriseInfo = { } enterpriseDeviceManager.setEnterpriseInfo(wantTemp, enterpriseInfo) .then((result) => { - console.log(result); + console.log("result is " + result); }).catch(error => { console.log("error occurs" + error); }); @@ -551,7 +551,7 @@ SystemCapability.Customation.EnterpriseDeviceManager **Example** -``` +```js let wantTemp = { bundleName: "com.example.myapplication", abilityName: "com.example.myapplication.MainAbility", @@ -591,7 +591,7 @@ SystemCapability.Customation.EnterpriseDeviceManager **Example** -``` +```js let wantTemp = { bundleName: "com.example.myapplication", abilityName: "com.example.myapplication.MainAbility", diff --git a/en/application-dev/reference/apis/js-apis-hiappevent.md b/en/application-dev/reference/apis/js-apis-hiappevent.md index f75b45946a8f5aa6541ce502c7ff58673ecd4e8a..c684f0ea4f3c4cdd77de4e189b00e15f41a82855 100644 --- a/en/application-dev/reference/apis/js-apis-hiappevent.md +++ b/en/application-dev/reference/apis/js-apis-hiappevent.md @@ -1,5 +1,7 @@ # HiAppEvent +This module provides the application event logging functions, such as writing application events to the event file and managing the event logging configuration. + > ![icon-note.gif](public_sys-resources/icon-note.gif) **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. diff --git a/en/application-dev/reference/apis/js-apis-hitracechain.md b/en/application-dev/reference/apis/js-apis-hitracechain.md index 485eddc0fbfb59946228e859760885ad0ce1b633..cbaf898f75c37ba8921fe3d8ffd11e5484ec28e8 100644 --- a/en/application-dev/reference/apis/js-apis-hitracechain.md +++ b/en/application-dev/reference/apis/js-apis-hitracechain.md @@ -1,5 +1,7 @@ # Distributed Call Chain Tracing +This module implements call chain tracing throughout a service process. It provides functions such as starting and stopping call chain tracing and configuring trace points. + > ![icon-note.gif](public_sys-resources/icon-note.gif) **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. diff --git a/en/application-dev/reference/apis/js-apis-hitracemeter.md b/en/application-dev/reference/apis/js-apis-hitracemeter.md index 656063edf90a71a74e8f7b5e90375acfccfdae9c..e856ee20a4c8956ff0f05707b596935b68ca9e7a 100644 --- a/en/application-dev/reference/apis/js-apis-hitracemeter.md +++ b/en/application-dev/reference/apis/js-apis-hitracemeter.md @@ -1,5 +1,7 @@ # Performance Tracing +This module provides the functions of tracing service processes and monitoring the system performance. It provides the data needed for hiTraceMeter to carry out performance analysis. + > ![icon-note.gif](public_sys-resources/icon-note.gif) **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. diff --git a/en/application-dev/reference/apis/js-apis-image.md b/en/application-dev/reference/apis/js-apis-image.md index 5b564c7addd10b39e5873bf50faa84efc9ff1ad6..cad0b582b715f1d7d7d4a7075853dd4573416866 100644 --- a/en/application-dev/reference/apis/js-apis-image.md +++ b/en/application-dev/reference/apis/js-apis-image.md @@ -1,6 +1,7 @@ # Image Processing -> **NOTE**
+> **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 @@ -20,7 +21,7 @@ Creates a **PixelMap** object. This API uses a promise to return the result. | Name | Type | Mandatory| Description | | ------- | ------------------------------------------------ | ---- | ------------------------------------------------------------ | -| colors | ArrayBuffer | Yes | Color array. | +| colors | ArrayBuffer | Yes | Color array in BGRA_8888 format. | | options | [InitializationOptions](#initializationoptions8) | Yes | Pixel properties, including the alpha type, size, scale mode, pixel format, and editable.| **Return value** @@ -32,9 +33,11 @@ Creates a **PixelMap** object. This API uses a promise to return the result. **Example** ```js -image.createPixelMap(Color, opts) - .then((pixelmap) => { - }) +const color = new ArrayBuffer(96); +let opts = { editable: true, pixelFormat: 3, size: { height: 4, width: 6 } } +image.createPixelMap(color, opts) + .then((pixelmap) => { + }) ``` ## image.createPixelMap8+ @@ -49,15 +52,17 @@ Creates a **PixelMap** object. This API uses an asynchronous callback to return | Name | Type | Mandatory| Description | | -------- | ------------------------------------------------ | ---- | -------------------------- | -| colors | ArrayBuffer | Yes | Color array. | +| colors | ArrayBuffer | Yes | Color array in BGRA_8888 format. | | options | [InitializationOptions](#initializationoptions8) | Yes | Pixel properties. | | callback | AsyncCallback\<[PixelMap](#pixelmap7)> | Yes | Callback used to return the **PixelMap** object.| **Example** ```js -image.createPixelMap(Color, opts, (pixelmap) => { - }) +const color = new ArrayBuffer(96); +let opts = { editable: true, pixelFormat: 3, size: { height: 4, width: 6 } } +image.createPixelMap(color, opts, (pixelmap) => { + }) ``` ## PixelMap7+ @@ -95,11 +100,11 @@ Reads image pixel map data and writes the data to an **ArrayBuffer**. This API u **Example** ```js -pixelmap.readPixelsToBuffer(readBuffer).then(() => { - // Called if the condition is met. - }).catch(error => { - // Called if no condition is met. - }) +pixelmap.readPixelsToBuffer(ReadBuffer).then(() => { + console.log('readPixelsToBuffer succeeded.'); // Called if the condition is met. +}).catch(error => { + console.log('readPixelsToBuffer failed.'); // Called if no condition is met. +}) ``` ### readPixelsToBuffer7+ @@ -120,8 +125,13 @@ Reads image pixel map data and writes the data to an **ArrayBuffer**. This API u **Example** ```js -pixelmap.readPixelsToBuffer(readBuffer, () => { - }) +pixelmap.readPixelsToBuffer(ReadBuffer, (err, res) => { + if(err) { + console.log('readPixelsToBuffer failed.'); // Called if the condition is met. + } else { + console.log('readPixelsToBuffer succeeded.'); // Called if the condition is met. + } +}) ``` ### readPixels7+ @@ -147,11 +157,11 @@ Reads image pixel map data in an area. This API uses a promise to return the dat **Example** ```js -pixelmap.readPixels(area).then((data) => { - // Called if the condition is met. - }).catch(error => { - // Called if no condition is met. - }) +pixelmap.readPixels(Area).then((data) => { + console.log('readPixels succeeded.'); // Called if the condition is met. +}).catch(error => { + console.log('readPixels failed.'); // Called if no condition is met. +}) ``` ### readPixels7+ @@ -174,19 +184,17 @@ Reads image pixel map data in an area. This API uses an asynchronous callback to ```js let opts = { editable: true, pixelFormat: 3, size: { height: 4, width: 6 } } image.createPixelMap(color, opts, (err, pixelmap) => { - if(pixelmap == undefined){ - console.info('createPixelMap failed'); - expect(false).assertTrue(); - done(); - }else{ - const area = { pixels: new ArrayBuffer(8), - offset: 0, - stride: 8, - region: { size: { height: 1, width: 2 }, x: 0, y: 0 }} - pixelmap.readPixels(area, () => { - console.info('readPixels success'); - }) - } + if(pixelmap == undefined){ + console.info('createPixelMap failed.'); + } else { + const area = { pixels: new ArrayBuffer(8), + offset: 0, + stride: 8, + region: { size: { height: 1, width: 2 }, x: 0, y: 0 }}; + pixelmap.readPixels(area, () => { + console.info('readPixels success'); + }) + } }) ``` @@ -218,9 +226,7 @@ let opts = { editable: true, pixelFormat: 3, size: { height: 4, width: 6 } } image.createPixelMap(color, opts) .then( pixelmap => { if (pixelmap == undefined) { - console.info('createPixelMap failed'); - expect(false).assertTrue() - done(); + console.info('createPixelMap failed.'); } const area = { pixels: new ArrayBuffer(8), offset: 0, @@ -240,11 +246,8 @@ image.createPixelMap(color, opts) region: { size: { height: 1, width: 2 }, x: 0, y: 0 } } }) - }) - .catch(error => { + }).catch(error => { console.log('error: ' + error); - expect().assertFail(); - done(); }) ``` @@ -266,14 +269,14 @@ Writes image pixel map data to an area. This API uses an asynchronous callback t **Example** ```js -pixelmap.writePixels(area, () => { - const readArea = { - pixels: new ArrayBuffer(20), - offset: 0, - stride: 8, - region: { size: { height: 1, width: 2 }, x: 0, y: 0 }, - } - }) +pixelmap.writePixels(Area, () => { + const readArea = { + pixels: new ArrayBuffer(20), + offset: 0, + stride: 8, + region: { size: { height: 1, width: 2 }, x: 0, y: 0 }, + } +}) ``` ### writeBufferToPixels7+ @@ -299,11 +302,11 @@ Reads image data in an **ArrayBuffer** and writes the data to a **PixelMap** obj **Example** ```js -pixelMap.writeBufferToPixels(colorBuffer).then(() => { +PixelMap.writeBufferToPixels(color).then(() => { console.log("Succeeded in writing data from a buffer to a PixelMap."); }).catch((err) => { console.error("Failed to write data from a buffer to a PixelMap."); -}); +}) ``` ### writeBufferToPixels7+ @@ -324,12 +327,13 @@ Reads image data in an **ArrayBuffer** and writes the data to a **PixelMap** obj **Example** ```js -pixelMap.writeBufferToPixels(colorBuffer, function(err) { +PixelMap.writeBufferToPixels(color, function(err) { if (err) { console.error("Failed to write data from a buffer to a PixelMap."); return; - } - console.log("Succeeded in writing data from a buffer to a PixelMap."); + } else { + console.log("Succeeded in writing data from a buffer to a PixelMap."); + } }); ``` @@ -350,7 +354,7 @@ Obtains pixel map information of this image. This API uses a promise to return t **Example** ```js -pixelMap.getImageInfo().then(function(info) { +PixelMap.getImageInfo().then(function(info) { console.log("Succeeded in obtaining the image pixel map information."); }).catch((err) => { console.error("Failed to obtain the image pixel map information."); @@ -374,7 +378,11 @@ Obtains pixel map information of this image. This API uses an asynchronous callb **Example** ```js -pixelmap.getImageInfo((imageInfo) => {}) +pixelmap.getImageInfo((imageInfo) => { + console.log("getImageInfo succeeded."); +}).catch((err) => { + console.error("getImageInfo failed."); +}) ``` ### getBytesNumberPerRow7+ @@ -394,7 +402,9 @@ Obtains the number of bytes per line of the image pixel map. **Example** ```js -rowCount = pixelmap.getBytesNumberPerRow() +image.createPixelMap(clolr, opts, (err,pixelmap) => { + let rowCount = pixelmap.getBytesNumberPerRow(); +}) ``` ### getPixelBytesNumber7+ @@ -414,7 +424,7 @@ Obtains the total number of bytes of the image pixel map. **Example** ```js -pixelBytesNumber = pixelmap.getPixelBytesNumber() +let pixelBytesNumber = pixelmap.getPixelBytesNumber(); ``` ### release7+ @@ -434,8 +444,13 @@ Releases this **PixelMap** object. This API uses a promise to return the result. **Example** ```js - pixelmap.release().then(() => { }) - .catch(error => {}) +image.createPixelMap(color, opts, (pixelmap) => { + pixelmap.release().then(() => { + console.log('release succeeded.'); + }).catch(error => { + console.log('release failed.'); + }) +}) ``` ### release7+ @@ -455,7 +470,13 @@ Releases this **PixelMap** object. This API uses an asynchronous callback to ret **Example** ```js -pixelmap.release(()=>{ }) +image.createPixelMap(color, opts, (pixelmap) => { + pixelmap.release().then(() => { + console.log('release succeeded.'); + }).catch(error => { + console.log('release failed.'); + }) +}) ``` ## image.createImageSource @@ -508,7 +529,7 @@ Creates an **ImageSource** instance based on the file descriptor. **Example** ```js -const imageSourceApi = image.createImageSource(0) +const imageSourceApi = image.createImageSource(0); ``` ## ImageSource @@ -541,7 +562,13 @@ Obtains information about an image with the specified index. This API uses an as **Example** ```js -imageSourceApi.getImageInfo(0,(error, imageInfo) => {}) +imageSourceApi.getImageInfo(0,(error, imageInfo) => { + if(error) { + console.log('getImageInfo failed.'); + } else { + console.log('getImageInfo succeeded.'); + } +}) ``` ### getImageInfo @@ -561,7 +588,11 @@ Obtains information about this image. This API uses an asynchronous callback to **Example** ```js -imageSourceApi.getImageInfo(imageInfo => {}) +imageSourceApi.getImageInfo(imageInfo => { + console.log('getImageInfo succeeded.'); +}).catch(error => { + console.log('getImageInfo failed.'); +}) ``` ### getImageInfo @@ -588,8 +619,11 @@ Obtains information about an image with the specified index. This API uses a pro ```js imageSourceApi.getImageInfo(0) - .then(imageInfo => {}) - .catch(error => {}) + .then(imageInfo => { + console.log('getImageInfo succeeded.'); + }).catch(error => { + console.log('getImageInfo failed.'); + }) ``` ### getImageProperty7+ @@ -617,8 +651,11 @@ Obtains the value of a property with the specified index in this image. This API ```js imageSourceApi.getImageProperty("BitsPerSample") - .then(data => {}) - .catch(error => {}) + .then(data => { + console.log('getImageProperty succeeded.'); + }).catch(error => { + console.log('getImageProperty failed.'); + }) ``` ### getImageProperty7+ @@ -639,7 +676,13 @@ Obtains the value of a property with the specified index in this image. This API **Example** ```js -imageSourceApi.getImageProperty("BitsPerSample",(error,data) => {}) +imageSourceApi.getImageProperty("BitsPerSample",(error,data) => { + if(error) { + console.log('getImageProperty failed.'); + } else { + console.log('getImageProperty succeeded.'); + } +}) ``` ### getImageProperty7+ @@ -661,7 +704,13 @@ Obtains the value of a property in this image. This API uses an asynchronous cal **Example** ```js -imageSourceApi.getImageProperty("BitsPerSample",property,(error,data) => {}) +imageSourceApi.getImageProperty("BitsPerSample",Property,(error,data) => { + if(error) { + console.log('getImageProperty failed.'); + } else { + console.log('getImageProperty succeeded.'); + } +}) ``` ### createPixelMap7+ @@ -687,8 +736,11 @@ Creates a **PixelMap** object based on image decoding parameters. This API uses **Example** ```js -imageSourceApi.createPixelMap().then(pixelmap => {}) - .catch(error => {}) +imageSourceApi.createPixelMap().then(pixelmap => { + console.log('createPixelMap succeeded.'); +}).catch(error => { + console.log('createPixelMap failed.'); +}) ``` ### createPixelMap7+ @@ -708,7 +760,11 @@ Creates a **PixelMap** object based on the default parameters. This API uses an **Example** ```js -imageSourceApi.createPixelMap(pixelmap => {}) +imageSourceApi.createPixelMap(pixelmap => { + console.log('createPixelMap succeeded.'); +}).catch(error => { + console.log('createPixelMap failed.'); +}) ``` ### createPixelMap7+ @@ -729,7 +785,11 @@ Creates a **PixelMap** object based on image decoding parameters. This API uses **Example** ```js -imageSourceApi.createPixelMap(decodingOptions, pixelmap => {}) +imageSourceApi.createPixelMap(decodingOptions, pixelmap => { + console.log('createPixelMap succeeded.'); +}).catch(error => { + console.log('createPixelMap failed.'); +}) ``` ### release @@ -749,7 +809,11 @@ Releases this **ImageSource** instance. This API uses an asynchronous callback t **Example** ```js -imageSourceApi.release(() => {}) +imageSourceApi.release(() => { + console.log('release succeeded.'); +}).catch(error => { + console.log('release failed.'); +}) ``` ### release @@ -769,7 +833,11 @@ Releases this **ImageSource** instance. This API uses a promise to return the re **Example** ```js -imageSourceApi.release().then(()=>{ }).catch(error => {}) +imageSourceApi.release().then(()=>{ + console.log('release succeeded.'); +}).catch(error => { + console.log('release failed.'); +}) ``` ## image.createImagePacker @@ -823,8 +891,8 @@ Packs an image. This API uses an asynchronous callback to return the result. **Example** ```js -let packOpts = { format:["image/jpeg"], quality:98 } -imagePackerApi.packing(imageSourceApi, packOpts, data => {}) +let packOpts = { format:["image/jpeg"], quality:98 }; +imagePackerApi.packing(ImageSourceApi, packOpts, data => {}) ``` ### packing @@ -852,9 +920,12 @@ Packs an image. This API uses a promise to return the result. ```js let packOpts = { format:["image/jpeg"], quality:98 } -imagePackerApi.packing(imageSourceApi, packOpts) - .then( data => { }) - .catch(error => {}) +imagePackerApi.packing(ImageSourceApi, packOpts) + .then( data => { + console.log('packing succeeded.'); + }).catch(error => { + console.log('packing failed.'); + }) ``` ### packing8+ @@ -877,7 +948,11 @@ Packs an image. This API uses an asynchronous callback to return the result. ```js let packOpts = { format:["image/jpeg"], quality:98 } -imagePackerApi.packing(pixelMapApi, packOpts, data => {}) +imagePackerApi.packing(PixelMapApi, packOpts, data => { + console.log('packing succeeded.'); +}).catch(error => { + console.log('packing failed.'); +}) ``` ### packing8+ @@ -905,9 +980,12 @@ Packs an image. This API uses a promise to return the result. ```js let packOpts = { format:["image/jpeg"], quality:98 } -imagePackerApi.packing(pixelMapApi, packOpts) - .then( data => { }) - .catch(error => {}) +imagePackerApi.packing(PixelMapApi, packOpts) + .then( data => { + console.log('packing succeeded.'); + }).catch(error => { + console.log('packing failed.'); + }) ``` ### release @@ -927,7 +1005,11 @@ Releases this **ImagePacker** instance. This API uses an asynchronous callback t **Example** ```js -imagePackerApi.release(()=>{}) +imagePackerApi.release(()=>{ + console.log('release succeeded.'); +}).catch(error => { + console.log('release failed.'); +}) ``` ### release @@ -947,8 +1029,11 @@ Releases this **ImagePacker** instance. This API uses a promise to return the re **Example** ```js - imagePackerApi.release().then(()=>{ - }).catch((error)=>{}) +imagePackerApi.release().then(()=>{ + console.log('release succeeded.'); +}).catch((error)=>{ + console.log('release failed.'); +}) ``` ## image.createImageReceiver9+ @@ -977,7 +1062,7 @@ Create an **ImageReceiver** instance by specifying the image width, height, form **Example** ```js -var receiver = image.createImageReceiver(8192, 8, 4, 8) +var receiver = image.createImageReceiver(8192, 8, 4, 8); ``` ## ImageReceiver9+ @@ -1013,7 +1098,13 @@ Obtains a surface ID for the camera or other components. This API uses an asynch **Example** ```js - receiver.getReceivingSurfaceId((err, id) => {}); + receiver.getReceivingSurfaceId((err, id) => { + if(err) { + console.log('getReceivingSurfaceId failed.'); + } else { + console.log('getReceivingSurfaceId succeeded.'); + } +}); ``` ### getReceivingSurfaceId9+ @@ -1034,8 +1125,10 @@ Obtains a surface ID for the camera or other components. This API uses a promise ```js receiver.getReceivingSurfaceId().then( id => { - }).catch(error => { - }) + console.log('getReceivingSurfaceId succeeded.'); +}).catch(error => { + console.log('getReceivingSurfaceId failed.'); +}) ``` ### readLatestImage9+ @@ -1055,7 +1148,13 @@ Reads the latest image from the **ImageReceiver** instance. This API uses an asy **Example** ```js - receiver.readLatestImage((err, img) => { }); +receiver.readLatestImage((err, img) => { + if(err) { + console.log('readLatestImage failed.'); + } else { + console.log('readLatestImage succeeded.'); + } +}); ``` ### readLatestImage9+ @@ -1075,8 +1174,11 @@ Reads the latest image from the **ImageReceiver** instance. This API uses a prom **Example** ```js -receiver.readLatestImage().then(img => {}) - .catch(error => {}) +receiver.readLatestImage().then(img => { + console.log('readLatestImage succeeded.'); +}).catch(error => { + console.log('readLatestImage failed.'); +}) ``` ### readNextImage9+ @@ -1096,7 +1198,13 @@ Reads the next image from the **ImageReceiver** instance. This API uses an async **Example** ```js -receiver.readNextImage((err, img) => {}); +receiver.readNextImage((err, img) => { + if(err) { + console.log('readNextImage failed.'); + } else { + console.log('readNextImage succeeded.'); + } +}); ``` ### readNextImage9+ @@ -1116,9 +1224,11 @@ Reads the next image from the **ImageReceiver** instance. This API uses a promis **Example** ```js - receiver.readNextImage().then(img => { - }).catch(error => { - }) +receiver.readNextImage().then(img => { + console.log('readNextImage succeeded.'); +}).catch(error => { + console.log('readNextImage failed.'); +}) ``` ### on('imageArrival')9+ @@ -1139,7 +1249,7 @@ Listens for image arrival events. **Example** ```js - receiver.on('imageArrival', () => {}) +receiver.on('imageArrival', () => {}) ``` ### release9+ @@ -1159,7 +1269,7 @@ Releases this **ImageReceiver** instance. This API uses an asynchronous callback **Example** ```js - receiver.release(() => {}) +receiver.release(() => {}) ``` ### release9+ @@ -1179,8 +1289,11 @@ Releases this **ImageReceiver** instance. This API uses a promise to return the **Example** ```js - receiver.release().then(() => {}) - .catch(error => {}) +receiver.release().then(() => { + console.log('release succeeded.'); +}).catch(error => { + console.log('release failed.'); +}) ``` ## Image9+ @@ -1215,7 +1328,13 @@ Obtains the component buffer from the **Image** instance based on the color comp **Example** ```js - img.getComponent(4, (err, component) => {}) +img.getComponent(4, (err, component) => { + if(err) { + console.log('getComponent failed.'); + } else { + console.log('getComponent succeeded.'); + } +}) ``` ### getComponent9+ @@ -1263,7 +1382,11 @@ The corresponding resources must be released before another image arrives. **Example** ```js -img.release(() =>{ }) +img.release(() =>{ + console.log('release succeeded.'); +}).catch(error => { + console.log('release failed.'); +}) ``` ### release9+ @@ -1286,8 +1409,10 @@ The corresponding resources must be released before another image arrives. ```js img.release().then(() =>{ - }).catch(error => { - }) + console.log('release succeeded.'); +}).catch(error => { + console.log('release failed.'); +}) ``` ## PositionArea7+ diff --git a/en/application-dev/reference/apis/js-apis-inputdevice.md b/en/application-dev/reference/apis/js-apis-inputdevice.md index eca20fafe0a0510de5543a7fc777839c0c99862b..c47a977b1f2b1559488b6f6602a6ed116ad88197 100644 --- a/en/application-dev/reference/apis/js-apis-inputdevice.md +++ b/en/application-dev/reference/apis/js-apis-inputdevice.md @@ -15,6 +15,70 @@ The input device management module is used to listen for the connection, disconn import inputDevice from '@ohos.multimodalInput.inputDevice'; ``` +## inputDevice.on9+ + +on(type: "change", listener: Callback<DeviceListener>): void + +Enables listening for hot swap events of an input device. + +**System capability**: SystemCapability.MultimodalInput.Input.InputDevice + +**Parameters** + +| Name | Type | Mandatory | Description | +| -------- | ---------------------------------------- | ---- | ----------- | +| type | string | Yes | Event type of the input device. | +| listener | Callback<[DeviceListener](#devicelistener9+)> | Yes | Listener for events of the input device.| + +**Example** + +```js +let isPhysicalKeyboardExist = true; +inputDevice.on("change", (data) => { + console.log("type: " + data.type + ", deviceId: " + data.deviceId); + inputDevice.getKeyboardType(data.deviceId, (err, ret) => { + console.log("The keyboard type of the device is: " + ret); + if (ret == inputDevice.KeyboardType.ALPHABETIC_KEYBOARD && data.type == 'add') { + // The physical keyboard is connected. + isPhysicalKeyboardExist = true; + } else if (ret == inputDevice.KeyboardType.ALPHABETIC_KEYBOARD && data.type == 'remove') { + // The physical keyboard is disconnected. + isPhysicalKeyboardExist = false; + } + }); +}); +// Check whether the soft keyboard is open based on the value of isPhysicalKeyboardExist. +``` + +## inputDevice.off9+ + +off(type: "change", listener?: Callback<DeviceListener>): void + +Disables listening for hot swap events of an input device. + +**System capability**: SystemCapability.MultimodalInput.Input.InputDevice + +**Parameters** + +| Name | Type | Mandatory | Description | +| -------- | ---------------------------------------- | ---- | ----------- | +| type | string | Yes | Event type of the input device. | +| listener | Callback<[DeviceListener](#devicelistener9+)> | No | Listener for events of the input device.| + +**Example** + +```js +function listener(data) { + console.log("type: " + data.type + ", deviceId: " + data.deviceId); +} + +// Disable this listener. +inputDevice.off("change", listener); + +// Disable all listeners. +inputDevice.off("change"); +// By default, the soft keyboard is closed when listening is disabled. +``` ## inputDevice.getDeviceIds @@ -30,28 +94,17 @@ Obtains the IDs of all input devices. This API uses an asynchronous callback to | -------- | ---------------------------------------- | ---- | ----- | | callback | AsyncCallback<Array<number>> | Yes | Callback used to return the result.| - **Example** ```js -export default { - data: { - deviceIds: Array, - }, - callback: function(ids) { - this.deviceIds = ids; - }, - testGetDeviceIds: function () { - console.info("InputDeviceJsTest---start---testGetDeviceIds"); - inputDevice.getDeviceIds(this.callback); - console.info("InputDeviceJsTest---end---testGetDeviceIds"); - } -} +inputDevice.getDeviceIds((ids)=>{ + console.log("The device ID list is: " + ids); +}); ``` ## inputDevice.getDeviceIds -function getDeviceIds(): Promise> +getDeviceIds(): Promise<Array<number>> Obtains the IDs of all input devices. This API uses a promise to return the result. @@ -59,35 +112,23 @@ Obtains the IDs of all input devices. This API uses a promise to return the resu **Return value** -| Parameter | Description | -| ---------------------- | ------------------ | -| Promise> | Promise used to return the result.| +| Parameter | Description | +| ---------------------------------- | ------------------- | +| Promise<Array<number>> | Promise used to return the result.| **Example** ```js -export default { - testGetDeviceIds: function () { - console.info("InputDeviceJsTest---start---testGetDeviceIds"); - let promise = inputDevice.getDeviceIds(); - promise.then((data)=> { - console.info('GetDeviceIds successed, Data: ' + JSON.stringify(data)) - }).catch((err)=>{ - console.error('Failed GetDeviceIds. Cause: ' + JSON.stringify(err)); - }); - } -} +inputDevice.getDeviceIds().then((ids)=>{ + console.log("The device ID list is: " + ids); +}); ``` - - - - ## inputDevice.getDevice getDevice(deviceId: number, callback: AsyncCallback<InputDeviceData>): void -Obtains the information about an input device. This API uses an asynchronous callback to return the result. +Obtains information about an input device. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.MultimodalInput.Input.InputDevice @@ -95,107 +136,212 @@ Obtains the information about an input device. This API uses an asynchronous cal | Name | Type | Mandatory | Description | | -------- | ---------------------------------------- | ---- | --------------------------- | -| deviceId | number | Yes | ID of the input device whose information is to be obtained. | -| callback | AsyncCallback<[InputDeviceData](#inputdevicedata)> | Yes | Callback used to return the **InputDeviceData** object.| +| deviceId | number | Yes | ID of the input device. | +| callback | AsyncCallback<[InputDeviceData](#inputdevicedata)> | Yes | Callback used to return the result, which is an **InputDeviceData** object.| **Example** ```js -export default { - InputDeviceData: { - deviceId : 0, - name : "NA", - sources : Array, - axisRanges : Array, - }, - callback: function(deviceData) { - this.InputDeviceData = deviceData; - }, - testGetDevice: function () { - // The example is used to obtain the information about the device whose ID is 1. - console.info("InputDeviceJsTest---start---testGetDevice"); - inputDevice.getDevice(1, this.callback); - console.info("InputDeviceJsTest---end---testGetDevice"); - } -} +// Obtain the name of the device whose ID is 1. +inputDevice.getDevice(1, (inputDevice)=>{ + console.log("The device name is: " + inputDevice.name); +}); ``` ## inputDevice.getDevice -function getDevice(deviceId: number): Promise\ +getDevice(deviceId: number): Promise<InputDeviceData> -Obtains the information about an input device. This API uses a promise to return the result. +Obtains information about an input device. This API uses a promise to return the result. **System capability**: SystemCapability.MultimodalInput.Input.InputDevice +**Parameters** + +| Name | Type | Mandatory | Description | +| -------- | ------ | ---- | ------------ | +| deviceId | number | Yes | ID of the input device.| + **Return value** -| Parameter | Description | -| ------------------------ | ------------------ | -| Promise\ | Promise used to return the result.| +| Parameter | Description | +| ---------------------------------------- | ------------------- | +| Promise<[InputDeviceData](#inputdevicedata)> | Promise used to return the result.| **Example** ```js -export default { - InputDeviceData: { - deviceId : 0, - name : "NA", - sources : Array, - axisRanges : Array, - }, - testGetDevice: function () { - // The example is used to obtain the information about the device whose ID is 1. - console.info("InputDeviceJsTest---start---testGetDevice"); - let promise = inputDevice.getDevice(1); - promise.then((data)=> { - console.info('GetDeviceId successed, Data: ' + JSON.stringify(data)) - }).catch((err)=>{ - console.error('Failed GetDeviceId. Cause: ' + JSON.stringify(err)); - }); - } -} +// Obtain the name of the device whose ID is 1. +inputDevice.getDevice(1).then((inputDevice)=>{ + console.log("The device name is: " + inputDevice.name); +}); ``` +## inputDevice.supportKeys9+ +supportKeys(deviceId: number, keys: Array<KeyCode>, callback: Callback<Array<boolean>>): void; -## InputDeviceData +Obtains the key codes supported by the input device. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.MultimodalInput.Input.InputDevice + +**Parameters** + +| Name | Type | Mandatory | Description | +| -------- | ------------------------------------ | ---- | --------------------------------- | +| deviceId | number | Yes | Unique ID of the input device. If the same physical device is repeatedly inserted and removed, its ID changes.| +| keys | Array<KeyCode> | Yes | Key codes to be queried. A maximum of five key codes can be specified. | +| callback | Callback<Array<boolean>> | Yes | Callback used to return the result. | + +**Example** + +```js +// Check whether the input device whose ID is 1 supports key codes 17, 22, and 2055. +inputDevice.supportKeys(1, [17, 22, 2055], (ret)=>{ + console.log("The query result is as follows: " + ret); +}); +``` + +## inputDevice.supportKeys9+ + +supportKeys(deviceId: number, keys: Array<KeyCode>): Promise<Array<boolean>>; + +Obtains the key codes supported by the input device. This API uses a promise to return the result. + +**System capability**: SystemCapability.MultimodalInput.Input.InputDevice + +**Parameters** + +| Name | Type | Mandatory | Description | +| -------- | -------------------- | ---- | --------------------------------- | +| deviceId | number | Yes | Unique ID of the input device. If the same physical device is repeatedly inserted and removed, its ID changes.| +| keys | Array<KeyCode> | Yes | Key codes to be queried. A maximum of five key codes can be specified. | + +**Return value** + +| Parameter | Description | +| ----------------------------------- | ------------------- | +| Promise<Array<boolean>> | Promise used to return the result.| + +**Example** + +```js +// Check whether the input device whose ID is 1 supports key codes 17, 22, and 2055. +inputDevice.supportKeys(1, [17, 22, 2055]).then((ret)=>{ + console.log("The query result is as follows: " + ret); +}) +``` + +## inputDevice.getKeyboardType9+ + +getKeyboardType(deviceId: number, callback: AsyncCallback<KeyboardType>): void; + +Obtains the keyboard type of an input device. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.MultimodalInput.Input.InputDevice + +**Parameters** + +| Name | Type | Mandatory | Description | +| -------- | ---------------------------------------- | ---- | --------------------------------- | +| deviceId | number | Yes | Unique ID of the input device. If the same physical device is repeatedly inserted and removed, its ID changes.| +| callback | AsyncCallback<[KeyboardType](#keyboardtype)> | Yes | Callback used to return the result. | + +**Example** + +```js +// Query the keyboard type of the input device whose ID is 1. +inputDevice.getKeyboardType(1, (ret)=>{ + console.log("The keyboard type of the device is: " + ret); +}); +``` + +## inputDevice.getKeyboardType9+ + +getKeyboardType(deviceId: number,): Promise<KeyboardType>; + +Obtains the keyboard type of an input device. This API uses a promise to return the result. + +**System capability**: SystemCapability.MultimodalInput.Input.InputDevice + +**Return value** + +| Parameter | Description | +| ---------------------------------------- | ------------------- | +| Promise<[KeyboardType](#keyboardtype)> | Promise used to return the result.| + +**Example** + +```js +// Query the keyboard type of the input device whose ID is 1. +inputDevice.getKeyboardType(1).then((ret)=>{ + console.log("The keyboard type of the device is: " + ret); +}) +``` + +## DeviceListener9+ Defines the information about an input device. **System capability**: SystemCapability.MultimodalInput.Input.InputDevice -| Name | Type | Description | -| ---------- | -------------------------- | ---------------------------------------------------- | -| id | number | Unique identifier of an input device. If the same physical device is repeatedly inserted and removed, its ID changes. | -| name | string | Name of the input device. | -| sources | Array<[SourceType](#sourcetype)> | Source types of the input device. For example, if a keyboard is attached with a touchpad, the device has two input sources: keyboard and touchpad. | -| axisRanges | Array<[axisRanges](#axisrange)> | Axis information of the input device. | -| bus | number | Bus type of the input device. | -| product | number | Product information of the input device. | -| vendor | number | Vendor information of the input device. | -| version | number | Version information of the input device. | -| phys | string | Physical address of the input device. | -| uniq | string | Unique ID of the input device. | +| Name | Type | Description | +| -------- | ------------------------- | --------------------------------- | +| type | [ChangeType](#changetype) | Device change type, which indicates whether an input device is inserted or removed. | +| deviceId | number | Unique ID of the input device. If the same physical device is repeatedly inserted and removed, its ID changes.| -## AxisType +## InputDeviceData -Defines the axis type of an input device, which is **NULL**. +Defines the information about an input device. -## AxisRange +**System capability**: SystemCapability.MultimodalInput.Input.InputDevice + +| Name | Type | Description | +| -------------------- | -------------------------------------- | ---------------------------------------- | +| id | number | Unique ID of the input device. If the same physical device is repeatedly inserted and removed, its ID changes. | +| name | string | Name of the input device. | +| sources | Array<[SourceType](#sourcetype)> | Source type of the input device. For example, if a keyboard is attached with a touchpad, the device has two input sources: keyboard and touchpad.| +| axisRanges | Array<[axisRanges](#axisrange)> | Axis information of the input device. | +| bus9+ | number | Bus type of the input device. | +| product9+ | number | Product information of the input device. | +| vendor9+ | number | Vendor information of the input device. | +| version9+ | number | Version information of the input device. | +| phys9+ | string | Physical address of the input device. | +| uniq9+ | string | Unique ID of the input device. | + +## AxisType9+ -Defines the axis information of an input device. +Defines the axis type of an input device. **System capability**: SystemCapability.MultimodalInput.Input.InputDevice -| Name | Type | Description | -| ------ | ------------------------- | -------- | -| source | [SourceType](#sourcetype) | Input source type of the axis.| -| axis | [AxisType](axistype) | Axis type. | -| max | number | Maximum value reported by the axis. | -| min | number | Minimum value reported by the axis. | +| Name | Type | Description | +| ----------- | ------ | --------------- | +| touchMajor | string | touchMajor axis. | +| touchMinor | string | touchMinor axis. | +| toolMinor | string | toolMinor axis. | +| toolMajor | string | toolMajor axis. | +| orientation | string | Orientation axis.| +| pressure | string | Pressure axis. | +| x | string | X axis. | +| y | string | Y axis. | +| NULL | string | None. | +## AxisRange + +Defines the axis range of an input device. + +**System capability**: SystemCapability.MultimodalInput.Input.InputDevice +| Name | Type | Description | +| ----------------------- | ------------------------- | -------- | +| source | [SourceType](#sourcetype) | Input source type of the axis.| +| axis | [AxisType](#axistype) | Axis type. | +| max | number | Maximum value of the axis. | +| min | number | Minimum value of the axis. | +| fuzz9+ | number | Fuzzy value of the axis. | +| flat9+ | number | Benchmark value of the axis. | +| resolution9+ | number | Resolution of the axis. | ## SourceType @@ -211,3 +357,29 @@ Enumerates the input source types. For example, if a mouse reports an x-axis eve | trackball | string | The input device is a trackball.| | touchpad | string | The input device is a touchpad.| | joystick | string | The input device is a joystick.| + +## ChangeType + +Defines the change type for the hot swap event of an input device. + +**System capability**: SystemCapability.MultimodalInput.Input.InputDevice + +| Name | Type | Description | +| ------ | ------ | --------- | +| add | string | An input device is inserted.| +| remove | string | An input device is removed.| + +## KeyboardType9+ + +Enumerates the keyboard types. + +**System capability**: SystemCapability.MultimodalInput.Input.InputDevice + +| Name | Type | Value | Description | +| ------------------- | ------ | ---- | --------- | +| NONE | number | 0 | Keyboard without keys. | +| UNKNOWN | number | 1 | Keyboard with unknown keys.| +| ALPHABETIC_KEYBOARD | number | 2 | Full keyboard. | +| DIGITAL_KEYBOARD | number | 3 | Keypad. | +| HANDWRITING_PEN | number | 4 | Stylus. | +| REMOTE_CONTROL | number | 5 | Remote control. | diff --git a/en/application-dev/reference/apis/js-apis-list.md b/en/application-dev/reference/apis/js-apis-list.md index dfd940b660fe213cf114a7a2b3391c75eb608c5e..0b839a5a0baae3fa58e4592485c3b9e959183530 100644 --- a/en/application-dev/reference/apis/js-apis-list.md +++ b/en/application-dev/reference/apis/js-apis-list.md @@ -364,10 +364,10 @@ list.add(2); list.add(4); list.add(5); list.add(4); -list.replaceAllElements((value, index) => { +list.replaceAllElements((value: number, index: number) => { return value = 2 * value; }); -list.replaceAllElements((value, index) => { +list.replaceAllElements((value: number, index: number) => { return value = value - 2; }); ``` @@ -439,8 +439,8 @@ list.add(2); list.add(4); list.add(5); list.add(4); -list.sort((a, b) => a - b); -list.sort((a, b) => b - a); +list.sort((a: number, b: number) => a - b); +list.sort((a: number, b: number) => b - a); ``` ### getSubList @@ -472,9 +472,9 @@ list.add(2); list.add(4); list.add(5); list.add(4); -let result = list.subList(2, 4); -let result1 = list.subList(4, 3); -let result2 = list.subList(2, 6); +let result = list.getSubList(2, 4); +let result1 = list.getSubList(4, 3); +let result2 = list.getSubList(2, 6); ``` ### clear diff --git a/en/application-dev/reference/apis/js-apis-mediaquery.md b/en/application-dev/reference/apis/js-apis-mediaquery.md index 1f1f8526fb73fcd6d460b3f5502b82bac160186c..2f052176253fbbe14159bb8551aecbce13cc7de2 100644 --- a/en/application-dev/reference/apis/js-apis-mediaquery.md +++ b/en/application-dev/reference/apis/js-apis-mediaquery.md @@ -1,6 +1,7 @@ # Media Query -> ![icon-note.gif](public_sys-resources/icon-note.gif)**NOTE** +> **NOTE** +> > The APIs of this module are supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. @@ -22,19 +23,21 @@ matchMediaSync(condition: string): MediaQueryListener Sets the media query criteria and returns the corresponding listening handle. -- Parameters - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | condition | string | Yes| Matching condition of a media event.| +**System capability**: SystemCapability.ArkUI.ArkUI.Full -- Return value - | Type| Description| - | -------- | -------- | - | MediaQueryListener | Listening handle to a media event, which is used to register or unregister the listening callback.| +**Parameters** +| Name | Type | Mandatory | Description | +| --------- | ------ | ---- | ---------------------------------------- | +| condition | string | Yes | Matching condition of a media event. For details, see [Syntax of Media Query Conditions](../../ui/ui-ts-layout-mediaquery.md#syntax-of-media-query-conditions).| -- Example +**Return value** +| Type | Description | +| ------------------ | ---------------------- | +| MediaQueryListener | Listening handle to a media event, which is used to register or deregister the listening callback.| + +**Example** ```js -let listener = mediaquery.matchMediaSync('(orientation: landscape)'); // Listen for landscape events. +listener = mediaquery.matchMediaSync('(orientation: landscape)'); // Listen for landscape events. ``` @@ -42,13 +45,14 @@ let listener = mediaquery.matchMediaSync('(orientation: landscape)'); // Listen Media query handle, including the first query result when the handle is applied for. +**System capability**: SystemCapability.ArkUI.ArkUI.Full ### Attributes -| Name| Type| Readable| Writable| Description| -| -------- | -------- | -------- | -------- | -------- | -| matches | boolean | Yes| No| Whether the match condition is met.| -| media | string | Yes| No| Matching condition of a media event.| +| Name | Type | Readable | Writable | Description | +| ------- | ------- | ---- | ---- | ---------- | +| matches | boolean | Yes | No | Whether the match condition is met. | +| media | string | Yes | No | Matching condition of a media event.| ### on @@ -57,13 +61,15 @@ on(type: 'change', callback: Callback<MediaQueryResult>): void Registers a callback with the corresponding query condition by using the handle. This callback is triggered when the media attributes change. -- Parameters - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | type | string | Yes| Must enter the string **change**.| - | callback | Callback<MediaQueryResult> | Yes| Callback registered with media query.| +**System capability**: SystemCapability.ArkUI.ArkUI.Full + +**Parameters** +| Name | Type | Mandatory | Description | +| -------- | -------------------------------- | ---- | ---------------- | +| type | string | Yes | Must enter the string **change**.| +| callback | Callback<MediaQueryResult> | Yes | Callback registered with media query. | -- Example +**Example** For details, see [off Example](#off). @@ -71,18 +77,21 @@ Registers a callback with the corresponding query condition by using the handle. off(type: 'change', callback?: Callback<MediaQueryResult>): void -Unregisters a callback with the corresponding query condition by using the handle, so that no callback is triggered when the media attributes change. -- Parameters - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | type | boolean | Yes| Must enter the string **change**.| - | callback | Callback<MediaQueryResult> | No| Callback to be unregistered. If the default value is used, all callbacks of the handle are unregistered.| +Deregisters a callback with the corresponding query condition by using the handle, so that no callback is triggered when the media attributes change. + +**System capability**: SystemCapability.ArkUI.ArkUI.Full + +**Parameters** +| Name | Type | Mandatory | Description | +| -------- | -------------------------------- | ---- | ----------------------------- | +| type | boolean | Yes | Must enter the string **change**. | +| callback | Callback<MediaQueryResult> | No | Callback to be deregistered. If the default value is used, all callbacks of the handle are deregistered.| -- Example +**Example** ```js import mediaquery from '@ohos.mediaquery' - let listener = mediaquery.matchMediaSync('(orientation: landscape)'); // Listen for landscape events. + listener = mediaquery.matchMediaSync('(orientation: landscape)'); // Listen for landscape events. function onPortrait(mediaQueryResult) { if (mediaQueryResult.matches) { // do something here @@ -91,7 +100,7 @@ Unregisters a callback with the corresponding query condition by using the handl } } listener.on('change', onPortrait) // Register a callback. - listener.off('change', onPortrait) // Unregister a callback. + listener.off('change', onPortrait) // Deregister a callback. ``` @@ -100,10 +109,10 @@ Unregisters a callback with the corresponding query condition by using the handl ### Attributes -| Name| Type| Readable| Writable| Description| -| -------- | -------- | -------- | -------- | -------- | -| matches | boolean | Yes| No| Whether the match condition is met.| -| media | string | Yes| No| Matching condition of a media event.| +| Name | Type | Readable | Writable | Description | +| ------- | ------- | ---- | ---- | ---------- | +| matches | boolean | Yes | No | Whether the match condition is met. | +| media | string | Yes | No | Matching condition of a media event.| ### Example diff --git a/en/application-dev/reference/apis/js-apis-pasteboard.md b/en/application-dev/reference/apis/js-apis-pasteboard.md index c5ca90fd33c1de4b2eb4f4fff33eee5e2d899a79..3dc7bd863f5aaa22245bb2c779b6c426e065f49e 100644 --- a/en/application-dev/reference/apis/js-apis-pasteboard.md +++ b/en/application-dev/reference/apis/js-apis-pasteboard.md @@ -1,7 +1,7 @@ # Pasteboard -> ![icon-note.gif](public_sys-resources/icon-note.gif) **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. > @@ -48,9 +48,9 @@ Creates a **PasteData** object for plain text. **Example** -```js -var pasteData = pasteboard.createPlainTextData("content"); -``` + ```js + var pasteData = pasteboard.createPlainTextData("content"); + ``` ## pasteboard.createHtmlData7+ @@ -75,10 +75,10 @@ Creates a **PasteData** object for HTML text. **Example** -```js -var html = "\n" + "\n" + "\n" + "\n" + "HTML-PASTEBOARD_HTML\n" + "\n" + "\n" + "

HEAD

\n" + "

\n" + "\n" + ""; -var pasteData = pasteboard.createHtmlData(html); -``` + ```js + var html = "\n" + "\n" + "\n" + "\n" + "HTML-PASTEBOARD_HTML\n" + "\n" + "\n" + "

HEAD

\n" + "

\n" + "\n" + ""; + var pasteData = pasteboard.createHtmlData(html); + ``` ## pasteboard.createWantData7+ @@ -103,13 +103,13 @@ Creates a **PasteData** object for Want text. **Example** -```js -var object = { - bundleName: "com.example.aafwk.test", - abilityName: "com.example.aafwk.test.TwoAbility" -}; -var pasteData = pasteboard.createWantData(object); -``` + ```js + var object = { + bundleName: "com.example.aafwk.test", + abilityName: "com.example.aafwk.test.TwoAbility" + }; + var pasteData = pasteboard.createWantData(object); + ``` ## pasteboard.createUriData7+ @@ -134,9 +134,9 @@ Creates a **PasteData** object for URI text. **Example** -```js -var pasteData = pasteboard.createUriData("dataability:///com.example.myapplication1?user.txt"); -``` + ```js + var pasteData = pasteboard.createUriData("dataability:///com.example.myapplication1?user.txt"); + ``` ## pasteboard.createPlainTextRecord7+ @@ -161,9 +161,9 @@ Creates a **PasteDataRecord** object of the plain text type. **Example** -```js -var record = pasteboard.createPlainTextRecord("hello"); -``` + ```js + var record = pasteboard.createPlainTextRecord("hello"); + ``` ## pasteboard.createHtmlTextRecord7+ @@ -188,10 +188,10 @@ Creates a **PasteDataRecord** object of the HTML text type. **Example** -```js -var html = "\n" + "\n" + "\n" + "\n" + "HTML-PASTEBOARD_HTML\n" + "\n" + "\n" + "

HEAD

\n" + "

\n" + "\n" + ""; -var record = pasteboard.createHtmlTextRecord(html); -``` + ```js + var html = "\n" + "\n" + "\n" + "\n" + "HTML-PASTEBOARD_HTML\n" + "\n" + "\n" + "

HEAD

\n" + "

\n" + "\n" + ""; + var record = pasteboard.createHtmlTextRecord(html); + ``` ## pasteboard.createWantRecord7+ @@ -216,13 +216,13 @@ Creates a **PasteDataRecord** object of the Want text type. **Example** -```js -var object = { - bundleName: "com.example.aafwk.test", - abilityName: "com.example.aafwk.test.TwoAbility" -}; -var record = pasteboard.createWantRecord(object); -``` + ```js + var object = { + bundleName: "com.example.aafwk.test", + abilityName: "com.example.aafwk.test.TwoAbility" + }; + var record = pasteboard.createWantRecord(object); + ``` ## pasteboard.createUriRecord7+ @@ -247,9 +247,9 @@ Creates a **PasteDataRecord** object of the URI text type. **Example** -```js -var record = pasteboard.createUriRecord("dataability:///com.example.myapplication1?user.txt"); -``` + ```js + var record = pasteboard.createUriRecord("dataability:///com.example.myapplication1?user.txt"); + ``` ## PasteDataProperty7+ @@ -301,14 +301,14 @@ Forcibly converts the content in this **PasteData** object to the plain text. Th **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)); -}); -``` + ```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+ @@ -327,16 +327,16 @@ Forcibly converts the content in this **PasteData** object to the plain text. Th **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)); -}); -``` + ```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 @@ -366,10 +366,10 @@ Obtains the plain text of the primary record. **Example** -```js -var pasteData = pasteboard.createPlainTextData("hello"); -var plainText = pasteData.getPrimaryText(); -``` + ```js + var pasteData = pasteboard.createPlainTextData("hello"); + var plainText = pasteData.getPrimaryText(); + ``` ### getPrimaryHtml7+ @@ -388,11 +388,11 @@ Obtains the HTML text of the primary record. **Example** -```js -var html = "\n" + "\n" + "\n" + "\n" + "HTML-PASTEBOARD_HTML\n" + "\n" + "\n" + "

HEAD

\n" + "

\n" + "\n" + ""; -var pasteData = pasteboard.createHtmlData(html); -var htmlText = pasteData.getPrimaryHtml(); -``` + ```js + var html = "\n" + "\n" + "\n" + "\n" + "HTML-PASTEBOARD_HTML\n" + "\n" + "\n" + "

HEAD

\n" + "

\n" + "\n" + ""; + var pasteData = pasteboard.createHtmlData(html); + var htmlText = pasteData.getPrimaryHtml(); + ``` ### getPrimaryWant7+ @@ -411,14 +411,14 @@ Obtains the **Want** object of the primary record. **Example** -```js -var object = { - bundleName: "com.example.aafwk.test", - abilityName: "com.example.aafwk.test.TwoAbility" -}; -var pasteData = pasteboard.createWantData(object); -var want = pasteData.getPrimaryWant(); -``` + ```js + var object = { + bundleName: "com.example.aafwk.test", + abilityName: "com.example.aafwk.test.TwoAbility" + }; + var pasteData = pasteboard.createWantData(object); + var want = pasteData.getPrimaryWant(); + ``` ### getPrimaryUri7+ @@ -437,10 +437,10 @@ Obtains the URI text of the primary record. **Example** -```js -var pasteData = pasteboard.createUriData("dataability:///com.example.myapplication1?user.txt"); -var uri = pasteData.getPrimaryUri(); -``` + ```js + var pasteData = pasteboard.createUriData("dataability:///com.example.myapplication1?user.txt"); + var uri = pasteData.getPrimaryUri(); + ``` ### addTextRecord7+ @@ -461,10 +461,10 @@ The pasteboard supports a maximum number of 128 data records. **Example** -```js -var pasteData = pasteboard.createPlainTextData("hello"); -pasteData.addTextRecord("good"); -``` + ```js + var pasteData = pasteboard.createPlainTextData("hello"); + pasteData.addTextRecord("good"); + ``` ### addHtmlRecord7+ @@ -485,11 +485,11 @@ The pasteboard supports a maximum number of 128 data records. **Example** -```js -var pasteData = pasteboard.createPlainTextData("hello"); -var html = "\n" + "\n" + "\n" + "\n" + "HTML-PASTEBOARD_HTML\n" + "\n" + "\n" + "

HEAD

\n" + "

\n" + "\n" + ""; -pasteData.addHtmlRecord(html); -``` + ```js + var pasteData = pasteboard.createPlainTextData("hello"); + var html = "\n" + "\n" + "\n" + "\n" + "HTML-PASTEBOARD_HTML\n" + "\n" + "\n" + "

HEAD

\n" + "

\n" + "\n" + ""; + pasteData.addHtmlRecord(html); + ``` ### addWantRecord7+ @@ -510,14 +510,14 @@ The pasteboard supports a maximum number of 128 data records. **Example** -```js -var pasteData = pasteboard.createPlainTextData("hello"); -var object = { - bundleName: "com.example.aafwk.test", - abilityName: "com.example.aafwk.test.TwoAbility" -}; -pasteData.addWantRecord(object); -``` + ```js + var pasteData = pasteboard.createPlainTextData("hello"); + var object = { + bundleName: "com.example.aafwk.test", + abilityName: "com.example.aafwk.test.TwoAbility" + }; + pasteData.addWantRecord(object); + ``` ### addUriRecord7+ @@ -538,10 +538,10 @@ The pasteboard supports a maximum number of 128 data records. **Example** -```js -var pasteData = pasteboard.createPlainTextData("hello"); -pasteData.addUriRecord("dataability:///com.example.myapplication1?user.txt"); -``` + ```js + var pasteData = pasteboard.createPlainTextData("hello"); + pasteData.addUriRecord("dataability:///com.example.myapplication1?user.txt"); + ``` ### addRecord7+ @@ -562,14 +562,14 @@ The pasteboard supports a maximum number of 128 data records. **Example** -```js -var pasteData = pasteboard.createUriData("dataability:///com.example.myapplication1?user.txt"); -var textRecord = pasteboard.createPlainTextRecord("hello"); -var html = "\n" + "\n" + "\n" + "\n" + "HTML-PASTEBOARD_HTML\n" + "\n" + "\n" + "

HEAD

\n" + "

\n" + "\n" + ""; -var htmlRecord = pasteboard.createHtmlTextRecord(html); -pasteData.addRecord(textRecord); -pasteData.addRecord(htmlRecord); -``` + ```js + var pasteData = pasteboard.createUriData("dataability:///com.example.myapplication1?user.txt"); + var textRecord = pasteboard.createPlainTextRecord("hello"); + var html = "\n" + "\n" + "\n" + "\n" + "HTML-PASTEBOARD_HTML\n" + "\n" + "\n" + "

HEAD

\n" + "

\n" + "\n" + ""; + var htmlRecord = pasteboard.createHtmlTextRecord(html); + pasteData.addRecord(textRecord); + pasteData.addRecord(htmlRecord); + ``` ### getMimeTypes7+ @@ -588,10 +588,10 @@ Obtains **mimeTypes** in [PasteDataProperty](#pastedataproperty7) from this past **Example** -```js -var pasteData = pasteboard.createPlainTextData("hello"); -var types = pasteData.getMimeTypes(); -``` + ```js + var pasteData = pasteboard.createPlainTextData("hello"); + var types = pasteData.getMimeTypes(); + ``` ### getPrimaryMimeType7+ @@ -610,10 +610,10 @@ Obtains the data type of the primary record. **Example** -```js -var pasteData = pasteboard.createPlainTextData("hello"); -var type = pasteData.getPrimaryMimeType(); -``` + ```js + var pasteData = pasteboard.createPlainTextData("hello"); + var type = pasteData.getPrimaryMimeType(); + ``` ### getProperty7+ @@ -632,10 +632,10 @@ Obtains the property description object. **Example** -```js -var pasteData = pasteboard.createPlainTextData("hello"); -var property = pasteData.getProperty(); -``` + ```js + var pasteData = pasteboard.createPlainTextData("hello"); + var property = pasteData.getProperty(); + ``` ### getRecordAt7+ @@ -660,10 +660,10 @@ Obtains the record with the specified index. **Example** -```js -var pasteData = pasteboard.createPlainTextData("hello"); -var record = pasteData.getRecordAt(0); -``` + ```js + var pasteData = pasteboard.createPlainTextData("hello"); + var record = pasteData.getRecordAt(0); + ``` ### getRecordCount7+ @@ -682,10 +682,10 @@ Obtains the number of data records in this pasteboard. **Example** -```js -var pasteData = pasteboard.createPlainTextData("hello"); -var count = pasteData.getRecordCount(); -``` + ```js + var pasteData = pasteboard.createPlainTextData("hello"); + var count = pasteData.getRecordCount(); + ``` ### getTag7+ @@ -704,10 +704,10 @@ Obtains the user-defined tag content. If the tag content is not set, null is ret **Example** -```js -var pasteData = pasteboard.createPlainTextData("hello"); -var tag = pasteData.getTag(); -``` + ```js + var pasteData = pasteboard.createPlainTextData("hello"); + var tag = pasteData.getTag(); + ``` ### hasMimeType7+ @@ -732,10 +732,10 @@ Checks whether the content of this pasteboard contains the specified data type. **Example** -```js -var pasteData = pasteboard.createPlainTextData("hello"); -var hasType = pasteData.hasMimeType(pasteboard.MIMETYPE_TEXT_PLAIN); -``` + ```js + var pasteData = pasteboard.createPlainTextData("hello"); + var hasType = pasteData.hasMimeType(pasteboard.MIMETYPE_TEXT_PLAIN); + ``` ### removeRecordAt7+ @@ -760,10 +760,10 @@ Removes the data record with a specified index from this pasteboard. **Example** -```js -var pasteData = pasteboard.createPlainTextData("hello"); -var isRemove = pasteData.removeRecordAt(0); -``` + ```js + var pasteData = pasteboard.createPlainTextData("hello"); + var isRemove = pasteData.removeRecordAt(0); + ``` ### replaceRecordAt7+ @@ -789,11 +789,11 @@ Replaces the data record with a specified index in this pasteboard. **Example** -```js -var pasteData = pasteboard.createPlainTextData("hello"); -var record = pasteboard.createUriRecord("dataability:///com.example.myapplication1?user.txt"); -var isReplace = pasteData.replaceRecordAt(0, record); -``` + ```js + var pasteData = pasteboard.createPlainTextData("hello"); + var record = pasteboard.createUriRecord("dataability:///com.example.myapplication1?user.txt"); + var isReplace = pasteData.replaceRecordAt(0, record); + ``` ## pasteboard.getSystemPasteboard @@ -812,9 +812,9 @@ Obtains the system pasteboard. **Example** -```js -var systemPasteboard = pasteboard.getSystemPasteboard(); -``` + ```js + var systemPasteboard = pasteboard.getSystemPasteboard(); + ``` ## SystemPasteboard @@ -843,17 +843,17 @@ Writes data to a pasteboard. This API uses an asynchronous callback to return th **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.'); -}); -``` + ```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 @@ -878,15 +878,15 @@ Writes data to a pasteboard. This API uses a promise to return the 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); -}); -``` + ```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 @@ -905,16 +905,16 @@ Reads the system pasteboard content. This API uses an asynchronous callback to r **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(); -}); -``` + ```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 @@ -933,14 +933,14 @@ Reads the system pasteboard content. This API uses a promise to return the resul **Example** -```js -var systemPasteboard = pasteboard.getSystemPasteboard(); -systemPasteboard.getPasteData().then((pasteData) => { - var text = pasteData.getPrimaryText(); -}).catch((error) => { - console.error('Failed to getPasteData. Cause: ' + error.message); -}) -``` + ```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+ @@ -960,18 +960,18 @@ Subscribes to the content change event of the system pasteboard. If the pasteboa **Example** -```js -var systemPasteboard = pasteboard.getSystemPasteboard(); -var listener = ()=>{ - console.info('The system pasteboard has changed'); -}; -systemPasteboard.on('update', listener); -``` + ```js + var systemPasteboard = pasteboard.getSystemPasteboard(); + var listener = () => { + console.info('The system pasteboard has changed'); + }; + systemPasteboard.on('update', listener); + ``` ### off('update')7+ -off(type: 'update', callback? : () =>void ): void +off(type: 'update', callback?: () =>void ): void Unsubscribes from the system pasteboard content change event. @@ -986,9 +986,12 @@ Unsubscribes from the system pasteboard content change event. **Example** -```js -systemPasteboard.off('update', listener); -``` + ```js + let listener = () => { + console.info('The system pasteboard has changed'); + }; + systemPasteboard.off('update', listener); + ``` ### hasPasteData7+ @@ -1007,15 +1010,15 @@ Checks whether the system pasteboard contains content. This API uses an asynchro **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)); -}); -``` + ```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+ @@ -1059,15 +1062,15 @@ Clears the system pasteboard content. This API uses an asynchronous callback to **Example** -```js -systemPasteboard.clear((err, data) => { - if (err) { - console.error('failed to clear because ' + JSON.stringify(err)); - return; - } - console.info('success clear'); -}); -``` + ```js + systemPasteboard.clear((err, data) => { + if (err) { + console.error('failed to clear because ' + JSON.stringify(err)); + return; + } + console.info('success clear'); + }); + ``` ### clear7+ @@ -1086,10 +1089,10 @@ Clears the system pasteboard content. This API uses a promise to return the resu **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 + ```js + systemPasteboard.clear().then((data) => { + console.info('success clear'); + }).catch((error) => { + console.error('failed to clear because ' + JSON.stringify(error)); + }); + ``` diff --git a/en/application-dev/reference/apis/js-apis-router.md b/en/application-dev/reference/apis/js-apis-router.md index b17d29151d7c1c9a9ee53de976cd4c0f77ea838a..40076077bd258dab549dbcb46e16a7137961c107 100644 --- a/en/application-dev/reference/apis/js-apis-router.md +++ b/en/application-dev/reference/apis/js-apis-router.md @@ -1,6 +1,6 @@ # Page Routing -> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**
+> **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. > - Page routing APIs can be invoked only after page rendering is complete. Do not call the APIs in **onInit** and **onReady** when the page is still in the rendering phase. @@ -190,6 +190,8 @@ getLength(): string Obtains the number of pages in the current stack. +**System capability**: SystemCapability.ArkUI.ArkUI.Full + **Return value** | Type| Description| | -------- | -------- | @@ -275,7 +277,7 @@ Enables the display of a confirm dialog box before returning to the previous pag Describes the confirm dialog box. -**System capability**: SystemCapability.ArkUI.ArkUI.Lite +**System capability**: SystemCapability.ArkUI.ArkUI.Full | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | diff --git a/en/application-dev/reference/apis/js-apis-screenshot.md b/en/application-dev/reference/apis/js-apis-screenshot.md index 573909893ea8c182e91b739d753a2f36bf244d16..5e2d47e03ba31ab4bae9118e3dc373359d56da11 100644 --- a/en/application-dev/reference/apis/js-apis-screenshot.md +++ b/en/application-dev/reference/apis/js-apis-screenshot.md @@ -1,8 +1,11 @@ # Screenshot +Provides APIs for you to set information such as the region to capture and the size of the screen region when capturing a screen. > **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. +> +> The APIs provided by this module are system APIs. ## Modules to Import @@ -17,11 +20,12 @@ Describes screenshot options. **System capability**: SystemCapability.WindowManager.WindowManager.Core -| Name | Type | Mandatory| Description | -| ---------- | ------------- | ---- | ------------------------------------------------------------ | -| screenRect | [Rect](#rect) | No | Region of the screen to capture. If this parameter is null, the full screen will be captured.| -| imageSize | [Size](#size) | No | Size of the screen region to capture. If this parameter is null, the full screen will be captured.| -| rotation | number | No | Rotation angle of the screenshot. Currently, the value can be **0** only. The default value is **0**.| +| Name | Type | Mandatory| Description | +| ---------------------- | ------------- | ---- | ------------------------------------------------------------ | +| screenRect | [Rect](#rect) | No | Region of the screen to capture. If this parameter is null, the full screen will be captured. | +| imageSize | [Size](#size) | No | Size of the screen region to capture. If this parameter is null, the full screen will be captured. | +| rotation | number | No | Rotation angle of the screenshot. Currently, the value can be **0** only. The default value is **0**. | +| displayId8+ | number | No | ID of the [display](js-apis-display.md#display) device on which the screen region is to be captured.| ## Rect @@ -63,7 +67,7 @@ Takes a screenshot and saves it as a **PixelMap** object. This method uses a cal | Name | Type | Mandatory| Description | | -------- | --------------------------------------- | ---- | ------------------------------------------------------------ | -| options | [ScreenshotOptions](#screenshotoptions) | No | Screenshot options, which consist of **screenRect**, **imageSize**, and **rotation**. You need to set these parameters.| +| options | [ScreenshotOptions](#screenshotoptions) | No | Consists of **screenRect**, **imageSize**, **rotation**, and **displayId**. You can set them separately.| | callback | AsyncCallback<image.PixelMap> | Yes | Callback used to return a **PixelMap** object. | **Example** @@ -78,7 +82,8 @@ Takes a screenshot and saves it as a **PixelMap** object. This method uses a cal "imageSize": { "width": 300, "height": 300}, - "rotation": 0 + "rotation": 0, + "displayId": 0 }; screenshot.save(ScreenshotOptions, (err, data) => { if (err) { @@ -103,13 +108,13 @@ Takes a screenshot and saves it as a **PixelMap** object. This method uses a pro | Name | Type | Mandatory| Description | | ------- | --------------------------------------- | ---- | ------------------------------------------------------------ | -| options | [ScreenshotOptions](#screenshotoptions) | No | Screenshot options, which consist of **screenRect**, **imageSize**, and **rotation**. You need to set these parameters.| +| options | [ScreenshotOptions](#screenshotoptions) | No | Consists of **screenRect**, **imageSize**, **rotation**, and **displayId**. You can set them separately.| **Return value** | Type | Description | | ----------------------------- | ----------------------------------------------- | -| Promise<image.PixelMap> | Promise used to return an **image.PixelMap** object.| +| Promise<image.PixelMap> | Promise used to return a **PixelMap** object.| **Example** @@ -123,7 +128,8 @@ Takes a screenshot and saves it as a **PixelMap** object. This method uses a pro "imageSize": { "width": 300, "height": 300}, - "rotation": 0 + "rotation": 0, + "displayId": 0 }; let promise = screenshot.save(ScreenshotOptions); promise.then(() => { diff --git a/en/application-dev/reference/apis/js-apis-system-bluetooth.md b/en/application-dev/reference/apis/js-apis-system-bluetooth.md index 27223da59dd798215ff27a2a6bad0f49282097c9..9f2ef61d8465f220a97884f3097c43b203e07b80 100644 --- a/en/application-dev/reference/apis/js-apis-system-bluetooth.md +++ b/en/application-dev/reference/apis/js-apis-system-bluetooth.md @@ -1,7 +1,7 @@ # Bluetooth -> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**
+> **NOTE**
> > - The APIs of this module are no longer maintained since API version 7. You are advised to use [`@ohos.bluetooth`](js-apis-bluetooth.md). > @@ -15,7 +15,6 @@ import bluetooth from '@system.bluetooth'; ``` - ## bluetooth.startBLEScan(OBJECT) Scans for Bluetooth Low Energy (BLE) devices nearby. This operation consumes system resources. Call [bluetooth.stopBLEScan](#bluetoothstopblescanobject) to stop the scan after a BLE device is detected and connected. @@ -25,7 +24,6 @@ Scans for Bluetooth Low Energy (BLE) devices nearby. This operation consumes sys **System capability**: SystemCapability.Communication.Bluetooth.Lite **Parameters** - **Table 1** StartBLEScanOptions | Name| Type| Mandatory| Description| @@ -61,7 +59,6 @@ Stops scanning for BLE devices nearby. This API is used with [bluetooth.startBLE **System capability**: SystemCapability.Communication.Bluetooth.Lite **Parameters** - **Table 2** StopBLEScanOptions | Name| Type| Mandatory| Description| @@ -74,6 +71,7 @@ Stops scanning for BLE devices nearby. This API is used with [bluetooth.startBLE ``` bluetooth.stopBLEScan({ + interval:0, success() { console.log('call bluetooth.stopBLEScan success.'); }, @@ -96,7 +94,6 @@ Subscribes to the newly detected BLE device. If this API is called multiple time **System capability**: SystemCapability.Communication.Bluetooth.Lite **Parameters** - **Table 3** SubscribeBLEFoundOptions | Name| Type| Mandatory| Description| @@ -123,7 +120,7 @@ Subscribes to the newly detected BLE device. If this API is called multiple time **Example** ``` - bluetooth.startaBLEScan({ + bluetooth.startBLEScan({ success() { bluetooth.subscribeBLEFound({ success(data) { diff --git a/en/application-dev/reference/apis/js-apis-system-parameter.md b/en/application-dev/reference/apis/js-apis-system-parameter.md index c111c6c2cbfa5e809816b3246a28ac8114e35f76..73735820c91a554fc8ea5a5dc14e9ef241327736 100644 --- a/en/application-dev/reference/apis/js-apis-system-parameter.md +++ b/en/application-dev/reference/apis/js-apis-system-parameter.md @@ -1,6 +1,6 @@ # System Parameter -> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** +> **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. > - This is a system API and cannot be called by third-party applications. @@ -203,9 +203,9 @@ try { ``` -## parameter.set(key: string, def?: string) +## parameter.set -set(key: string, def?: string): Promise<string> +set(key: string, value: string): Promise<void> Sets a value for the attribute with the specified key. This API uses a promise to return the result. @@ -222,7 +222,7 @@ Sets a value for the attribute with the specified key. This API uses a promise t | Type| Description| | -------- | -------- | -| Promise<string> | Promise used to return the execution result.| +| Promise<void> | Promise used to return the execution result.| **Example** 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 74beca3c0aacbabd628f99f7987b96caf5988f61..b61e69a07cf8ddf5d1d72a7e49c888ca71e2002d 100644 --- a/en/application-dev/reference/apis/js-apis-system-time.md +++ b/en/application-dev/reference/apis/js-apis-system-time.md @@ -1,7 +1,7 @@ # Setting the System Time -> ![icon-note.gif](public_sys-resources/icon-note.gif) **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. -> +This module is used to set and obtain the current system date, time, and time zone. +> **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 @@ -189,7 +189,7 @@ Obtains the time elapsed since system start, excluding the deep sleep time. This **Example** ```js - systemTime.getCurrentTime().then((data) => { + systemTime.getRealActiveTime().then((data) => { console.log(`systemTime.getRealActiveTime success data : ` + JSON.stringify(data)); }).catch((error) => { console.error(`failed to systemTime.getRealActiveTime because ` + JSON.stringify(error)); diff --git a/en/application-dev/reference/apis/js-apis-update.md b/en/application-dev/reference/apis/js-apis-update.md index 251c1d59b610f4d01372186d0e40d0521cf62ca8..cba0c8a1ce4f475c5b60964ba37c8beee9454fc7 100644 --- a/en/application-dev/reference/apis/js-apis-update.md +++ b/en/application-dev/reference/apis/js-apis-update.md @@ -134,11 +134,11 @@ Obtains the new version information. This function uses an asynchronous callback **Example** ``` -updater.getNewVersionInfo(info => { +updater.getNewVersionInfo((err, info) => { console.log("getNewVersionInfo success " + info.status); - console.log(`info versionName = ` + info.checkResult[0].versionName); - console.log(`info versionCode = ` + info.checkResult[0].versionCode); - console.log(`info verifyInfo = ` + info.checkResult[0].verifyInfo); + console.log(`info versionName = ` + info.checkResults[0].versionName); + console.log(`info versionCode = ` + info.checkResults[0].versionCode); + console.log(`info verifyInfo = ` + info.checkResults[0].verifyInfo); }); ``` @@ -160,9 +160,9 @@ Obtains the new version information. This function uses a promise to return the ``` updater.getNewVersionInfo().then(value => { - console.log(`info versionName = ` + value.checkResult[0].versionName); - console.log(`info versionCode = ` + value.checkResult[0].versionCode); - console.log(`info verifyInfo = ` + value.checkResult[0].verifyInfo); + console.log(`info versionName = ` + value.checkResults[0].versionName); + console.log(`info versionCode = ` + value.checkResults[0].versionCode); + console.log(`info verifyInfo = ` + value.checkResults[0].verifyInfo); }).catch(err => { console.log("getNewVersionInfo promise error: " + err.code); }); @@ -185,11 +185,11 @@ Checks whether the current version is the latest. This function uses an asynchro **Example** ``` -updater.checkNewVersion(info => { +updater.checkNewVersion((err, info) => { console.log("checkNewVersion success " + info.status); - console.log(`info versionName = ` + info.checkResult[0].versionName); - console.log(`info versionCode = ` + info.checkResult[0].versionCode); - console.log(`info verifyInfo = ` + info.checkResult[0].verifyInfo); + console.log(`info versionName = ` + info.checkResults[0].versionName); + console.log(`info versionCode = ` + info.checkResults[0].versionCode); + console.log(`info verifyInfo = ` + info.checkResults[0].verifyInfo); }); ``` @@ -211,9 +211,9 @@ Checks whether the current version is the latest. This function uses a promise t ``` updater.checkNewVersion().then(value => { - console.log(`info versionName = ` + value.checkResult[0].versionName); - console.log(`info versionCode = ` + value.checkResult[0].versionCode); - console.log(`info verifyInfo = ` + value.checkResult[0].verifyInfo); + console.log(`info versionName = ` + value.checkResults[0].versionName); + console.log(`info versionCode = ` + value.checkResults[0].versionCode); + console.log(`info verifyInfo = ` + value.checkResults[0].verifyInfo); }).catch(err => { console.log("checkNewVersion promise error: " + err.code); }); @@ -284,7 +284,7 @@ Reboots the device and clears the user partition data. This function uses a prom **Example** ``` -updater.rebootAndCleanUserData(result => { +updater.rebootAndCleanUserData((err, result) => { console.log("rebootAndCleanUserData ", result) }); ``` @@ -330,7 +330,7 @@ Installs the update package. This function uses a promise to return the result. **Example** ``` -updater.applyNewVersion(result => { +updater.applyNewVersion((err, result) => { console.log("applyNewVersion ", result) }); ``` @@ -399,7 +399,7 @@ let policy = { autoUpgradeInterval: [ 2, 3 ], autoUpgradeCondition: 2 } -updater.setUpdatePolicy(policy, result => { +updater.setUpdatePolicy(policy, (err, result) => { console.log("setUpdatePolicy ", result) }); ``` @@ -458,7 +458,7 @@ Obtains the update policy. This function uses an asynchronous callback to return **Example** ``` -updater.getUpdatePolicy(policy => { +updater.getUpdatePolicy((err, policy) => { console.log("getUpdatePolicy success"); console.log(`policy autoDownload = ` + policy.autoDownload); console.log(`policy autoDownloadNet = ` + policy.autoDownloadNet); diff --git a/en/application-dev/reference/apis/js-apis-url.md b/en/application-dev/reference/apis/js-apis-url.md index 9f105f845950f1f206c326dcd94c4adf8b83c12c..d97e984d438c8b18febfae5e578cf73dbff244d3 100755 --- a/en/application-dev/reference/apis/js-apis-url.md +++ b/en/application-dev/reference/apis/js-apis-url.md @@ -1,6 +1,7 @@ # URL String Parsing -> **NOTE**
+> **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. @@ -25,16 +26,16 @@ Creates a **URLSearchParams** instance. | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | -| init | string[][] \| Record<string, string> \| string \| URLSearchParams | No| Input parameter objects, which include the following:
- **string[][]**: two-dimensional string array
- **Record<string, string>**: list of objects
- **string**: string
- **URLSearchParams**: object | +| init | string[][] \| Record<string, string> \| string \| URLSearchParams | No| Input parameter objects, which include the following:
- **string[][]**: two-dimensional string array
- **Record<string, string>**: list of objects
- **string**: string
- **URLSearchParams**: object | **Example** ```js -var objectParams = new URLSearchParams([ ['user1', 'abc1'], ['query2', 'first2'], ['query3', 'second3'] ]); -var objectParams1 = new URLSearchParams({"fod" : 1 , "bard" : 2}); -var objectParams2 = new URLSearchParams('?fod=1&bard=2'); -var urlObject = new URL('https://developer.mozilla.org/?fod=1&bard=2'); -var params = new URLSearchParams(urlObject.search); +var objectParams = new Url.URLSearchParams([ ['user1', 'abc1'], ['query2', 'first2'], ['query3', 'second3'] ]); +var objectParams1 = new Url.URLSearchParams({"fod" : 1 , "bard" : 2}); +var objectParams2 = new Url.URLSearchParams('?fod=1&bard=2'); +var urlObject = new Url.URL('https://developer.mozilla.org/?fod=1&bard=2'); +var params = new Url.URLSearchParams(urlObject.search); ``` @@ -48,16 +49,16 @@ Appends a key-value pair into the query string. **Parameters** - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | name | string | Yes | Key of the key-value pair to append. | - | value | string | Yes | Value of the key-value pair to append. | +| Name | Type | Mandatory | Description | +| -------- | -------- | -------- | -------- | +| name | string | Yes | Key of the key-value pair to append. | +| value | string | Yes | Value of the key-value pair to append. | **Example** ```js -let urlObject = new URL('https://developer.exampleUrl/?fod=1&bard=2'); -let paramsObject = new URLSearchParams(urlObject.search.slice(1)); +let urlObject = new Url.URL('https://developer.exampleUrl/?fod=1&bard=2'); +let paramsObject = new Url.URLSearchParams(urlObject.search.slice(1)); paramsObject.append('fod', 3); ``` @@ -72,15 +73,15 @@ Deletes key-value pairs of the specified key. **Parameters** - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | name | string | Yes | Key of the key-value pairs to delete. | +| Name | Type | Mandatory | Description | +| -------- | -------- | -------- | -------- | +| name | string | Yes | Key of the key-value pairs to delete. | **Example** ```js -let urlObject = new URL('https://developer.exampleUrl/?fod=1&bard=2'); -let paramsobject = new URLSearchParams(urlObject.search.slice(1)); +let urlObject = new Url.URL('https://developer.exampleUrl/?fod=1&bard=2'); +let paramsobject = new Url.URLSearchParams(urlObject.search.slice(1)); paramsobject.delete('fod'); ``` @@ -95,21 +96,21 @@ Obtains all the key-value pairs based on the specified key. **Parameters** - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | name | string | Yes | Key specified to obtain all key-value pairs. | +| Name | Type | Mandatory | Description | +| -------- | -------- | -------- | -------- | +| name | string | Yes | Key specified to obtain all key-value pairs. | **Return value** - | Type | Description | - | -------- | -------- | - | string[] | All key-value pairs matching the specified key. | +| Type | Description | +| -------- | -------- | +| string[] | All key-value pairs matching the specified key. | **Example** ```js -let urlObject = new URL('https://developer.exampleUrl/?fod=1&bard=2'); -let paramsObject = new URLSearchParams(urlObject.search.slice(1)); +let urlObject = new Url.URL('https://developer.exampleUrl/?fod=1&bard=2'); +let paramsObject = new Url.URLSearchParams(urlObject.search.slice(1)); paramsObject.append('fod', 3); // Add a second value for the fod parameter. console.log(params.getAll('fod')) // Output ["1","3"]. ``` @@ -125,14 +126,14 @@ Obtains an ES6 iterator. Each item of the iterator is a JavaScript array, and th **Return value** - | Type | Description | - | -------- | -------- | - | IterableIterator<[string, string]> | ES6 iterator. | +| Type | Description | +| -------- | -------- | +| IterableIterator<[string, string]> | ES6 iterator. | **Example** ```js -var searchParamsObject = new URLSearchParams("keyName1=valueName1&keyName2=valueName2"); +var searchParamsObject = new Url.URLSearchParams("keyName1=valueName1&keyName2=valueName2"); for (var pair of searchParamsObject .entries()) { // Show keyName/valueName pairs console.log(pair[0]+ ', '+ pair[1]); } @@ -149,23 +150,23 @@ Traverses the key-value pairs in the **URLSearchParams** instance by using a cal **Parameters** - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | callbackfn | function | Yes | Callback invoked to traverse the key-value pairs in the **URLSearchParams** instance. | - | thisArg | Object | No | Value to use when the callback is invoked. | +| Name | Type | Mandatory | Description | +| -------- | -------- | -------- | -------- | +| callbackfn | function | Yes | Callback invoked to traverse the key-value pairs in the **URLSearchParams** instance. | +| thisArg | Object | No | Value to use when the callback is invoked. | **Table 1** callbackfn parameter description - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | value | string | Yes | Value that is currently traversed. | - | key | string | Yes | Key that is currently traversed. | - | searchParams | Object | Yes | Instance that invokes the **forEach** method. | +| Name | Type | Mandatory | Description | +| -------- | -------- | -------- | -------- | +| value | string | Yes | Value that is currently traversed. | +| key | string | Yes | Key that is currently traversed. | +| searchParams | Object | Yes | Instance that invokes the **forEach** method. | **Example** ```js -const myURLObject = new URL('https://developer.exampleUrl/?fod=1&bard=2'); +const myURLObject = new Url.URL('https://developer.exampleUrl/?fod=1&bard=2'); myURLObject.searchParams.forEach((value, name, searchParams) => { console.log(name, value, myURLObject.searchParams === searchParams); }); @@ -182,21 +183,21 @@ Obtains the value of the first key-value pair based on the specified key. **Parameters** - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | name | string | Yes | Key specified to obtain the value. | +| Name | Type | Mandatory | Description | +| -------- | -------- | -------- | -------- | +| name | string | Yes | Key specified to obtain the value. | **Return value** - | Type | Description | - | -------- | -------- | - | string | Returns the value of the first key-value pair if obtained. | - | null | Returns null if no value is obtained. | +| Type | Description | +| -------- | -------- | +| string | Returns the value of the first key-value pair if obtained. | +| null | Returns null if no value is obtained. | **Example** ```js -var paramsOject = new URLSearchParams(document.location.search.substring(1)); +var paramsOject = new Url.URLSearchParams(document.location.search.substring(1)); var name = paramsOject.get("name"); // is the string "Jonathan" var age = parseInt(paramsOject.get("age"), 10); // is the number 18 var address = paramsOject.get("address"); // null @@ -213,21 +214,21 @@ Checks whether a key has a value. **Parameters** - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | name | string | Yes | Key specified to search for its value. | +| Name | Type | Mandatory | Description | +| -------- | -------- | -------- | -------- | +| name | string | Yes | Key specified to search for its value. | **Return value** - | Type | Description | - | -------- | -------- | - | boolean | Returns **true** if the value exists; returns **false** otherwise. | +| Type | Description | +| -------- | -------- | +| boolean | Returns **true** if the value exists; returns **false** otherwise. | **Example** ```js -let urlObject = new URL('https://developer.exampleUrl/?fod=1&bard=2'); -let paramsObject = new URLSearchParams(urlObject.search.slice(1)); +let urlObject = new Url.URL('https://developer.exampleUrl/?fod=1&bard=2'); +let paramsObject = new Url.URLSearchParams(urlObject.search.slice(1)); paramsObject.has('bard') === true; ``` @@ -242,16 +243,16 @@ Sets the value for a key. If key-value pairs matching the specified key exist, t **Parameters** - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | name | string | Yes | Key of the value to set. | - | value | string | Yes | Value to set. | +| Name | Type | Mandatory | Description | +| -------- | -------- | -------- | -------- | +| name | string | Yes | Key of the value to set. | +| value | string | Yes | Value to set. | **Example** ```js -let urlObject = new URL('https://developer.exampleUrl/?fod=1&bard=2'); -let paramsObject = new URLSearchParams(urlObject.search.slice(1)); +let urlObject = new Url.URL('https://developer.exampleUrl/?fod=1&bard=2'); +let paramsObject = new Url.URLSearchParams(urlObject.search.slice(1)); paramsObject.set('baz', 3); // Add a third parameter. ``` @@ -267,7 +268,7 @@ Sorts all key-value pairs contained in this object based on the Unicode code poi **Example** ```js -var searchParamsObject = new URLSearchParams("c=3&a=9&b=4&d=2"); // Create a test URLSearchParams object +var searchParamsObject = new Url.URLSearchParams("c=3&a=9&b=4&d=2"); // Create a test URLSearchParams object searchParamsObject.sort(); // Sort the key/value pairs console.log(searchParamsObject.toString()); // Display the sorted query string // Output a=9&b=2&c=3&d=4 ``` @@ -283,14 +284,14 @@ Obtains an ES6 iterator that contains the keys of all the key-value pairs. **Return value** - | Type | Description | - | -------- | -------- | - | IterableIterator<string> | ES6 iterator that contains the keys of all the key-value pairs. | +| Type | Description | +| -------- | -------- | +| IterableIterator<string> | ES6 iterator that contains the keys of all the key-value pairs. | **Example** ```js -var searchParamsObject = new URLSearchParams("key1=value1&key2=value2"); // Create a URLSearchParamsObject object for testing +var searchParamsObject = new Url.URLSearchParams("key1=value1&key2=value2"); // Create a URLSearchParamsObject object for testing for (var key of searchParamsObject .keys()) { // Output key-value pairs console.log(key); } @@ -307,14 +308,14 @@ Obtains an ES6 iterator that contains the values of all the key-value pairs. **Return value** - | Type | Description | - | -------- | -------- | - | IterableIterator<string> | ES6 iterator that contains the values of all the key-value pairs. | +| Type | Description | +| -------- | -------- | +| IterableIterator<string> | ES6 iterator that contains the values of all the key-value pairs. | **Example** ```js -var searchParams = new URLSearchParams("key1=value1&key2=value2"); // Create a URLSearchParamsObject object for testing +var searchParams = new Url.URLSearchParams("key1=value1&key2=value2"); // Create a URLSearchParamsObject object for testing for (var value of searchParams.values()) { console.log(value); } @@ -331,14 +332,14 @@ Obtains an ES6 iterator. Each item of the iterator is a JavaScript array, and th **Return value** - | Type | Description | - | -------- | -------- | - | IterableIterator<[string, string]> | ES6 iterator. | +| Type | Description | +| -------- | -------- | +| IterableIterator<[string, string]> | ES6 iterator. | **Example** ```js -const paramsObject = new URLSearchParams('fod=bay&edg=bap'); +const paramsObject = new Url.URLSearchParams('fod=bay&edg=bap'); for (const [name, value] of paramsObject) { console.log(name, value); } @@ -355,15 +356,15 @@ Obtains search parameters that are serialized as a string and, if necessary, per **Return value** - | Type | Description | - | -------- | -------- | - | string | String of serialized search parameters, which is percent-encoded if necessary. | +| Type | Description | +| -------- | -------- | +| string | String of serialized search parameters, which is percent-encoded if necessary. | **Example** ```js -let url = new URL('https://developer.exampleUrl/?fod=1&bard=2'); -let params = new URLSearchParams(url.search.slice(1)); +let url = new Url.URL('https://developer.exampleUrl/?fod=1&bard=2'); +let params = new Url.URLSearchParams(url.search.slice(1)); params.append('fod', 3); console.log(params.toString()); ``` @@ -401,26 +402,26 @@ Creates a URL. **Parameters** - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | url | string | Yes | Input object. | - | base | string \ | URL | No | Input parameter, which can be any of the following:
- **string**: string
- **URL**: string or object | +| Name | Type | Mandatory | Description | +| -------- | -------- | -------- | -------- | +| url | string | Yes | Input object. | +| base | string \ |& URL | No | Input parameter, which can be any of the following:
- **string**: string
- **URL**: string or object | **Example** ```js var mm = 'http://username:password@host:8080'; -var a = new URL("/", mm); // Output 'http://username:password@host:8080/'; -var b = new URL(mm); // Output 'http://username:password@host:8080/'; -new URL('path/path1', b); // Output 'http://username:password@host:8080/path/path1'; -var c = new URL('/path/path1', b); // Output 'http://username:password@host:8080/path/path1'; -new URL('/path/path1', c); // Output 'http://username:password@host:8080/path/path1'; -new URL('/path/path1', a); // Output 'http://username:password@host:8080/path/path1'; -new URL('/path/path1', "https://www.exampleUrl/fr-FR/toto"); // Output https://www.exampleUrl/path/path1 -new URL('/path/path1', ''); // Raises a TypeError exception as '' is not a valid URL -new URL('/path/path1'); // Raises a TypeError exception as '/path/path1' is not a valid URL -new URL('http://www.shanxi.com', ); // Output http://www.shanxi.com/ -new URL('http://www.shanxi.com', b); // Output http://www.shanxi.com/ +var a = new Url.URL("/", mm); // Output 'http://username:password@host:8080/'; +var b = new Url.URL(mm); // Output 'http://username:password@host:8080/'; +new Url.URL('path/path1', b); // Output 'http://username:password@host:8080/path/path1'; +var c = new Url.URL('/path/path1', b); // Output 'http://username:password@host:8080/path/path1'; +new Url.URL('/path/path1', c); // Output 'http://username:password@host:8080/path/path1'; +new Url.URL('/path/path1', a); // Output 'http://username:password@host:8080/path/path1'; +new Url.URL('/path/path1', "https://www.exampleUrl/fr-FR/toto"); // Output https://www.exampleUrl/path/path1 +new Url.URL('/path/path1', ''); // Raises a TypeError exception as '' is not a valid URL +new Url.URL('/path/path1'); // Raises a TypeError exception as '/path/path1' is not a valid URL +new Url.URL('http://www.shanxi.com', ); // Output http://www.shanxi.com/ +new Url.URL('http://www.shanxi.com', b); // Output http://www.shanxi.com/ ``` @@ -434,14 +435,14 @@ Converts the parsed URL into a string. **Return value** - | Type | Description | - | -------- | -------- | - | string | Website address in a serialized string. | +| Type | Description | +| -------- | -------- | +| string | Website address in a serialized string. | **Example** ```js -const url = new URL('http://username:password@host:8080/directory/file?query=pppppp#qwer=da'); +const url = new Url.URL('http://username:password@host:8080/directory/file?query=pppppp#qwer=da'); url.toString() ``` @@ -456,12 +457,12 @@ Converts the parsed URL into a JSON string. **Return value** - | Type | Description | - | -------- | -------- | - | string | Website address in a serialized string. | +| Type | Description | +| -------- | -------- | +| string | Website address in a serialized string. | **Example** ```js -const url = new URL('http://username:password@host:8080/directory/file?query=pppppp#qwer=da'); +const url = new Url.URL('http://username:password@host:8080/directory/file?query=pppppp#qwer=da'); url.toJSON() ``` \ No newline at end of file diff --git a/en/application-dev/reference/apis/js-apis-util.md b/en/application-dev/reference/apis/js-apis-util.md index 0ee9fb84705d1c23d9c453e75dd47689bc66d1d3..2ac8daeb3799908d57a5b7a2c5fd456dcfee8f59 100755 --- a/en/application-dev/reference/apis/js-apis-util.md +++ b/en/application-dev/reference/apis/js-apis-util.md @@ -1,11 +1,12 @@ # util -> **NOTE**
+> **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. -This module provides common utility functions, such as **TextEncoder** and **TextDecoder** for string encoding and decoding, **RationalNumber** for rational number operations, **LruBuffer** for buffer management, **Scope** for range determination, **Base64** for Base64 encoding and decoding, and **types** for checks of built-in object types. +This module provides common utility functions, such as **TextEncoder** and **TextDecoder** for string encoding and decoding, **RationalNumber** for rational number operations, **LruBuffer** for buffer management, **Scope** for range determination, **Base64** for Base64 encoding and decoding, and **Types** for checks of built-in object types. ## Modules to Import @@ -23,15 +24,15 @@ Prints the input content in a formatted string. **System capability**: SystemCapability.Utils.Lang **Parameters** - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | format | string | Yes | Format of the string to print. | - | ...args | Object[] | No | Data to format. | +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| format | string | Yes| Format of the string to print.| +| ...args | Object[] | No| Data to format.| **Return value** - | Type | Description | - | -------- | -------- | - | string | String in the specified format. | +| Type| Description| +| -------- | -------- | +| string | String in the specified format.| **Example** ```js @@ -49,14 +50,14 @@ Obtains detailed information about a system error code. **System capability**: SystemCapability.Utils.Lang **Parameters** - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | errno | number | Yes | Error code generated. | +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| errno | number | Yes| Error code generated.| **Return value** - | Type | Description | - | -------- | -------- | - | string | Detailed information about the error code. | +| Type| Description| +| -------- | -------- | +| string | Detailed information about the error code.| **Example** ```js @@ -76,14 +77,14 @@ Calls back an asynchronous function. In the callback, the first parameter indica **Parameters** - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | original | Function | Yes | Asynchronous function. | +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| original | Function | Yes| Asynchronous function.| **Return value** - | Type | Description | - | -------- | -------- | - | Function | Callback, in which the first parameter indicates the cause of the rejection (the value is **null** if the promise has been resolved) and the second parameter indicates the resolved value. | +| Type| Description| +| -------- | -------- | +| Function | Callback, in which the first parameter indicates the cause of the rejection (the value is **null** if the promise has been resolved) and the second parameter indicates the resolved value.| **Example** ```js @@ -107,14 +108,14 @@ Processes an asynchronous function and returns a promise version. **System capability**: SystemCapability.Utils.Lang **Parameters** - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | original | Function | Yes | Asynchronous function. | +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| original | Function | Yes| Asynchronous function.| **Return value** - | Type | Description | - | -------- | -------- | - | Function | Function in the error-first style (that is, **(err, value) =>...** is called as the last parameter) and the promise version. | +| Type| Description| +| -------- | -------- | +| Function | Function in the error-first style (that is, **(err, value) =>...** is called as the last parameter) and the promise version.| **Example** ```js @@ -138,11 +139,11 @@ Processes an asynchronous function and returns a promise version. **System capability**: SystemCapability.Utils.Lang - | Name | Type | Readable | Writable | Description | - | -------- | -------- | -------- | -------- | -------- | - | encoding | string | Yes | No | Encoding format.
- Supported formats: utf-8, ibm866, iso-8859-2, iso-8859-3, iso-8859-4, iso-8859-5, iso-8859-6, iso-8859-7, iso-8859-8, iso-8859-8-i, iso-8859-10, iso-8859-13, iso-8859-14, iso-8859-15, koi8-r, koi8-u, macintosh, windows-874, windows-1250, windows-1251, windows-1252, windows-1253, windows-1254, windows-1255, windows-1256, windows-1257, windows-1258, x-mac-cyrilli, gbk, gb18030, big5, euc-jp, iso-2022-jp, shift_jis, euc-kr, utf-16be, utf-16le | - | fatal | boolean | Yes | No | Whether to display fatal errors. | - | ignoreBOM | boolean | Yes | No | Whether to ignore the byte order marker (BOM). The default value is **false**, which indicates that the result contains the BOM. | +| Name| Type| Readable| Writable| Description| +| -------- | -------- | -------- | -------- | -------- | +| encoding | string | Yes| No| Encoding format.
- Supported formats: utf-8, ibm866, iso-8859-2, iso-8859-3, iso-8859-4, iso-8859-5, iso-8859-6, iso-8859-7, iso-8859-8, iso-8859-8-i, iso-8859-10, iso-8859-13, iso-8859-14, iso-8859-15, koi8-r, koi8-u, macintosh, windows-874, windows-1250, windows-1251, windows-1252, windows-1253, windows-1254, windows-1255, windows-1256, windows-1257, windows-1258, x-mac-cyrilli, gbk, gb18030, big5, euc-jp, iso-2022-jp, shift_jis, euc-kr, utf-16be, utf-16le| +| fatal | boolean | Yes| No| Whether to display fatal errors.| +| ignoreBOM | boolean | Yes| No| Whether to ignore the byte order marker (BOM). The default value is **false**, which indicates that the result contains the BOM.| ### constructor @@ -154,17 +155,17 @@ A constructor used to create a **TextDecoder** object. **System capability**: SystemCapability.Utils.Lang **Parameters** - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | encoding | string | No | Encoding format. | - | options | Object | No | Encoding-related options, which include **fatal** and **ignoreBOM**. | +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| encoding | string | No| Encoding format.| +| options | Object | No| Encoding-related options, which include **fatal** and **ignoreBOM**.| **Table 1** options - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | fatal | boolean | No | Whether to display fatal errors. | - | ignoreBOM | boolean | No | Whether to ignore the BOM. | +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| fatal | boolean | No| Whether to display fatal errors.| +| ignoreBOM | boolean | No| Whether to ignore the BOM.| **Example** ```js @@ -181,21 +182,21 @@ Decodes the input content. **System capability**: SystemCapability.Utils.Lang **Parameters** - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | input | Unit8Array | Yes | Uint8Array to decode. | - | options | Object | No | Options related to decoding. | +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| input | Unit8Array | Yes| Uint8Array to decode.| +| options | Object | No| Options related to decoding.| **Table 2** options - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | stream | boolean | No | Whether to allow data blocks in subsequent **decode()**. If data is processed in blocks, set this parameter to **true**. If this is the last data block to process or data is not divided into blocks, set this parameter to **false**. The default value is **false**. | +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| stream | boolean | No| Whether to allow data blocks in subsequent **decode()**. If data is processed in blocks, set this parameter to **true**. If this is the last data block to process or data is not divided into blocks, set this parameter to **false**. The default value is **false**.| **Return value** - | Type | Description | - | -------- | -------- | - | string | Data decoded. | +| Type| Description| +| -------- | -------- | +| string | Data decoded.| **Example** ```js @@ -208,9 +209,6 @@ Decodes the input content. result[4] = 0x62; result[5] = 0x63; console.log("input num:"); - for(var j= 0; j < 6; j++) { - console.log(result[j]); - } var retStr = textDecoder.decode( result , {stream: false}); console.log("retStr = " + retStr); ``` @@ -222,9 +220,9 @@ Decodes the input content. **System capability**: SystemCapability.Utils.Lang - | Name | Type | Readable | Writable | Description | - | -------- | -------- | -------- | -------- | -------- | - | encoding | string | Yes | No | Encoding format. The default format is **utf-8**. | +| Name| Type| Readable| Writable| Description| +| -------- | -------- | -------- | -------- | -------- | +| encoding | string | Yes| No| Encoding format. The default format is **utf-8**.| ### constructor @@ -250,18 +248,19 @@ Encodes the input content. **System capability**: SystemCapability.Utils.Lang **Parameters** - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | input | string | Yes | String to encode. | +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| input | string | Yes| String to encode.| **Return value** - | Type | Description | - | -------- | -------- | - | Uint8Array | Encoded text. | +| Type| Description| +| -------- | -------- | +| Uint8Array | Encoded text.| **Example** ```js var textEncoder = new util.TextEncoder(); + var buffer = new ArrayBuffer(20); var result = new Uint8Array(buffer); result = textEncoder.encode("\uD800¥¥"); ``` @@ -276,15 +275,15 @@ Stores the UTF-8 encoded text. **System capability**: SystemCapability.Utils.Lang **Parameters** - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | input | string | Yes | String to encode. | - | dest | Uint8Array | Yes | **Uint8Array** instance used to store the UTF-8 encoded text. | +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| input | string | Yes| String to encode.| +| dest | Uint8Array | Yes| **Uint8Array** instance used to store the UTF-8 encoded text.| **Return value** - | Type | Description | - | -------- | -------- | - | Uint8Array | Encoded text. | +| Type| Description| +| -------- | -------- | +| Uint8Array | Encoded text.| **Example** ```js @@ -306,10 +305,10 @@ A constructor used to create a **RationalNumber** object. **System capability**: SystemCapability.Utils.Lang **Parameters** - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | numerator | number | Yes | Numerator, which is an integer. | - | denominator | number | Yes | Denominator, which is an integer. | +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| numerator | number | Yes| Numerator, which is an integer.| +| denominator | number | Yes| Denominator, which is an integer.| **Example** ```js @@ -326,14 +325,14 @@ Creates a **RationalNumber** object based on the given string. **System capability**: SystemCapability.Utils.Lang **Parameters** - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | rationalString | string | Yes | String used to create the **RationalNumber** object. | +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| rationalString | string | Yes| String used to create the **RationalNumber** object.| **Return value** - | Type | Description | - | -------- | -------- | - | object | **RationalNumber** object created. | +| Type| Description| +| -------- | -------- | +| object | **RationalNumber** object created.| **Example** ```js @@ -351,17 +350,16 @@ Compares this **RationalNumber** object with a given object. **System capability**: SystemCapability.Utils.Lang **Parameters** - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | another | RationalNumber | Yes | Object used to compare with this **RationalNumber** object. | +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| another | RationalNumber | Yes| Object used to compare with this **RationalNumber** object.| **Return value** - | Type | Description | - | -------- | -------- | - | number | Returns **0** if the two objects are equal; returns **1** if the given object is less than this object; return **-1** if the given object is greater than this object. | +| Type| Description| +| -------- | -------- | +| number | Returns **0** if the two objects are equal; returns **1** if the given object is less than this object; return **-1** if the given object is greater than this object.| **Example** - ```js var rationalNumber = new util.RationalNumber(1,2); var rational = rationalNumer.creatRationalFromString("3/4"); @@ -378,9 +376,9 @@ Obtains the value of this **RationalNumber** object as an integer or a floating- **System capability**: SystemCapability.Utils.Lang **Return value** - | Type | Description | - | -------- | -------- | - | number | An integer or a floating-point number. | +| Type| Description| +| -------- | -------- | +| number | An integer or a floating-point number.| **Example** ```js @@ -398,14 +396,14 @@ Checks whether this **RationalNumber** object equals the given object. **System capability**: SystemCapability.Utils.Lang **Parameters** - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | object | Object | Yes | Object used to compare with this **RationalNumber** object. | +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| object | Object | Yes| Object used to compare with this **RationalNumber** object.| **Return value** - | Type | Description | - | -------- | -------- | - | boolean | Returns **true** if the two objects are equal; returns **false** otherwise. | +| Type| Description| +| -------- | -------- | +| boolean | Returns **true** if the two objects are equal; returns **false** otherwise.| **Example** ```js @@ -424,15 +422,15 @@ Obtains the greatest common divisor of two specified integers. **System capability**: SystemCapability.Utils.Lang **Parameters** - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | number1 | number | Yes | The first integer used to get the greatest common divisor. | - | number2 | number | Yes | The second integer used to get the greatest common divisor. | +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| number1 | number | Yes| The first integer used to get the greatest common divisor.| +| number2 | number | Yes| The second integer used to get the greatest common divisor.| **Return value** - | Type | Description | - | -------- | -------- | - | number | Greatest common divisor obtained. | +| Type| Description| +| -------- | -------- | +| number | Greatest common divisor obtained.| **Example** ```js @@ -451,9 +449,9 @@ Obtains the numerator of this **RationalNumber** object. **Return value** - | Type | Description | - | -------- | -------- | - | number | Numerator of this **RationalNumber** object. | +| Type| Description| +| -------- | -------- | +| number | Numerator of this **RationalNumber** object.| **Example** ```js @@ -471,9 +469,9 @@ Obtains the denominator of this **RationalNumber** object. **System capability**: SystemCapability.Utils.Lang **Return value** - | Type | Description | - | -------- | -------- | - | number | Denominator of this **RationalNumber** object. | +| Type| Description| +| -------- | -------- | +| number | Denominator of this **RationalNumber** object.| **Example** ```js @@ -484,16 +482,16 @@ Obtains the denominator of this **RationalNumber** object. ### isZero8+ -isZero​(): boolean +isZero​():boolean Checks whether this **RationalNumber** object is **0**. **System capability**: SystemCapability.Utils.Lang **Return value** - | Type | Description | - | -------- | -------- | - | boolean | Returns **true** if the value of this **RationalNumber** object is **0**; returns **false** otherwise. | +| Type| Description| +| -------- | -------- | +| boolean | Returns **true** if the value of this **RationalNumber** object is **0**; returns **false** otherwise.| **Example** ```js @@ -511,9 +509,9 @@ Checks whether this **RationalNumber** object is a Not a Number (NaN). **System capability**: SystemCapability.Utils.Lang **Return value** - | Type | Description | - | -------- | -------- | - | boolean | Returns **true** if this **RationalNumber** object is a NaN (the denominator and numerator are both **0**); returns **false** otherwise. | +| Type| Description| +| -------- | -------- | +| boolean | Returns **true** if this **RationalNumber** object is a NaN (the denominator and numerator are both **0**); returns **false** otherwise.| **Example** ```js @@ -524,16 +522,16 @@ Checks whether this **RationalNumber** object is a Not a Number (NaN). ### isFinite8+ -isFinite​(): boolean +isFinite​():boolean Checks whether this **RationalNumber** object represents a finite value. **System capability**: SystemCapability.Utils.Lang **Return value** - | Type | Description | - | -------- | -------- | - | boolean | Returns **true** if this **RationalNumber** object represents a finite value (the denominator is not **0**); returns **false** otherwise. | +| Type| Description| +| -------- | -------- | +| boolean | Returns **true** if this **RationalNumber** object represents a finite value (the denominator is not **0**); returns **false** otherwise.| **Example** ```js @@ -551,9 +549,9 @@ Obtains the string representation of this **RationalNumber** object. **System capability**: SystemCapability.Utils.Lang **Return value** - | Type | Description | - | -------- | -------- | - | string | Returns **NaN** if the numerator and denominator of this object are both **0**; returns a string in Numerator/Denominator format otherwise, for example, **3/5**. | +| Type| Description| +| -------- | -------- | +| string | Returns **NaN** if the numerator and denominator of this object are both **0**; returns a string in Numerator/Denominator format otherwise, for example, **3/5**.| **Example** ```js @@ -567,9 +565,9 @@ Obtains the string representation of this **RationalNumber** object. **System capability**: SystemCapability.Utils.Lang - | Name | Type | Readable | Writable | Description | - | -------- | -------- | -------- | -------- | -------- | - | length | number | Yes | No | Total number of values in this buffer. | +| Name| Type| Readable| Writable| Description| +| -------- | -------- | -------- | -------- | -------- | +| length | number | Yes| No| Total number of values in this buffer.| **Example** ```js @@ -589,9 +587,9 @@ A constructor used to create an **LruBuffer** instance. The default capacity of **System capability**: SystemCapability.Utils.Lang **Parameters** - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | capacity | number | No | Capacity of the **LruBuffer** to create. | +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| capacity | number | No| Capacity of the **LruBuffer** to create.| **Example** ```js @@ -608,9 +606,9 @@ Changes the **LruBuffer** capacity. If the new capacity is less than or equal to **System capability**: SystemCapability.Utils.Lang **Parameters** - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | newCapacity | number | Yes | New capacity of the **LruBuffer**. | +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| newCapacity | number | Yes| New capacity of the **LruBuffer**.| **Example** ```js @@ -628,9 +626,9 @@ Obtains the string representation of this **LruBuffer** object. **System capability**: SystemCapability.Utils.Lang **Return value** - | Type | Description | - | -------- | -------- | - | string | String representation of this **LruBuffer** object. | +| Type| Description| +| -------- | -------- | +| string | String representation of this **LruBuffer** object.| **Example** ```js @@ -651,9 +649,9 @@ Obtains the capacity of this buffer. **System capability**: SystemCapability.Utils.Lang **Return value** - | Type | Description | - | -------- | -------- | - | number | Capacity of this buffer. | +| Type| Description| +| -------- | -------- | +| number | Capacity of this buffer.| **Example** ```js @@ -688,9 +686,9 @@ Obtains the number of return values for **createDefault()**. **System capability**: SystemCapability.Utils.Lang **Return value** - | Type | Description | - | -------- | -------- | - | number | Number of return values for **createDefault()**. | +| Type| Description| +| -------- | -------- | +| number | Number of return values for **createDefault()**.| **Example** ```js @@ -709,9 +707,9 @@ Obtains the number of times that the queried values are mismatched. **System capability**: SystemCapability.Utils.Lang **Return value** - | Type | Description | - | -------- | -------- | - | number | Number of times that the queried values are mismatched. | +| Type| Description| +| -------- | -------- | +| number | Number of times that the queried values are mismatched.| **Example** ```js @@ -731,9 +729,9 @@ Obtains the number of removals from this buffer. **System capability**: SystemCapability.Utils.Lang **Return value** - | Type | Description | - | -------- | -------- | - | number | Number of removals from the buffer. | +| Type| Description| +| -------- | -------- | +| number | Number of removals from the buffer.| **Example** ```js @@ -754,9 +752,9 @@ Obtains the number of times that the queried values are matched. **System capability**: SystemCapability.Utils.Lang **Return value** - | Type | Description | - | -------- | -------- | - | number | Number of times that the queried values are matched. | +| Type| Description| +| -------- | -------- | +| number | Number of times that the queried values are matched.| **Example** ```js @@ -776,9 +774,9 @@ Obtains the number of additions to this buffer. **System capability**: SystemCapability.Utils.Lang **Return value** - | Type | Description | - | -------- | -------- | - | number | Number of additions to the buffer. | +| Type| Description| +| -------- | -------- | +| number | Number of additions to the buffer.| **Example** ```js @@ -797,9 +795,9 @@ Checks whether this buffer is empty. **System capability**: SystemCapability.Utils.Lang **Return value** - | Type | Description | - | -------- | -------- | - | boolean | Returns **true** if the buffer does not contain any value. | +| Type| Description| +| -------- | -------- | +| boolean | Returns **true** if the buffer does not contain any value.| **Example** ```js @@ -811,21 +809,21 @@ Checks whether this buffer is empty. ### get8+ -get(key: K): V | undefined +get(key: K): V | undefined Obtains the value of the specified key. **System capability**: SystemCapability.Utils.Lang **Parameters** - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | key | K | Yes | Key based on which the value is queried. | +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| key | K | Yes| Key based on which the value is queried.| **Return value** - | Type | Description | - | -------- | -------- | - | V \ | undefind | Returns the value of the key if a match is found in the buffer; returns **undefined** otherwise. | +| Type| Description| +| -------- | -------- | +| V \| undefind | Returns the value of the key if a match is found in the buffer; returns **undefined** otherwise.| **Example** ```js @@ -844,15 +842,15 @@ Adds a key-value pair to this buffer. **System capability**: SystemCapability.Utils.Lang **Parameters** - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | key | K | Yes | Key of the key-value pair to add. | - | value | V | Yes | Value of the key-value pair to add. | +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| key | K | Yes| Key of the key-value pair to add.| +| value | V | Yes| Value of the key-value pair to add.| **Return value** - | Type | Description | - | -------- | -------- | - | V | Returns the existing value if the key already exists; returns the value added otherwise. If the key or value is null, an exception will be thrown. | +| Type| Description| +| -------- | -------- | +| V | Returns the existing value if the key already exists; returns the value added otherwise. If the key or value is null, an exception will be thrown. | **Example** ```js @@ -870,9 +868,9 @@ Obtains all values in this buffer, listed from the most to the least recently ac **System capability**: SystemCapability.Utils.Lang **Return value** - | Type | Description | - | -------- | -------- | - | V [] | All values in the buffer, listed from the most to the least recently accessed. | +| Type| Description| +| -------- | -------- | +| V [] | All values in the buffer, listed from the most to the least recently accessed.| **Example** ```js @@ -893,9 +891,9 @@ Obtains all keys in this buffer, listed from the most to the least recently acce **System capability**: SystemCapability.Utils.Lang **Return value** - | Type | Description | - | -------- | -------- | - | K [] | All keys in the buffer, listed from the most to the least recently accessed. | +| Type| Description| +| -------- | -------- | +| K [] | All keys in the buffer, listed from the most to the least recently accessed.| **Example** ```js @@ -907,21 +905,21 @@ Obtains all keys in this buffer, listed from the most to the least recently acce ### remove8+ -remove(key: K): V | undefined +remove(key: K): V | undefined Removes the specified key and its value from this buffer. **System capability**: SystemCapability.Utils.Lang **Parameters** - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | key | K | Yes | Key to remove. | +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| key | K | Yes| Key to remove.| **Return value** - | Type | Description | - | -------- | -------- | - | V \ | undefind | Returns an **Optional** object containing the removed key-value pair if the key exists in the buffer; returns an empty **Optional** object otherwise. If the key is null, an exception will be thrown. | +| Type| Description| +| -------- | -------- | +| V \| undefind | Returns an **Optional** object containing the removed key-value pair if the key exists in the buffer; returns an empty **Optional** object otherwise. If the key is null, an exception will be thrown.| **Example** ```js @@ -940,12 +938,12 @@ Performs subsequent operations after a value is removed. **System capability**: SystemCapability.Utils.Lang **Parameters** - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | isEvict | boolean | No | Whether the buffer capacity is insufficient. If the value is **true**, this method is called due to insufficient capacity. | - | key | K | Yes | Key removed. | - | value | V | Yes | Value removed. | - | newValue | V | No | New value for the key if the **put()** method is called and the key to be added already exists. In other cases, this parameter is left blank. | +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| isEvict | boolean | No| Whether the buffer capacity is insufficient. If the value is **true**, this method is called due to insufficient capacity.| +| key | K | Yes| Key removed.| +| value | V | Yes| Value removed.| +| newValue | V | No| New value for the key if the **put()** method is called and the key to be added already exists. In other cases, this parameter is left blank.| **Example** ```js @@ -985,14 +983,14 @@ Checks whether this buffer contains the specified key. **System capability**: SystemCapability.Utils.Lang **Parameters** - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | key | K | Yes | Key to check. | +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| key | K | Yes| Key to check.| **Return value** - | Type | Description | - | -------- | -------- | - | boolean | Returns **true** if the buffer contains the specified key; returns **false** otherwise. | +| Type| Description| +| -------- | -------- | +| boolean | Returns **true** if the buffer contains the specified key; returns **false** otherwise.| **Example** ```js @@ -1011,14 +1009,14 @@ Creates a value if the value of the specified key is not available. **System capability**: SystemCapability.Utils.Lang **Parameters** - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | key | K | Yes | Key of which the value is missing. | +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| key | K | Yes| Key of which the value is missing.| **Return value** - | Type | Description | - | -------- | -------- | - | V | Value of the key. | +| Type| Description| +| -------- | -------- | +| V | Value of the key.| **Example** ```js @@ -1036,9 +1034,9 @@ Obtains a new iterator object that contains all key-value pairs in this object. **System capability**: SystemCapability.Utils.Lang **Return value** - | Type | Description | - | -------- | -------- | - | [K, V] | Iterable array. | +| Type| Description| +| -------- | -------- | +| [K, V] | Iterable array.| **Example** ```js @@ -1057,9 +1055,9 @@ Obtains a two-dimensional array in key-value pairs. **System capability**: SystemCapability.Utils.Lang **Return value** - | Type | Description | - | -------- | -------- | - | [K, V] | Two-dimensional array in key-value pairs. | +| Type| Description| +| -------- | -------- | +| [K, V] | Two-dimensional array in key-value pairs.| **Example** ```js @@ -1081,7 +1079,7 @@ The values of the **ScopeComparable** type are used to implement the **compareTo interface ScopeComparable{ compareTo(other: ScopeComparable): boolean; } -type ScopeType = ScopeComparable | number; +type ScopeType = ScopeComparable | number; ``` @@ -1092,6 +1090,8 @@ Example ```js class Temperature{ constructor(value){ + // If TS is used for development, add the following code: + // private readonly _temp: Temperature; this._temp = value; } comapreTo(value){ @@ -1116,10 +1116,10 @@ A constructor used to create a **Scope** object with the specified upper and low **System capability**: SystemCapability.Utils.Lang **Parameters** - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | lowerObj | [ScopeType](#scopetype8) | Yes | Lower limit of the **Scope** object. | - | upperObj | [ScopeType](#scopetype8) | Yes | Upper limit of the **Scope** object. | +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| lowerObj | [ScopeType](#scopetype8) | Yes| Lower limit of the **Scope** object.| +| upperObj | [ScopeType](#scopetype8) | Yes| Upper limit of the **Scope** object.| **Example** ```js @@ -1138,9 +1138,9 @@ Obtains a string representation that contains this **Scope**. **System capability**: SystemCapability.Utils.Lang **Return value** - | Type | Description | - | -------- | -------- | - | string | String representation containing the **Scope**. | +| Type| Description| +| -------- | -------- | +| string | String representation containing the **Scope**.| **Example** ```js @@ -1160,14 +1160,14 @@ Obtains the intersection of this **Scope** and the given **Scope**. **System capability**: SystemCapability.Utils.Lang **Parameters** - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | range | [Scope](#scope8) | Yes | **Scope** specified. | +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| range | [Scope](#scope8) | Yes| **Scope** specified.| **Return value** - | Type | Description | - | -------- | -------- | - | [Scope](#scope8) | Intersection of this **Scope** and the given **Scope**. | +| Type| Description| +| -------- | -------- | +| [Scope](#scope8) | Intersection of this **Scope** and the given **Scope**.| **Example** ```js @@ -1183,22 +1183,22 @@ Obtains the intersection of this **Scope** and the given **Scope**. ### intersect8+ -intersect(lowerObj: ScopeType,upperObj: ScopeType): Scope +intersect(lowerObj:ScopeType,upperObj:ScopeType):Scope Obtains the intersection of this **Scope** and the given lower and upper limits. **System capability**: SystemCapability.Utils.Lang **Parameters** - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | lowerObj | [ScopeType](#scopetype8) | Yes | Lower limit. | - | upperObj | [ScopeType](#scopetype8) | Yes | Upper limit. | +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| lowerObj | [ScopeType](#scopetype8) | Yes| Lower limit.| +| upperObj | [ScopeType](#scopetype8) | Yes| Upper limit.| **Return value** - | Type | Description | - | -------- | -------- | - | [Scope](#scope8) | Intersection of this **Scope** and the given lower and upper limits. | +| Type| Description| +| -------- | -------- | +| [Scope](#scope8) | Intersection of this **Scope** and the given lower and upper limits.| **Example** ```js @@ -1221,9 +1221,9 @@ Obtains the upper limit of this **Scope**. **Return value** - | Type | Description | - | -------- | -------- | - | [ScopeType](#scopetype8) | Upper limit of this **Scope**. | +| Type| Description| +| -------- | -------- | +| [ScopeType](#scopetype8) | Upper limit of this **Scope**.| **Example** ```js @@ -1243,9 +1243,9 @@ Obtains the lower limit of this **Scope**. **System capability**: SystemCapability.Utils.Lang **Return value** - | Type | Description | - | -------- | -------- | - | [ScopeType](#scopetype8) | Lower limit of this **Scope**. | +| Type| Description| +| -------- | -------- | +| [ScopeType](#scopetype8) | Lower limit of this **Scope**.| **Example** ```js @@ -1265,17 +1265,18 @@ Obtains the union set of this **Scope** and the given lower and upper limits. **System capability**: SystemCapability.Utils.Lang **Parameters** - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | lowerObj | [ScopeType](#scopetype8) | Yes | Lower limit. | - | upperObj | [ScopeType](#scopetype8) | Yes | Upper limit. | +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| lowerObj | [ScopeType](#scopetype8) | Yes| Lower limit.| +| upperObj | [ScopeType](#scopetype8) | Yes| Upper limit.| **Return value** - | Type | Description | - | -------- | -------- | - | [Scope](#scope8) | Union set of this **Scope** and the given lower and upper limits. | +| Type| Description| +| -------- | -------- | +| [Scope](#scope8) | Union set of this **Scope** and the given lower and upper limits.| **Example** + ```js var tempLower = new Temperature(30); var tempUpper = new Temperature(40); @@ -1288,21 +1289,21 @@ Obtains the union set of this **Scope** and the given lower and upper limits. ### expand8+ -expand(range:Scope):Scope +expand(range: Scope): Scope Obtains the union set of this **Scope** and the given **Scope**. **System capability**: SystemCapability.Utils.Lang **Parameters** - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | range | [Scope](#scope8) | Yes | **Scope** specified. | +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| range | [Scope](#scope8) | Yes| **Scope** specified.| **Return value** - | Type | Description | - | -------- | -------- | - | [Scope](#scope8) | Union set of this **Scope** and the given **Scope**. | +| Type| Description| +| -------- | -------- | +| [Scope](#scope8) | Union set of this **Scope** and the given **Scope**.| **Example** ```js @@ -1325,14 +1326,14 @@ Obtains the union set of this **Scope** and the given value. **System capability**: SystemCapability.Utils.Lang **Parameters** - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | value | [ScopeType](#scopetype8) | Yes | Value specified. | +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| value | [ScopeType](#scopetype8) | Yes| Value specified.| **Return value** - | Type | Description | - | -------- | -------- | - | [Scope](#scope8) | Union set of this **Scope** and the given value. | +| Type| Description| +| -------- | -------- | +| [Scope](#scope8) | Union set of this **Scope** and the given value.| **Example** ```js @@ -1353,14 +1354,14 @@ Checks whether a value is within this **Scope**. **System capability**: SystemCapability.Utils.Lang **Parameters** - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | value | [ScopeType](#scopetype8) | Yes | Value specified. | +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| value | [ScopeType](#scopetype8) | Yes| Value specified.| **Return value** - | Type | Description | - | -------- | -------- | - | boolean | Returns **true** if the value is within this **Scope**; returns **false** otherwise. | +| Type| Description| +| -------- | -------- | +| boolean | Returns **true** if the value is within this **Scope**; returns **false** otherwise.| **Example** ```js @@ -1381,14 +1382,14 @@ Checks whether a range is within this **Scope**. **System capability**: SystemCapability.Utils.Lang **Parameters** - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | range | [Scope](#scope8) | Yes | **Scope** specified. | +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| range | [Scope](#scope8) | Yes| **Scope** specified.| **Return value** - | Type | Description | - | -------- | -------- | - | boolean | Returns **true** if the range is within this **Scope**; returns **false** otherwise. | +| Type| Description| +| -------- | -------- | +| boolean | Returns **true** if the range is within this **Scope**; returns **false** otherwise.| **Example** ```js @@ -1411,14 +1412,14 @@ Limits a value to this **Scope**. **System capability**: SystemCapability.Utils.Lang **Parameters** - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | value | [ScopeType](#scopetype8) | Yes | Value specified. | +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| value | [ScopeType](#scopetype8) | Yes| Value specified.| **Return value** - | Type | Description | - | -------- | -------- | - | [ScopeType](#scopetype8) | Returns **lowerObj** if the specified value is less than the lower limit; returns **upperObj** if the specified value is greater than the upper limit; returns the specified value if it is within this **Scope**. | +| Type| Description| +| -------- | -------- | +| [ScopeType](#scopetype8) | Returns **lowerObj** if the specified value is less than the lower limit; returns **upperObj** if the specified value is greater than the upper limit; returns the specified value if it is within this **Scope**.| **Example** ```js @@ -1456,14 +1457,14 @@ Encodes the input content. **System capability**: SystemCapability.Utils.Lang **Parameters** - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | src | Uint8Array | Yes | Uint8Array to encode. | +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| src | Uint8Array | Yes| Uint8Array to encode.| **Return value** - | Type | Description | - | -------- | -------- | - | Uint8Array | Uint8Array encoded. | +| Type| Description| +| -------- | -------- | +| Uint8Array | Uint8Array encoded.| **Example** ```js @@ -1482,14 +1483,14 @@ Encodes the input content. **System capability**: SystemCapability.Utils.Lang **Parameters** - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | src | Uint8Array | Yes | Uint8Array to encode. | +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| src | Uint8Array | Yes| Uint8Array to encode.| **Return value** - | Type | Description | - | -------- | -------- | - | string | String encoded from the Uint8Array. | +| Type| Description| +| -------- | -------- | +| string | String encoded from the Uint8Array.| **Example** ```js @@ -1501,21 +1502,21 @@ Encodes the input content. ### decodeSync8+ -decodeSync(src: Uint8Array | string): Uint8Array +decodeSync(src: Uint8Array | string): Uint8Array Decodes the input content. **System capability**: SystemCapability.Utils.Lang **Parameters** - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | src | Uint8Array \ | string | Yes | Uint8Array or string to decode. | +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| src | Uint8Array \| string | Yes| Uint8Array or string to decode.| **Return value** - | Type | Description | - | -------- | -------- | - | Uint8Array | Uint8Array decoded. | +| Type| Description| +| -------- | -------- | +| Uint8Array | Uint8Array decoded.| **Example** ```js @@ -1534,14 +1535,14 @@ Encodes the input content asynchronously. **System capability**: SystemCapability.Utils.Lang **Parameters** - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | src | Uint8Array | Yes | Uint8Array to encode asynchronously. | +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| src | Uint8Array | Yes| Uint8Array to encode asynchronously.| **Return value** - | Type | Description | - | -------- | -------- | - | Promise<Uint8Array> | Uint8Array obtained after asynchronous encoding. | +| Type| Description| +| -------- | -------- | +| Promise<Uint8Array> | Uint8Array obtained after asynchronous encoding.| **Example** ```js @@ -1565,14 +1566,14 @@ Encodes the input content asynchronously. **System capability**: SystemCapability.Utils.Lang **Parameters** - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | src | Uint8Array | Yes | Uint8Array to encode asynchronously. | +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| src | Uint8Array | Yes| Uint8Array to encode asynchronously.| **Return value** - | Type | Description | - | -------- | -------- | - | Promise<string> | String obtained after asynchronous encoding. | +| Type| Description| +| -------- | -------- | +| Promise<string> | String obtained after asynchronous encoding.| **Example** ```js @@ -1586,21 +1587,21 @@ Encodes the input content asynchronously. ### decode8+ -decode(src: Uint8Array | string): Promise<Uint8Array> +decode(src: Uint8Array | string): Promise<Uint8Array> Decodes the input content asynchronously. **System capability**: SystemCapability.Utils.Lang **Parameters** - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | src | Uint8Array \ | string | Yes | Uint8Array or string to decode asynchronously. | +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| src | Uint8Array \| string | Yes| Uint8Array or string to decode asynchronously.| **Return value** - | Type | Description | - | -------- | -------- | - | Promise<Uint8Array> | Uint8Array obtained after asynchronous decoding. | +| Type| Description| +| -------- | -------- | +| Promise<Uint8Array> | Uint8Array obtained after asynchronous decoding.| **Example** ```js @@ -1622,7 +1623,7 @@ Decodes the input content asynchronously. constructor() -A constructor used to create a **types** object. +A constructor used to create a **Types** object. **System capability**: SystemCapability.Utils.Lang @@ -1641,14 +1642,14 @@ Checks whether the input value is of the **ArrayBuffer** type. **System capability**: SystemCapability.Utils.Lang **Parameters** - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | value | Object | Yes | Object to check. | +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| value | Object | Yes| Object to check.| **Return value** - | Type | Description | - | -------- | -------- | - | boolean | Returns **true** if the input value is of the **ArrayBuffer** type; returns **false** otherwise. | +| Type| Description| +| -------- | -------- | +| boolean | Returns **true** if the input value is of the **ArrayBuffer** type; returns **false** otherwise.| **Example** ```js @@ -1668,14 +1669,14 @@ Checks whether the input value is of the **ArrayBufferView** type. **System capability**: SystemCapability.Utils.Lang **Parameters** - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | value | Object | Yes | Object to check. | +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| value | Object | Yes| Object to check.| **Return value** - | Type | Description | - | -------- | -------- | - | boolean | Returns **true** if the input value is of the **ArrayBufferView** type; returns **false** otherwise. | +| Type| Description| +| -------- | -------- | +| boolean | Returns **true** if the input value is of the **ArrayBufferView** type; returns **false** otherwise.| **Example** ```js @@ -1693,14 +1694,14 @@ Checks whether the input value is of the **arguments** type. **System capability**: SystemCapability.Utils.Lang **Parameters** - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | value | Object | Yes | Object to check. | +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| value | Object | Yes| Object to check.| **Return value** - | Type | Description | - | -------- | -------- | - | boolean | Returns **true** if the input value is of the **arguments** type; returns **false** otherwise. | +| Type| Description| +| -------- | -------- | +| boolean | Returns **true** if the input value is of the **arguments** type; returns **false** otherwise.| **Example** ```js @@ -1721,14 +1722,14 @@ Checks whether the input value is of the **ArrayBuffer** type. **System capability**: SystemCapability.Utils.Lang **Parameters** - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | value | Object | Yes | Object to check. | +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| value | Object | Yes| Object to check.| **Return value** - | Type | Description | - | -------- | -------- | - | boolean | Returns **true** if the input value is of the **ArrayBuffer** type; returns **false** otherwise. | +| Type| Description| +| -------- | -------- | +| boolean | Returns **true** if the input value is of the **ArrayBuffer** type; returns **false** otherwise.| **Example** ```js @@ -1746,14 +1747,14 @@ Checks whether the input value is an asynchronous function. **System capability**: SystemCapability.Utils.Lang **Parameters** - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | value | Object | Yes | Object to check. | +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| value | Object | Yes| Object to check.| **Return value** - | Type | Description | - | -------- | -------- | - | boolean | Returns **true** if the input value is an asynchronous function; returns **false** otherwise. | +| Type| Description| +| -------- | -------- | +| boolean | Returns **true** if the input value is an asynchronous function; returns **false** otherwise.| **Example** ```js @@ -1771,14 +1772,14 @@ Checks whether the input value is of the **Boolean** type. **System capability**: SystemCapability.Utils.Lang **Parameters** - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | value | Object | Yes | Object to check. | +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| value | Object | Yes| Object to check.| **Return value** - | Type | Description | - | -------- | -------- | - | boolean | Returns **true** if the input value is of the **Boolean** type; returns **false** otherwise. | +| Type| Description| +| -------- | -------- | +| boolean | Returns **true** if the input value is of the **Boolean** type; returns **false** otherwise.| **Example** ```js @@ -1796,14 +1797,14 @@ Checks whether the input value is of the **Boolean**, **Number**, **String**, or **System capability**: SystemCapability.Utils.Lang **Parameters** - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | value | Object | Yes | Object to check. | +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| value | Object | Yes| Object to check.| **Return value** - | Type | Description | - | -------- | -------- | - | boolean | Returns **true** if the input value is of the **Boolean**, **Number**, **String**, or **Symbol** type; returns **false** otherwise. | +| Type| Description| +| -------- | -------- | +| boolean | Returns **true** if the input value is of the **Boolean**, **Number**, **String**, or **Symbol** type; returns **false** otherwise.| **Example** ```js @@ -1821,14 +1822,14 @@ Checks whether the input value is of the **DataView** type. **System capability**: SystemCapability.Utils.Lang **Parameters** - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | value | Object | Yes | Object to check. | +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| value | Object | Yes| Object to check.| **Return value** - | Type | Description | - | -------- | -------- | - | boolean | Returns **true** if the input value is of the **DataView** type; returns **false** otherwise. | +| Type| Description| +| -------- | -------- | +| boolean | Returns **true** if the input value is of the **DataView** type; returns **false** otherwise.| **Example** ```js @@ -1847,14 +1848,14 @@ Checks whether the input value is of the **Date** type. **System capability**: SystemCapability.Utils.Lang **Parameters** - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | value | Object | Yes | Object to check. | +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| value | Object | Yes| Object to check.| **Return value** - | Type | Description | - | -------- | -------- | - | boolean | Returns **true** if the input value is of the **Date** type; returns **false** otherwise. | +| Type| Description| +| -------- | -------- | +| boolean | Returns **true** if the input value is of the **Date** type; returns **false** otherwise.| **Example** ```js @@ -1872,14 +1873,14 @@ Checks whether the input value is of the **native external** type. **System capability**: SystemCapability.Utils.Lang **Parameters** - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | value | Object | Yes | Object to check. | +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| value | Object | Yes| Object to check.| **Return value** - | Type | Description | - | -------- | -------- | - | boolean | Returns **true** if the input value is of the **native external** type; returns **false** otherwise. | +| Type| Description| +| -------- | -------- | +| boolean | Returns **true** if the input value is of the **native external** type; returns **false** otherwise.| **Example** ```js @@ -1898,14 +1899,14 @@ Checks whether the input value is of the **Float32Array** type. **System capability**: SystemCapability.Utils.Lang **Parameters** - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | value | Object | Yes | Object to check. | +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| value | Object | Yes| Object to check.| **Return value** - | Type | Description | - | -------- | -------- | - | boolean | Returns **true** if the input value is of the **Float32Array** type; returns **false** otherwise. | +| Type| Description| +| -------- | -------- | +| boolean | Returns **true** if the input value is of the **Float32Array** type; returns **false** otherwise.| **Example** ```js @@ -1923,14 +1924,14 @@ Checks whether the input value is of the **Float64Array** type. **System capability**: SystemCapability.Utils.Lang **Parameters** - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | value | Object | Yes | Object to check. | +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| value | Object | Yes| Object to check.| **Return value** - | Type | Description | - | -------- | -------- | - | boolean | Returns **true** if the input value is of the **Float64Array** type; returns **false** otherwise. | +| Type| Description| +| -------- | -------- | +| boolean | Returns **true** if the input value is of the **Float64Array** type; returns **false** otherwise.| **Example** ```js @@ -1948,14 +1949,14 @@ Checks whether the input value is a generator function. **System capability**: SystemCapability.Utils.Lang **Parameters** - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | value | Object | Yes | Object to check. | +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| value | Object | Yes| Object to check.| **Return value** - | Type | Description | - | -------- | -------- | - | boolean | Returns **true** if the input value is a generator function; returns **false** otherwise. | +| Type| Description| +| -------- | -------- | +| boolean | Returns **true** if the input value is a generator function; returns **false** otherwise.| **Example** ```js @@ -1973,14 +1974,14 @@ Checks whether the input value is a generator object. **System capability**: SystemCapability.Utils.Lang **Parameters** - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | value | Object | Yes | Object to check. | +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| value | Object | Yes| Object to check.| **Return value** - | Type | Description | - | -------- | -------- | - | boolean | Returns **true** if the input value is a generator object; returns **false** otherwise. | +| Type| Description| +| -------- | -------- | +| boolean | Returns **true** if the input value is a generator object; returns **false** otherwise.| **Example** ```js @@ -2000,14 +2001,14 @@ Checks whether the input value is of the **Int8Array** type. **System capability**: SystemCapability.Utils.Lang **Parameters** - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | value | Object | Yes | Object to check. | +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| value | Object | Yes| Object to check.| **Return value** - | Type | Description | - | -------- | -------- | - | boolean | Returns **true** if the input value is of the **Int8Array** type; returns **false** otherwise. | +| Type| Description| +| -------- | -------- | +| boolean | Returns **true** if the input value is of the **Int8Array** type; returns **false** otherwise.| **Example** ```js @@ -2025,14 +2026,14 @@ Checks whether the input value is of the **Int16Array** type. **System capability**: SystemCapability.Utils.Lang **Parameters** - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | value | Object | Yes | Object to check. | +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| value | Object | Yes| Object to check.| **Return value** - | Type | Description | - | -------- | -------- | - | boolean | Returns **true** if the input value is of the **Int16Array** type; returns **false** otherwise. | +| Type| Description| +| -------- | -------- | +| boolean | Returns **true** if the input value is of the **Int16Array** type; returns **false** otherwise.| **Example** ```js @@ -2050,14 +2051,14 @@ Checks whether the input value is of the **Int32Array** type. **System capability**: SystemCapability.Utils.Lang **Parameters** - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | value | Object | Yes | Object to check. | +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| value | Object | Yes| Object to check.| **Return value** - | Type | Description | - | -------- | -------- | - | boolean | Returns **true** if the input value is of the **Int32Array** type; returns **false** otherwise. | +| Type| Description| +| -------- | -------- | +| boolean | Returns **true** if the input value is of the **Int32Array** type; returns **false** otherwise.| **Example** ```js @@ -2075,14 +2076,14 @@ Checks whether the input value is of the **Map** type. **System capability**: SystemCapability.Utils.Lang **Parameters** - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | value | Object | Yes | Object to check. | +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| value | Object | Yes| Object to check.| **Return value** - | Type | Description | - | -------- | -------- | - | boolean | Returns **true** if the input value is of the **Map** type; returns **false** otherwise. | +| Type| Description| +| -------- | -------- | +| boolean | Returns **true** if the input value is of the **Map** type; returns **false** otherwise.| **Example** ```js @@ -2100,14 +2101,14 @@ Checks whether the input value is of the **MapIterator** type. **System capability**: SystemCapability.Utils.Lang **Parameters** - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | value | Object | Yes | Object to check. | +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| value | Object | Yes| Object to check.| **Return value** - | Type | Description | - | -------- | -------- | - | boolean | Returns **true** if the input value is of the **MapIterator** type; returns **false** otherwise. | +| Type| Description| +| -------- | -------- | +| boolean | Returns **true** if the input value is of the **MapIterator** type; returns **false** otherwise.| **Example** ```js @@ -2126,14 +2127,14 @@ Checks whether the input value is of the **Error** type. **System capability**: SystemCapability.Utils.Lang **Parameters** - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | value | Object | Yes | Object to check. | +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| value | Object | Yes| Object to check.| **Return value** - | Type | Description | - | -------- | -------- | - | boolean | Returns **true** if the input value is of the **Error** type; returns **false** otherwise. | +| Type| Description| +| -------- | -------- | +| boolean | Returns **true** if the input value is of the **Error** type; returns **false** otherwise.| **Example** ```js @@ -2151,14 +2152,14 @@ Checks whether the input value is a number object. **System capability**: SystemCapability.Utils.Lang **Parameters** - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | value | Object | Yes | Object to check. | +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| value | Object | Yes| Object to check.| **Return value** - | Type | Description | - | -------- | -------- | - | boolean | Returns **true** if the input value is a number object; returns **false** otherwise. | +| Type| Description| +| -------- | -------- | +| boolean | Returns **true** if the input value is a number object; returns **false** otherwise.| **Example** ```js @@ -2176,14 +2177,14 @@ Checks whether the input value is a promise. **System capability**: SystemCapability.Utils.Lang **Parameters** - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | value | Object | Yes | Object to check. | +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| value | Object | Yes| Object to check.| **Return value** - | Type | Description | - | -------- | -------- | - | boolean | Returns **true** if the input value is a promise; returns **false** otherwise. | +| Type| Description| +| -------- | -------- | +| boolean | Returns **true** if the input value is a promise; returns **false** otherwise.| **Example** ```js @@ -2201,14 +2202,14 @@ Checks whether the input value is a proxy. **System capability**: SystemCapability.Utils.Lang **Parameters** - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | value | Object | Yes | Object to check. | +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| value | Object | Yes| Object to check.| **Return value** - | Type | Description | - | -------- | -------- | - | boolean | Returns **true** if the input value is a proxy; returns **false** otherwise. | +| Type| Description| +| -------- | -------- | +| boolean | Returns **true** if the input value is a proxy; returns **false** otherwise.| **Example** ```js @@ -2228,14 +2229,14 @@ Checks whether the input value is of the **RegExp** type. **System capability**: SystemCapability.Utils.Lang **Parameters** - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | value | Object | Yes | Object to check. | +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| value | Object | Yes| Object to check.| **Return value** - | Type | Description | - | -------- | -------- | - | boolean | Returns **true** if the input value is of the **RegExp** type; returns **false** otherwise. | +| Type| Description| +| -------- | -------- | +| boolean | Returns **true** if the input value is of the **RegExp** type; returns **false** otherwise.| **Example** ```js @@ -2253,14 +2254,14 @@ Checks whether the input value is of the **Set** type. **System capability**: SystemCapability.Utils.Lang **Parameters** - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | value | Object | Yes | Object to check. | +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| value | Object | Yes| Object to check.| **Return value** - | Type | Description | - | -------- | -------- | - | boolean | Returns **true** if the input value is of the **Set** type; returns **false** otherwise. | +| Type| Description| +| -------- | -------- | +| boolean | Returns **true** if the input value is of the **Set** type; returns **false** otherwise.| **Example** ```js @@ -2278,14 +2279,14 @@ Checks whether the input value is of the **SetIterator** type. **System capability**: SystemCapability.Utils.Lang **Parameters** - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | value | Object | Yes | Object to check. | +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| value | Object | Yes| Object to check.| **Return value** - | Type | Description | - | -------- | -------- | - | boolean | Returns **true** if the input value is of the **SetIterator** type; returns **false** otherwise. | +| Type| Description| +| -------- | -------- | +| boolean | Returns **true** if the input value is of the **SetIterator** type; returns **false** otherwise.| **Example** ```js @@ -2304,14 +2305,14 @@ Checks whether the input value is a string object. **System capability**: SystemCapability.Utils.Lang **Parameters** - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | value | Object | Yes | Object to check. | +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| value | Object | Yes| Object to check.| **Return value** - | Type | Description | - | -------- | -------- | - | boolean | Returns **true** if the input value is a string object; returns **false** otherwise. | +| Type| Description| +| -------- | -------- | +| boolean | Returns **true** if the input value is a string object; returns **false** otherwise.| **Example** ```js @@ -2329,14 +2330,14 @@ Checks whether the input value is a symbol object. **System capability**: SystemCapability.Utils.Lang **Parameters** - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | value | Object | Yes | Object to check. | +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| value | Object | Yes| Object to check.| **Return value** - | Type | Description | - | -------- | -------- | - | boolean | Returns **true** if the input value is a symbol object; returns **false** otherwise. | +| Type| Description| +| -------- | -------- | +| boolean | Returns **true** if the input value is a symbol object; returns **false** otherwise.| **Example** ```js @@ -2357,14 +2358,14 @@ Checks whether the input value is of the **TypedArray** type. **System capability**: SystemCapability.Utils.Lang **Parameters** - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | value | Object | Yes | Object to check. | +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| value | Object | Yes| Object to check.| **Return value** - | Type | Description | - | -------- | -------- | - | boolean | Returns **true** if the input value is of the **TypedArray** type; returns **false** otherwise. | +| Type| Description| +| -------- | -------- | +| boolean | Returns **true** if the input value is of the **TypedArray** type; returns **false** otherwise.| **Example** ```js @@ -2382,14 +2383,14 @@ Checks whether the input value is of the **Uint8Array** type. **System capability**: SystemCapability.Utils.Lang **Parameters** - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | value | Object | Yes | Object to check. | +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| value | Object | Yes| Object to check.| **Return value** - | Type | Description | - | -------- | -------- | - | boolean | Returns **true** if the input value is of the **Uint8Array** type; returns **false** otherwise. | +| Type| Description| +| -------- | -------- | +| boolean | Returns **true** if the input value is of the **Uint8Array** type; returns **false** otherwise.| **Example** ```js @@ -2407,14 +2408,14 @@ Checks whether the input value is of the **Uint8ClampedArray** type. **System capability**: SystemCapability.Utils.Lang **Parameters** - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | value | Object | Yes | Object to check. | +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| value | Object | Yes| Object to check.| **Return value** - | Type | Description | - | -------- | -------- | - | boolean | Returns **true** if the input value is of the **Uint8ClampedArray** type; returns **false** otherwise. | +| Type| Description| +| -------- | -------- | +| boolean | Returns **true** if the input value is of the **Uint8ClampedArray** type; returns **false** otherwise.| **Example** ```js @@ -2432,14 +2433,14 @@ Checks whether the input value is of the **Uint16Array** type. **System capability**: SystemCapability.Utils.Lang **Parameters** - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | value | Object | Yes | Object to check. | +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| value | Object | Yes| Object to check.| **Return value** - | Type | Description | - | -------- | -------- | - | boolean | Returns **true** if the input value is of the **Uint16Array** type; returns **false** otherwise. | +| Type| Description| +| -------- | -------- | +| boolean | Returns **true** if the input value is of the **Uint16Array** type; returns **false** otherwise.| **Example** ```js @@ -2457,14 +2458,14 @@ Checks whether the input value is of the **Uint32Array** type. **System capability**: SystemCapability.Utils.Lang **Parameters** - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | value | Object | Yes | Object to check. | +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| value | Object | Yes| Object to check.| **Return value** - | Type | Description | - | -------- | -------- | - | boolean | Returns **true** if the input value is of the **Uint32Array** type; returns **false** otherwise. | +| Type| Description| +| -------- | -------- | +| boolean | Returns **true** if the input value is of the **Uint32Array** type; returns **false** otherwise.| **Example** ```js @@ -2482,14 +2483,14 @@ Checks whether the input value is of the **WeakMap** type. **System capability**: SystemCapability.Utils.Lang **Parameters** - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | value | Object | Yes | Object to check. | +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| value | Object | Yes| Object to check.| **Return value** - | Type | Description | - | -------- | -------- | - | boolean | Returns **true** if the input value is of the **WeakMap** type; returns **false** otherwise. | +| Type| Description| +| -------- | -------- | +| boolean | Returns **true** if the input value is of the **WeakMap** type; returns **false** otherwise.| **Example** ```js @@ -2507,17 +2508,17 @@ Checks whether the input value is of the **WeakSet** type. **System capability**: SystemCapability.Utils.Lang **Parameters** - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | value | Object | Yes | Object to check. | +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| value | Object | Yes| Object to check.| **Return value** - | Type | Description | - | -------- | -------- | - | boolean | Returns **true** if the input value is of the **WeakSet** type; returns **false** otherwise. | +| Type| Description| +| -------- | -------- | +| boolean | Returns **true** if the input value is of the **WeakSet** type; returns **false** otherwise.| **Example** ```js var that = new util.types(); var result = that.isWeakSet(new WeakSet()); - ``` \ No newline at end of file + ``` diff --git a/en/application-dev/reference/apis/js-apis-vector.md b/en/application-dev/reference/apis/js-apis-vector.md index 9288f871d45e7a08a542221ddf561e6a4e4fe81b..5dd8e49bb0c2467b2885784b9c1281f61e46a003 100644 --- a/en/application-dev/reference/apis/js-apis-vector.md +++ b/en/application-dev/reference/apis/js-apis-vector.md @@ -319,10 +319,10 @@ vector.add(2); vector.add(4); vector.add(5); vector.add(4); -vector.replaceAllElements((value, index) => { +vector.replaceAllElements((value: number, index: number) => { return value = 2 * value; }); -vector.replaceAllElements((value, index) => { +vector.replaceAllElements((value: number, index: number) => { return value = value - 2; }); ``` @@ -394,8 +394,8 @@ vector.add(2); vector.add(4); vector.add(5); vector.add(4); -vector.sort((a, b) => a - b); -vector.sort((a, b) => b - a); +vector.sort((a: number, b: number) => a - b); +vector.sort((a: number, b: number) => b - a); vector.sort(); ``` @@ -620,7 +620,7 @@ vector.add(2); vector.add(4); vector.add(5); vector.add(4); -let result = vector.toSting(); +let result = vector.toString(); ``` ### copyToArray diff --git a/en/application-dev/reference/apis/js-apis-wallpaper.md b/en/application-dev/reference/apis/js-apis-wallpaper.md index 726134af57d86fcb611dd5a03c898d3e656bd272..75dda908af3e32140bf7c94b92ff73117be0ad7e 100644 --- a/en/application-dev/reference/apis/js-apis-wallpaper.md +++ b/en/application-dev/reference/apis/js-apis-wallpaper.md @@ -1,8 +1,7 @@ # Wallpaper -> ![icon-note.gif](public_sys-resources/icon-note.gif) **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 @@ -29,18 +28,18 @@ Defines the wallpaper type. getColors(wallpaperType: WallpaperType, callback: AsyncCallback<Array<RgbaColor>>): void -Obtains the main color information of the wallpaper of a specified type. +Obtains the main color information of the wallpaper of the specified type. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.MiscServices.Wallpaper -- 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. | +**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. | + +**Example** -- Example - ```js wallpaper.getColors(wallpaper.WallpaperType.WALLPAPER_SYSTEM, (error, data) => { if (error) { @@ -56,7 +55,7 @@ Obtains the main color information of the wallpaper of a specified type. getColors(wallpaperType: WallpaperType): Promise<Array<RgbaColor>> -Obtains the main color information of the wallpaper of a specified type. +Obtains the main color information of the wallpaper of the specified type. This API uses a promise to return the result. **System capability**: SystemCapability.MiscServices.Wallpaper @@ -74,20 +73,20 @@ Obtains the main color information of the wallpaper of a specified type. **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)); -}); -``` + ```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 getId(wallpaperType: WallpaperType, callback: AsyncCallback<number>): void -Obtains the ID of the wallpaper of the specified type. +Obtains the ID of the wallpaper of the specified type. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.MiscServices.Wallpaper @@ -100,25 +99,26 @@ Obtains the ID of the wallpaper of the specified type. **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)); -}); -``` + ```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 getId(wallpaperType: WallpaperType): Promise<number> -Obtains the ID of the wallpaper of the specified type. +Obtains the ID of the wallpaper of the specified type. This API uses a promise to return the result. **System capability**: SystemCapability.MiscServices.Wallpaper + **Parameters** | Name | Type | Mandatory | Description | @@ -133,20 +133,20 @@ Obtains the ID of the wallpaper of the specified type. **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)); -}); -``` + ```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 getMinHeight(callback: AsyncCallback<number>): void -Obtains the minimum height of the wallpaper. +Obtains the minimum height of this wallpaper. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.MiscServices.Wallpaper @@ -158,25 +158,26 @@ Obtains the minimum height of the wallpaper. **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)); -}); -``` + ```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 getMinHeight(): Promise<number> -Obtains the minimum height of the wallpaper. +Obtains the minimum height of this wallpaper. This API uses a promise to return the result. **System capability**: SystemCapability.MiscServices.Wallpaper + **Return value** | Type | Description | @@ -185,20 +186,20 @@ Obtains the minimum height of the wallpaper. **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)); -}); -``` + ```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 getMinWidth(callback: AsyncCallback<number>): void -Obtains the minimum width of the wallpaper. +Obtains the minimum width of this wallpaper. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.MiscServices.Wallpaper @@ -210,22 +211,22 @@ Obtains the minimum width of the wallpaper. **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)); -}); -``` + ```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 getMinWidth(): Promise<number> -Obtains the minimum width of the wallpaper. +Obtains the minimum width of this wallpaper. This API uses a promise to return the result. **System capability**: SystemCapability.MiscServices.Wallpaper @@ -237,20 +238,20 @@ Obtains the minimum width of the wallpaper. **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)); -}); -``` + ```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 isChangePermitted(callback: AsyncCallback<boolean>): void -Checks whether to allow the application to change the wallpaper for the current user. +Checks whether to allow the application to change the wallpaper for the current user. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.MiscServices.Wallpaper @@ -258,26 +259,26 @@ Checks whether to allow the application to change the wallpaper for the current | Name | Type | Mandatory | Description | | -------- | -------- | -------- | -------- | -| callback | AsyncCallback<boolean> | Yes | Callback used to return the queried result. Returns **true** if it is allowed; returns **false** otherwise. | +| callback | AsyncCallback<boolean> | Yes | Returns **true** if the application is allowed to change the wallpaper for the current user; 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)); -}); -``` + ```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 isChangePermitted(): Promise<boolean> -Checks whether to allow the application to change the wallpaper for the current user. +Checks whether to allow the application to change the wallpaper for the current user. This API uses a promise to return the result. **System capability**: SystemCapability.MiscServices.Wallpaper @@ -285,24 +286,24 @@ Checks whether to allow the application to change the wallpaper for the current | 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. | +| Promise<boolean> | Returns **true** if the application is allowed to change the wallpaper for the current user; 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)); -}); -``` + ```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 isOperationAllowed(callback: AsyncCallback<boolean>): void -Checks whether the user is allowed to set wallpapers. +Checks whether the user is allowed to set wallpapers. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.MiscServices.Wallpaper @@ -310,26 +311,26 @@ Checks whether the user is allowed to set wallpapers. | 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. | +| callback | AsyncCallback<boolean> | Yes | Returns **true** if the user is allowed to set wallpapers; 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)); -}); -``` + ```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 isOperationAllowed(): Promise<boolean> -Checks whether the user is allowed to set wallpapers. +Checks whether the user is allowed to set wallpapers. This API uses a promise to return the result. **System capability**: SystemCapability.MiscServices.Wallpaper @@ -337,26 +338,26 @@ Checks whether the user is allowed to set wallpapers. | 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. | +| Promise<boolean> | Returns **true** if the user is allowed to set wallpapers; 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)); -}); -``` + ```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 reset(wallpaperType: WallpaperType, callback: AsyncCallback<void>): void -Removes a wallpaper of the specified type and restores the default one. +Resets the wallpaper of the specified type to the default wallpaper. This API uses an asynchronous callback to return the result. -**Required permission**: ohos.permission.SET_WALLPAPER +**Required permissions**: ohos.permission.SET_WALLPAPER **System capability**: SystemCapability.MiscServices.Wallpaper @@ -365,28 +366,28 @@ Removes a wallpaper of the specified type and restores the default one. | 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. | +| callback | AsyncCallback<void> | Yes | Callback used to return the result. If the operation is successful, the result 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.`); -}); -``` + ```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 reset(wallpaperType: WallpaperType): Promise<void> -Removes a wallpaper of the specified type and restores the default one. +Resets the wallpaper of the specified type to the default wallpaper. This API uses a promise to return the result. -**Required permission**: ohos.permission.SET_WALLPAPER +**Required permissions**: ohos.permission.SET_WALLPAPER **System capability**: SystemCapability.MiscServices.Wallpaper @@ -400,26 +401,26 @@ Removes a wallpaper of the specified type and restores the default one. | 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. | +| Promise<void> | Promise used to return the result. If the operation is successful, the result 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)); -}); -``` + ```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 setWallpaper(source: string | image.PixelMap, wallpaperType: WallpaperType, callback: AsyncCallback<void>): void -Sets a specified source as the wallpaper of a specified type. +Sets a specified source as the wallpaper of a specified type. This API uses an asynchronous callback to return the result. -**Required permission**: ohos.permission.SET_WALLPAPER +**Required permissions**: ohos.permission.SET_WALLPAPER **System capability**: SystemCapability.MiscServices.Wallpaper @@ -427,7 +428,7 @@ Sets a specified source as the wallpaper of a specified type. | 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. | +| source | string \| [PixelMap](js-apis-image.md#pixelmap7) | Yes | URI of a JPEG or PNG file, or bitmap of a 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. | @@ -435,45 +436,45 @@ Sets a specified source as the wallpaper of a specified type. ```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.`); -}); - + 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)); -}); -``` + 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 setWallpaper(source: string | image.PixelMap, wallpaperType: WallpaperType): Promise<void> -Sets a specified source as the wallpaper of a specified type. +Sets a specified source as the wallpaper of a specified type. This API uses a promise to return the result. -**Required permission**: ohos.permission.SET_WALLPAPER +**Required permissions**: ohos.permission.SET_WALLPAPER **System capability**: SystemCapability.MiscServices.Wallpaper @@ -494,38 +495,38 @@ Sets a specified source as the wallpaper of a specified type. ```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)); -}); - + 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)); -}); -``` + 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+ getFile(wallpaperType: WallpaperType, callback: AsyncCallback<number>): void -Obtains the wallpaper of the specified type. +Obtains the wallpaper of the specified type. This API uses an asynchronous callback to return the result. **Required permissions**: ohos.permission.SET_WALLPAPER and ohos.permission.READ_USER_STORAGE @@ -540,23 +541,23 @@ Obtains the wallpaper of the specified type. **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)); -}); -``` + ```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+ getFile(wallpaperType: WallpaperType): Promise<number> -Obtains the wallpaper of the specified type. +Obtains the wallpaper of the specified type. This API uses a promise to return the result. -**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 @@ -574,13 +575,75 @@ Obtains the wallpaper of the specified type. **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)); -}); -``` + ```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.getPixelMap + +getPixelMap(wallpaperType: WallpaperType, callback: AsyncCallback<image.PixelMap>): void; + +Obtains the pixel image for the wallpaper of the specified type. This API uses an asynchronous callback to return the result. + +**Required permissions**: ohos.permission.GET_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<void> | Yes| Callback used to return the result. If the operation is successful, the result is returned. Otherwise, error information is returned.| + +**Example** + + ```js + wallpaper.getPixelMap(wallpaper.WallpaperType.WALLPAPER_SYSTEM, function (err, data) { + console.info('wallpaperXTS ===> testGetPixelMapCallbackSystem err : ' + JSON.stringify(err)); + console.info('wallpaperXTS ===> testGetPixelMapCallbackSystem data : ' + JSON.stringify(data)); + }); + ``` + + +## wallpaper.getPixelMap + +getPixelMap(wallpaperType: WallpaperType): Promise<image.PixelMap> + +Obtains the pixel image for the wallpaper of the specified type. This API uses a promise to return the result. + +**Required permissions**: ohos.permission.GET_WALLPAPER and ohos.permission.READ_USER_STORAGE + +**System capability**: SystemCapability.MiscServices.Wallpaper + +**Parameters** + +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| wallpaperType | [WallpaperType](#wallpapertype) | Yes| Wallpaper type.| + +**Return value** + +| Type| Description| +| -------- | -------- | +| Promise<void> | Promise used to return the result. If the operation is successful, the result is returned. Otherwise, error information is returned.| + +**Example** + + ```js + wallpaper.getPixelMap(WALLPAPER_SYSTEM).then((data) => { + console.info('wallpaperXTS ===> testGetPixelMapPromiseSystem data : ' + data); + console.info('wallpaperXTS ===> testGetPixelMapPromiseSystem data : ' + JSON.stringify(data)); + }).catch((err) => { + console.info('wallpaperXTS ===> testGetPixelMapPromiseSystem err : ' + err); + console.info('wallpaperXTS ===> testGetPixelMapPromiseSystem err : ' + JSON.stringify(err)); + }); + ``` ## wallpaper.on('colorChange') @@ -596,16 +659,16 @@ Subscribes to the wallpaper color change event. | 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. | +| 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); -``` + ```js + let listener = (colors, wallpaperType) => { + console.log(`wallpaper color changed.`); + }; + wallpaper.on('colorChange', listener); + ``` ## wallpaper.off('colorChange') @@ -621,15 +684,15 @@ Unsubscribes from the wallpaper color change event. | 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. | +| 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); + ```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. diff --git a/en/application-dev/reference/apis/js-apis-xml.md b/en/application-dev/reference/apis/js-apis-xml.md index c014e5dbbef4cd972a9af5bb77efd71c3c363ae3..1175651b960bcc61cfef74c9c724d281487f6582 100644 --- a/en/application-dev/reference/apis/js-apis-xml.md +++ b/en/application-dev/reference/apis/js-apis-xml.md @@ -1,6 +1,7 @@ # XML Parsing and Generation -> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**
+> **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. @@ -25,7 +26,7 @@ A constructor used to create an **XmlSerializer** instance. | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | -| buffer | ArrayBuffer \| DataView | Yes| **ArrayBuffer** or **DataView** for storing the XML information to write.| +| buffer | ArrayBuffer \| DataView | Yes| **ArrayBuffer** or **DataView** for storing the XML information to write.| | encoding | string | No| Encoding format.| **Example** @@ -55,6 +56,8 @@ Sets an attribute. **Example** ```js +var arrayBuffer = new ArrayBuffer(1024); +var bufView = new DataView(arrayBuffer); var thatSer = new xml.XmlSerializer(bufView); thatSer.setAttributes("importance", "high"); ``` @@ -77,6 +80,8 @@ Adds an empty element. **Example** ```js +var arrayBuffer = new ArrayBuffer(1024); +var bufView = new DataView(arrayBuffer); var thatSer = new xml.XmlSerializer(bufView); thatSer.addEmptyElement("b"); // => ``` @@ -93,6 +98,8 @@ Sets a declaration. **Example** ```js +var arrayBuffer = new ArrayBuffer(1024); +var bufView = new DataView(arrayBuffer); var thatSer = new xml.XmlSerializer(bufView); thatSer.setDeclaration() // => ; ``` @@ -133,6 +140,8 @@ Writes the end tag of the element. **Example** ```js +var arrayBuffer = new ArrayBuffer(1024); +var bufView = new DataView(arrayBuffer); var thatSer = new xml.XmlSerializer(bufView); thatSer.setNamespace("h", "http://www.w3.org/TR/html4/"); thatSer.startElement("table"); @@ -280,7 +289,7 @@ Creates and returns an **XmlPullParser** object. The **XmlPullParser** object pa | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | -| buffer | ArrayBuffer \| DataView | Yes| **ArrayBuffer** or **DataView** that contains XML text information.| +| buffer | ArrayBuffer \| DataView | Yes| **ArrayBuffer** or **DataView** that contains XML text information.| | encoding | string | No| Encoding format. Only UTF-8 is supported.| **Example** @@ -358,9 +367,9 @@ Defines the XML parsing options. | -------- | -------- | -------- | -------- | | supportDoctype | boolean | No| Whether to ignore **Doctype**. The default value is **false**.| | ignoreNameSpace | boolean | No| Whether to ignore **Namespace**. The default value is **false**.| -| tagValueCallbackFunction | (name: string, value: string)=> boolean | No| Callback used to return **tagValue**.| -| attributeValueCallbackFunction | (name: string, value: string)=> boolean | No| Callback used to return **attributeValue**.| -| tokenValueCallbackFunction | (eventType: [EventType](#eventtype), value: [ParseInfo](#parseinfo))=> boolean | No| Callback used to return **tokenValue**.| +| tagValueCallbackFunction | (name: string, value: string)=> boolean | No| Callback used to return **tagValue**.| +| attributeValueCallbackFunction | (name: string, value: string)=> boolean | No| Callback used to return **attributeValue**.| +| tokenValueCallbackFunction | (eventType: [EventType](#eventtype), value: [ParseInfo](#parseinfo))=> boolean | No| Callback used to return **tokenValue**.| ## ParseInfo diff --git a/en/application-dev/reference/arkui-js/js-components-media-video.md b/en/application-dev/reference/arkui-js/js-components-media-video.md index 1e2b132c923351e37d92eafeea3bf71ef34d3fb1..b957ee6d968a2a4b038c4d600d7ea6adef966b40 100644 --- a/en/application-dev/reference/arkui-js/js-components-media-video.md +++ b/en/application-dev/reference/arkui-js/js-components-media-video.md @@ -1,240 +1,134 @@ -# video +# video -The **** component provides a video player. ->![](../../public_sys-resources/icon-note.gif) **NOTE:** ->- Configure the following information in the **config.json** file: -> ``` -> "configChanges": ["orientation"] -> ``` +> **NOTE**
+> +> - This component is supported since API version 4. Updates will be marked with a superscript to indicate their earliest API version. +> +> - Set **configChanges** under **abilities** in the **config.json** file to **orientation**. +> ``` +> "abilities": [ +> { +> "configChanges": ["orientation"], +> ... +> } +> ] +> ``` -## Required Permissions +The **\ diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-plugincomponent.md b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-plugincomponent.md index 5de8e8e49af823f38c955dce1c8eedacbeeff469..482a3ec6773869df4e0b8989657d6e4617a8f628 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-plugincomponent.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-plugincomponent.md @@ -81,7 +81,8 @@ push(param: PushParameters, callback: AsyncCallback<void>): void | extraData | KVObject | 否 | 附加数据值。 | - 示例 - 见[组件使用者调用接口](#组件使用者调用接口)示例。 + + 见[Plugin组件提供方](#组件提供方)示例。 ## request @@ -117,7 +118,8 @@ request(param: RequestParameters, callback: AsyncCallback<RequestCallbackPara - 示例 - 见[组件使用者调用接口](#组件使用者调用接口)示例。 + + 见[Plugin组件使用方](#组件使用方)示例。 ## on @@ -146,22 +148,23 @@ on(eventType: string, callback: OnPushEventCallback | OnRequestEventCallback): v | extraData | KVObjec | 附加数据。 | - 示例 - 见[组件使用者调用接口](#组件使用者调用接口)示例。 + + 见[Plugin组件工具](#Plugin组件工具)示例。 ## 示例 -### 使用PluginComponent组件 +### 组件使用方 -``` -import plugin from "../../test/plugin_component.js" -import plugincomponent from '@ohos.plugincomponent' +```ts +//PluginUserExample.ets +import plugin from "plugin_component.js" @Entry @Component -struct PluginComponentExample { +struct PluginUserExample { @StorageLink("plugincount") plugincount: Object[] = [ { source: 'plugincomponent1', ability: 'com.example.plugin' }, { source: 'plugintemplate', ability: 'com.example.myapplication' }, @@ -172,32 +175,23 @@ struct PluginComponentExample { Text('Hello World') .fontSize(50) .fontWeight(FontWeight.Bold) - Button('Push') - .fontSize(50) - .width(400) - .height(100) - .onClick(() => { - plugin.Push() - console.log("Button('Push')") - }) - .margin({ top: 20 }) - Button('Request1') - .fontSize(50) + Button('Register Request Listener') + .fontSize(30) .width(400) .height(100) - .margin({ top: 20 }) - .onClick(() => { - plugin.Request1() - console.log("Button('Request1')") + .margin({top:20}) + .onClick(()=>{ + plugin.onListener() + console.log("Button('Register Request Listener')") }) - Button('Request2') + Button('Request') .fontSize(50) .width(400) .height(100) .margin({ top: 20 }) .onClick(() => { - plugin.Request2() - console.log("Button('Request2')") + plugin.Request() + console.log("Button('Request')") }) ForEach(this.plugincount, item => { PluginComponent({ @@ -214,15 +208,58 @@ struct PluginComponentExample { } .width('100%') .height('100%') + } } ``` +### 组件提供方 -### 组件使用者调用接口 +```ts +//PluginProviderExample.ets +import plugin from "plugin_component.js" +@Entry +@Component +struct PluginProviderExample { + @State message: string = 'no click!' + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Button('Register Push Listener') + .fontSize(30) + .width(400) + .height(100) + .margin({top:20}) + .onClick(()=>{ + plugin.onListener() + console.log("Button('Register Push Listener')") + }) + Button('Push') + .fontSize(30) + .width(400) + .height(100) + .margin({top:20}) + .onClick(()=>{ + plugin.Push() + this.message = "Button('Push')" + console.log("Button('Push')") + }) + Text(this.message) + .height(150) + .fontSize(30) + .padding(5) + .margin(5) + }.width('100%').height('100%').backgroundColor(0xDCDCDC).padding({ top: 5 }) + } +} ``` -import pluginComponentManager from '@ohos.plugincomponent' + +### Plugin组件工具 + + +```js +//plugin_component.js +import pluginComponentManager from '@ohos.pluginComponent' function onPushListener(source, template, data, extraData) { console.log("onPushListener template.source=" + template.source) @@ -239,14 +276,23 @@ function onPushListener(source, template, data, extraData) { console.log("onPushListener extraData=" + JSON.stringify(extraData)) } +function onRequestListener(source, name, data) +{ + console.log("onRequestListener name=" + name); + console.log("onRequestListener data=" + JSON.stringify(data)); + return {template:"plugintemplate", data:data}; +} + export default { //register listener onListener() { pluginComponentManager.on("push", onPushListener) + pluginComponentManager.on("request", onRequestListener) }, - Request() { - // 组件使用者主动发送事件 - pluginComponentManager.request({ + Push() { + // 组件提供方主动发送事件 + pluginComponentManager.push( + { want: { bundleName: "com.example.myapplication", abilityName: "com.example.myapplication.MainAbility", @@ -256,43 +302,19 @@ export default { "key_1": "plugin component test", "key_2": 34234 }, - jsonPath: "assets/js", + extraData: { + "extra_str": "this is push event" + }, + jsonPath: "", }, (err, data) => { - console.log("request_callback1: componentTemplate.ability=" + data.componentTemplate.ability) - console.log("request_callback1: componentTemplate.source=" + data.componentTemplate.source) - var jsonObject = JSON.parse(data.componentTemplate.source) - console.log("request_callback1:source json object" + jsonObject) - var jsonArry = jsonObject.ExternalComponent - for (var i in jsonArry) { - console.log(jsonArry[i]) - } - console.log("request_callback1:source json string" + JSON.stringify(jsonObject)) - console.log("request_callback1: data=" + JSON.stringify(data.data)) - console.log("request_callback1: extraData=" + JSON.stringify(data.extraData)) + console.log("push_callback: push ok!"); } ) - } -} - -// 组件提供者使用接口示例 -import pluginComponentManager from '@ohos.plugincomponent' - -function onRequestListener(source, name, data) { - console.log("onRequestListener name=" + name) - console.log("onRequestListener data=" + JSON.stringify(data)) - return { template: "plugintemplate", data: data } -} - -export default { - //register listener - onListener() { - pluginComponentManager.on("request", onRequestListener) }, - Push() { - // 组件提供者主动发送事件 - pluginComponentManager.push( - { + Request() { + // 组件使用方主动发送事件 + pluginComponentManager.request({ want: { bundleName: "com.example.myapplication", abilityName: "com.example.myapplication.MainAbility", @@ -302,17 +324,22 @@ export default { "key_1": "plugin component test", "key_2": 34234 }, - extraData: { - "extra_str": "this is push event" - }, - jsonPath: "assets/js", + jsonPath: "", }, (err, data) => { - console.log("push_callback1: componentTemplate.ability=" + data.componentTemplate.ability) - console.log("push_callback1: componentTemplate.source=" + data.componentTemplate.source) - console.log("push ok!") + console.log("request_callback: componentTemplate.ability=" + data.componentTemplate.ability) + console.log("request_callback: componentTemplate.source=" + data.componentTemplate.source) + var jsonObject = JSON.parse(data.componentTemplate.source) + console.log("request_callback:source json object" + jsonObject) + var jsonArry = jsonObject.ExternalComponent + for (var i in jsonArry) { + console.log(jsonArry[i]) + } + console.log("request_callback:source json string" + JSON.stringify(jsonObject)) + console.log("request_callback: data=" + JSON.stringify(data.data)) + console.log("request_callback: extraData=" + JSON.stringify(data.extraData)) } ) - }, + } } ``` diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-progress.md b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-progress.md index 1acb2860c210eb3d445c238c27bfcc3bb81e4cbf..412a9e92d689abe82a752e1e6aa76956218bc71b 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-progress.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-progress.md @@ -86,8 +86,8 @@ struct ProgressExample { Text('Capsule Progress').fontSize(9).fontColor(0xCCCCCC).width('90%') Row({ space: 40 }) { - Progress({ value: 10, type: ProgressType.Capsule }).width(100) - Progress({ value: 20, total: 150, type: ProgressType.Capsule }).color(Color.Grey).value(50).width(100) + Progress({ value: 10, type: ProgressType.Capsule }).width(100).height(50) + Progress({ value: 20, total: 150, type: ProgressType.Capsule }).color(Color.Grey).value(50).width(100).height(50) } }.width('100%').margin({ top: 30 }) } diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-textarea.md b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-textarea.md index f513523443f42d8038c2fc34ed5d3d4d40e1129a..4198db7e5be91587fb5a41102494ed813eb3c43f 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-textarea.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-textarea.md @@ -19,7 +19,7 @@ ## 接口 -TextArea(value?:{placeholder?: string controller?: TextAreaController}) +TextArea(value?:{placeholder?: string, controller?: TextAreaController}) - 参数 | 参数名 | 参数类型 | 必填 | 默认值 | 参数描述 | @@ -89,10 +89,11 @@ caretPosition(value: number): void @Entry @Component struct TextAreaExample1 { + controller: TextAreaController = new TextAreaController() @State text: string = '' build() { Column() { - TextArea({ placeholder: 'input your word'}) + TextArea({ placeholder: 'input your word', controller: this.controller}) .placeholderColor("rgb(0,0,225)") .placeholderFont({ size: 30, weight: 100, family: 'cursive', style: FontStyle.Italic }) .textAlign(TextAlign.Center) @@ -108,6 +109,7 @@ struct TextAreaExample1 { }) .onChange((value: string) => { this.text = value + this.controller.caretPosition(-1) }) Text(this.text).width('90%') } diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-container-navigator.md b/zh-cn/application-dev/reference/arkui-ts/ts-container-navigator.md index b8afaa69fd71ca9e71ee62ddc6b4e7cfa9cf51b9..cab72748f3c7faa088f282a5a93ffc9eb1a5f554 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-container-navigator.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-container-navigator.md @@ -53,12 +53,13 @@ Navigator(value?: {target: string, type?: NavigationType}) @Component struct NavigatorExample { @State active: boolean = false - @State Text: string = 'news' + @State Text: object = {name: 'news'} build() { Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Start, justifyContent: FlexAlign.SpaceBetween }) { Navigator({ target: 'pages/container/navigator/Detail', type: NavigationType.Push }) { - Text('Go to ' + this.Text + ' page').width('100%').textAlign(TextAlign.Center) + Text('Go to ' + this.Text['name'] + ' page') + .width('100%').textAlign(TextAlign.Center) }.params({ text: this.Text }) Navigator() { @@ -79,7 +80,7 @@ import router from '@system.router' @Entry @Component struct DetailExample { - @State text: string = router.getParams().text + @State text: any = router.getParams().text build() { Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Start, justifyContent: FlexAlign.SpaceBetween }) { @@ -87,7 +88,8 @@ struct DetailExample { Text('Go to back page').width('100%').height(20) } - Text('This is ' + this.text + ' page').width('100%').textAlign(TextAlign.Center) + Text('This is ' + this.text['name'] + ' page') + .width('100%').textAlign(TextAlign.Center) } .width('100%').height(200).padding({ left: 35, right: 35, top: 35 }) }