diff --git a/README.md b/README.md
index 602a868e0c5966d52b77eff891a6f32232c7d579..9351f7f58964229343c0dbfc3c9875e212a4a54f 100644
--- a/README.md
+++ b/README.md
@@ -18,7 +18,7 @@ This repository stores device and application development documents provided by
- master: the latest version.
- - OpenHarmony 3.2 Beta3. [Learn more](en/release-notes/OpenHarmony-v3.2-beta3.md)
+ - OpenHarmony 3.2 Beta5. [Learn more](en/release-notes/OpenHarmony-v3.2-beta5.md)
- OpenHarmony 3.1 Release. [Learn more](en/release-notes/OpenHarmony-v3.1-release.md)
@@ -34,7 +34,7 @@ This repository stores device and application development documents provided by
### Historical Stable Versions
-OpenHarmony_v1.x_release: OpenHarmony v1.1.5 LTS. [Learn more](en/release-notes/OpenHarmony-v1.1.5-LTS.md)
+OpenHarmony_v1.x_release: OpenHarmony 1.1.5 LTS. [Learn more](en/release-notes/OpenHarmony-v1.1.5-LTS.md)
[More versions](en/release-notes/)
@@ -51,6 +51,6 @@ You can evaluate available documents, make simple modifications, provide feedbac
Excellent contributors will be awarded and the contributions will be publicized in the developer community.
-- Mail list: docs@openharmony.io
+- Mailing list: docs@openharmony.io
- Zulip group: documentation_sig
\ No newline at end of file
diff --git a/en/application-dev/Readme-EN.md b/en/application-dev/Readme-EN.md
index a627e1116a792c5d4fc885ae01aa6ccb172b7b1d..29bcc1f42bc0624e1eccf130493642699bdc5994 100644
--- a/en/application-dev/Readme-EN.md
+++ b/en/application-dev/Readme-EN.md
@@ -70,7 +70,7 @@
- [DevEco Studio (OpenHarmony) User Guide](quick-start/deveco-studio-user-guide-for-openharmony.md)
- [Debugging Tools](tools/Readme-EN.md)
- Hands-On Tutorials
- - [Samples](https://gitee.com/openharmony/applications_app_samples/blob/master/README.md)
+ - [Samples](https://gitee.com/openharmony/applications_app_samples/blob/monthly_20221018/README.md)
- [Codelabs](https://gitee.com/openharmony/codelabs)
- API References
- [SystemCapability](reference/syscap.md)
diff --git a/en/application-dev/application-dev-guide-for-gitee.md b/en/application-dev/application-dev-guide-for-gitee.md
index 96e956f86e1528c5946c094b204c83e6e7d96222..a7e38127fecf4cf89afff3bb59a1a1a0a5811746 100644
--- a/en/application-dev/application-dev-guide-for-gitee.md
+++ b/en/application-dev/application-dev-guide-for-gitee.md
@@ -48,7 +48,7 @@ DevEco Studio is a high-performance integrated development environment (IDE) rec
### Hands-On Tutorials
-To make you better understand how functions work together and jumpstart your application development projects, we provide stripped-down, real-world [samples](https://gitee.com/openharmony/applications_app_samples/blob/master/README.md) and [codelabs](https://gitee.com/openharmony/codelabs).
+To make you better understand how functions work together and jumpstart your application development projects, we provide stripped-down, real-world [samples](https://gitee.com/openharmony/applications_app_samples/blob/monthly_20221018/README.md) and [codelabs](https://gitee.com/openharmony/codelabs).
### API References
diff --git a/en/application-dev/application-dev-guide.md b/en/application-dev/application-dev-guide.md
index b9bc5bb92ed39b292ca4eede0023989364eb473c..403eded3099303d5b618691bce5846a0f216a16b 100644
--- a/en/application-dev/application-dev-guide.md
+++ b/en/application-dev/application-dev-guide.md
@@ -24,7 +24,7 @@ First thing first, familiarize yourself with the two cornerstone frameworks in O
All applications should be developed on top of these frameworks.
Then, equip yourself for developing the key features, with the following guidelines:
-- [Common Event and Notification](notification/notification-brief.md)
+- [Common Event and Notification](notification/notification-overview.md)
- [Window Manager](windowmanager/window-overview.md)
- [WebGL](webgl/webgl-overview.md)
- [Media](media/audio-overview.md)
@@ -48,7 +48,7 @@ DevEco Studio is a high-performance integrated development environment (IDE) rec
### Hands-On Tutorials
-To make you better understand how functions work together and jumpstart your application development projects, we provide stripped-down, real-world [samples](https://gitee.com/openharmony/applications_app_samples/blob/master/README.md) and [codelabs](https://gitee.com/openharmony/codelabs).
+To make you better understand how functions work together and jumpstart your application development projects, we provide stripped-down, real-world [samples](https://gitee.com/openharmony/applications_app_samples/blob/monthly_20221018/README.md) and [codelabs](https://gitee.com/openharmony/codelabs).
### API References
diff --git a/en/application-dev/application-models/Readme-EN.md b/en/application-dev/application-models/Readme-EN.md
index 2a920300623358bc25f7256d6af8b957665bc600..46ed4f21a9b9654552b106e59aa0f702fa9fcea4 100644
--- a/en/application-dev/application-models/Readme-EN.md
+++ b/en/application-dev/application-models/Readme-EN.md
@@ -17,8 +17,10 @@
- ExtensionAbility Component
- [ExtensionAbility Component Overview](extensionability-overview.md)
- [ServiceExtensionAbility](serviceextensionability.md)
- - [DataShareExtensionAbility](datashareextensionability.md)
+ - [DataShareExtensionAbility (System Applications Only)](datashareextensionability.md)
- [FormExtensionAbility (Widget)](widget-development-stage.md)
+ - [AccessibilityExtensionAbility](accessibilityextensionability.md)
+ - [WindowExtensionAbility](windowextensionability.md)
- [AbilityStage Component Container](abilitystage.md)
- [Context](application-context-stage.md)
- Want
@@ -31,8 +33,8 @@
- [Component Startup Rules](component-startup-rules.md)
- Inter-Device Application Component Interaction (Continuation)
- [Continuation Overview](inter-device-interaction-hop-overview.md)
- - [Cross-Device Migration](hop-cross-device-migration.md)
- - [Multi-device Collaboration](hop-multi-device-collaboration.md)
+ - [Cross-Device Migration (System Applications Only)](hop-cross-device-migration.md)
+ - [Multi-device Collaboration (System Applications Only)](hop-multi-device-collaboration.md)
- IPC
- [Process Model](process-model-stage.md)
- Common Events
@@ -49,7 +51,6 @@
- [Mission Management Scenarios](mission-management-overview.md)
- [Mission Management and Launch Type](mission-management-launch-type.md)
- [Page Stack and MissionList](page-mission-stack.md)
- - [Application Configuration File](config-file-stage.md)
- FA Model Development
- [FA Model Development Overview](fa-model-development-overview.md)
- FA Mode Application Components
@@ -62,7 +63,7 @@
- [Creating a PageAbility](create-pageability.md)
- [Starting a Local PageAbility](start-local-pageability.md)
- [Stopping a PageAbility](stop-pageability.md)
- - [Starting a Remote PageAbility](start-remote-pageability.md)
+ - [Starting a Remote PageAbility (System Applications Only)](start-remote-pageability.md)
- [Starting a Specified Page](start-page.md)
- [Window Properties](window-properties.md)
- [Requesting Permissions](request-permissions.md)
@@ -94,7 +95,6 @@
- [Thread Model](thread-model-fa.md)
- [Inter-Thread Communication](itc-fa-overview.md)
- [Mission Management](mission-management-fa.md)
- - [Application Configuration File](config-file-fa.md)
- Development of Component Interaction Between the FA Model and Stage Model
- [Component Interaction Between the FA Model and Stage Model](fa-stage-interaction-overview.md)
- [Starting a UIAbility from the FA Model](start-uiability-from-fa.md)
diff --git a/en/application-dev/application-models/accessibilityextensionability.md b/en/application-dev/application-models/accessibilityextensionability.md
new file mode 100644
index 0000000000000000000000000000000000000000..4c912d5e58a1b8083ba1037cccf449dd953d245c
--- /dev/null
+++ b/en/application-dev/application-models/accessibilityextensionability.md
@@ -0,0 +1,118 @@
+# AccessibilityExtensionAbility Development
+
+The **AccessibilityExtensionAbility** module provides accessibility extension capabilities based on the **ExtensionAbility** framework. You can develop your accessibility applications by applying the **AccessibilityExtensionAbility** template to enhance usability.
+
+> **Environment Requirements**
+>
+> IDE: DevEco Studio 3.0 Beta3 (3.0.0.900) or later
+>
+> SDK: API version 9 or later
+>
+> Model: stage
+
+This document is organized as follows:
+
+- [Creating an AccessibilityExtAbility File](#creating-an-accessibility-extension-service)
+- [Processing an Accessibility Event](#processing-an-accessibility-event)
+- [Declaring Capabilities of Accessibility Extension Services](#declaring-capabilities-of-accessibility-extension-services)
+- [Enabling a Custom Accessibility Extension Service](#enabling-a-custom-accessibility-extension-service)
+
+## Creating an Accessibility Extension Service
+
+You can create an accessibility extension service by creating a project from scratch or adding the service to an existing project.
+
+### Creating a Project
+
+Perform the following steps in DevEco Studio:
+1. From the upper left corner of DevEco Studio, choose **File** > **New** > **Create Project**.
+2. By following the project creation wizard, click the **OpenHarmony** tab, select the **Empty Ability** template, and then click **Next**.
+3. Set **Project type** to **Application**, **Compile API** (or **Compile SDK**, depending on the version used) to **9**, and **Model** to **Stage**, and then click **Finish**.
+
+### Creating an AccessibilityExtAbility File
+
+To add an accessibility extension service to a project, create the **AccessibilityExtAbility** folder in the **ets** folder of the project, create the **AccessibilityExtAbility.ts** file in the new folder, and add the following code to the new file:
+
+```typescript
+import AccessibilityExtensionAbility from '@ohos.application.AccessibilityExtensionAbility';
+
+class AccessibilityExtAbility extends AccessibilityExtensionAbility {
+ onConnect() {
+ console.log('AccessibilityExtAbility onConnect');
+ }
+
+ onDisconnect() {
+ console.log('AccessibilityExtAbility onDisconnect');
+ }
+
+ onAccessibilityEvent(accessibilityEvent) {
+ console.log('AccessibilityExtAbility onAccessibilityEvent: ' + JSON.stringify(accessibilityEvent));
+ }
+}
+
+export default AccessibilityExtAbility;
+```
+
+The APIs defined in the file are as follows.
+
+| API| Description|
+| ---- | ---- |
+| onConnect(): void | Called when a connection with the extension service is set up.|
+| onDisconnect(): void | Called when the connection with the extension service is severed.|
+| onAccessibilityEvent(event: AccessibilityEvent): void | Called when an accessibility event occurs|
+
+## Processing an Accessibility Event
+
+You can process the service logic for accessibility events in the **onAccessibilityEvent()** API. For details about the events, see [AccessibilityEvent](../reference/apis/js-apis-application-accessibilityExtensionAbility.md#accessibilityevent). The following code snippet uses the **pageStateUpdate** event as an example.
+
+```typescript
+onAccessibilityEvent(accessibilityEvent) {
+ console.log('AccessibilityExtAbility onAccessibilityEvent: ' + JSON.stringify(accessibilityEvent));
+ if (accessibilityEvent.eventType === 'pageStateUpdate') {
+ console.log('AccessibilityExtAbility onAccessibilityEvent: pageStateUpdate');
+ // TODO: Develop custom logic.
+ }
+}
+```
+For an accessibility event, you can use the APIs of the [AccessibilityExtensionContext](../reference/apis/js-apis-inner-application-accessibilityExtensionContext.md) module to configure the concerned information, obtain root information, and inject gestures.
+
+You can also process physical key events in the accessibility extension service. For details, see [onKeyEvent](../reference/apis/js-apis-application-accessibilityExtensionAbility.md#accessibilityextensionabilityonkeyevent).
+
+## Declaring Capabilities of Accessibility Extension Services
+
+After developing the custom logic for an accessibility extension service, you must add the configuration information of the service to the corresponding module-level **module.json5** file in the project directory. In the file, the **srcEntrance** tag indicates the path to the accessibility extension service. Make sure the value of the **type** tag is fixed at **accessibility**. Otherwise, the connection to the service will fail.
+
+```json
+"extensionAbilities": [
+ {
+ "name": "AccessibilityExtAbility",
+ "srcEntrance": "./ets/AccessibilityExtAbility/AccessibilityExtAbility.ts",
+ "label": "$string:MainAbility_label",
+ "description": "$string:MainAbility_desc",
+ "type": "accessibility",
+ "metadata": [
+ {
+ "name": "ohos.accessibleability",
+ "resource": "$profile:accessibility_config"
+ }
+ ]
+ }
+]
+```
+**accessibility_config** is the specific configuration of the accessibility extension service. You need to create the **accessibility_config.json** file in **resources/base/profile/** and declare the [capabilities](../reference/apis/js-apis-accessibility.md#capability) of the service in the file.
+```json
+{
+ "accessibilityCapabilities": [
+ "retrieve",
+ "gesture"
+ ]
+}
+```
+## Enabling a Custom Accessibility Extension Service
+
+To enable or disable an accessibility extension service, run the following command:
+- To enable the service: **accessibility enable -a AccessibilityExtAbility -b com.example.demo -c rg**
+- To disable the service: **accessibility disable -a AccessibilityExtAbility -b com.example.demo**
+
+In the preceding commands, **AccessibilityExtAbility** indicates the name of the accessibility extension service, **com.example.demo** indicates the bundle name, and **rg** indicates the capabilities (**r** is short for retrieve).
+
+If the service is enabled or disabled successfully, the message "enable ability successfully" or "disable ability successfully" is displayed.
diff --git a/en/application-dev/application-models/application-component-configuration-stage.md b/en/application-dev/application-models/application-component-configuration-stage.md
index de9e29941b5ddcc9e29f62ddc039fb38b6bc54b6..356429972800d60f1062a6c180934d237e648e26 100644
--- a/en/application-dev/application-models/application-component-configuration-stage.md
+++ b/en/application-dev/application-models/application-component-configuration-stage.md
@@ -3,7 +3,8 @@
When developing an application, you may need to configure certain tags to identify the application, such as the bundle name and application icon. This topic describes key tags that need to be configured during application development. Icons and labels are usually configured together. There is the application icon, application label, entry icon, and entry label, which correspond to the **icon** and **label** fields in the [app.json5 file](../quick-start/app-configuration-file.md) and [module.json5 file](../quick-start/module-configuration-file.md). The application icon and label are used in **Settings**. For example, they are displayed in the application list in **Settings**. The entry icon is displayed on the device's home screen after the application is installed. The entry icon maps to a [UIAbility](uiability-overview.md) component. Therefore, an application can have multiple entry icons and labels. When you touch one of them, the corresponding UIAbility page is displayed.
-**Figure 1** Icons and labels
+
+ **Figure 1** Icons and labels

@@ -14,11 +15,11 @@ When developing an application, you may need to configure certain tags to identi
- **Configuring the application icon and label**
- The application icon is specified by the **icon** field in the [app.json5 file](../quick-start/app-configuration-file.md) in the **AppScope** directory of the project. The **icon** field must be set to the index of an image so that the image is displayed as the application icon. The application icon is usually displayed in an application list, for example, the application list in **Settings**.
+ You must configure an icon and label for an application on the stage model.
- The application label is specified by the **label** field in the [app.json5 file](../quick-start/app-configuration-file.md) in the **AppScope** module of the project. The **label** field specifies the application name displayed to users. It must be set to the index of a string resource.
+ The application icon is specified by the **icon** field in the [app.json5 file](../quick-start/app-configuration-file.md) in the **AppScope** directory of the project. The **icon** field must be set to the index of an image so that the image is displayed as the application icon.
- The **icon** and **label** fields in the **app.json5** file are under **app**, as follows:
+ The application label is specified by the **label** field in the [app.json5 file](../quick-start/app-configuration-file.md) in the **AppScope** module of the project. The **label** field specifies the application name displayed to users. It must be set to the index of a string resource.
```json
{
@@ -32,7 +33,11 @@ When developing an application, you may need to configure certain tags to identi
- **Configuring the entry icon and label**
- The entry icon and label are configured by specifying **icon** and **label** under **abilities** in the [module.json5 file](../quick-start/module-configuration-file.md). For example, if you want to display the icon and label of the UIAbility component on the home screen, add **entity.system.home** to **entities** and **action.system.home** to **actions** under **skills**. If the preceding fields are configured for multiple UIAbility components of an application, multiple icons and labels are displayed on the home screen, corresponding to their respective UIAbility component.
+ On the stage model, you can configure an entry icon and label for each application component. The entry icon and label are displayed on the home screen.
+
+ The entry icon is configured by specifying **icon** under **abilities** in the [module.json5 file](../quick-start/module-configuration-file.md). For example, if you want to display the icon of the UIAbility component on the home screen, add **entity.system.home** to **entities** and **action.system.home** to **actions** under **skills**. If this field is configured for multiple UIAbility components of an application, multiple icons are displayed on the home screen, corresponding to their respective UIAbility component.
+
+ The entry label is configured by specifying **label** under **abilities** in the [module.json5 file](../quick-start/module-configuration-file.md). For example, if you want to display the icon of the UIAbility component on the home screen, add **entity.system.home** to **entities** and **action.system.home** to **actions** under **skills**. If this field is configured for multiple UIAbility components of an application, multiple labels are displayed on the home screen, corresponding to their respective UIAbility component.
```json
{
@@ -58,6 +63,7 @@ When developing an application, you may need to configure certain tags to identi
}
}
```
+
- **Configuring application version declaration**
To declare the application version, configure the **versionCode** and **versionName** fields in the [app.json5 file](../quick-start/app-configuration-file.md) in the **AppScope** directory of the project. **versionCode** specifies the version number of the application. The value is a 32-bit non-negative integer. It is used only to determine whether a version is later than another version. A larger value indicates a later version. **versionName** provides the text description of the version number.
@@ -69,4 +75,3 @@ When developing an application, you may need to configure certain tags to identi
- **Configuring the module permission**
The **requestPermission** field in the [module.json5 file](../quick-start/module-configuration-file.md) is used to configure the permission information required by the module to access the protected part of the system or other applications. This field declares the name of the permission to request, the reason for requesting the permission, and the scenario where the permission is used.
-
diff --git a/en/application-dev/application-models/application-model-description.md b/en/application-dev/application-models/application-model-description.md
index de7e3045d79eff2c681291f8d4de55129d361245..0cdfa7323c6ef367a47a44e2c30104d3201ca159 100644
--- a/en/application-dev/application-models/application-model-description.md
+++ b/en/application-dev/application-models/application-model-description.md
@@ -14,7 +14,7 @@ The stage model is designed based on the following considerations, which make it
1. **Designed for complex applications**
- In the stage model, multiple application components share an ArkTS engine (VM running the programming language ArkTS) instance, making it easy for application components to share objects and status while requiring less memory.
-- The object-oriented development mode makes the code of complex applications easy to read, maintain, and scale.
+ - The object-oriented development mode makes the code of complex applications easy to read, maintain, and scale.
2. **Native support for [cross-device migration](hop-cross-device-migration.md) and [multi-device collaboration](hop-multi-device-collaboration.md) at the application component level**
@@ -48,13 +48,12 @@ In the stage model, multiple application components share the same ArkTS engine
The table below describes their differences in detail.
- **Table 1** Differences between the FA model and stage model
+**Table 1** Differences between the FA model and stage model
| Item| FA model| Stage model|
| -------- | -------- | -------- |
-| **Application component**| 1. Component classification
- PageAbility: has the UI and supports user interaction. For details, see [PageAbility Component Overview](pageability-overview.md).
- ServiceAbility: provides background services and has no UI. For details, see [ServiceAbility Component Overview](serviceability-overview.md).
- DataAbility: provides the data sharing capability and has no UI. For details, see [DataAbility Component Overview](dataability-overview.md).
2. Development mode
Application components are specified by exporting anonymous objects and fixed entry files. You cannot perform derivation. It is inconvenient for capability expansion.| 1. Component classification
- UIAbility: has the UI and supports user interaction. For details, see [UIAbility Component Overview](uiability-overview.md).
- ExtensionAbility: provides extension capabilities (such as widget and input methods) for specific scenarios. For details, see [ExtensionAbility Component Overview](extensionability-overview.md).
2. Development mode
The object-oriented mode is used to provide open application components as classes. You can derive application components for capability expansion.|
-| **Process model**| There are two types of processes:
1. Main process
2. Rendering process
For details, see [Process Model (FA Model)](process-model-fa.md). | There are three types of processes:
1. Main process
2. ExtensionAbility process
3. Rendering process
For details, see [Process Model (Stage Model)](process-model-stage.md). |
-| **Thread model**| 1. ArkTS engine instance creation
A process can run multiple application component instances, and each application component instance runs in an independent ArkTS engine instance.
2. Thread model
Each ArkTS engine instance is created on an independent thread (non-main thread). The main thread does not have an ArkTS engine instance.
3. Intra-process object sharing: not supported.
For details, see [Thread Model (FA Model)](thread-model-fa.md). | 1. ArkTS engine instance creation
A process can run multiple application component instances, and all application component instances share one ArkTS engine instance.
2. Thread model
The ArkTS engine instance is created on the main thread.
3. Intra-process object sharing: supported.
For details, see [Thread Model (Stage Model)](thread-model-stage.md). |
+| **Application component**| 1. Component classification

- PageAbility: has the UI and supports user interaction For details, see [PageAbility Component Overview](pageability-overview.md).
- ServiceAbility: provides background services and has no UI. For details, see [ServiceAbility Component Overview](serviceability-overview.md).
- DataAbility: provides the data sharing capability and has no UI. For details, see [DataAbility Component Overview](dataability-overview.md).
2. Development mode
Application components are specified by exporting anonymous objects and fixed entry files. You cannot perform derivation. It is inconvenient for capability expansion. | 1. Component classification

- UIAbility: has the UI and supports user interaction. For details, see [UIAbility Component Overview](uiability-overview.md).
- ExtensionAbility: provides extension capabilities (such as widget and input methods) for specific scenarios. For details, see [ExtensionAbility Component Overview](extensionability-overview.md).
2. Development mode
The object-oriented mode is used to provide open application components as classes. You can derive application components for capability expansion. |
+| **Process model**| There are two types of processes:
1. Main process
2. Rendering process
For details, see [Process Model (FA Model)](process-model-fa.md).| There are three types of processes:
1. Main process
2. ExtensionAbility process
3. Rendering process
For details, see [Process Model (Stage Model)](process-model-stage.md).|
+| **Thread model**| 1. ArkTS engine instance creation
A process can run multiple application component instances, and each application component instance runs in an independent ArkTS engine instance.
2. Thread model
Each ArkTS engine instance is created on an independent thread (non-main thread). The main thread does not have an ArkTS engine instance.
3. Intra-process object sharing: not supported.
For details, see [Thread Model (FA Model)](thread-model-fa.md).| 1. ArkTS engine instance creation
A process can run multiple application component instances, and all application component instances share one ArkTS engine instance.
2. Thread model
The ArkTS engine instance is created on the main thread.
3. Intra-process object sharing: supported.
For details, see [Thread Model (Stage Model)](thread-model-stage.md).|
| **Mission management model**| - A mission is created for each PageAbility component instance.
- Missions are stored persistently until the number of missions exceeds the maximum (customized based on the product configuration) or users delete missions.
- PageAbility components do not form a stack structure.
For details, see [Mission Management Scenarios](mission-management-overview.md).| - A mission is created for each UIAbility component instance.
- Missions are stored persistently until the number of missions exceeds the maximum (customized based on the product configuration) or users delete missions.
- UIAbility components do not form a stack structure.
For details, see [Mission Management Scenarios](mission-management-overview.md).|
| **Application configuration file**| The **config.json** file is used to describe the application, HAP, and application component information.
For details, see [Application Configuration File Overview (FA Model)](../quick-start/application-configuration-file-overview-fa.md).| The **app.json5** file is used to describe the application information, and the **module.json5** file is used to describe the HAP and application component information.
For details, see [Application Configuration File Overview (Stage Model)](../quick-start/application-configuration-file-overview-stage.md).|
-
diff --git a/en/application-dev/application-models/datashareextensionability.md b/en/application-dev/application-models/datashareextensionability.md
index 5b07ba68180fbcc2a51047d37ca9a82addd89cd8..1f968abfa743d7fb917fb7db3e0e41342e41c848 100644
--- a/en/application-dev/application-models/datashareextensionability.md
+++ b/en/application-dev/application-models/datashareextensionability.md
@@ -1,4 +1,4 @@
-# DataShareExtensionAbility
+# DataShareExtensionAbility (System Applications Only)
-DataShareExtensionAbility is available only for system application. It provides the data sharing capability. System applications can implement a DataShareExtensionAbility or access an existing DataShareExtensionAbility in the system. Third-party applications can only access an existing DataShareExtensionAbility. For details, see [DataShare Development](../database/database-datashare-guidelines.md).
+DataShareExtensionAbility provides the data sharing capability. System applications can implement a DataShareExtensionAbility or access an existing DataShareExtensionAbility in the system. Third-party applications can only access an existing DataShareExtensionAbility. For details, see [DataShare Development](../database/database-datashare-guidelines.md).
diff --git a/en/application-dev/application-models/extensionability-overview.md b/en/application-dev/application-models/extensionability-overview.md
index d85f02ace879e409a8d42d6f09408680a99f8056..5f03c023d20bc16e64a2eb4a28bbe026f0a7feb7 100644
--- a/en/application-dev/application-models/extensionability-overview.md
+++ b/en/application-dev/application-models/extensionability-overview.md
@@ -9,7 +9,7 @@ An [ExtensionAbilityType](../reference/apis/js-apis-bundleManager.md#extensionab
- [FormExtensionAbility](../reference/apis/js-apis-app-form-formExtensionAbility.md): ExtensionAbility component of the form type, which provides APIs related to widgets.
-- [WorkSchedulerExtensionAbility](../reference/apis/js-apis-resourceschedule-workScheduler.md): ExtensionAbility component of the work_scheduler type, which provides APIs for registering, canceling, and querying Work Scheduler tasks.
+- [WorkSchedulerExtensionAbility](../reference/apis/js-apis-WorkSchedulerExtensionAbility.md): ExtensionAbility component of the work_scheduler type, which provides APIs for registering, canceling, and querying Work Scheduler tasks.
- [InputMethodExtensionAbility](../reference/apis/js-apis-inputmethod.md): ExtensionAbility component of the input_method type, which provides an input method framework that can be used to hide the keyboard, obtain the list of installed input methods, display the dialog box for input method selection, and more.
@@ -21,7 +21,7 @@ An [ExtensionAbilityType](../reference/apis/js-apis-bundleManager.md#extensionab
- [StaticSubscriberExtensionAbility](../reference/apis/js-apis-application-staticSubscriberExtensionAbility.md): ExtensionAbility component of the static_subscriber type, which provides APIs for static broadcast.
-- [WindowExtensionAbility](../reference/apis/js-apis-application-windowExtensionAbility.md): ExtensionAbility component of the window type, which allows system applications to display UIs of other applications.
+- [WindowExtensionAbility](../reference/apis/js-apis-application-windowExtensionAbility.md): ExtensionAbility component of the window type, which allows a system application to be embedded in and displayed over another application.
- [EnterpriseAdminExtensionAbility](../reference/apis/js-apis-EnterpriseAdminExtensionAbility.md): ExtensionAbility component of the enterprise_admin type, which provides APIs for processing enterprise management events, such as application installation events on devices and events indicating too many incorrect screen-lock password attempts.
@@ -33,6 +33,7 @@ All types of ExtensionAbility components are started by the corresponding system
The following uses [InputMethodExtensionAbility](../reference/apis/js-apis-inputmethod.md) as an example. As shown in the figure below, when an application calls the InputMethodExtensionAbility component, the input method management service is called first. The input method management service starts the InputMethodExtensionAbility component, returns the component to the application, and starts to manage its lifecycle.
**Figure 1** Using the InputMethodExtensionAbility component
+

@@ -48,11 +49,11 @@ You do not need to care when to add or delete a widget. The lifecycle of the For
> **NOTE**
>
> For an application, all ExtensionAbility components of the same type run in an independent process, whereas UIAbility, ServiceExtensionAbility, and DataShareExtensionAbility run in another independent process. For details, see [Process Model (Stage Model)](process-model-stage.md).
->
+>
> For example, an application has one UIAbility component, one ServiceExtensionAbility, one DataShareExtensionAbility, two FormExtensionAbility, and one ImeExtensionAbility. When the application is running, there are three processes:
->
+>
> - UIAbility, ServiceExtensionAbility, and DataShareExtensionAbility run in an independent process.
->
+>
> - The two FormExtensionAbility components run in an independent process.
->
+>
> - The two ImeExtensionAbility components run in an independent process.
diff --git a/en/application-dev/application-models/figures/fa-model-component.png b/en/application-dev/application-models/figures/fa-model-component.png
new file mode 100644
index 0000000000000000000000000000000000000000..0c28038326c5475abb3f897c5f7cbe9eb50aec00
Binary files /dev/null and b/en/application-dev/application-models/figures/fa-model-component.png differ
diff --git a/en/application-dev/application-models/figures/mission-chain3.png b/en/application-dev/application-models/figures/mission-chain3.png
index e02c135ad4a90f99bb65bdccd821d29990b9536e..0357874ea633a490da800ef5baa2e70d53ce6a2d 100644
Binary files a/en/application-dev/application-models/figures/mission-chain3.png and b/en/application-dev/application-models/figures/mission-chain3.png differ
diff --git a/en/application-dev/application-models/figures/stage-model-component.png b/en/application-dev/application-models/figures/stage-model-component.png
new file mode 100644
index 0000000000000000000000000000000000000000..6de8c778aff28cc9c7353270ce8ab4ad0c10fb02
Binary files /dev/null and b/en/application-dev/application-models/figures/stage-model-component.png differ
diff --git a/en/application-dev/application-models/hop-cross-device-migration.md b/en/application-dev/application-models/hop-cross-device-migration.md
index 6d30435a819da49855cf9ae818bac419a1c0b614..a482ae26ced4987d0b0c02382ac132c42ea932c0 100644
--- a/en/application-dev/application-models/hop-cross-device-migration.md
+++ b/en/application-dev/application-models/hop-cross-device-migration.md
@@ -1,9 +1,9 @@
-# Cross-Device Migration
+# Cross-Device Migration (System Applications Only)]
## When to Use
-Cross-device migration is available only for system applications. The main task is to migrate the current task (including the page control status) of an application to the target device so that the task can continue on it. Cross-device migration supports the following functionalities:
+The main task of cross-device migration is to migrate the current task (including the page control status) of an application to the target device so that the task can continue on it. Cross-device migration supports the following functionalities:
- Storage and restoration of custom data
diff --git a/en/application-dev/application-models/hop-multi-device-collaboration.md b/en/application-dev/application-models/hop-multi-device-collaboration.md
index 3a6fa2646a37785d41793407d4803d60743342dd..50fa38b975f137a508063869ac2760beb2dbbcdb 100644
--- a/en/application-dev/application-models/hop-multi-device-collaboration.md
+++ b/en/application-dev/application-models/hop-multi-device-collaboration.md
@@ -1,9 +1,9 @@
-# Multi-device Collaboration
+# Multi-device Collaboration (System Applications Only)
## When to Use
-Multi-device coordination is available only for system applications. It involves the following scenarios:
+Multi-device coordination involves the following scenarios:
- [Starting UIAbility and ServiceExtensionAbility Across Devices (No Data Returned)](#starting-uiability-and-serviceextensionability-across-devices-no-data-returned)
diff --git a/en/application-dev/application-models/serviceextensionability.md b/en/application-dev/application-models/serviceextensionability.md
index c4ffdbd980fff4ce568115f92af884da06739ad2..edccb0b736c9ad81f5ae316e7310b6cc35ae34e0 100644
--- a/en/application-dev/application-models/serviceextensionability.md
+++ b/en/application-dev/application-models/serviceextensionability.md
@@ -1,5 +1,6 @@
# ServiceExtensionAbility
+
[ServiceExtensionAbility](../reference/apis/js-apis-app-ability-serviceExtensionAbility.md) is an ExtensionAbility component of the service type that provides extension capabilities related to background services.
@@ -17,9 +18,9 @@ Each type of ExtensionAbility has its own context. ServiceExtensionAbility has [
This topic describes how to use ServiceExtensionAbility in the following scenarios:
-- [Implementing a Background Service](#implementing-a-background-service)
+- [Implementing a Background Service (System Applications Only)](#implementing-a-background-service-system-applications-only)
-- [Starting a Background Service](#starting-a-background-service)
+- [Starting a Background Service (System Applications Only)](#starting-a-background-service-system-applications-only)
- [Connecting to a Background Service](#connecting-to-a-background-service)
@@ -32,36 +33,32 @@ This topic describes how to use ServiceExtensionAbility in the following scenari
> - Third-party applications can connect to ServiceExtensionAbility provided by the system only when they gain focus in the foreground.
-## Implementing a Background Service
+## Implementing a Background Service (System Applications Only)
-This feature applies only to system applications. [ServiceExtensionAbility](../reference/apis/js-apis-app-ability-serviceExtensionAbility.md) provides the callbacks **onCreate()**, **onRequest()**, **onConnect()**, **onDisconnect()**, and **onDestory()**. Override them as required. The following figure shows the lifecycle of ServiceExtensionAbility.
+[ServiceExtensionAbility](../reference/apis/js-apis-app-ability-serviceExtensionAbility.md) provides the callbacks **onCreate()**, **onRequest()**, **onConnect()**, **onDisconnect()**, and **onDestory()**. Override them as required. The following figure shows the lifecycle of ServiceExtensionAbility.
**Figure 1** ServiceExtensionAbility lifecycle

- **onCreate**
-
-This callback is triggered when a service is created for the first time. You can perform initialization operations, for example, registering a common event listener.
+ This callback is triggered when a service is created for the first time. You can perform initialization operations, for example, registering a common event listener.
> **NOTE**
->
+ >
> If a service has been created, starting it again does not trigger the **onCreate()** callback.
- **onRequest**
-
-This callback is triggered when another component calls the **startServiceExtensionAbility()** method to start the service. After being started, the service runs in the background.
+ This callback is triggered when another component calls the **startServiceExtensionAbility()** method to start the service. After being started, the service runs in the background.
- **onConnect**
-
-This callback is triggered when another component calls the **connectServiceExtensionAbility()** method to connect to the service. In this method, a remote proxy object (IRemoteObject) is returned, through which the client communicates with the server by means of RPC.
+ This callback is triggered when another component calls the **connectServiceExtensionAbility()** method to connect to the service. In this method, a remote proxy object (IRemoteObject) is returned, through which the client communicates with the server by means of RPC.
- **onDisconnect**
-
-This callback is triggered when a component calls the **disconnectServiceExtensionAbility()** method to disconnect from the service.
+ This callback is triggered when a component calls the **disconnectServiceExtensionAbility()** method to disconnect from the service.
- **onDestroy**
@@ -167,9 +164,9 @@ To implement a background service, manually create a ServiceExtensionAbility com
```
-## Starting a Background Service
+## Starting a Background Service (System Applications Only)
-This feature applies only to system applications. A system application uses the [startServiceExtensionAbility()](../reference/apis/js-apis-inner-application-uiAbilityContext.md#abilitycontextstartserviceextensionability) method to start a background service. The [onRequest()](../reference/apis/js-apis-app-ability-serviceExtensionAbility.md#serviceextensionabilityonrequest) callback is invoked, and the **Want** object passed by the caller is received through the callback. After the background service is started, its lifecycle is independent of that of the client. In other words, even if the client is destroyed, the background service can still run. Therefore, the background service must be stopped by calling [terminateSelf()](../reference/apis/js-apis-inner-application-serviceExtensionContext.md#serviceextensioncontextterminateself) when its work is complete. Alternatively, another component can call [stopServiceExtensionAbility()](../reference/apis/js-apis-inner-application-uiAbilityContext.md#abilitycontextstopserviceextensionability) to stop the background service.
+A system application uses the [startServiceExtensionAbility()](../reference/apis/js-apis-inner-application-uiAbilityContext.md#abilitycontextstartserviceextensionability) method to start a background service. The [onRequest()](../reference/apis/js-apis-app-ability-serviceExtensionAbility.md#serviceextensionabilityonrequest) callback is invoked, and the **Want** object passed by the caller is received through the callback. After the background service is started, its lifecycle is independent of that of the client. In other words, even if the client is destroyed, the background service can still run. Therefore, the background service must be stopped by calling [terminateSelf()](../reference/apis/js-apis-inner-application-serviceExtensionContext.md#serviceextensioncontextterminateself) when its work is complete. Alternatively, another component can call [stopServiceExtensionAbility()](../reference/apis/js-apis-inner-application-uiAbilityContext.md#abilitycontextstopserviceextensionability) to stop the background service.
> **NOTE**
>
diff --git a/en/application-dev/application-models/start-remote-pageability.md b/en/application-dev/application-models/start-remote-pageability.md
index 4e998a15d23d298bfdb402bd18ea0db2a9f819eb..7d270a68058448025def436e71ace635b4a1297c 100644
--- a/en/application-dev/application-models/start-remote-pageability.md
+++ b/en/application-dev/application-models/start-remote-pageability.md
@@ -1,7 +1,7 @@
-# Starting a Remote PageAbility
+# Starting a Remote PageAbility (System Applications Only)
-This feature applies only to system applications. The **startAbility()** method in the **featureAbility** class is used to start a remote PageAbility.
+The **startAbility()** method in the **featureAbility** class is used to start a remote PageAbility.
In addition to **'\@ohos.ability.featureAbility'**, you must import **'\@ohos.distributedHardware.deviceManager'**, which provides account-independent distributed device networking capabilities. Then you can use **getTrustedDeviceListSync** of the **DeviceManager** module to obtain the remote device ID and pass the remote device ID in the **want** parameter for starting the remote PageAbility.
diff --git a/en/application-dev/application-models/uiability-intra-device-interaction.md b/en/application-dev/application-models/uiability-intra-device-interaction.md
index 78363a3a2b65bee17a2ea7524b2fe7180de38909..4ec507ae7043e9b95f47a2ec954f1e95c52d53cb 100644
--- a/en/application-dev/application-models/uiability-intra-device-interaction.md
+++ b/en/application-dev/application-models/uiability-intra-device-interaction.md
@@ -17,7 +17,7 @@ This topic describes the UIAbility interaction modes in the following scenarios.
- [Starting a Specified Page of UIAbility](#starting-a-specified-page-of-uiability)
-- [Using Ability Call to Implement UIAbility Interaction](#using-ability-call-to-implement-uiability-interaction)
+- [Using Ability Call to Implement UIAbility Interaction (System Applications Only)](#using-ability-call-to-implement-uiability-interaction-system-applications-only)
## Starting UIAbility in the Same Application
@@ -416,9 +416,9 @@ In summary, when a UIAbility instance of application A has been created and the
> When the [launch type of the callee UIAbility](uiability-launch-type.md) is set to **standard**, a new instance is created each time the callee UIAbility is started. In this case, the [onNewWant()](../reference/apis/js-apis-app-ability-uiAbility.md#abilityonnewwant) callback will not be invoked.
-## Using Ability Call to Implement UIAbility Interaction
+## Using Ability Call to Implement UIAbility Interaction (System Applications Only)
-This feature applies only to system applications. Ability call is an extension of the UIAbility capability. It enables the UIAbility to be invoked by and communicate with external systems. The UIAbility invoked can be either started in the foreground or created and run in the background. You can use the ability call to implement data sharing between two UIAbility instances (caller ability and callee ability) through IPC.
+Ability call is an extension of the UIAbility capability. It enables the UIAbility to be invoked by and communicate with external systems. The UIAbility invoked can be either started in the foreground or created and run in the background. You can use the ability call to implement data sharing between two UIAbility instances (caller ability and callee ability) through IPC.
The core API used for the ability call is **startAbilityByCall**, which differs from **startAbility** in the following ways:
diff --git a/en/application-dev/application-models/uiability-overview.md b/en/application-dev/application-models/uiability-overview.md
index 14cb5c4652749c97dd6e50c4232b6f65fb6feaab..6767d667e441f6baee987d175c30052bac0afc01 100644
--- a/en/application-dev/application-models/uiability-overview.md
+++ b/en/application-dev/application-models/uiability-overview.md
@@ -3,7 +3,7 @@
## Overview
-UIAbility has the UI and is mainly used for user interaction.
+UIAbility is a type of application component that provides the UI for user interaction.
UIAbility is the basic unit scheduled by the system and provides a window for applications to draw UIs. A UIAbility component can implement a functional module through multiple pages. Each UIAbility component instance corresponds to a mission in **Recents**.
@@ -32,8 +32,3 @@ To enable an application to properly use a UIAbility component, declare the UIAb
}
}
```
-
-> **NOTE**
->
-> For the ability composition, see [Adding an Ability to a Module](https://developer.harmonyos.com/en/docs/documentation/doc-guides-V3/ohos-adding-ability-0000001218280664-V3).
-
diff --git a/en/application-dev/application-models/windowextensionability.md b/en/application-dev/application-models/windowextensionability.md
new file mode 100644
index 0000000000000000000000000000000000000000..cf2ce01947412e479d29516601c45aebc2b55b17
--- /dev/null
+++ b/en/application-dev/application-models/windowextensionability.md
@@ -0,0 +1,112 @@
+# WindowExtensionAbility
+
+[WindowExtensionAbility](../reference/apis/js-apis-application-windowExtensionAbility.md) is a type of ExtensionAbility component that allows a system application to be embedded in and displayed over another application.
+
+
+The WindowExtensionAbility component must be used together with the [AbilityComponent](../reference/arkui-ts/ts-container-ability-component.md) to process services of the started application. WindowExtensionAbility is run in connection mode. A system application must use the AbilityComponent to start the WindowExtensionAbility component.
+
+Each ExtensionAbility has its own context. For WindowExtensionAbility,
+the context is [WindowExtensionContext](../reference/apis/js-apis-inner-application-windowExtensionContext.md).
+
+> **NOTE**
+>
+> **WindowExtensionAbility** is a system API. To embed a third-party application in another application and display it over the application, switch to the full SDK by following the instructions provided in [Guide to Switching to Full SDK](../../application-dev/quick-start/full-sdk-switch-guide.md).
+>
+
+
+## Setting an Embedded Ability (System Applications Only)
+
+The **WindowExtensionAbility** class provides **onConnect()**, **onDisconnect()**, and **onWindowReady()** lifecycle callbacks, which can be overridden.
+
+- The **onWindowReady()** callback is invoked when a window is created for the ability.
+
+- The **onConnect()** callback is invoked when the AbilityComponent corresponding to the window connects to the ability.
+
+- The **onDisconnect()** callback is invoked when the AbilityComponent disconnects from the ability.
+
+
+**How to Develop**
+
+To implement an embedded application, manually create a WindowExtensionAbility in DevEco Studio as follows:
+
+1. In the **ets** directory of the **Module** project, right-click and choose **New > Directory** to create a directory named **WindowExtAbility**.
+
+2. Right-click the **WindowExtAbility** directory, and choose **New > TypeScript File** to create a file named **WindowExtAbility.ts**.
+
+3. Open the **WindowExtAbility.ts** file and import the dependency package of **WindowExtensionAbility**. Customize a class that inherits from **WindowExtensionAbility** and implement the **onWindowReady()**, **onConnect()**, and **onDisconnect()** lifecycle callbacks.
+
+ ```ts
+ import Extension from '@ohos.application.WindowExtensionAbility'
+
+ export default class WindowExtAbility extends Extension {
+ onWindowReady(window) {
+ window.loadContent('WindowExtAbility/pages/index1').then(() => {
+ window.getProperties().then((pro) => {
+ console.log("WindowExtension " + JSON.stringify(pro));
+ })
+ window.show();
+ })
+ }
+
+ onConnect(want) {
+ console.info('JSWindowExtension onConnect ' + want.abilityName);
+ }
+
+ onDisconnect(want) {
+ console.info('JSWindowExtension onDisconnect ' + want.abilityName);
+ }
+ }
+ ```
+
+4. Register the WindowExtensionAbility in the [module.json5 file](../quick-start/module-configuration-file.md) corresponding to the **Module** project. Set **type** to **"window"** and **srcEntrance** to the code path of the ExtensionAbility component.
+
+ ```json
+ {
+ "module": {
+ "extensionAbilities": [
+ {
+ "name": "WindowExtAbility",
+ "srcEntrance": "./ets/WindowExtAbility/WindowExtAbility.ts",
+ "icon": "$media:icon",
+ "description": "WindowExtension",
+ "type": "window",
+ "visible": true,
+ }
+ ],
+ }
+ }
+ ```
+
+
+## Starting an Embedded Ability (System Applications Only)
+
+System applications can load the created WindowExtensionAbility through the AbilityComponent.
+
+**How to Develop**
+
+1. To connect to an embedded application, add the AbilityComponent to the corresponding pages in the DevEco Studio project.
+
+2. Set **bundleName** and **abilityName** in the AbilityComponent.
+
+3. Set the width and height. The sample code is as follows:
+
+```ts
+@Entry
+@Component
+struct Index {
+ @State message: string = 'Hello World'
+
+ build() {
+ Row() {
+ Column() {
+ AbilityComponent({ abilityName: "WindowExtAbility", bundleName: "com.example.WindowExtAbility"})
+ .width(500)
+ .height(500)
+ }
+ .width('100%')
+ }
+ .height('100%')
+ .backgroundColor(0x64BB5c)
+ }
+}
+```
diff --git a/en/application-dev/application-test/arkxtest-guidelines.md b/en/application-dev/application-test/arkxtest-guidelines.md
index ce7a28154635b724d127a50af801c74f84607402..5f4f36e78850272bc5101fa1b86e76f6e91d5f37 100644
--- a/en/application-dev/application-test/arkxtest-guidelines.md
+++ b/en/application-dev/application-test/arkxtest-guidelines.md
@@ -108,7 +108,7 @@ You write a UI test script based on the unit test framework, adding the invoking
In this example, the UI test script is written based on the preceding unit test script. First, add the dependency package, as shown below:
```js
-import {UiDriver,BY,UiComponent,MatchPattern} from '@ohos.uitest'
+import {Driver,ON,Component,MatchPattern} from '@ohos.uitest'
```
Then, write specific test code. Specifically, implement the click action on the started application page and add checkpoint check cases.
@@ -131,16 +131,16 @@ export default function abilityTest() {
expect(Ability.context.abilityInfo.name).assertEqual('MainAbility');
})
//ui test code
- //init uidriver
- var driver = await UiDriver.create();
+ //init driver
+ var driver = await Driver.create();
await driver.delayMs(1000);
//find button by text 'Next'
- var button = await driver.findComponent(BY.text('Next'));
+ var button = await driver.findComponent(ON.text('Next'));
//click button
await button.click();
await driver.delayMs(1000);
//check text
- await driver.assertComponentExist(BY.text('after click'));
+ await driver.assertComponentExist(ON.text('after click'));
await driver.pressBack();
done();
})
diff --git a/en/application-dev/application-test/figures/Execute.PNG b/en/application-dev/application-test/figures/Execute.PNG
index 90dcb55338ad473d29557e4c761801b16c770d45..0260b7983a13851dc1ef8e45928f952eb509a7d8 100644
Binary files a/en/application-dev/application-test/figures/Execute.PNG and b/en/application-dev/application-test/figures/Execute.PNG differ
diff --git a/en/application-dev/database/database-distributedobject-guidelines.md b/en/application-dev/database/database-distributedobject-guidelines.md
index ec77d5330b57751e36b3ba2d96b57028c340dd36..dcbc34b48912020e0a7c6e0c987ce5de1d0b75c8 100644
--- a/en/application-dev/database/database-distributedobject-guidelines.md
+++ b/en/application-dev/database/database-distributedobject-guidelines.md
@@ -16,16 +16,18 @@ Call **createDistributedObject()** to create a distributed data object instance.
**Table 1** API for creating a distributed data object instance
-| Package| API| Description|
+
+| Bundle Name| API| Description|
| -------- | -------- | -------- |
-| ohos.data.distributedDataObject| createDistributedObject(source: object): DistributedObject | Creates a distributed data object instance for data operations.
- **source**: attributes of the distributed data object to set.
- **DistributedObject**: returns the distributed data object created. |
+| ohos.data.distributedDataObject| createDistributedObject(source: object): DistributedObject | Creates a distributed data object instance for data operations.
- **source**: attributes of the distributed data object to create.
- **DistributedObject**: returns the distributed data object created.|
### Generating a Session ID
Call **genSessionId()** to generate a session ID randomly. The generated session ID can be used to set the session ID of a distributed data object.
**Table 2** API for generating a session ID randomly
-| Package| API| Description|
+
+| Bundle Name| API| Description|
| -------- | -------- | -------- |
| ohos.data.distributedDataObject| genSessionId(): string | Generates a session ID, which can be used as the session ID of a distributed data object.|
@@ -34,9 +36,10 @@ Call **genSessionId()** to generate a session ID randomly. The generated session
Call **setSessionId()** to set a session ID for a distributed data object. The session ID is a unique identifier for one collaboration across devices. The distributed data objects to be synchronized must be associated with the same session ID.
**Table 3** API for setting a session ID
+
| Class| API| Description|
| -------- | -------- | -------- |
-| DistributedDataObject | setSessionId(sessionId?: string): boolean | Sets a session ID for a distributed data object.
**sessionId**: session ID of a distributed data object in a trusted network. To remove a distributed data object from the network, set this parameter to "" or leave it empty. |
+| DistributedDataObject | setSessionId(sessionId?: string): boolean | Sets a session ID for this distributed data object.
**sessionId**: ID of the distributed data object on a trusted network. To remove a distributed data object from the network, set this parameter to "" or leave it empty.|
### Observing Data Changes
@@ -54,6 +57,7 @@ Call **on()** to subscribe to data changes of a distributed data object. When th
Call **on()** to subscribe to status changes of a distributed data object. The status can be online or offline. When the status changes, a callback will be invoked to return the status. You can use **off()** to unsubscribe from the status changes.
**Table 5** APIs for observing status changes of a distributed data object
+
| Class| API| Description|
| -------- | -------- | -------- |
| DistributedDataObject| on(type: 'status', callback: Callback<{ sessionId: string, networkId: string, status: 'online' \| 'offline' }>): void | Subscribes to the status changes of a distributed data object.|
@@ -87,89 +91,105 @@ The following example shows how to implement distributed data object synchroniza
```js
import distributedObject from '@ohos.data.distributedDataObject';
```
-
2. Apply for the permission.
- Add the permissions required (FA model) to the **config.json** file. The sample code is as follows:
+ Add the required permission (FA model) to the **config.json** file.
- ```json
- {
+ ```json
+ {
"module": {
"reqPermissions": [
{
- "name": "ohos.permission.DISTRIBUTED_DATASYNC"
+ "name": "ohos.permission.DISTRIBUTED_DATASYNC"
}
]
}
- }
- ```
+ }
+ ```
For the apps based on the stage model, see [Declaring Permissions](../security/accesstoken-guidelines.md#stage-model).
- This permission must also be granted by the user when the application is started for the first time. The sample code is as follows:
+ This permission must also be granted by the user when the application is started for the first time.
- ```js
- import featureAbility from '@ohos.ability.featureAbility';
-
- function grantPermission() {
- console.info('grantPermission');
- let context = featureAbility.getContext();
- context.requestPermissionsFromUser(['ohos.permission.DISTRIBUTED_DATASYNC'], 666, function (result) {
- console.info(`result.requestCode=${result.requestCode}`)
-
- })
- console.info('end grantPermission');
- }
-
- grantPermission();
- ```
+ ```js
+ // FA model
+ import featureAbility from '@ohos.ability.featureAbility';
+
+ function grantPermission() {
+ console.info('grantPermission');
+ let context = featureAbility.getContext();
+ context.requestPermissionsFromUser(['ohos.permission.DISTRIBUTED_DATASYNC'], 666, function (result) {
+ console.info(`requestPermissionsFromUser CallBack`);
+
+ })
+ console.info('end grantPermission');
+ }
+
+ grantPermission();
+ ```
+
+ ```ts
+ // Stage model
+ import UIAbility from '@ohos.app.ability.UIAbility';
+
+ let context = null;
+
+ class EntryAbility extends UIAbility {
+ onWindowStageCreate(windowStage) {
+ context = this.context;
+ }
+ }
+
+ function grantPermission() {
+ let permissions = ['ohos.permission.DISTRIBUTED_DATASYNC'];
+ context.requestPermissionsFromUser(permissions).then((data) => {
+ console.info('success: ${data}');
+ }).catch((error) => {
+ console.error('failed: ${error}');
+ });
+ }
+
+ grantPermission();
+ ```
3. Obtain a distributed data object instance.
- The sample code is as follows:
-
```js
- var local_object = distributedObject.createDistributedObject({
- name: undefined,
- age: undefined,
- isVis: true,
- parent: undefined,
- list: undefined
+ let localObject = distributedObject.createDistributedObject({
+ name: undefined,
+ age: undefined,
+ isVis: true,
+ parent: undefined,
+ list: undefined
});
- var sessionId = distributedObject.genSessionId();
+ let sessionId = distributedObject.genSessionId();
```
4. Add the distributed data object instance to a network for data synchronization. The data objects in the synchronization network include the local and remote objects.
-
- The sample code is as follows:
```js
// Local object
- var local_object = distributedObject.createDistributedObject({
- name: "jack",
- age: 18,
- isVis: true,
- parent: { mother: "jack mom", father: "jack Dad" },
- list: [{ mother: "jack mom" }, { father: "jack Dad" }]
+ let localObject = distributedObject.createDistributedObject({
+ name: "jack",
+ age: 18,
+ isVis: true,
+ parent: { mother: "jack mom", father: "jack Dad" },
+ list: [{ mother: "jack mom" }, { father: "jack Dad" }]
});
- local_object.setSessionId(sessionId);
+ localObject.setSessionId(sessionId);
// Remote object
- var remote_object = distributedObject.createDistributedObject({
- name: undefined,
- age: undefined,
- isVis: true,
- parent: undefined,
- list: undefined
+ let remoteObject = distributedObject.createDistributedObject({
+ name: undefined,
+ age: undefined,
+ isVis: true,
+ parent: undefined,
+ list: undefined
});
// After learning that the local device goes online, the remote object synchronizes data. That is, name changes to jack and age to 18.
- remote_object.setSessionId(sessionId);
+ remoteObject.setSessionId(sessionId);
```
-
-5. Observe the data changes of the distributed data object.
- You can subscribe to data changes of the remote object. When the data in the remote object changes, a callback will be called to return the data changes.
-
- The sample code is as follows:
+5. Observe the data changes of the distributed data object. You can subscribe to data changes of the remote object. When the data in the remote object changes, a callback will be invoked to return the data changes.
```js
function changeCallback(sessionId, changeData) {
@@ -177,109 +197,86 @@ The following example shows how to implement distributed data object synchroniza
if (changeData != null && changeData != undefined) {
changeData.forEach(element => {
- console.info("changed !" + element + " " + local_object[element]);
- });
- }
+ console.info("changed !" + element + " " + localObject[element]);
+ });
+ }
}
// To refresh the page in changeCallback, correctly bind (this) to the changeCallback.
- local_object.on("change", this.changeCallback.bind(this));
+ localObject.on("change", this.changeCallback.bind(this));
```
-6. Modify attributes of the distributed data object.
-
- The object attributes support basic data types (such as number, Boolean, and string) and complex data types (array and nested basic types).
-
- The sample code is as follows:
+6. Modify attributes of the distributed data object. The object attributes support basic data types (such as number, Boolean, and string) and complex data types (array and nested basic types).
```js
- local_object.name = "jack";
- local_object.age = 19;
- local_object.isVis = false;
- local_object.parent = { mother: "jack mom", father: "jack Dad" };
- local_object.list = [{ mother: "jack mom" }, { father: "jack Dad" }];
+ localObject.name = "jack";
+ localObject.age = 19;
+ localObject.isVis = false;
+ localObject.parent = { mother: "jack mom", father: "jack Dad" };
+ localObject.list = [{ mother: "jack mom" }, { father: "jack Dad" }];
```
> **NOTE**
- > For the distributed data object of the complex type, only the root attribute can be modified. The subordinate attributes cannot be modified. Example:
+ > For the distributed data object of the complex type, only the root attribute can be modified. The subordinate attributes cannot be modified.
```js
// Supported modification.
- local_object.parent = { mother: "mom", father: "dad" };
+ localObject.parent = { mother: "mom", father: "dad" };
// Modification not supported.
- local_object.parent.mother = "mom";
+ localObject.parent.mother = "mom";
```
-7. Access the distributed data object.
-
- Obtain the distributed data object attributes, which are the latest data on the network.
-
- The sample code is as follows:
+7. Access the distributed data object.
Obtain the distributed data object attributes, which are the latest data on the network.
```js
- console.info("name " + local_object["name"]);
+ console.info("name " + localObject["name"]);
```
-
-8. Unsubscribe from data changes.
-
- You can specify the callback to unregister. If you do not specify the callback, all data change callbacks of the distributed data object will be unregistered.
-
- The sample code is as follows:
+8. Unsubscribe from data changes. You can specify the callback to unregister. If you do not specify the callback, all data change callbacks of the distributed data object will be unregistered.
```js
// Unregister the specified data change callback.
- local_object.off("change", changeCallback);
+ localObject.off("change", changeCallback);
// Unregister all data change callbacks.
- local_object.off("change");
+ localObject.off("change");
```
-
-9. Subscribe to the status (online/offline) changes of the distributed data object. A callback will be invoked to report the status change when the target distributed data object goes online or offline.
- The sample code is as follows:
+9. Subscribe to status changes of this distributed data object. A callback will be invoked to report the status change when the target distributed data object goes online or offline.
```js
- function statusCallback(sessionId, networkId, status) {
- this.response += "status changed " + sessionId + " " + status + " " + networkId;
- }
+ function statusCallback(sessionId, networkId, status) {
+ this.response += "status changed " + sessionId + " " + status + " " + networkId;
+ }
- local_object.on("status", this.statusCallback);
+ localObject.on("status", this.statusCallback);
```
10. Save a distributed data object and delete it.
```js
// Save a distributed data object.
- g_object.save("local").then((result) => {
- console.info("save sessionId " + result.sessionId);
- console.info("save version " + result.version);
- console.info("save deviceId " + result.deviceId);
+ localObject.save("local").then((result) => {
+ console.info("save sessionId " + result.sessionId);
+ console.info("save version " + result.version);
+ console.info("save deviceId " + result.deviceId);
}, (result) => {
- console.info("save local failed.");
+ console.info("save local failed.");
});
- // Delete a distributed data object..
- g_object.revokeSave().then((result) => {
- console.info("revokeSave success.");
+ // Revoke the data saving operation.
+ localObject.revokeSave().then((result) => {
+ console.info("revokeSave success.");
}, (result) => {
- console.info("revokeSave failed.");
+ console.info("revokeSave failed.");
});
```
-
-11. Unsubscribe from the status changes of the distributed data object.
-
- You can specify the callback to unregister. If you do not specify the callback, all status change callbacks of this distributed data object will be unregistered.
-
- The sample code is as follows:
+11. Unsubscribe from the status changes of this distributed data object. You can specify the callback to unregister. If you do not specify the callback, this API unregisters all status change callbacks of this distributed data object.
```js
// Unregister the specified status change callback.
- local_object.off("status", this.statusCallback);
+ localObject.off("status", this.statusCallback);
// Unregister all status change callbacks.
- local_object.off("status");
+ localObject.off("status");
```
-
-12. Remove a distributed data object from the synchronization network. Data changes on the local object will not be synchronized to the removed distributed data object.
-
- The sample code is as follows:
+12. Remove the distributed data object from the synchronization network. The data changes on the local object will not be synchronized to the removed distributed data object.
```js
- local_object.setSessionId("");
+ localObject.setSessionId("");
```
diff --git a/en/application-dev/database/database-preference-guidelines.md b/en/application-dev/database/database-preference-guidelines.md
index c440e385232bf3f3bb8c4aa3a7e254a5e6fc0d90..724e273675061c4b6969fb3fcd6f6cbdd984a15f 100644
--- a/en/application-dev/database/database-preference-guidelines.md
+++ b/en/application-dev/database/database-preference-guidelines.md
@@ -24,7 +24,7 @@ Obtain a **Preferences** instance for data operations. A **Preferences** instanc
**Table 1** API for obtaining a **Preferences** instance
-| Package | API | Description |
+| Bundle Name | API | Description |
| --------------------- | ------------------------------------------------------------ | ------------------------------------------------------------ |
| ohos.data.preferences | getPreferences(context: Context, name: string): Promise\ | Obtains a **Preferences** instance.|
@@ -75,7 +75,7 @@ You can use the following APIs to delete a **Preferences** instance or data file
**Table 6** APIs for deleting **Preferences**
-| Package | API | Description |
+| Bundle Name | API | Description |
| --------------------- | ------------------------------------------------------------ | ------------------------------------------------------------ |
| ohos.data.preferences | deletePreferences(context: Context, name: string): Promise\ | Deletes a **Preferences** instance from the memory and its files from the device.|
| ohos.data.preferences | removePreferencesFromCache(context: Context, name: string): Promise\ | Removes a **Preferences** instance from the memory to release memory. |
@@ -113,22 +113,20 @@ You can use the following APIs to delete a **Preferences** instance or data file
```ts
// Obtain the context.
- import UIAbility from '@ohos.app.ability.UIAbility'
- let context = null;
+ import UIAbility from '@ohos.app.ability.UIAbility';
let preferences = null;
export default class EntryAbility extends UIAbility {
- onWindowStageCreate(windowStage){
- context = this.context;
+ onWindowStageCreate(windowStage) {
+ let promise = data_preferences.getPreferences(this.context, 'mystore');
+ promise.then((pref) => {
+ preferences = pref;
+ }).catch((err) => {
+ console.info("Failed to get the preferences.");
+ })
}
}
- let promise = data_preferences.getPreferences(context, 'mystore');
- promise.then((pref) => {
- preferences = pref;
- }).catch((err) => {
- console.info("Failed to get the preferences.");
- })
```
3. Write data.
@@ -200,6 +198,6 @@ You can use the following APIs to delete a **Preferences** instance or data file
proDelete.then(() => {
console.info("Deleted data successfully.");
}).catch((err) => {
- console.info("Failed to delete data. Cause: " + err);
+ console.info("Failed to delete data. Cause: " + err);
})
```
diff --git a/en/application-dev/device-usage-statistics/device-usage-statistics-overview.md b/en/application-dev/device-usage-statistics/device-usage-statistics-overview.md
index 69fca5fb8177eddc65ddfc0ffade70350446a8a1..d8d93e847c73e5c6eb1e96604a17bd456b010162 100644
--- a/en/application-dev/device-usage-statistics/device-usage-statistics-overview.md
+++ b/en/application-dev/device-usage-statistics/device-usage-statistics-overview.md
@@ -36,5 +36,5 @@ Currently you can have access to statistics on the application usage, and the no
Deregister the callback for application group changes.
## Required Permissions
-- Before calling the following system APIs, you need to apply for the **ohos.permission.BUNDLE_ACTIVE_INFO** permission: **queryBundleActiveStates**, **queryBundleStateInfos**, **queryBundleStateInfoByInterval**, **queryBundleActiveEventStates**, **queryAppNotificationNumber**, **queryAppUsagePriorityGroup(bundleName?)**, **setBundleGroup**, **registerGroupCallBack**, and **unRegisterGroupCallBack**.
-- This permission is not required for calling third-party APIs: **queryCurrentBundleActiveStates**, **queryAppUsagePriorityGroup()**, and **isIdleState**.
+- Before calling the following system APIs, you must request the **ohos.permission.BUNDLE_ACTIVE_INFO** permission: **isIdleState**, **queryBundleEvents**, **queryBundleStatsInfos**, **queryBundleStatsInfoByInterval**, **queryDeviceEventStats**, **queryNotificationEventStats**, **queryAppGroup(bundleName)**, **setAppGroup**, **registerAppGroupCallBack**, **unregisterAppGroupCallBack**, **queryModuleUsageRecords**, and **queryModuleUsageRecords(maxnum)**.
+- You do not need to request this permission before calling **queryCurrentBundleEvents** and **queryAppGroup()**, which are third-party APIs.
diff --git a/en/application-dev/device-usage-statistics/device-usage-statistics-use-guide.md b/en/application-dev/device-usage-statistics/device-usage-statistics-use-guide.md
index 45255f18ee313ad96d072e42f620b219315a8adf..82027e91a9c15b1fd1b62a8c5ef4cddc2f9c0ef3 100644
--- a/en/application-dev/device-usage-statistics/device-usage-statistics-use-guide.md
+++ b/en/application-dev/device-usage-statistics/device-usage-statistics-use-guide.md
@@ -225,7 +225,7 @@ import usageStatistics from '@ohos.resourceschedule.usageStatistics';
}
```
-7. Check whether the application specified by **bundleName** is in the idle state. This requires no permission to be configured. A third-party application can only check the idle status of itself.
+7. Check whether the application specified by **bundleName** is in the idle state. This requires the **ohos.permission.BUNDLE_ACTIVE_INFO** permission to be configured.
```js
import usageStatistics from '@ohos.resourceschedule.usageStatistics'
@@ -531,4 +531,4 @@ import usageStatistics from '@ohos.resourceschedule.usageStatistics';
} catch (error) {
console.log('BUNDLE_ACTIVE unregisterAppGroupCallBack throw error, code is: ' + error.code + ',message is: ' + error.message);
}
- ```
\ No newline at end of file
+ ```
diff --git a/en/application-dev/device/Readme-EN.md b/en/application-dev/device/Readme-EN.md
index 6e7fd27fd4506a487faeac457371c7c015a6b771..e3b30cb70e0cfb49e53391f497ae24727e959bee 100644
--- a/en/application-dev/device/Readme-EN.md
+++ b/en/application-dev/device/Readme-EN.md
@@ -1,4 +1,4 @@
-# Device
+# Device Management
- USB Service
- [USB Service Overview](usb-overview.md)
@@ -17,3 +17,5 @@
- Update Service
- [Sample Server Overview](sample-server-overview.md)
- [Sample Server Development](sample-server-guidelines.md)
+- Stationary
+ - [stationary Development](stationary-guidelines.md)
diff --git a/en/application-dev/device/stationary-guidelines.md b/en/application-dev/device/stationary-guidelines.md
new file mode 100644
index 0000000000000000000000000000000000000000..9f6693027a29f48c2c434b842df74beb5209f319
--- /dev/null
+++ b/en/application-dev/device/stationary-guidelines.md
@@ -0,0 +1,84 @@
+# Stationary Development
+
+
+## When to Use
+
+An application can call the **Stationary** module to obtain the device status, for example, whether the device is absolutely or relatively still.
+
+For details about the APIs, see [Stationary](../reference/apis/js-apis-stationary.md).
+
+## Device Status Type Parameters
+
+| Name| Description|
+| -------- | -------- |
+| still | Absolutely still.|
+| relativeStill | Relatively still.|
+
+## Parameters for Subscribing to Device Status events
+
+| Name | Value | Description |
+| ------------------------------ | ---- | ---------------------------------------- |
+| ENTER | 1 | Event indicating entering device status. |
+| EXIT | 2 | Event indicating exiting device status.|
+| ENTER_EXIT | 3 | Event indicating entering and exiting device status.|
+
+## Returned Device Status Parameters
+
+| Name | Value | Description |
+| ------------------------------ | ---- | ---------------------------------------- |
+| ENTER | 1 | Entering device status. |
+| EXIT | 2 | Exiting device status.|
+
+## Available APIs
+
+| Module | Name | Description |
+| ------------- | ------------------------------------------------------------ | ------------------------------------------------------------ |
+| ohos.stationary | on(activity: ActivityType, event: ActivityEvent, reportLatencyNs: number, callback: Callback<ActivityResponse>): void | Subscribes to the device status. This API uses an asynchronous callback to return the result.|
+| ohos.stationary | once(activity: ActivityType, callback: Callback<ActivityResponse>): void | Obtains the device status. This API uses an asynchronous callback to return the result.|
+| ohos.stationary | off(activity: ActivityType, event: ActivityEvent, callback?: Callback<ActivityResponse>): void | Unsubscribes from the device status. |
+
+## Constraints
+
+The device must support the acceleration sensor.
+
+## How to Develop
+
+1. Subscribe to the event indicating entering the absolute still state, and the event is reported every 1 second.
+
+ ```js
+ import stationary from '@ohos.stationary';
+ var reportLatencyNs = 1000000000;
+ try {
+ stationary.on('still', stationary.ActivityEvent.ENTER, reportLatencyNs, (data) => {
+ console.log('data='+ JSON.stringify(data));
+ })
+ } catch (err) {
+ console.error('errCode: ' + err.code + ' ,msg: ' + err.message);
+ }
+ ```
+
+2. Obtain the event indicating entering the absolute still state.
+
+ ```js
+ import stationary from '@ohos.stationary';
+ try {
+ stationary.once('still', (data) => {
+ console.log('data='+ JSON.stringify(data));
+ })
+ } catch (err) {
+ console.error('errCode: ' + err.code + ' ,msg: ' + err.message);
+ }
+ ```
+
+3. Unsubscribe from the event indicating entering the absolute still state.
+
+ ```js
+ import stationary from '@ohos.stationary';
+ try {
+ stationary.off('still', stationary.ActivityEvent.ENTER, (data) => {
+ console.log('data='+ JSON.stringify(data));
+ })
+ } catch (err) {
+ console.error('errCode: ' + err.code + ' ,msg: ' + err.message);
+ }
+ ```
diff --git a/en/application-dev/dfx/Readme-EN.md b/en/application-dev/dfx/Readme-EN.md
index f46c27be2587586dfeb65552a0afe340b5a6187b..b8a4496e09420b3a7557e5c8b8996deaf14ce1c9 100644
--- a/en/application-dev/dfx/Readme-EN.md
+++ b/en/application-dev/dfx/Readme-EN.md
@@ -1,11 +1,8 @@
# DFX
-- Application Event Logging
- - [Development of Application Event Logging](hiappevent-guidelines.md)
-- Performance Tracing
- - [Development of Performance Tracing](hitracemeter-guidelines.md)
-- Distributed Call Chain Tracing
- - [Development of Distributed Call Chain Tracing](hitracechain-guidelines.md)
+- [Development of Application Event Logging](hiappevent-guidelines.md)
+- [Development of Performance Tracing](hitracemeter-guidelines.md)
+- [Development of Distributed Call Chain Tracing](hitracechain-guidelines.md)
- Error Management
- [Development of Error Manager](errormanager-guidelines.md)
- - [Development of Application Recovery](apprecovery-guidelines.md)
\ No newline at end of file
+ - [Development of Application Recovery](apprecovery-guidelines.md)
diff --git a/en/application-dev/dfx/apprecovery-guidelines.md b/en/application-dev/dfx/apprecovery-guidelines.md
index b2992e7c9958f0a1ffd87db9e4549bf0187bad78..bae804c558a57b61915760d37f46b73a03ebcf84 100644
--- a/en/application-dev/dfx/apprecovery-guidelines.md
+++ b/en/application-dev/dfx/apprecovery-guidelines.md
@@ -134,7 +134,7 @@ After the callback triggers **appRecovery.saveAppState()**, **onSaveState(state,
- Restore data.
-After the callback triggers **appRecovery.restartApp()**, the application is restarted. After the restart, **onSaveState(state, wantParams)** of **MainAbility** is called, and the saved data is in **parameters** of **want**.
+After the callback triggers **appRecovery.restartApp()**, the application is restarted. After the restart, **onCreate(want, launchParam)** of **MainAbility** is called, and the saved data is in **parameters** of **want**.
```ts
storage: LocalStorage
diff --git a/en/application-dev/dfx/errormanager-guidelines.md b/en/application-dev/dfx/errormanager-guidelines.md
index 631445b862097d5aa71320ff154d6e235660a95e..a43d7c1fcec9042c6d8cbeb1287cebdddd3915d1 100644
--- a/en/application-dev/dfx/errormanager-guidelines.md
+++ b/en/application-dev/dfx/errormanager-guidelines.md
@@ -37,10 +37,10 @@ When an asynchronous callback is used, the return value can be processed directl
## Development Example
```ts
import Ability from '@ohos.application.Ability'
-import errorManager from '@ohos.application.errorManager'
+import errorManager from '@ohos.app.ability.errorManager';
-var registerId = -1;
-var callback = {
+let registerId = -1;
+let callback = {
onUnhandledException: function (errMsg) {
console.log(errMsg);
}
@@ -48,13 +48,13 @@ var callback = {
export default class MainAbility extends Ability {
onCreate(want, launchParam) {
console.log("[Demo] MainAbility onCreate")
- registerId = errorManager.registerErrorObserver(callback);
+ registerId = errorManager.on("error", callback);
globalThis.abilityWant = want;
}
onDestroy() {
console.log("[Demo] MainAbility onDestroy")
- errorManager.unregisterErrorObserver(registerId, (result) => {
+ errorManager.off("error", registerId, (result) => {
console.log("[Demo] result " + result.code + ";" + result.message)
});
}
diff --git a/en/application-dev/file-management/filepicker-guidelines.md b/en/application-dev/file-management/filepicker-guidelines.md
index 8fcf96b2219151a9c197cd1f6bc2e738775646b7..ec813e256d3f4c1b3fe302aaf1653866a837a36a 100644
--- a/en/application-dev/file-management/filepicker-guidelines.md
+++ b/en/application-dev/file-management/filepicker-guidelines.md
@@ -9,11 +9,10 @@ FilePicker provides the following modes:
## Development Guidelines
> **NOTE**
->
> FilePicker supports only the applications developed based on the stage model.
> For details about the stage model, see [Interpretation of the Application Model](../application-models/application-model-description.md).
-You can use [AbilityContext.startAbilityForResult(want, options)](../reference/apis/js-apis-ability-context.md##abilitycontextstartabilityforresult-1) with different parameters to start different FilePicker modes.
+You can use [AbilityContext.startAbilityForResult(want, options)](../reference/apis/js-apis-inner-application-uiAbilityContext.md#uiabilitycontextstartabilityforresult-1) with different parameters to start FilePicker in different modes.
You need to use [Want](../reference/apis/js-apis-application-want.md) to specify **bundleName** and **abilityName** to start FilePicker. For details, see the following sample code.
@@ -32,8 +31,7 @@ ArkTS sample code:
// Start FilePicker to select a file.
globalThis.context.startAbilityForResult(
{
- bundleName: "com.ohos.filepicker",
- abilityName: "EntryAbility",
+ action: "ohos.want.action.OPEN_FILE",
parameters: {
'startMode': 'choose', //choose or save
}
@@ -44,8 +42,7 @@ globalThis.context.startAbilityForResult(
// Start FilePicker to save a file.
globalThis.context.startAbilityForResult(
{
- bundleName: "com.ohos.filepicker",
- abilityName: "EntryAbility",
+ action: "ohos.want.action.CREATE_FILE",
parameters: {
'startMode': 'save', //choose or save
'saveFile': 'test.jpg',
diff --git a/en/application-dev/file-management/medialibrary-album-guidelines.md b/en/application-dev/file-management/medialibrary-album-guidelines.md
index f03e11cf3cbc0e94737d3a66214f72dfb0a47ba3..0fa043bad49b51aff526198137550f5079bd4349 100644
--- a/en/application-dev/file-management/medialibrary-album-guidelines.md
+++ b/en/application-dev/file-management/medialibrary-album-guidelines.md
@@ -39,19 +39,19 @@ The following describes how to create an album named **myAlbum**.
```ts
async function example() {
- let mediaType = mediaLibrary.MediaType.IMAGE;
- let DIR_IMAGE = mediaLibrary.DirectoryType.DIR_IMAGE;
- const context = getContext(this);
- let media = mediaLibrary.getMediaLibrary(context);
- const path = await media.getPublicDirectory(DIR_IMAGE);
- // myAlbum is the path for storing the new file and the name of the new album.
- media.createAsset(mediaType, 'test.jpg', path + 'myAlbum/', (err, fileAsset) => {
- if (fileAsset != undefined) {
- console.info('createAlbum successfully, message = ' + fileAsset);
- } else {
- console.info('createAlbum failed, message = ' + err);
- }
- });
+ let mediaType = mediaLibrary.MediaType.IMAGE;
+ let DIR_IMAGE = mediaLibrary.DirectoryType.DIR_IMAGE;
+ const context = getContext(this);
+ let media = mediaLibrary.getMediaLibrary(context);
+ const path = await media.getPublicDirectory(DIR_IMAGE);
+ // myAlbum is the path for storing the new file and the name of the new album.
+ media.createAsset(mediaType, 'test.jpg', path + 'myAlbum/', (err, fileAsset) => {
+ if (fileAsset === undefined) {
+ console.error('createAlbum failed, message = ' + err);
+ } else {
+ console.info('createAlbum successfully, message = ' + JSON.stringify(fileAsset));
+ }
+ });
}
```
@@ -75,20 +75,20 @@ The following describes how to rename the album **newAlbum**.
```ts
async function example() {
- let AlbumNoArgsfetchOp = {
- selections: '',
- selectionArgs: [],
- };
- const context = getContext(this);
- let media = mediaLibrary.getMediaLibrary(context);
- let albumList = await media.getAlbums(AlbumNoArgsfetchOp);
- let album = albumList[0];
- album.albumName = 'newAlbum';
- // Void callback.
- album.commitModify().then(function() {
- console.info("albumRename successfully");
- }).catch(function(err){
- console.info("albumRename failed with error: " + err);
- });
+ let AlbumNoArgsfetchOp = {
+ selections: '',
+ selectionArgs: [],
+ };
+ const context = getContext(this);
+ let media = mediaLibrary.getMediaLibrary(context);
+ let albumList = await media.getAlbums(AlbumNoArgsfetchOp);
+ let album = albumList[0];
+ album.albumName = 'newAlbum';
+ // Void callback.
+ album.commitModify().then(() => {
+ console.info("albumRename successfully");
+ }).catch((err) => {
+ console.error("albumRename failed with error: " + err);
+ });
}
```
diff --git a/en/application-dev/file-management/medialibrary-filepath-guidelines.md b/en/application-dev/file-management/medialibrary-filepath-guidelines.md
index 7e4a1cdaff6cbd76995b295d5f4606f54c35913e..4c7e2ecd4db6723a66930e624bd4b36b556330d1 100644
--- a/en/application-dev/file-management/medialibrary-filepath-guidelines.md
+++ b/en/application-dev/file-management/medialibrary-filepath-guidelines.md
@@ -37,15 +37,15 @@ The following describes how to obtain the public directory that stores camera fi
```ts
async function example(){
- const context = getContext(this);
- let media = mediaLibrary.getMediaLibrary(context);
- let DIR_CAMERA = mediaLibrary.DirectoryType.DIR_CAMERA;
- const dicResult = await media.getPublicDirectory(DIR_CAMERA);
- if (dicResult == 'Camera/') {
- console.info('mediaLibraryTest : getPublicDirectory passed');
- } else {
- console.info('mediaLibraryTest : getPublicDirectory failed');
- }
+ const context = getContext(this);
+ let media = mediaLibrary.getMediaLibrary(context);
+ let DIR_CAMERA = mediaLibrary.DirectoryType.DIR_CAMERA;
+ const dicResult = await media.getPublicDirectory(DIR_CAMERA);
+ if (dicResult == 'Camera/') {
+ console.info('mediaLibraryTest : getPublicDirectory passed');
+ } else {
+ console.error('mediaLibraryTest : getPublicDirectory failed');
+ }
}
```
@@ -59,47 +59,52 @@ Users can access files stored in the public directories through the system appli
You can call [mediaLibrary.FileAsset.open](../reference/apis/js-apis-medialibrary.md#open8-1) to open a file in a public directory.
-You can call [fileio.open](../reference/apis/js-apis-fileio.md#fileioopen7) to open a file in the application sandbox. The sandbox directory can be accessed only through the application context.
+You can call [fs.open](../reference/apis/js-apis-file-fs.md#fsopen) to open a file in the application sandbox. The sandbox directory can be accessed only through the application context.
**Prerequisites**
- You have obtained a **MediaLibrary** instance.
-- You have granted the permission **ohos.permission.WRITE_MEDIA**.
-- You have imported the module [@ohos.fileio](../reference/apis/js-apis-fileio.md) in addition to @ohos.multimedia.mediaLibrary.
+- You have granted the permissions **ohos.permission.READ_MEDIA** and **ohos.permission.WRITE_MEDIA**.
+- You have imported the module [@ohos.file.fs](../reference/apis/js-apis-file-fs.md) in addition to @ohos.multimedia.mediaLibrary.
+- The **testFile.txt** file has been created and contains content.
**How to Develop**
-1. Call [context.filesDir](../reference/apis/js-apis-inner-app-context.md#contextgetfilesdir) to obtain the directory of the application sandbox.
+1. Call [context.filesDir](../reference/apis/js-apis-file-fs.md) to obtain the directory of the application sandbox.
2. Call **MediaLibrary.getFileAssets** and **FetchFileResult.getFirstObject** to obtain the first file in the result set of the public directory.
-3. Call **fileio.open** to open the file in the sandbox.
+3. Call **fs.open** to open the file in the sandbox.
4. Call **fileAsset.open** to open the file in the public directory.
-5. Call **fileio.copyfile** to copy the file.
-6. Call **fileAsset.close** and **fileio.close** to close the file.
+5. Call [fs.copyfile](../reference/apis/js-apis-file-fs.md#fscopyfile) to copy the file.
+6. Call **fileAsset.close** and [fs.close](../reference/apis/js-apis-file-fs.md#fsclose) to close the file.
**Example 1: Copying Files from the Public Directory to the Sandbox**
```ts
async function copyPublic2Sandbox() {
+ try {
const context = getContext(this);
let media = mediaLibrary.getMediaLibrary(context);
- let sandboxDirPath = globalThis.context.filesDir;
+ let sandboxDirPath = context.filesDir;
let fileKeyObj = mediaLibrary.FileKey;
let fileAssetFetchOp = {
- selections: fileKeyObj.DISPLAY_NAME + '= ?',
- selectionArgs: ['testFile.txt'],
+ selections: fileKeyObj.DISPLAY_NAME + '= ?',
+ selectionArgs: ['testFile.txt'],
};
let fetchResult = await media.getFileAssets(fileAssetFetchOp);
let fileAsset = await fetchResult.getFirstObject();
let fdPub = await fileAsset.open('rw');
- let fdSand = await fileio.open(sandboxDirPath + '/testFile.txt', 0o2 | 0o100, 0o666);
- await fileio.copyFile(fdPub, fdSand);
+ let fdSand = await fs.open(sandboxDirPath + '/testFile.txt', fs.OpenMode.READ_WRITE | fs.OpenMode.CREATE);
+ await fs.copyFile(fdPub, fdSand.fd);
await fileAsset.close(fdPub);
- await fileio.close(fdSand);
+ await fs.close(fdSand.fd);
- let content_sand = await fileio.readText(sandboxDirPath + '/testFile.txt');
- console.log('content read from sandbox file: ', content_sand)
+ let content_sand = await fs.readText(sandboxDirPath + '/testFile.txt');
+ console.info('content read from sandbox file: ', content_sand)
+ } catch (err) {
+ console.info('[demo] copyPublic2Sandbox fail, err: ', err);
+ }
}
```
@@ -107,81 +112,81 @@ async function copyPublic2Sandbox() {
```ts
async function copySandbox2Public() {
- const context = getContext(this);
- let media = mediaLibrary.getMediaLibrary(context);
- let sandboxDirPath = globalThis.context.filesDir;
-
- let DIR_DOCUMENTS = mediaLibrary.DirectoryType.DIR_DOCUMENTS;
- const publicDirPath = await media.getPublicDirectory(DIR_DOCUMENTS);
- try {
- let fileAsset = await media.createAsset(mediaLibrary.MediaType.FILE, 'testFile02.txt', publicDirPath);
- console.info('createFile successfully, message = ' + fileAsset);
- } catch (err) {
- console.info('createFile failed, message = ' + err);
- }
- try {
- let fileKeyObj = mediaLibrary.FileKey;
- let fileAssetFetchOp = {
- selections: fileKeyObj.DISPLAY_NAME + '= ?',
- selectionArgs: ['testFile02.txt'],
- };
- let fetchResult = await media.getFileAssets(fileAssetFetchOp);
- var fileAsset = await fetchResult.getFirstObject();
- } catch (err) {
- console.info('file asset get failed, message = ' + err);
- }
- let fdPub = await fileAsset.open('rw');
- let fdSand = await fileio.open(sandboxDirPath + 'testFile.txt', 0o2);
- await fileio.copyFile(fdSand, fdPub);
- await fileio.close(fdPub);
- await fileio.close(fdSand);
- let fdPubRead = await fileAsset.open('rw');
- try {
- let arrayBuffer = new ArrayBuffer(4096);
- await fileio.read(fdPubRead, arrayBuffer);
- var content_pub = String.fromCharCode(...new Uint8Array(arrayBuffer));
- fileAsset.close(fdPubRead);
- } catch (err) {
- console.log('read text failed, message = ', err);
- }
- console.log('content read from public file: ', content_pub);
+ const context = getContext(this);
+ let media = mediaLibrary.getMediaLibrary(context);
+ let sandboxDirPath = context.filesDir;
+
+ let DIR_DOCUMENTS = mediaLibrary.DirectoryType.DIR_DOCUMENTS;
+ const publicDirPath = await media.getPublicDirectory(DIR_DOCUMENTS);
+ try {
+ let fileAsset = await media.createAsset(mediaLibrary.MediaType.FILE, 'testFile02.txt', publicDirPath);
+ console.info('createFile successfully, message = ' + fileAsset);
+ } catch (err) {
+ console.error('createFile failed, message = ' + err);
+ }
+ try {
+ let fileKeyObj = mediaLibrary.FileKey;
+ let fileAssetFetchOp = {
+ selections: fileKeyObj.DISPLAY_NAME + '= ?',
+ selectionArgs: ['testFile02.txt'],
+ };
+ let fetchResult = await media.getFileAssets(fileAssetFetchOp);
+ var fileAsset = await fetchResult.getFirstObject();
+ } catch (err) {
+ console.error('file asset get failed, message = ' + err);
+ }
+ let fdPub = await fileAsset.open('rw');
+ let fdSand = await fs.open(sandboxDirPath + 'testFile.txt', OpenMode.READ_WRITE);
+ await fs.copyFile(fdSand.fd, fdPub);
+ await fileAsset.close(fdPub);
+ await fs.close(fdSand.fd);
+ let fdPubRead = await fileAsset.open('rw');
+ try {
+ let arrayBuffer = new ArrayBuffer(4096);
+ await fs.read(fdPubRead, arrayBuffer);
+ var content_pub = String.fromCharCode(...new Uint8Array(arrayBuffer));
+ fileAsset.close(fdPubRead);
+ } catch (err) {
+ console.error('read text failed, message = ', err);
+ }
+ console.info('content read from public file: ', content_pub);
}
```
### Reading and Writing a File
-You can use **FileAsset.open** and **FileAsset.close** of [mediaLibrary](../reference/apis/js-apis-medialibrary.md) to open and close a file, and use **fileio.read** and **fileio.write** of [fileio](../reference/apis/js-apis-fileio.md) to read and write a file.
+You can use **FileAsset.open** and **FileAsset.close** of [mediaLibrary](../reference/apis/js-apis-medialibrary.md) to open and close a file, and use **fs.read** and **fs.write** in [file.fs](../reference/apis/js-apis-file-fs.md) to read and write the file.
**Prerequisites**
- You have obtained a **MediaLibrary** instance.
-- You have granted the permission **ohos.permission.WRITE_MEDIA**.
-- You have imported the module [@ohos.fileio](../reference/apis/js-apis-fileio.md) in addition to @ohos.multimedia.mediaLibrary.
+- You have granted the permissions **ohos.permission.READ_MEDIA** and **ohos.permission.WRITE_MEDIA**.
+- You have imported the module [@ohos.file.fs](../reference/apis/js-apis-file-fs.md) in addition to @ohos.multimedia.mediaLibrary.
**How to Develop**
1. Create a file.
- ```ts
- async function example() {
- let mediaType = mediaLibrary.MediaType.FILE;
- let DIR_DOCUMENTS = mediaLibrary.DirectoryType.DIR_DOCUMENTS;
- const context = getContext(this);
- let media = mediaLibrary.getMediaLibrary(context);
- const path = await media.getPublicDirectory(DIR_DOCUMENTS);
- media.createAsset(mediaType, "testFile.text", path).then (function (asset) {
- console.info("createAsset successfully:" + JSON.stringify(asset));
- }).catch(function(err){
- console.info("createAsset failed with error: " + err);
- });
- }
- ```
+```ts
+async function example() {
+ let mediaType = mediaLibrary.MediaType.FILE;
+ let DIR_DOCUMENTS = mediaLibrary.DirectoryType.DIR_DOCUMENTS;
+ const context = getContext(this);
+ let media = mediaLibrary.getMediaLibrary(context);
+ const path = await media.getPublicDirectory(DIR_DOCUMENTS);
+ media.createAsset(mediaType, "testFile.text", path).then((asset) => {
+ console.info("createAsset successfully:" + JSON.stringify(asset));
+ }).catch((err) => {
+ console.error("createAsset failed with error: " + err);
+ });
+}
+```
2. Call **FileAsset.open** to open the file.
-3. Call **fileio.write** to write a string to the file.
+3. Call [fs.write](../reference/apis/js-apis-file-fs.md#fswrite) to write a string to the file.
-4. Call **fileio.read** to read the file and save the data read in an array buffer.
+4. Call [fs.read](../reference/apis/js-apis-file-fs.md#fsread) to read the file and save the data read in an array buffer.
5. Convert the array buffer to a string.
@@ -191,25 +196,25 @@ You can use **FileAsset.open** and **FileAsset.close** of [mediaLibrary](../refe
```ts
async function writeOnlyPromise() {
- const context = getContext(this);
- let media = mediaLibrary.getMediaLibrary(context);
- let fileKeyObj = mediaLibrary.FileKey;
- let fileAssetFetchOp = {
- selections: fileKeyObj.DISPLAY_NAME + '= ?',
- selectionArgs: ['testFile.txt'],
- };
- let fetchResult = await media.getFileAssets(fileAssetFetchOp);
- let fileAsset = await fetchResult.getFirstObject();
- console.info('fileAssetName: ', fileAsset.displayName);
-
- try {
- let fd = await fileAsset.open('w');
- console.info('file descriptor: ', fd);
- await fileio.write(fd, "Write file test content.");
- await fileAsset.close(fd);
- } catch (err) {
- console.info('write file failed, message = ', err);
- }
+ const context = getContext(this);
+ let media = mediaLibrary.getMediaLibrary(context);
+ let fileKeyObj = mediaLibrary.FileKey;
+ let fileAssetFetchOp = {
+ selections: fileKeyObj.DISPLAY_NAME + '= ?',
+ selectionArgs: ['testFile.txt'],
+ };
+ let fetchResult = await media.getFileAssets(fileAssetFetchOp);
+ let fileAsset = await fetchResult.getFirstObject();
+ console.info('fileAssetName: ', fileAsset.displayName);
+
+ try {
+ let fd = await fileAsset.open('w');
+ console.info('file descriptor: ', fd);
+ await fs.write(fd, "Write file test content.");
+ await fileAsset.close(fd);
+ } catch (err) {
+ console.error('write file failed, message = ', err);
+ }
}
```
@@ -217,28 +222,28 @@ async function writeOnlyPromise() {
```ts
async function readOnlyPromise() {
- const context = getContext(this);
- let media = mediaLibrary.getMediaLibrary(context);
- let fileKeyObj = mediaLibrary.FileKey;
- let fileAssetFetchOp = {
- selections: fileKeyObj.DISPLAY_NAME + '= ?' ,
- selectionArgs: ['testFile.txt'],
- };
- let fetchResult = await media.getFileAssets(fileAssetFetchOp);
- let fileAsset = await fetchResult.getFirstObject();
- console.info('fileAssetName: ', fileAsset.displayName);
-
- try {
- let fd = await fileAsset.open('r');
- let arrayBuffer = new ArrayBuffer(4096);
- await fileio.read(fd, arrayBuffer);
- let fileContent = String.fromCharCode(...new Uint8Array(arrayBuffer));
- globalThis.fileContent = fileContent;
- globalThis.fileName = fileAsset.displayName;
- console.info('file content: ', fileContent);
- await fileAsset.close(fd);
- } catch (err) {
- console.info('read file failed, message = ', err);
- }
+ const context = getContext(this);
+ let media = mediaLibrary.getMediaLibrary(context);
+ let fileKeyObj = mediaLibrary.FileKey;
+ let fileAssetFetchOp = {
+ selections: fileKeyObj.DISPLAY_NAME + '= ?' ,
+ selectionArgs: ['testFile.txt'],
+ };
+ let fetchResult = await media.getFileAssets(fileAssetFetchOp);
+ let fileAsset = await fetchResult.getFirstObject();
+ console.info('fileAssetName: ', fileAsset.displayName);
+
+ try {
+ let fd = await fileAsset.open('r');
+ let arrayBuffer = new ArrayBuffer(4096);
+ await fs.read(fd, arrayBuffer);
+ let fileContent = String.fromCharCode(...new Uint8Array(arrayBuffer));
+ globalThis.fileContent = fileContent;
+ globalThis.fileName = fileAsset.displayName;
+ console.info('file content: ', fileContent);
+ await fileAsset.close(fd);
+ } catch (err) {
+ console.error('read file failed, message = ', err);
+ }
}
```
diff --git a/en/application-dev/file-management/medialibrary-overview.md b/en/application-dev/file-management/medialibrary-overview.md
index b29472da8ca9558385bd0371dbdfa00012a45f32..f7e0ab9ac4772a7770b1e2bc9f6b63845cb654b5 100644
--- a/en/application-dev/file-management/medialibrary-overview.md
+++ b/en/application-dev/file-management/medialibrary-overview.md
@@ -64,64 +64,64 @@ After configuring the permissions in the **module.json5** file, the application
1. Declare the permissions in the **module.json5** file. Add the **requestPermissions** tag under **module** in the file, and set the tag based on the project requirements. For details about the tag, see [Guide for Requesting Permissions from User](../security/accesstoken-guidelines.md).
- ```json
- {
- "module": {
- "requestPermissions": [
- {
- "name": "ohos.permission.MEDIA_LOCATION",
- "reason": "$string:reason",
- "usedScene": {
- "abilities": [
- "MainAbility"
- ],
- "when": "always"
- }
- },
- {
- "name": "ohos.permission.READ_MEDIA",
- "reason": "$string:reason",
- "usedScene": {
- "abilities": [
- "MainAbility"
- ],
- "when": "always"
- }
- },
- {
- "name": "ohos.permission.WRITE_MEDIA",
- "reason": "$string:reason",
- "usedScene": {
- "abilities": [
- "MainAbility"
- ],
- "when": "always"
- }
- }
- ]
- }
- }
- ```
+```json
+{
+ "module": {
+ "requestPermissions": [
+ {
+ "name": "ohos.permission.MEDIA_LOCATION",
+ "reason": "$string:reason",
+ "usedScene": {
+ "abilities": [
+ "EntryAbility"
+ ],
+ "when": "always"
+ }
+ },
+ {
+ "name": "ohos.permission.READ_MEDIA",
+ "reason": "$string:reason",
+ "usedScene": {
+ "abilities": [
+ "EntryAbility"
+ ],
+ "when": "always"
+ }
+ },
+ {
+ "name": "ohos.permission.WRITE_MEDIA",
+ "reason": "$string:reason",
+ "usedScene": {
+ "abilities": [
+ "EntryAbility"
+ ],
+ "when": "always"
+ }
+ }
+ ]
+ }
+}
+```
2. In the **Ability.ts** file, call **requestPermissionsFromUser** in the **onWindowStageCreate** callback to check for the required permissions and if they are not granted, request the permissions from the user by displaying a dialog box.
- ```ts
- import UIAbility from '@ohos.app.ability.UIAbility';
- import abilityAccessCtrl, {Permissions} from '@ohos.abilityAccessCtrl';
-
- export default class MainAbility extends Ability {
- onWindowStageCreate(windowStage) {
- let list : Array = ['ohos.permission.READ_MEDIA', 'ohos.permission.WRITE_MEDIA'];
- let permissionRequestResult;
- let atManager = abilityAccessCtrl.createAtManager();
- atManager.requestPermissionsFromUser(this.context, list, (err, result) => {
- if (err) {
- console.log('requestPermissionsFromUserError: ' + JSON.stringify(err));
- } else {
- permissionRequestResult=result;
- console.log('permissionRequestResult: ' + JSON.stringify(permissionRequestResult));
- }
- });
- }
- }
- ```
+```ts
+import UIAbility from '@ohos.app.ability.UIAbility';
+import abilityAccessCtrl, {Permissions} from '@ohos.abilityAccessCtrl';
+
+export default class EntryAbility extends UIAbility {
+ onWindowStageCreate(windowStage) {
+ let list : Array = ['ohos.permission.READ_MEDIA', 'ohos.permission.WRITE_MEDIA'];
+ let permissionRequestResult;
+ let atManager = abilityAccessCtrl.createAtManager();
+ atManager.requestPermissionsFromUser(this.context, list, (err, result) => {
+ if (err) {
+ console.error('requestPermissionsFromUserError: ' + JSON.stringify(err));
+ } else {
+ permissionRequestResult = result;
+ console.info('permissionRequestResult: ' + JSON.stringify(permissionRequestResult));
+ }
+ });
+ }
+}
+```
diff --git a/en/application-dev/file-management/medialibrary-resource-guidelines.md b/en/application-dev/file-management/medialibrary-resource-guidelines.md
index dea130ff3de563a904684d021a7d8f7f9b514c83..7d120ec9a4fa9fd38ba92be97ee7fdd5a6f33816 100644
--- a/en/application-dev/file-management/medialibrary-resource-guidelines.md
+++ b/en/application-dev/file-management/medialibrary-resource-guidelines.md
@@ -33,30 +33,33 @@ To specify the image as the media type, set **selectionArgs** to **MediaType.IMA
```ts
async function example() {
- let fileKeyObj = mediaLibrary.FileKey;
- let fileType = mediaLibrary.MediaType.IMAGE;
- let option = {
- selections: fileKeyObj.MEDIA_TYPE + '= ?',
- selectionArgs: [fileType.toString()],
- };
- const context = getContext(this);
- let media = mediaLibrary.getMediaLibrary(context);
- const fetchFileResult = await media.getFileAssets(option);
- for (let i = 0; i < fetchFileResult.getCount(); i++) {
- fetchFileResult.getNextObject((err, fileAsset) => {
- if (err) {
- console.error('Failed ');
- return;
- }
- console.log('fileAsset.displayName ' + i + ': ' + fileAsset.displayName);
- })
- }
+ let fileKeyObj = mediaLibrary.FileKey;
+ let fileType = mediaLibrary.MediaType.IMAGE;
+ let option = {
+ selections: fileKeyObj.MEDIA_TYPE + '= ?',
+ selectionArgs: [fileType.toString()],
+ };
+ const context = getContext(this);
+ let media = mediaLibrary.getMediaLibrary(context);
+ const fetchFileResult = await media.getFileAssets(option);
+ fetchFileResult.getFirstObject().then((fileAsset) => {
+ console.log('getFirstObject.displayName : ' + fileAsset.displayName);
+ for (let i = 1; i < fetchFileResult.getCount(); i++) {
+ fetchFileResult.getNextObject().then((fileAsset) => {
+ console.info('fileAsset.displayName ' + i + ': ' + fileAsset.displayName);
+ }).catch((err) => {
+ console.error('Failed to get next object: ' + err);
+ });
+ }
+ }).catch((err) => {
+ console.error('Failed to get first object: ' + err);
+ });
}
```
### Querying Media Assets with the Specified Date
-The following describes how to obtain media assets that are added on the specified date. You can also use the modification date and shooting date as the retrieval conditions.
+The following describes how to obtain all the media assets that are added from the specified date. You can also use the modification date and shooting date as the retrieval conditions.
To specify the date when the files are added as the retrieval condition, set **selections** to **FileKey.DATE_ADDED**.
@@ -64,23 +67,26 @@ To specify the date 2022-8-5, set **selectionArgs** to **2022-8-5**.
```ts
async function example() {
- let fileKeyObj = mediaLibrary.FileKey;
- let option = {
- selections: fileKeyObj.DATE_ADDED + '= ?',
- selectionArgs: ['2022-8-5'],
- };
- const context = getContext(this);
- let media = mediaLibrary.getMediaLibrary(context);
- const fetchFileResult = await media.getFileAssets(option);
- for (let i = 0; i < fetchFileResult.getCount(); i++) {
- fetchFileResult.getNextObject((err, fileAsset) => {
- if (err) {
- console.error('Failed ');
- return;
- }
- console.log('fileAsset.displayName ' + i + ': ' + fileAsset.displayName);
- })
- }
+ let fileKeyObj = mediaLibrary.FileKey;
+ let option = {
+ selections: fileKeyObj.DATE_ADDED + '> ?',
+ selectionArgs: ['2022-8-5'],
+ };
+ const context = getContext(this);
+ let media = mediaLibrary.getMediaLibrary(context);
+ const fetchFileResult = await media.getFileAssets(option);
+ fetchFileResult.getFirstObject().then((fileAsset) => {
+ console.info('getFirstObject.displayName : ' + fileAsset.displayName);
+ for (let i = 1; i < fetchFileResult.getCount(); i++) {
+ fetchFileResult.getNextObject().then((fileAsset) => {
+ console.info('fileAsset.displayName ' + i + ': ' + fileAsset.displayName);
+ }).catch((err) => {
+ console.error('Failed to get next object: ' + err);
+ });
+ }
+ }).catch((err) => {
+ console.error('Failed to get first object: ' + err);
+ });
}
```
@@ -92,25 +98,28 @@ To sort files in descending order by the date when they are added, set **order**
```ts
async function example() {
- let fileKeyObj = mediaLibrary.FileKey;
- let fileType = mediaLibrary.MediaType.IMAGE;
- let option = {
- selections: fileKeyObj.MEDIA_TYPE + '= ?',
- selectionArgs: [fileType.toString()],
- order: fileKeyObj.DATE_ADDED + " DESC",
- };
- const context = getContext(this);
- let media = mediaLibrary.getMediaLibrary(context);
- const fetchFileResult = await media.getFileAssets(option);
- for (let i = 0; i < fetchFileResult.getCount(); i++) {
- fetchFileResult.getNextObject((err, fileAsset) => {
- if (err) {
- console.error('Failed ');
- return;
- }
- console.log('fileAsset.displayName ' + i + ': ' + fileAsset.displayName);
- })
- }
+ let fileKeyObj = mediaLibrary.FileKey;
+ let fileType = mediaLibrary.MediaType.IMAGE;
+ let option = {
+ selections: fileKeyObj.MEDIA_TYPE + '= ?',
+ selectionArgs: [fileType.toString()],
+ order: fileKeyObj.DATE_ADDED + " DESC",
+ };
+ const context = getContext(this);
+ let media = mediaLibrary.getMediaLibrary(context);
+ const fetchFileResult = await media.getFileAssets(option);
+ fetchFileResult.getFirstObject().then((fileAsset) => {
+ console.info('getFirstObject.displayName : ' + fileAsset.displayName);
+ for (let i = 1; i < fetchFileResult.getCount(); i++) {
+ fetchFileResult.getNextObject().then((fileAsset) => {
+ console.info('fileAsset.displayName ' + i + ': ' + fileAsset.displayName);
+ }).catch((err) => {
+ console.error('Failed to get next object: ' + err);
+ });
+ }
+ }).catch((err) => {
+ console.error('Failed to get first object: ' + err);
+ });
}
```
@@ -124,31 +133,29 @@ To specify the album name **'myAlbum'**, set **selectionArgs** to **'myAlbum'**.
```ts
async function example() {
- let fileKeyObj = mediaLibrary.FileKey;
- let fileType = mediaLibrary.MediaType.IMAGE;
- let option = {
- selections: fileKeyObj.ALBUM_NAME + '= ?',
- selectionArgs: ['myAlbum'],
- };
- const context = getContext(this);
- let media = mediaLibrary.getMediaLibrary(context);
- const fetchFileResult = await media.getFileAssets(option);
- for (let i = 0; i < fetchFileResult.getCount(); i++) {
- fetchFileResult.getNextObject((err, fileAsset) => {
- if (err) {
- console.error('Failed ');
- return;
- }
- console.log('fileAsset.displayName ' + i + ': ' + fileAsset.displayName);
- })
- }
+ let fileKeyObj = mediaLibrary.FileKey;
+ let option = {
+ selections: fileKeyObj.ALBUM_NAME + '= ?',
+ selectionArgs: ['myAlbum'],
+ };
+ const context = getContext(this);
+ let media = mediaLibrary.getMediaLibrary(context);
+ const fetchFileResult = await media.getFileAssets(option);
+ if (albumList.length > 0) {
+ fetchFileResult.getFirstObject().then((album) => {
+ console.info('getFirstObject.displayName : ' + album.albumName);
+ }).catch((err) => {
+ console.error('Failed to get first object: ' + err);
+ });
+ } else {
+ console.info('getAlbum list is: 0');
+ }
}
```
## Obtaining Images and Videos in an Album
You can obtain media assets in an album in either of the following ways:
-
- Call [MediaLibrary.getFileAssets](../reference/apis/js-apis-medialibrary.md#getfileassets7-1) with an album specified, as described in [Querying Media Assets with the Specfied Album Name](#querying-media-assets-with-the-specified-album-name).
- Call [Album.getFileAssets](../reference/apis/js-apis-medialibrary.md#getfileassets7-3) to obtain an **Album** instance, so as to obtain the media assets in it.
@@ -163,24 +170,24 @@ The following describes how to obtain videos in an album named **New Album 1**.
1. Create a retrieval condition for obtaining the target **Album** instance.
- ```ts
- let fileKeyObj = mediaLibrary.FileKey;
- let AlbumNoArgsFetchOp = {
- selections: fileKeyObj.ALBUM_NAME + '= ?',
- selectionArgs:['New Album 1']
- }
- ```
+```ts
+let fileKeyObj = mediaLibrary.FileKey;
+let AlbumNoArgsFetchOp = {
+ selections: fileKeyObj.ALBUM_NAME + '= ?',
+ selectionArgs:['New Album 1']
+}
+```
2. Create a retrieval condition for obtaining videos in the target album.
- ```ts
- let fileKeyObj = mediaLibrary.FileKey;
- let imageType = mediaLibrary.MediaType.VIDEO;
- let imagesFetchOp = {
- selections: fileKeyObj.MEDIA_TYPE + '= ?',
- selectionArgs: [imageType.toString()],
- }
- ```
+```ts
+let fileKeyObj = mediaLibrary.FileKey;
+let videoType = mediaLibrary.MediaType.VIDEO;
+let videoFetchOp = {
+ selections: fileKeyObj.MEDIA_TYPE + '= ?',
+ selectionArgs: [videoType.toString()],
+}
+```
3. Call **Album.getFileAssets** to obtain the videos in the target album.
@@ -188,28 +195,28 @@ Complete sample code:
```ts
async function getCameraImagePromise() {
- const context = getContext(this);
- let media = mediaLibrary.getMediaLibrary(context);
- let fileKeyObj = mediaLibrary.FileKey;
- let imageType = mediaLibrary.MediaType.IMAGE;
- let imagesFetchOp = {
- selections: fileKeyObj.MEDIA_TYPE + '= ?',
- selectionArgs: [imageType.toString()],
- }
- let AlbumNoArgsFetchOp = {
- selections: fileKeyObj.ALBUM_NAME + '= ?',
- selectionArgs:['New Album 1']
- }
-
- let albumList = await media.getAlbums(AlbumNoArgsFetchOp);
- if (albumList.length > 0) {
- const album = albumList[0];
- let fetchFileResult = await album.getFileAssets(imagesFetchOp);
- let count = fetchFileResult.getCount();
- console.info("get mediaLibrary IMAGE number", count);
- } else {
- console.info('getAlbum list is: 0');
- }
+ const context = getContext(this);
+ let media = mediaLibrary.getMediaLibrary(context);
+ let fileKeyObj = mediaLibrary.FileKey;
+ let videoType = mediaLibrary.MediaType.VIDEO;
+ let videoFetchOp = {
+ selections: fileKeyObj.MEDIA_TYPE + '= ?',
+ selectionArgs: [videoType.toString()],
+ }
+ let AlbumNoArgsFetchOp = {
+ selections: fileKeyObj.ALBUM_NAME + '= ?',
+ selectionArgs:['New Album 1']
+ }
+
+ let albumList = await media.getAlbums(AlbumNoArgsFetchOp);
+ if (albumList.length > 0) {
+ const album = albumList[0];
+ let fetchFileResult = await album.getFileAssets(videoFetchOp);
+ let count = fetchFileResult.getCount();
+ console.info("get mediaLibrary VIDEO number", count);
+ } else {
+ console.info('getAlbum list is: 0');
+ }
}
```
@@ -235,31 +242,32 @@ The following describes how to obtain the thumbnail (size: 720 x 720) of the fir
```ts
async function getFirstThumbnailPromise() {
- const context = getContext(this);
- let media = mediaLibrary.getMediaLibrary(context);
- let fileKeyObj = mediaLibrary.FileKey;
- let imageType = mediaLibrary.MediaType.IMAGE;
- let imagesFetchOp = {
- selections: fileKeyObj.MEDIA_TYPE + '= ?',
- selectionArgs: [imageType.toString()],
- }
-
- let size = { width: 720, height: 720 };
- const fetchFileResult = await media.getFileAssets(imagesFetchOp);
- if (fetchFileResult != undefined) {
- const asset = await fetchFileResult.getFirstObject();
- asset.getThumbnail(size).then((pixelMap) => {
- pixelMap.getImageInfo().then((info) => {
- console.info('get Thumbnail info: ' + "width: " + info.size.width + " height: " + info.size.height);
- }).catch((err) => {
- console.info("getImageInfo failed with error:" + err);
- });
- }).catch((err) => {
- console.info("getImageInfo failed with error:" + err);
- });
- } else {
- console.info("get image failed with error");
- }
+ const context = getContext(this);
+ let media = mediaLibrary.getMediaLibrary(context);
+ let fileKeyObj = mediaLibrary.FileKey;
+ let imageType = mediaLibrary.MediaType.IMAGE;
+ let imagesFetchOp = {
+ selections: fileKeyObj.MEDIA_TYPE + '= ?',
+ selectionArgs: [imageType.toString()],
+ }
+
+ let size = { width: 720, height: 720 };
+ const fetchFileResult = await media.getFileAssets(imagesFetchOp);
+ if (fetchFileResult === undefined) {
+ console.error("get image failed with error");
+ return;
+ } else {
+ const asset = await fetchFileResult.getFirstObject();
+ asset.getThumbnail(size).then((pixelMap) => {
+ pixelMap.getImageInfo().then((info) => {
+ console.info('get Thumbnail info: ' + "width: " + info.size.width + " height: " + info.size.height);
+ }).catch((err) => {
+ console.error("getImageInfo failed with error: " + err);
+ });
+ }).catch((err) => {
+ console.error("getImageInfo failed with error: " + err);
+ });
+ }
}
```
@@ -277,16 +285,16 @@ The following describes how to create a file of the **MediaType.FILE** type.
```ts
async function example() {
- let mediaType = mediaLibrary.MediaType.FILE;
- let DIR_DOCUMENTS = mediaLibrary.DirectoryType.DIR_DOCUMENTS;
- const context = getContext(this);
- let media = mediaLibrary.getMediaLibrary(context);
- const path = await media.getPublicDirectory(DIR_DOCUMENTS);
- media.createAsset(mediaType, "testFile.text", path).then ((asset) => {
- console.info("createAsset successfully:"+ JSON.stringify(asset));
- }).catch((err) => {
- console.info("createAsset failed with error:"+ err);
- });
+ let mediaType = mediaLibrary.MediaType.FILE;
+ let DIR_DOCUMENTS = mediaLibrary.DirectoryType.DIR_DOCUMENTS;
+ const context = getContext(this);
+ let media = mediaLibrary.getMediaLibrary(context);
+ const path = await media.getPublicDirectory(DIR_DOCUMENTS);
+ media.createAsset(mediaType, "testFile.text", path).then((asset) => {
+ console.info("createAsset successfully:"+ JSON.stringify(asset));
+ }).catch((err) => {
+ console.error("createAsset failed with error: " + err);
+ });
}
```
@@ -312,26 +320,26 @@ The following describes how to move the first file in the result set to the recy
```ts
async function example() {
- let fileKeyObj = mediaLibrary.FileKey;
- let fileType = mediaLibrary.MediaType.FILE;
- let option = {
- selections: fileKeyObj.MEDIA_TYPE + '= ?',
- selectionArgs: [fileType.toString()],
- };
- const context = getContext(this);
- let media = mediaLibrary.getMediaLibrary(context);
- const fetchFileResult = await media.getFileAssets(option);
- let asset = await fetchFileResult.getFirstObject();
- if (asset == undefined) {
- console.error('asset not exist');
- return;
- }
- // Void callback.
- asset.trash(true).then(() => {
- console.info("trash successfully");
- }).catch((err) => {
- console.info("trash failed with error: " + err);
- });
+ let fileKeyObj = mediaLibrary.FileKey;
+ let fileType = mediaLibrary.MediaType.FILE;
+ let option = {
+ selections: fileKeyObj.MEDIA_TYPE + '= ?',
+ selectionArgs: [fileType.toString()],
+ };
+ const context = getContext(this);
+ let media = mediaLibrary.getMediaLibrary(context);
+ const fetchFileResult = await media.getFileAssets(option);
+ let asset = await fetchFileResult.getFirstObject();
+ if (asset === undefined) {
+ console.error('asset not exist');
+ return;
+ }
+ // Void callback.
+ asset.trash(true).then(() => {
+ console.info("trash successfully");
+ }).catch((err) => {
+ console.error("trash failed with error: " + err);
+ });
}
```
@@ -346,7 +354,7 @@ Before renaming a file, you must obtain the file, for example, by calling [Fetch
- You have obtained a **MediaLibrary** instance.
- You have granted the permission **ohos.permission.WRITE_MEDIA**.
-The following describes how to rename the first file in the result set as **newtitle.text**.
+The following describes how to rename the first file in the result set as **newImage.jpg**.
**How to Develop**
@@ -358,28 +366,28 @@ The following describes how to rename the first file in the result set as **newt
```ts
async function example() {
- let fileKeyObj = mediaLibrary.FileKey;
- let fileType = mediaLibrary.MediaType.FILE;
- let option = {
- selections: fileKeyObj.MEDIA_TYPE + '= ?',
- selectionArgs: [fileType.toString()],
- };
- const context = getContext(this);
- let media = mediaLibrary.getMediaLibrary(context);
- const fetchFileResult = await media.getFileAssets(option);
- let asset = await fetchFileResult.getFirstObject();
- if (asset == undefined) {
- console.error('asset not exist');
+ let fileKeyObj = mediaLibrary.FileKey;
+ let fileType = mediaLibrary.MediaType.IMAGE;
+ let option = {
+ selections: fileKeyObj.MEDIA_TYPE + '= ?',
+ selectionArgs: [fileType.toString()],
+ };
+ const context = getContext(this);
+ let media = mediaLibrary.getMediaLibrary(context);
+ const fetchFileResult = await media.getFileAssets(option);
+ let asset = await fetchFileResult.getFirstObject();
+ if (asset === undefined) {
+ console.error('asset not exist');
+ return;
+ }
+ asset.displayName = 'newImage.jpg';
+ // Void callback.
+ asset.commitModify((err) => {
+ if (err) {
+ console.error('fileRename Failed ');
return;
}
- asset.displayName = 'newImage.jpg';
- // Void callback.
- asset.commitModify((err) => {
- if (err) {
- console.error('fileRename Failed ');
- return;
- }
- console.log('fileRename successful.');
- });
+ console.info('fileRename successful.');
+ });
}
```
diff --git a/en/application-dev/media/Readme-EN.md b/en/application-dev/media/Readme-EN.md
index d65c0d9dbe51f963385afaac0b75deccc6b21d2b..94f8605a284976058c8df8537a5ae9aa4a624740 100755
--- a/en/application-dev/media/Readme-EN.md
+++ b/en/application-dev/media/Readme-EN.md
@@ -1,9 +1,7 @@
# Media
-- Audio
+- Audio and Video
- [Audio Overview](audio-overview.md)
- - [Audio Playback Development](audio-playback.md)
- - [Audio Recording Development](audio-recorder.md)
- [Audio Rendering Development](audio-renderer.md)
- [Audio Stream Management Development](audio-stream-manager.md)
- [Audio Capture Development](audio-capturer.md)
@@ -12,10 +10,12 @@
- [Audio Interruption Mode Development](audio-interruptmode.md)
- [Volume Management Development](audio-volume-manager.md)
- [Audio Routing and Device Management Development](audio-routing-manager.md)
-
-- Video
- - [Video Playback Development](video-playback.md)
- - [Video Recording Development](video-recorder.md)
+ - [AVPlayer Development (Recommended)](avplayer-playback.md)
+ - [AVRecorder Development (Recommended)](avrecorder.md)
+ - [Audio Playback Development (To Be Deprecated)](audio-playback.md)
+ - [Audio Recording Development (To Be Deprecated)](audio-recorder.md)
+ - [Video Playback Development (To Be Deprecated)](video-playback.md)
+ - [Video Recording Development (To Be Deprecated)](video-recorder.md)
- AVSession
- [AVSession Overview](avsession-overview.md)
diff --git a/en/application-dev/media/audio-capturer.md b/en/application-dev/media/audio-capturer.md
index 539de6bb5c5a0723aa68a8994f7ee1970f393a3f..e9dde600b1e01a5550174f282c2787ba8ba66511 100644
--- a/en/application-dev/media/audio-capturer.md
+++ b/en/application-dev/media/audio-capturer.md
@@ -21,7 +21,7 @@ This following figure shows the audio capturer state transitions.
## Constraints
-Before developing the audio data collection feature, configure the **ohos.permission.MICROPHONE** permission for your application. For details about permission configuration, see [Permission Application Guide](../security/accesstoken-guidelines.md).
+Before developing the audio data collection feature, configure the **ohos.permission.MICROPHONE** permission for your application. For details, see [Permission Application Guide](../security/accesstoken-guidelines.md).
## How to Develop
@@ -72,7 +72,7 @@ For details about the APIs, see [AudioCapturer in Audio Management](../reference
}
await audioCapturer.start();
- let state = audioCapturer.state;
+ state = audioCapturer.state;
if (state == audio.AudioState.STATE_RUNNING) {
console.info('AudioRecLog: Capturer started');
} else {
@@ -86,7 +86,7 @@ For details about the APIs, see [AudioCapturer in Audio Management](../reference
The following example shows how to write recorded data into a file.
```js
- import fileio from '@ohos.fileio';
+ import fs from '@ohos.file.fs';
let state = audioCapturer.state;
// The read operation can be performed only when the state is STATE_RUNNING.
@@ -96,31 +96,36 @@ For details about the APIs, see [AudioCapturer in Audio Management](../reference
}
const path = '/data/data/.pulse_dir/capture_js.wav'; // Path for storing the collected audio file.
- let fd = fileio.openSync(path, 0o102, 0o777);
- if (fd !== null) {
- console.info('AudioRecLog: file fd created');
- }
- else{
- console.info('AudioRecLog: file fd create : FAILED');
+ let file = fs.openSync(filePath, 0o2);
+ let fd = file.fd;
+ if (file !== null) {
+ console.info('AudioRecLog: file created');
+ } else {
+ console.info('AudioRecLog: file create : FAILED');
return;
}
-
- fd = fileio.openSync(path, 0o2002, 0o666);
+
if (fd !== null) {
console.info('AudioRecLog: file fd opened in append mode');
}
let numBuffersToCapture = 150; // Write data for 150 times.
+ let count = 0;
while (numBuffersToCapture) {
+ let bufferSize = await audioCapturer.getBufferSize();
let buffer = await audioCapturer.read(bufferSize, true);
+ let options = {
+ offset: count * this.bufferSize,
+ length: this.bufferSize
+ }
if (typeof(buffer) == undefined) {
console.info('AudioRecLog: read buffer failed');
} else {
- let number = fileio.writeSync(fd, buffer);
+ let number = fs.writeSync(fd, buffer, options);
console.info(`AudioRecLog: data written: ${number}`);
- }
-
+ }
numBuffersToCapture--;
+ count++;
}
```
@@ -178,18 +183,18 @@ For details about the APIs, see [AudioCapturer in Audio Management](../reference
// Obtain the audio capturer information.
let audioCapturerInfo : audio.AuduioCapturerInfo = await audioCapturer.getCapturerInfo();
-
+
// Obtain the audio stream information.
let audioStreamInfo : audio.AudioStreamInfo = await audioCapturer.getStreamInfo();
-
+
// Obtain the audio stream ID.
let audioStreamId : number = await audioCapturer.getAudioStreamId();
-
+
// Obtain the Unix timestamp, in nanoseconds.
let audioTime : number = await audioCapturer.getAudioTime();
-
+
// Obtain a proper minimum buffer size.
- let bufferSize : number = await audioCapturer.getBuffersize();
+ let bufferSize : number = await audioCapturer.getBufferSize();
```
7. (Optional) Use **on('markReach')** to subscribe to the mark reached event, and use **off('markReach')** to unsubscribe from the event.
diff --git a/en/application-dev/media/audio-playback.md b/en/application-dev/media/audio-playback.md
index bbdb993ecdb9a1289a939af43db0e670ec10f98f..1c7953d32b8ecee4c0ff34e82ab8d13947ac9271 100644
--- a/en/application-dev/media/audio-playback.md
+++ b/en/application-dev/media/audio-playback.md
@@ -38,7 +38,7 @@ For details about the **src** types supported by **AudioPlayer**, see the [src a
```js
import media from '@ohos.multimedia.media'
-import fileIO from '@ohos.fileio'
+import fs from '@ohos.file.fs'
// Print the stream track information.
function printfDescription(obj) {
@@ -112,14 +112,8 @@ async function audioPlayerDemo() {
let pathDir = "/data/storage/el2/base/haps/entry/files" // The path used here is an example. Obtain the path based on project requirements.
// The stream in the path can be pushed to the device by running the "hdc file send D:\xxx\01.mp3 /data/app/el2/100/base/ohos.acts.multimedia.audio.audioplayer/haps/entry/files" command.
let path = pathDir + '/01.mp3'
- await fileIO.open(path).then((fdNumber) => {
- fdPath = fdPath + '' + fdNumber;
- console.info('open fd success fd is' + fdPath);
- }, (err) => {
- console.info('open fd failed err is' + err);
- }).catch((err) => {
- console.info('open fd failed err is' + err);
- });
+ let file = await fs.open(path);
+ fdPath = fdPath + '' + file.fd;
audioPlayer.src = fdPath; // Set the src attribute and trigger the 'dataLoad' event callback.
}
```
@@ -128,7 +122,7 @@ async function audioPlayerDemo() {
```js
import media from '@ohos.multimedia.media'
-import fileIO from '@ohos.fileio'
+import fs from '@ohos.file.fs'
export class AudioDemo {
// Set the player callbacks.
@@ -154,14 +148,8 @@ export class AudioDemo {
let pathDir = "/data/storage/el2/base/haps/entry/files" // The path used here is an example. Obtain the path based on project requirements.
// The stream in the path can be pushed to the device by running the "hdc file send D:\xxx\01.mp3 /data/app/el2/100/base/ohos.acts.multimedia.audio.audioplayer/haps/entry/files" command.
let path = pathDir + '/01.mp3'
- await fileIO.open(path).then((fdNumber) => {
- fdPath = fdPath + '' + fdNumber;
- console.info('open fd success fd is' + fdPath);
- }, (err) => {
- console.info('open fd failed err is' + err);
- }).catch((err) => {
- console.info('open fd failed err is' + err);
- });
+ let file = await fs.open(path);
+ fdPath = fdPath + '' + file.fd;
audioPlayer.src = fdPath; // Set the src attribute and trigger the 'dataLoad' event callback.
}
}
@@ -171,7 +159,7 @@ export class AudioDemo {
```js
import media from '@ohos.multimedia.media'
-import fileIO from '@ohos.fileio'
+import fs from '@ohos.file.fs'
export class AudioDemo {
// Set the player callbacks.
@@ -202,14 +190,8 @@ export class AudioDemo {
let pathDir = "/data/storage/el2/base/haps/entry/files" // The path used here is an example. Obtain the path based on project requirements.
// The stream in the path can be pushed to the device by running the "hdc file send D:\xxx\02.mp3 /data/app/el2/100/base/ohos.acts.multimedia.audio.audioplayer/haps/entry/files" command.
let nextpath = pathDir + '/02.mp3'
- await fileIO.open(nextpath).then((fdNumber) => {
- nextFdPath = nextFdPath + '' + fdNumber;
- console.info('open fd success fd is' + nextFdPath);
- }, (err) => {
- console.info('open fd failed err is' + err);
- }).catch((err) => {
- console.info('open fd failed err is' + err);
- });
+ let nextFile = await fs.open(nextpath);
+ nextFdPath = nextFdPath + '' + nextFile.fd;
audioPlayer.src = nextFdPath; // Set the src attribute and trigger the 'dataLoad' event callback.
}
@@ -220,14 +202,8 @@ export class AudioDemo {
let pathDir = "/data/storage/el2/base/haps/entry/files" // The path used here is an example. Obtain the path based on project requirements.
// The stream in the path can be pushed to the device by running the "hdc file send D:\xxx\01.mp3 /data/app/el2/100/base/ohos.acts.multimedia.audio.audioplayer/haps/entry/files" command.
let path = pathDir + '/01.mp3'
- await fileIO.open(path).then((fdNumber) => {
- fdPath = fdPath + '' + fdNumber;
- console.info('open fd success fd is' + fdPath);
- }, (err) => {
- console.info('open fd failed err is' + err);
- }).catch((err) => {
- console.info('open fd failed err is' + err);
- });
+ let file = await fs.open(path);
+ fdPath = fdPath + '' + file.fd;
audioPlayer.src = fdPath; // Set the src attribute and trigger the 'dataLoad' event callback.
}
}
@@ -237,7 +213,7 @@ export class AudioDemo {
```js
import media from '@ohos.multimedia.media'
-import fileIO from '@ohos.fileio'
+import fs from '@ohos.file.fs'
export class AudioDemo {
// Set the player callbacks.
@@ -259,14 +235,8 @@ export class AudioDemo {
let pathDir = "/data/storage/el2/base/haps/entry/files" // The path used here is an example. Obtain the path based on project requirements.
// The stream in the path can be pushed to the device by running the "hdc file send D:\xxx\01.mp3 /data/app/el2/100/base/ohos.acts.multimedia.audio.audioplayer/haps/entry/files" command.
let path = pathDir + '/01.mp3'
- await fileIO.open(path).then((fdNumber) => {
- fdPath = fdPath + '' + fdNumber;
- console.info('open fd success fd is' + fdPath);
- }, (err) => {
- console.info('open fd failed err is' + err);
- }).catch((err) => {
- console.info('open fd failed err is' + err);
- });
+ let file = await fs.open(path);
+ fdPath = fdPath + '' + file.fd;
audioPlayer.src = fdPath; // Set the src attribute and trigger the 'dataLoad' event callback.
}
}
diff --git a/en/application-dev/media/audio-renderer.md b/en/application-dev/media/audio-renderer.md
index 0b5b382d72fec98bfa18c3cfdee7bd61ef713da1..6a631bddc5437b677c6b1188c37d8ab5ebeb5dbe 100644
--- a/en/application-dev/media/audio-renderer.md
+++ b/en/application-dev/media/audio-renderer.md
@@ -33,33 +33,32 @@ The following figure shows the audio renderer state transitions.
For details about the APIs, see [AudioRenderer in Audio Management](../reference/apis/js-apis-audio.md#audiorenderer8).
1. Use **createAudioRenderer()** to create an **AudioRenderer** instance.
-
-
-Set parameters of the **AudioRenderer** instance in **audioRendererOptions**. This instance is used to render audio, control and obtain the rendering status, and register a callback for notification.
+ Set parameters of the **AudioRenderer** instance in **audioRendererOptions**. This instance is used to render audio, control and obtain the rendering status, and register a callback for notification.
+
```js
- import audio from '@ohos.multimedia.audio';
+ import audio from '@ohos.multimedia.audio';
- let audioStreamInfo = {
- samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100,
- channels: audio.AudioChannel.CHANNEL_1,
- sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE,
- encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW
- }
- let audioRendererInfo = {
- content: audio.ContentType.CONTENT_TYPE_SPEECH,
- usage: audio.StreamUsage.STREAM_USAGE_VOICE_COMMUNICATION,
- rendererFlags: 0 // 0 is the extended flag bit of the audio renderer. The default value is 0.
+ let audioStreamInfo = {
+ samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_44100,
+ channels: audio.AudioChannel.CHANNEL_1,
+ sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE,
+ encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW
+ }
+ let audioRendererInfo = {
+ content: audio.ContentType.CONTENT_TYPE_SPEECH,
+ usage: audio.StreamUsage.STREAM_USAGE_VOICE_COMMUNICATION,
+ rendererFlags: 0 // 0 is the extended flag bit of the audio renderer. The default value is 0.
+ }
+ let audioRendererOptions = {
+ streamInfo: audioStreamInfo,
+ rendererInfo: audioRendererInfo
}
- let audioRendererOptions = {
- streamInfo: audioStreamInfo,
- rendererInfo: audioRendererInfo
- }
-
- let audioRenderer = await audio.createAudioRenderer(audioRendererOptions);
- console.log("Create audio renderer success.");
+
+ let audioRenderer = await audio.createAudioRenderer(audioRendererOptions);
+ console.log("Create audio renderer success.");
```
-
+
2. Use **start()** to start audio rendering.
```js
@@ -82,15 +81,15 @@ Set parameters of the **AudioRenderer** instance in **audioRendererOptions**. Th
}
}
```
- The renderer state will be **STATE_RUNNING** once the audio renderer is started. The application can then begin reading buffers.
+ The renderer state will be **STATE_RUNNING** once the audio renderer is started. The application can then begin reading buffers.
3. Call **write()** to write data to the buffer.
Read the audio data to be played to the buffer. Call **write()** repeatedly to write the data to the buffer.
```js
- import fileio from '@ohos.fileio';
+ import fs from '@ohos.file.fs';
import audio from '@ohos.multimedia.audio';
async function writeBuffer(buf) {
@@ -109,35 +108,33 @@ Set parameters of the **AudioRenderer** instance in **audioRendererOptions**. Th
// Set a proper buffer size for the audio renderer. You can also select a buffer of another size.
const bufferSize = await audioRenderer.getBufferSize();
let dir = globalThis.fileDir; // You must use the sandbox path.
- const path = dir + '/file_example_WAV_2MG.wav'; // The file to render is in the following path: /data/storage/el2/base/haps/entry/files/file_example_WAV_2MG.wav
- console.info(`file path: ${ path}`);
- let ss = fileio.createStreamSync(path, 'r');
- const totalSize = fileio.statSync(path).size; // Size of the file to render.
- let discardHeader = new ArrayBuffer(bufferSize);
- ss.readSync(discardHeader);
- let rlen = 0;
- rlen += bufferSize;
-
- let id = setInterval(() => {
- if (audioRenderer.state == audio.AudioState.STATE_RELEASED) { // The rendering stops if the audio renderer is in the STATE_RELEASED state.
- ss.closeSync();
- await audioRenderer.stop();
- clearInterval(id);
+ const filePath = dir + '/file_example_WAV_2MG.wav'; // The file to render is in the following path: /data/storage/el2/base/haps/entry/files/file_example_WAV_2MG.wav
+ console.info(`file filePath: ${ filePath}`);
+
+ let file = fs.openSync(filePath, fs.OpenMode.READ_ONLY);
+ let stat = await fs.stat(filePath); // Music file information.
+ let buf = new ArrayBuffer(bufferSize);
+ let len = stat.size % this.bufferSize == 0 ? Math.floor(stat.size / this.bufferSize) : Math.floor(stat.size / this.bufferSize + 1);
+ for (let i = 0;i < len; i++) {
+ let options = {
+ offset: i * this.bufferSize,
+ length: this.bufferSize
}
- if (audioRenderer.state == audio.AudioState.STATE_RUNNING) {
- if (rlen >= totalSize) { // The rendering stops if the file finishes reading.
- ss.closeSync();
- await audioRenderer.stop();
- clearInterval(id);
- }
- let buf = new ArrayBuffer(bufferSize);
- rlen += ss.readSync(buf);
- console.info(`Total bytes read from file: ${rlen}`);
- writeBuffer(buf);
- } else {
- console.info('check after next interval');
- }
- }, 30); // The timer interval is set based on the audio format. The unit is millisecond.
+ let readsize = await fs.read(file.fd, buf, options)
+ let writeSize = await new Promise((resolve,reject)=>{
+ this.audioRenderer.write(buf,(err,writeSize)=>{
+ if(err){
+ reject(err)
+ }else{
+ resolve(writeSize)
+ }
+ })
+ })
+ }
+
+ fs.close(file)
+ await audioRenderer.stop(); // Stop rendering.
+ await audioRenderer.release(); // Releases the resources.
```
4. (Optional) Call **pause()** or **stop()** to pause or stop rendering.
@@ -242,7 +239,7 @@ Set parameters of the **AudioRenderer** instance in **audioRendererOptions**. Th
let audioTime : number = await audioRenderer.getAudioTime();
// Obtain a proper minimum buffer size.
- let bufferSize : number = await audioRenderer.getBuffersize();
+ let bufferSize : number = await audioRenderer.getBufferSize();
// Obtain the audio renderer rate.
let renderRate : audio.AudioRendererRate = await audioRenderer.getRenderRate();
@@ -424,35 +421,31 @@ Set parameters of the **AudioRenderer** instance in **audioRendererOptions**. Th
let dir = globalThis.fileDir; // You must use the sandbox path.
const path1 = dir + '/music001_48000_32_1.wav'; // The file to render is in the following path: /data/storage/el2/base/haps/entry/files/music001_48000_32_1.wav
console.info(`audioRender1 file path: ${ path1}`);
- let ss1 = await fileio.createStream(path1,'r');
- const totalSize1 = fileio.statSync(path1).size; // Size of the file to render.
- console.info(`totalSize1 -------: ${totalSize1}`);
- let discardHeader = new ArrayBuffer(bufferSize);
- ss1.readSync(discardHeader);
- let rlen = 0;
- rlen += bufferSize;
-
+ let file1 = fs.openSync(path1, fs.OpenMode.READ_ONLY);
+ let stat = await fs.stat(path1); // Music file information.
+ let buf = new ArrayBuffer(bufferSize);
+ let len = stat.size % this.bufferSize == 0 ? Math.floor(stat.size / this.bufferSize) : Math.floor(stat.size / this.bufferSize + 1);
+
// 1.7 Render the original audio data in the buffer by using audioRender.
- let id = setInterval(async () => {
- if (audioRenderer1.state == audio.AudioState.STATE_RELEASED) { // The rendering stops if the audio renderer is in the STATE_RELEASED state.
- ss1.closeSync();
- audioRenderer1.stop();
- clearInterval(id);
+ for (let i = 0;i < len; i++) {
+ let options = {
+ offset: i * this.bufferSize,
+ length: this.bufferSize
}
- if (audioRenderer1.state == audio.AudioState.STATE_RUNNING) {
- if (rlen >= totalSize1) { // The rendering stops if the file finishes reading.
- ss1.closeSync();
- await audioRenderer1.stop();
- clearInterval(id);
- }
- let buf = new ArrayBuffer(bufferSize);
- rlen += ss1.readSync(buf);
- console.info(`Total bytes read from file: ${rlen}`);
- await writeBuffer(buf, that.audioRenderer1);
- } else {
- console.info('check after next interval');
- }
- }, 30); // The timer interval is set based on the audio format. The unit is millisecond.
+ let readsize = await fs.read(file.fd, buf, options)
+ let writeSize = await new Promise((resolve,reject)=>{
+ this.audioRenderer1.write(buf,(err,writeSize)=>{
+ if(err){
+ reject(err)
+ }else{
+ resolve(writeSize)
+ }
+ })
+ })
+ }
+ fs.close(file1)
+ await audioRenderer1.stop(); // Stop rendering.
+ await audioRenderer1.release(); Releases the resources.
}
async runningAudioRender2(){
@@ -499,36 +492,32 @@ Set parameters of the **AudioRenderer** instance in **audioRendererOptions**. Th
// 2.6 Read the original audio data file.
let dir = globalThis.fileDir; // You must use the sandbox path.
const path2 = dir + '/music002_48000_32_1.wav'; // The file to render is in the following path: /data/storage/el2/base/haps/entry/files/music002_48000_32_1.wav
- console.error(`audioRender1 file path: ${ path2}`);
- let ss2 = await fileio.createStream(path2,'r');
- const totalSize2 = fileio.statSync(path2).size; // Size of the file to render.
- console.error(`totalSize2 -------: ${totalSize2}`);
- let discardHeader2 = new ArrayBuffer(bufferSize);
- ss2.readSync(discardHeader2);
- let rlen = 0;
- rlen += bufferSize;
-
+ console.info(`audioRender2 file path: ${ path2}`);
+ let file2 = fs.openSync(path2, fs.OpenMode.READ_ONLY);
+ let stat = await fs.stat(path2); // Music file information.
+ let buf = new ArrayBuffer(bufferSize);
+ let len = stat.size % this.bufferSize == 0 ? Math.floor(stat.size / this.bufferSize) : Math.floor(stat.size / this.bufferSize + 1);
+
// 2.7 Render the original audio data in the buffer by using audioRender.
- let id = setInterval(async () => {
- if (audioRenderer2.state == audio.AudioState.STATE_RELEASED) { // The rendering stops if the audio renderer is in the STATE_RELEASED state.
- ss2.closeSync();
- that.audioRenderer2.stop();
- clearInterval(id);
+ for (let i = 0;i < len; i++) {
+ let options = {
+ offset: i * this.bufferSize,
+ length: this.bufferSize
}
- if (audioRenderer1.state == audio.AudioState.STATE_RUNNING) {
- if (rlen >= totalSize2) { // The rendering stops if the file finishes reading.
- ss2.closeSync();
- await audioRenderer2.stop();
- clearInterval(id);
- }
- let buf = new ArrayBuffer(bufferSize);
- rlen += ss2.readSync(buf);
- console.info(`Total bytes read from file: ${rlen}`);
- await writeBuffer(buf, that.audioRenderer2);
- } else {
- console.info('check after next interval');
- }
- }, 30); // The timer interval is set based on the audio format. The unit is millisecond.
+ let readsize = await fs.read(file.fd, buf, options)
+ let writeSize = await new Promise((resolve,reject)=>{
+ this.audioRenderer2.write(buf,(err,writeSize)=>{
+ if(err){
+ reject(err)
+ }else{
+ resolve(writeSize)
+ }
+ })
+ })
+ }
+ fs.close(file2)
+ await audioRenderer2.stop(); // Stop rendering.
+ await audioRenderer2.release(); // Releases the resources.
}
async writeBuffer(buf, audioRender) {
@@ -548,4 +537,4 @@ Set parameters of the **AudioRenderer** instance in **audioRendererOptions**. Th
await runningAudioRender2();
}
- ```
+ ```
\ No newline at end of file
diff --git a/en/application-dev/media/avplayer-playback.md b/en/application-dev/media/avplayer-playback.md
index 270081373fb500877ca4352366982b66f72bc09a..324dd43e6f73d46e5f0d264ae81ba36802ee6021 100644
--- a/en/application-dev/media/avplayer-playback.md
+++ b/en/application-dev/media/avplayer-playback.md
@@ -104,7 +104,7 @@ The full playback process includes creating an instance, setting resources, sett
```js
import media from '@ohos.multimedia.media'
import audio from '@ohos.multimedia.audio';
-import fileIO from '@ohos.fileio'
+import fs from '@ohos.file.fs'
const TAG = 'AVPlayerDemo:'
export class AVPlayerDemo {
@@ -223,14 +223,8 @@ export class AVPlayerDemo {
let pathDir = "/data/storage/el2/base/haps/entry/files" // The path used here is an example. Obtain the path based on project requirements.
// The stream in the path can be pushed to the device by running the "hdc file send D:\xxx\H264_AAC.mp4 /data/app/el2/100/base/ohos.acts.multimedia.media.avplayer/haps/entry/files" command.
let path = pathDir + '/H264_AAC.mp4'
- await fileIO.open(path).then((fdNumber) => {
- fdPath = fdPath + '' + fdNumber
- console.info('open fd success fd is' + fdPath)
- }, (err) => {
- console.info('open fd failed err is' + err)
- }).catch((err) => {
- console.info('open fd failed err is' + err)
- });
+ let file = await fs.open(path)
+ fdPath = fdPath + '' + file.fd
this.avPlayer.url = fdPath
}
}
@@ -240,7 +234,7 @@ export class AVPlayerDemo {
```js
import media from '@ohos.multimedia.media'
-import fileIO from '@ohos.fileio'
+import fs from '@ohos.file.fs'
const TAG = 'AVPlayerDemo:'
export class AVPlayerDemo {
@@ -280,7 +274,7 @@ export class AVPlayerDemo {
break;
case 'stopped': // This state is reported upon a successful callback of stop().
console.info(TAG + 'state stopped called')
- this.avPlayer.reset() // Call reset() to initialize the AVPlayer state.
+ this.avPlayer.release() // Call reset() to initialize the AVPlayer state.
break;
case 'released':
console.info(TAG + 'state released called')
@@ -302,24 +296,18 @@ export class AVPlayerDemo {
let pathDir = "/data/storage/el2/base/haps/entry/files" // The path used here is an example. Obtain the path based on project requirements.
// The stream in the path can be pushed to the device by running the "hdc file send D:\xxx\H264_AAC.mp4 /data/app/el2/100/base/ohos.acts.multimedia.media.avplayer/haps/entry/files" command.
let path = pathDir + '/H264_AAC.mp4'
- await fileIO.open(path).then((fdNumber) => {
- fdPath = fdPath + '' + fdNumber
- console.info('open fd success fd is' + fdPath)
- }, (err) => {
- console.info('open fd failed err is' + err)
- }).catch((err) => {
- console.info('open fd failed err is' + err)
- });
+ let file = await fs.open(path)
+ fdPath = fdPath + '' + file.fd
this.avPlayer.url = fdPath
}
}
```
-### Switching to the Next Video Clip
+### Looping a Song
```js
import media from '@ohos.multimedia.media'
-import fileIO from '@ohos.fileio'
+import fs from '@ohos.file.fs'
const TAG = 'AVPlayerDemo:'
export class AVPlayerDemo {
@@ -362,7 +350,7 @@ export class AVPlayerDemo {
break;
case 'stopped': // This state is reported upon a successful callback of stop().
console.info(TAG + 'state stopped called')
- this.avPlayer.reset() // Call reset() to initialize the AVPlayer state.
+ this.avPlayer.release() // Call reset() to initialize the AVPlayer state.
break;
case 'released':
console.info(TAG + 'state released called')
@@ -393,23 +381,17 @@ export class AVPlayerDemo {
let pathDir = "/data/storage/el2/base/haps/entry/files" // The path used here is an example. Obtain the path based on project requirements.
// The stream in the path can be pushed to the device by running the "hdc file send D:\xxx\H264_AAC.mp4 /data/app/el2/100/base/ohos.acts.multimedia.media.avplayer/haps/entry/files" command.
let path = pathDir + '/H264_AAC.mp4'
- await fileIO.open(path).then((fdNumber) => {
- fdPath = fdPath + '' + fdNumber
- console.info('open fd success fd is' + fdPath)
- }, (err) => {
- console.info('open fd failed err is' + err)
- }).catch((err) => {
- console.info('open fd failed err is' + err)
- });
+ let file = await fs.open(path)
+ fdPath = fdPath + '' + file.fd
this.avPlayer.url = fdPath
}
}
```
-### Looping a Song
+### Switching to the Next Video Clip
```js
import media from '@ohos.multimedia.media'
-import fileIO from '@ohos.fileio'
+import fs from '@ohos.file.fs'
const TAG = 'AVPlayerDemo:'
export class AVPlayerDemo {
@@ -422,14 +404,8 @@ export class AVPlayerDemo {
let pathDir = "/data/storage/el2/base/haps/entry/files" // The path used here is an example. Obtain the path based on project requirements.
// The stream in the path can be pushed to the device by running the "hdc file send D:\xxx\H264_MP3.mp4 /data/app/el2/100/base/ohos.acts.multimedia.media.avplayer/haps/entry/files" command.
let path = pathDir + '/H264_MP3.mp4'
- await fileIO.open(path).then((fdNumber) => {
- fdPath = fdPath + '' + fdNumber
- console.info('open fd success fd is' + fdPath)
- }, (err) => {
- console.info('open fd failed err is' + err)
- }).catch((err) => {
- console.info('open fd failed err is' + err)
- });
+ let file = await fs.open(path)
+ fdPath = fdPath + '' + file.fd
this.avPlayer.url = fdPath // The initialized state is reported again.
}
@@ -493,14 +469,8 @@ export class AVPlayerDemo {
let pathDir = "/data/storage/el2/base/haps/entry/files" // The path used here is an example. Obtain the path based on project requirements.
// The stream in the path can be pushed to the device by running the "hdc file send D:\xxx\H264_AAC.mp4 /data/app/el2/100/base/ohos.acts.multimedia.media.avplayer/haps/entry/files" command.
let path = pathDir + '/H264_AAC.mp4'
- await fileIO.open(path).then((fdNumber) => {
- fdPath = fdPath + '' + fdNumber
- console.info('open fd success fd is' + fdPath)
- }, (err) => {
- console.info('open fd failed err is' + err)
- }).catch((err) => {
- console.info('open fd failed err is' + err)
- });
+ let file = await fs.open(path)
+ fdPath = fdPath + '' + file.fd
this.avPlayer.url = fdPath
}
}
diff --git a/en/application-dev/media/avrecorder.md b/en/application-dev/media/avrecorder.md
index 6378b7515e675fcc0b924fc47a4af9db60707a47..d97ed9fb27f983d643b62244b2ba1d1f36929c69 100644
--- a/en/application-dev/media/avrecorder.md
+++ b/en/application-dev/media/avrecorder.md
@@ -67,14 +67,14 @@ export class AVRecorderDemo {
let surfaceID; // The surface ID is obtained by calling getInputSurface and transferred to the videoOutput object of the camera.
await this.getFd('01.mp4');
- // Configure the parameters related to audio and video recording.
+ // Configure the parameters related to audio and video recording based on those supported by the hardware device.
let avProfile = {
audioBitrate : 48000,
audioChannels : 2,
audioCodec : media.CodecMimeType.AUDIO_AAC,
audioSampleRate : 48000,
fileFormat : media.ContainerFormatType.CFT_MPEG_4,
- videoBitrate : 48000,
+ videoBitrate : 2000000,
videoCodec : media.CodecMimeType.VIDEO_MPEG4,
videoFrameWidth : 640,
videoFrameHeight : 480,
@@ -363,10 +363,10 @@ export class VideoRecorderDemo {
let surfaceID; // The surface ID is obtained by calling getInputSurface and transferred to the videoOutput object of the camera.
await this.getFd('01.mp4');
- // Configure the parameters related to video recording.
+ // Configure the parameters related to pure video recording based on those supported by the hardware device.
let videoProfile = {
fileFormat : media.ContainerFormatType.CFT_MPEG_4,
- videoBitrate : 48000,
+ videoBitrate : 2000000,
videoCodec : media.CodecMimeType.VIDEO_MPEG4,
videoFrameWidth : 640,
videoFrameHeight : 480,
diff --git a/en/application-dev/media/figures/en-us_image_avplayer_state_machine.png b/en/application-dev/media/figures/en-us_image_avplayer_state_machine.png
index aa8afdbcbf142fd745cee03fc422caec51cfe41b..12adecd8865a9ff1faaa2c6654e8558f2fac77aa 100644
Binary files a/en/application-dev/media/figures/en-us_image_avplayer_state_machine.png and b/en/application-dev/media/figures/en-us_image_avplayer_state_machine.png differ
diff --git a/en/application-dev/media/video-playback.md b/en/application-dev/media/video-playback.md
index b324f19b3cf0f3621bd74809c4f1a2d0b57d0abd..d4c895b452aa31b28690bd96bd9ef0fac64c4eb4 100644
--- a/en/application-dev/media/video-playback.md
+++ b/en/application-dev/media/video-playback.md
@@ -51,7 +51,7 @@ For details about how to create an XComponent, see [XComponent](../reference/ark
```js
import media from '@ohos.multimedia.media'
-import fileIO from '@ohos.fileio'
+import fs from '@ohos.file.fs'
export class VideoPlayerDemo {
// Report an error in the case of a function invocation failure.
failureCallback(error) {
@@ -82,14 +82,8 @@ export class VideoPlayerDemo {
let fdPath = 'fd://'
// The stream in the path can be pushed to the device by running the "hdc file send D:\xxx\H264_AAC.mp4 /data/app/el1/bundle/public/ohos.acts.multimedia.video.videoplayer/ohos.acts.multimedia.video.videoplayer/assets/entry/resources/rawfile" command.
let path = '/data/app/el1/bundle/public/ohos.acts.multimedia.video.videoplayer/ohos.acts.multimedia.video.videoplayer/assets/entry/resources/rawfile/H264_AAC.mp4';
- await fileIO.open(path).then((fdNumber) => {
- fdPath = fdPath + '' + fdNumber;
- console.info('open fd success fd is' + fdPath);
- }, (err) => {
- console.info('open fd failed err is' + err);
- }).catch((err) => {
- console.info('open fd failed err is' + err);
- });
+ let file = await fs.open(path);
+ fdPath = fdPath + '' + file.fd;
// Call createVideoPlayer to create a VideoPlayer instance.
await media.createVideoPlayer().then((video) => {
if (typeof (video) != 'undefined') {
@@ -180,7 +174,7 @@ export class VideoPlayerDemo {
```js
import media from '@ohos.multimedia.media'
-import fileIO from '@ohos.fileio'
+import fs from '@ohos.file.fs'
export class VideoPlayerDemo {
// Report an error in the case of a function invocation failure.
failureCallback(error) {
@@ -211,14 +205,8 @@ export class VideoPlayerDemo {
let fdPath = 'fd://'
// The stream in the path can be pushed to the device by running the "hdc file send D:\xxx\H264_AAC.mp4 /data/app/el1/bundle/public/ohos.acts.multimedia.video.videoplayer/ohos.acts.multimedia.video.videoplayer/assets/entry/resources/rawfile" command.
let path = '/data/app/el1/bundle/public/ohos.acts.multimedia.video.videoplayer/ohos.acts.multimedia.video.videoplayer/assets/entry/resources/rawfile/H264_AAC.mp4';
- await fileIO.open(path).then((fdNumber) => {
- fdPath = fdPath + '' + fdNumber;
- console.info('open fd success fd is' + fdPath);
- }, (err) => {
- console.info('open fd failed err is' + err);
- }).catch((err) => {
- console.info('open fd failed err is' + err);
- });
+ let file = await fs.open(path);
+ fdPath = fdPath + '' + file.fd;
// Call createVideoPlayer to create a VideoPlayer instance.
await media.createVideoPlayer().then((video) => {
if (typeof (video) != 'undefined') {
@@ -267,7 +255,7 @@ export class VideoPlayerDemo {
```js
import media from '@ohos.multimedia.media'
-import fileIO from '@ohos.fileio'
+import fs from '@ohos.file.fs'
export class VideoPlayerDemo {
// Report an error in the case of a function invocation failure.
failureCallback(error) {
@@ -299,14 +287,8 @@ export class VideoPlayerDemo {
// The stream in the path can be pushed to the device by running the "hdc file send D:\xxx\H264_AAC.mp4 /data/app/el1/bundle/public/ohos.acts.multimedia.video.videoplayer/ohos.acts.multimedia.video.videoplayer/assets/entry/resources/rawfile" command.
let path = '/data/app/el1/bundle/public/ohos.acts.multimedia.video.videoplayer/ohos.acts.multimedia.video.videoplayer/assets/entry/resources/rawfile/H264_AAC.mp4';
let nextPath = '/data/app/el1/bundle/public/ohos.acts.multimedia.video.videoplayer/ohos.acts.multimedia.video.videoplayer/assets/entry/resources/rawfile/MP4_AAC.mp4';
- await fileIO.open(path).then((fdNumber) => {
- fdPath = fdPath + '' + fdNumber;
- console.info('open fd success fd is' + fdPath);
- }, (err) => {
- console.info('open fd failed err is' + err);
- }).catch((err) => {
- console.info('open fd failed err is' + err);
- });
+ let file = await fs.open(path);
+ fdPath = fdPath + '' + file.fd;
// Call createVideoPlayer to create a VideoPlayer instance.
await media.createVideoPlayer().then((video) => {
if (typeof (video) != 'undefined') {
@@ -341,14 +323,8 @@ export class VideoPlayerDemo {
// Obtain the next video FD address.
fdPath = 'fd://'
- await fileIO.open(nextPath).then((fdNumber) => {
- fdPath = fdPath + '' + fdNumber;
- console.info('open fd success fd is' + fdPath);
- }, (err) => {
- console.info('open fd failed err is' + err);
- }).catch((err) => {
- console.info('open fd failed err is' + err);
- });
+ let nextFile = await fs.open(nextPath);
+ fdPath = fdPath + '' + nextFile.fd;
// Set the second video playback source.
videoPlayer.url = fdPath;
@@ -378,7 +354,7 @@ export class VideoPlayerDemo {
```js
import media from '@ohos.multimedia.media'
-import fileIO from '@ohos.fileio'
+import fs from '@ohos.file.fs'
export class VideoPlayerDemo {
// Report an error in the case of a function invocation failure.
failureCallback(error) {
@@ -409,14 +385,8 @@ export class VideoPlayerDemo {
let fdPath = 'fd://'
// The stream in the path can be pushed to the device by running the "hdc file send D:\xxx\H264_AAC.mp4 /data/app/el1/bundle/public/ohos.acts.multimedia.video.videoplayer/ohos.acts.multimedia.video.videoplayer/assets/entry/resources/rawfile" command.
let path = '/data/app/el1/bundle/public/ohos.acts.multimedia.video.videoplayer/ohos.acts.multimedia.video.videoplayer/assets/entry/resources/rawfile/H264_AAC.mp4';
- await fileIO.open(path).then((fdNumber) => {
- fdPath = fdPath + '' + fdNumber;
- console.info('open fd success fd is' + fdPath);
- }, (err) => {
- console.info('open fd failed err is' + err);
- }).catch((err) => {
- console.info('open fd failed err is' + err);
- });
+ let file = await fs.open(path);
+ fdPath = fdPath + '' + file.fd;
// Call createVideoPlayer to create a VideoPlayer instance.
await media.createVideoPlayer().then((video) => {
if (typeof (video) != 'undefined') {
diff --git a/en/application-dev/media/video-recorder.md b/en/application-dev/media/video-recorder.md
index bef55899bcb51359a6b6d68ef6d7894d70e435ae..fd9de91b4bae0591e2a5dc4869455bdd4055943e 100644
--- a/en/application-dev/media/video-recorder.md
+++ b/en/application-dev/media/video-recorder.md
@@ -76,14 +76,14 @@ export class VideoRecorderDemo {
let surfaceID = null; // Used to save the surface ID returned by getInputSurface.
// Obtain the FD address of the video to be recorded.
await this.getFd('01.mp4');
- // Recording-related parameter settings
+ // Configure the parameters related to video recording based on those supported by the hardware device.
let videoProfile = {
audioBitrate : 48000,
audioChannels : 2,
audioCodec : 'audio/mp4a-latm',
audioSampleRate : 48000,
fileFormat : 'mp4',
- videoBitrate : 48000,
+ videoBitrate : 2000000,
videoCodec : 'video/mp4v-es',
videoFrameWidth : 640,
videoFrameHeight : 480,
diff --git a/en/application-dev/napi/napi-guidelines.md b/en/application-dev/napi/napi-guidelines.md
index 5113c413d523b9d58363b78ac94ba42cc1954e9d..4448869d84d51b0fb17836e69af14ad28433f395 100644
--- a/en/application-dev/napi/napi-guidelines.md
+++ b/en/application-dev/napi/napi-guidelines.md
@@ -4,9 +4,7 @@ OpenHarmony applications use JavaScript (JS) when calling native APIs. The nativ
## How to Develop
-The DevEco Studio has a default project that uses NAPIs.
-
-You can choose **File** > **New** > **Create Project** to create a **Native C++** project. The **cpp** directory is generated in the **main** directory. You can use the NAPIs provided by the **ace_napi** repository for development.
+The DevEco Studio has a default project that uses NAPIs. You can choose **File** > **New** > **Create Project** to create a **Native C++** project. The **cpp** directory is generated in the **main** directory. You can use the NAPIs provided by the **ace_napi** repository for development.
You can import the native .so that contains the JS processing logic. For example, **import hello from 'libhello.so'** to use the **libhello.so** capability. Then, the JS object created using the NAPI can be passed to the **hello** object of the application to call the native capability.
@@ -19,7 +17,10 @@ You can import the native .so that contains the JS processing logic. For example
### .so Naming Rules
-Each module has a .so file. For example, if the module name is **hello**, name the .so file **libhello.so**. The **nm_modname** field in **napi_module** must be **hello**, which is the same as the module name. The sample code for importing the .so file is **import hello from 'libhello.so'**.
+The .so file names must comply with the following rules:
+
+* Each module has a .so file.
+* The **nm_modname** field in **napi_module** must be the same as the module name. For example, if the module name is **hello**, name the .so file **libhello.so**. The sample code for importing the .so file is **import hello from 'libhello.so'**.
### JS Objects and Threads
diff --git a/en/application-dev/quick-start/figures/hap-release.png b/en/application-dev/quick-start/figures/hap-release.png
index 527cefcf7e466e105f74065c3d8b59b18802d94b..9c7692a87e3975e01d125893fd276c247743c4e8 100644
Binary files a/en/application-dev/quick-start/figures/hap-release.png and b/en/application-dev/quick-start/figures/hap-release.png differ
diff --git a/en/application-dev/quick-start/module-configuration-file.md b/en/application-dev/quick-start/module-configuration-file.md
index 260d0cab1f9aa5b9365848e58bf070e1a70b4924..531d85960588b32a9f23a1a9e01a2202576219c1 100644
--- a/en/application-dev/quick-start/module-configuration-file.md
+++ b/en/application-dev/quick-start/module-configuration-file.md
@@ -22,19 +22,19 @@ This document gives an overview of the **module.json5** configuration file. To s
{
"name": "string",
"value": "string",
- "resource": "$profile:distrofilter_config"
+ "resource": "$profile:distributionFilter_config"
}
],
"abilities": [
{
"name": "EntryAbility",
- "srcEntrance": "./ets/entryability/EntryAbility.ts",
+ "srcEntry": "./ets/entryability/EntryAbility.ts",
"description": "$string:EntryAbility_desc",
"icon": "$media:icon",
"label": "$string:EntryAbility_label",
"startWindowIcon": "$media:icon",
"startWindowBackground": "$color:start_window_background",
- "visible": true,
+ "exported": true,
"skills": [
{
"entities": [
@@ -71,9 +71,9 @@ As shown above, the **module.json5** file contains several tags.
| Name| Description| Data Type| Initial Value Allowed|
| -------- | -------- | -------- | -------- |
-| name | Name of the module. The value is a string with a maximum of 31 bytes and must be unique in the entire application.| String| No|
+| name | Name of the module. The value is a string with a maximum of 31 bytes and must be unique in the entire application. Chinese characters are not allowed.| String| No|
| type | Type of the module. The value can be **entry** or **feature**.
- **entry**: main module of the application.
- **feature**: dynamic feature module of the application.| String| No|
-| srcEntrance | Code path corresponding to the module. The value is a string with a maximum of 127 bytes.| String| Yes (initial value: left empty)|
+| srcEntry | Code path corresponding to the module. The value is a string with a maximum of 127 bytes.| String| Yes (initial value: left empty)|
| description | Description of the module. The value is a string with a maximum of 255 bytes or a string resource index.| String| Yes (initial value: left empty)|
| process | Process name of the current module. The value is a string with a maximum of 31 bytes. If **process** is configured under **HAP**, all UIAbility, DataShareExtensionAbility, and ServiceExtensionAbility components of the application run in the specified process.
**NOTE**
This tag applies only to system applications and does not take effect for third-party applications.| String| Yes (initial value: value of **bundleName** under **app** in the **app.json5** file)|
| mainElement | Name of the entry UIAbility or ExtensionAbility of the module. The value is a string with a maximum of 255 bytes.| String| Yes (initial value: left empty)|
@@ -81,7 +81,6 @@ As shown above, the **module.json5** file contains several tags.
| deliveryWithInstall | Whether the HAP file of the module will be installed when the user installs the application.
- **true**: The HAP file will be installed when the user installs the application.
- **false**: The HAP file will not be installed when the user installs the application.| Boolean| No|
| installationFree | Whether the module supports the installation-free feature.
- **true**: The module supports the installation-free feature and meets installation-free constraints.
- **false**: The module does not support the installation-free feature.
**NOTE**
- If this tag is set to **true** for an entry-type module, it must also be set to **true** for feature-type modules of the same application.
- If this tag is set to **false** for an entry-type module, it can be set to **true** or **false** for feature-type modules of the same application based on service requirements.| Boolean| No|
| virtualMachine | Type of the target virtual machine (VM) where the module runs. It is used for cloud distribution, such as distribution by the application market and distribution center.
If the target VM type is ArkTS engine, the value is **ark**+*version number*.| String| Yes (initial value: automatically inserted when DevEco Studio builds the HAP file)|
-| uiSyntax (deprecated)| Syntax type of the component defined by the module syntax. This tag is deprecated since API version 9.
- **"hml"**: The component is developed using HML, CSS, or JS.
- **"ets"**: The component is developed using ArkTS.| String| Yes (initial value: **"hml"**)|
| [pages](#pages)| Profile that represents information about each page in the current module. The value can contain a maximum of 255 bytes.| String| No in the UIAbility scenario|
| [metadata](#metadata)| Custom metadata of the module. The setting is valid only for the current module, UIAbility, or ExtensionAbility.| Object array| Yes (initial value: left empty)|
| [abilities](#abilities) | UIAbility configuration of the module, which is valid only for the current UIAbility component.| Object| Yes (initial value: left empty)|
@@ -201,24 +200,25 @@ The **metadata** tag represents the custom metadata of the HAP file. The tag val
## abilities
-The **abilities** tag describes the UIAbility configuration of the component, which is valid only for the current UIAbility component. The tag value is an array.
+UIAbility configuration of the module, which is valid only for the current UIAbility component.
+
**Table 4** abilities
| Name| Description| Data Type| Initial Value Allowed|
| -------- | -------- | -------- | -------- |
-| name | Name of the UIAbility component, which must be unique in the entire application. The value is a string with a maximum of 127 bytes.| String| No|
-| srcEntrance | Code path of the entry UIAbility component. The value is a string with a maximum of 127 bytes.| String| No|
-| [launchType](../application-models/uiability-launch-type.md) | Launch type of the UIAbility component. The options are as follows:
- **standard**: A new UIAbility instance is created each time the UIAbility component is started.
- **singleton**: A new UIAbility instance is created only when the UIAbility component is started for the first time.
- **specified**: You can determine whether to create a new UIAbility instance when the application is running.| String| Yes (initial value: **"singleton"**)|
+| name | Name of the UIAbility component, which must be unique in the entire application. The value is a string with a maximum of 127 bytes. Chinese characters are not allowed.| String| No|
+| srcEntry | Code path of the entry UIAbility component. The value is a string with a maximum of 127 bytes.| String| No|
+| [launchType](../application-models/uiability-launch-type.md) | Launch type of the UIAbility component. The options are as follows:
- **multiton**: A new UIAbility instance is created each time the UIAbility component is started.
- **singleton**: A new UIAbility instance is created only when the UIAbility component is started for the first time.
- **specified**: You can determine whether to create a new UIAbility instance when the application is running.| String| Yes (initial value: **"singleton"**)|
| description | Description of the UIAbility component. The value is a string with a maximum of 255 bytes or a resource index to the description in multiple languages.| String| Yes (initial value: left empty)|
-| icon | Icon of the UIAbility component. The value is an icon resource index.
If **UIAbility** is set to **MainElement**, this attribute is mandatory. | String| Yes (initial value: left empty) |
+| icon | Icon of the UIAbility component. The value is an icon resource index.| String| Yes (initial value: left empty)
If **UIAbility** is set to **MainElement**, this attribute is mandatory.|
| label | Name of the UIAbility component displayed to users. The value is a string resource index.
If **UIAbility** is set to **MainElement** of the current module, this attribute is mandatory and its value must be unique in the application.| String| No|
| permissions | Permissions required for another application to access the UIAbility component.
The value is an array of permission names predefined by the system, generally in the reverse domain name notation. It contains a maximum of 255 bytes.| String array| Yes (initial value: left empty)|
| [metadata](#metadata)| Metadata information of the UIAbility component.| Object array| Yes (initial value: left empty)|
-| visible | Whether the UIAbility component can be called by other applications.
- **true**: The UIAbility component can be called by other applications.
- **false**: The UIAbility component cannot be called by other applications.| Boolean| Yes (initial value: **false**)|
+| exported | Whether the UIAbility component can be called by other applications.
- **true**: The UIAbility component can be called by other applications.
- **false**: The UIAbility component cannot be called by other applications.| Boolean| Yes (initial value: **false**)|
| continuable | Whether the UIAbility component can be [migrated](../application-models/hop-cross-device-migration.md).
- **true**: The UIAbility component can be migrated.
- **false**: The UIAbility component cannot be migrated.| Boolean| Yes (initial value: **false**)|
| [skills](#skills) | Feature set of [wants](../application-models/want-overview.md) that can be received by the current UIAbility or ExtensionAbility component.
Configuring rule:
- For HAPs of the entry type, you can configure multiple **skills** attributes with the entry capability for an OpenHarmony application. (A **skills** attribute with the entry capability is the one that has **ohos.want.action.home** and **entity.system.home** configured.)
- For HAPs of the feature type, you can configure **skills** attributes with the entry capability for an OpenHarmony application, but not for an OpenHarmony service.| Object array| Yes (initial value: left empty)|
-| backgroundModes | Continuous tasks of the UIAbility component.
Continuous tasks are classified into the following types:
- **dataTransfer**: service for downloading, backing up, sharing, or transferring data from the network or peer devices.
- **audioPlayback**: audio playback service.
- **audioRecording**: audio recording service.
- **location**: location and navigation services.
- **bluetoothInteraction**: Bluetooth scanning, connection, and transmission services (wearables).
- **multiDeviceConnection**: multi-device interconnection service.
- **wifiInteraction**: Wi-Fi scanning, connection, and transmission services (as used in the Multi-screen Collaboration and clone features)
- **voip**: voice/video call and VoIP services.
- **taskKeeping**: computing service.| String array| Yes (initial value: left empty)|
+| backgroundModes | Continuous tasks of the UIAbility component.
Continuous tasks are classified into the following types:
- **dataTransfer**: service for downloading, backing up, sharing, or transferring data from the network or peer devices.
- **audioPlayback**: audio playback service.
- **audioRecording**: audio recording service.
- **location**: location and navigation services.
- **bluetoothInteraction**: Bluetooth scanning, connection, and transmission services (wearables).
- **multiDeviceConnection**: multi-device interconnection service.
- **wifiInteraction**: Wi-Fi scanning, connection, and transmission services (as used in the Multi-screen Collaboration and clone features)
- **voip**: voice/video call and VoIP services.
- **taskKeeping**: computing service.| String array| Yes (initial value: left empty)|
| startWindowIcon | Index to the icon file of the UIAbility component startup page. Example: **$media:icon**.
The value is a string with a maximum of 255 bytes.| String| No|
| startWindowBackground | Index to the background color resource file of the UIAbility component startup page. Example: **$color:red**.
The value is a string with a maximum of 255 bytes.| String| No|
| removeMissionAfterTerminate | Whether to remove the relevant task from the task list after the UIAbility component is destroyed.
- **true**: Remove the relevant task from the task list after the UIAbility component is destroyed.
- **false**: Do not remove the relevant task from the task list after the UIAbility component is destroyed.| Boolean| Yes (initial value: **false**)|
@@ -240,14 +240,14 @@ Example of the **abilities** structure:
{
"abilities": [{
"name": "EntryAbility",
- "srcEntrance": "./ets/entryability/EntryAbility.ts",
- "launchType":"standard",
+ "srcEntry": "./ets/entryability/EntryAbility.ts",
+ "launchType":"singleton",
"description": "$string:description_main_ability",
"icon": "$media:icon",
"label": "Login",
"permissions": [],
"metadata": [],
- "visible": true,
+ "exported": true,
"continuable": true,
"skills": [{
"actions": ["ohos.want.action.home"],
@@ -335,7 +335,6 @@ Example of the **skills** structure:
}
```
-
## extensionAbilities
The **extensionAbilities** tag represents the configuration of extensionAbilities, which is valid only for the current extensionAbility.
@@ -345,16 +344,16 @@ The **extensionAbilities** tag represents the configuration of extensionAbilitie
| Name| Description| Data Type| Initial Value Allowed|
| -------- | -------- | -------- | -------- |
| name | Name of the ExtensionAbility component. The value is a string with a maximum of 127 bytes. The name must be unique in the entire application.| String| No|
-| srcEntrance | Code path corresponding to the ExtensionAbility component. The value is a string with a maximum of 127 bytes.| String| No|
+| srcEntry | Code path corresponding to the ExtensionAbility component. The value is a string with a maximum of 127 bytes.| String| No|
| description | Description of the ExtensionAbility component. The value is a string with a maximum of 255 bytes or a resource index to the description.| String| Yes (initial value: left empty)|
| icon | Icon of the ExtensionAbility component. The value is an icon resource index. If **ExtensionAbility** is set to **MainElement** of the current module, this attribute is mandatory and its value must be unique in the application.| String| Yes (initial value: left empty)|
| label | Name of the ExtensionAbility component displayed to users. The value is a string resource index.
**NOTE**
If **ExtensionAbility** is set to **MainElement** of the current module, this attribute is mandatory and its value must be unique in the application.| String| No|
| type | Type of the ExtensionAbility component. The options are as follows:
- **form**: ExtensionAbility of a widget.
- **workScheduler**: ExtensionAbility of a Work Scheduler task.
- **inputMethod**: ExtensionAbility of an input method.
- **service**: service component running in the background.
- **accessibility**: ExtensionAbility of an accessibility feature.
- **dataShare**: ExtensionAbility for data sharing.
- **fileShare**: ExtensionAbility for file sharing.
- **staticSubscriber**: ExtensionAbility for static broadcast.
- **wallpaper**: ExtensionAbility of the wallpaper.
- **backup**: ExtensionAbility for data backup.
- **window**: ExtensionAbility of a window. This type of ExtensionAbility creates a window during startup for which you can develop the GUI. The window is then combined with other application windows through **abilityComponent**.
- **thumbnail**: ExtensionAbility for obtaining file thumbnails. You can provide thumbnails for files of customized file types.
- **preview**: ExtensionAbility for preview. This type of ExtensionAbility can parse the file and display it in a window. You can combine the window with other application windows.
**NOTE**
The **service** and **dataShare** types apply only to system applications and do not take effect for third-party applications. | String| No|
| permissions | Permissions required for another application to access the ExtensionAbility component.
The value is generally in the reverse domain name notation and contains a maximum of 255 bytes. It is an array of permission names predefined by the system or customized. The name of a customized permission must be the same as the **name** value of a permission defined in the **defPermissions** attribute.| String array| Yes (initial value: left empty)|
| uri | Data URI provided by the ExtensionAbility component. The value is a string with a maximum of 255 bytes, in the reverse domain name notation.
**NOTE**
This attribute is mandatory when **type** of the ExtensionAbility component is set to **dataShare**.| String| Yes (initial value: left empty)|
-|skills | Feature set of [wants](../application-models/want-overview.md) that can be received by the ExtensionAbility component.
Configuration rule: In an entry package, you can configure multiple **skills** attributes with the entry capability. (A **skills** attribute with the entry capability is the one that has **ohos.want.action.home** and **entity.system.home** configured.) The **label** and **icon** in the first ExtensionAbility that has **skills** configured are used as the **label** and **icon** of the entire OpenHarmony service/application.
**NOTE**
The **skills** attribute with the entry capability can be configured for the feature-type package of an OpenHarmony application, but not for an OpenHarmony service. | Array| Yes (initial value: left empty)|
+|skills | Feature set of [wants](../application-models/want-overview.md) that can be received by the ExtensionAbility component.
Configuration rule: In an entry package, you can configure multiple **skills** attributes with the entry capability. (A **skills** attribute with the entry capability is the one that has **ohos.want.action.home** and **entity.system.home** configured.) The **label** and **icon** in the first ExtensionAbility that has **skills** configured are used as the **label** and **icon** of the entire OpenHarmony service/application.
**NOTE**
The **skills** attribute with the entry capability can be configured for the feature-type package of an OpenHarmony application,
but not for an OpenHarmony service.| Array| Yes (initial value: left empty)|
| [metadata](#metadata)| Metadata of the ExtensionAbility component.| Object| Yes (initial value: left empty)|
-| visible | Whether the ExtensionAbility component can be called by other applications.
- **true**: The ExtensionAbility component can be called by other applications.
- **false**: The UIAbility component cannot be called by other applications.| Boolean| Yes (initial value: **false**)|
+| exported | Whether the ExtensionAbility component can be called by other applications.
- **true**: The ExtensionAbility component can be called by other applications.
- **false**: The UIAbility component cannot be called by other applications.| Boolean| Yes (initial value: **false**)|
Example of the **extensionAbilities** structure:
@@ -364,7 +363,7 @@ Example of the **extensionAbilities** structure:
"extensionAbilities": [
{
"name": "FormName",
- "srcEntrance": "./form/MyForm.ts",
+ "srcEntry": "./form/MyForm.ts",
"icon": "$media:icon",
"label" : "$string:extension_name",
"description": "$string:form_description",
@@ -372,7 +371,7 @@ Example of the **extensionAbilities** structure:
"permissions": ["ohos.abilitydemo.permission.PROVIDER"],
"readPermission": "",
"writePermission": "",
- "visible": true,
+ "exported": true,
"uri":"scheme://authority/path/query",
"skills": [{
"actions": [],
@@ -395,12 +394,12 @@ Example of the **extensionAbilities** structure:
The **requestPermissions** tage represents a set of permissions that the application needs to request from the system for running correctly.
- **Table 8** requestPermissions
+**Table 8** requestPermissions
| Name| Description| Data Type| Value Range| Default Value|
| -------- | -------- | -------- | -------- | -------- |
| name | Permission name. This attribute is mandatory.| String| Custom| –|
-| reason | Reason for requesting the permission. This attribute is mandatory when the permission to request is **user_grant**.
**NOTE**
If the permission to request is **user_grant**, this attribute is required for the application to be released to the application market, and multi-language adaptation is required. | String| Resource reference of the string type in $string: \*\*\* format| A null value|
+| reason | Reason for requesting the permission. This attribute is mandatory when the permission to request is **user_grant**.
**NOTE**
If the permission to request is **user_grant**, this attribute is required for the application to be released to the application market, and multi-language adaptation is required.| String| Resource reference of the string type in $string: \*\*\* format| A null value|
| usedScene | Scene under which the permission is used. It consists of the **abilities** and **when** sub-attributes. Multiple abilities can be configured.
**NOTE**
This attribute is optional by default. If the permission to request is **user_grant**, the **abilities** sub-attribute is mandatory and **when** is optional.| **abilities**: string array
**when**: string| **abilities**: array of names of UIAbility or ExtensionAbility components
**when**: **inuse** or **always**| **abilities**: null
**when**: null|
Example of the **requestPermissions** structure:
@@ -473,7 +472,7 @@ The **shortcut** information is identified in **metadata**, where:
"abilities": [
{
"name": "EntryAbility",
- "srcEntrance": "./ets/entryability/EntryAbility.ts",
+ "srcEntry": "./ets/entryability/EntryAbility.ts",
// ...
"skills": [
{
@@ -498,49 +497,42 @@ The **shortcut** information is identified in **metadata**, where:
```
-## distroFilter
+## distributionFilter
-The **distroFilter** tag defines the rules for distributing HAP files based on different device specifications, so that precise matching can be performed when the application market distributes applications. Distribution rules cover five factors: API version, screen shape, screen size, screen resolution, and country code. During distribution, a unique HAP is determined based on the mapping between **deviceType** and these five factors. This tag must be configured in the **/resource/profile resource** directory.
+The **distributionFilter** tag defines the rules for distributing HAP files based on different device specifications, so that precise matching can be performed when the application market distributes applications. Distribution rules cover five factors: API version, screen shape, screen size, screen resolution, and country code. During distribution, a unique HAP is determined based on the mapping between **deviceType** and these five factors. This tag must be configured in the **/resource/profile resource** directory. Its sub-tags are optional.
- **Table 9** distroFilter
+ **Table 9** distributionFilter
| Name| Description| Data Type| Initial Value Allowed|
| -------- | -------- | -------- | -------- |
-| apiVersion | Supported API versions.| Object array| Yes (initial value: left empty)|
| screenShape | Supported screen shapes.| Object array| Yes (initial value: left empty)|
| screenWindow | Supported window resolutions for when the application is running. This attribute applies only to the lite wearables.| Object array| Yes (initial value: left empty)|
| screenDensity | Pixel density of the screen, in dots per inch (DPI). This attribute is optional. The value options are as follows:
- **sdpi**: small-scale DPI. This value is applicable to devices with a DPI range of (0, 120].
- **mdpi**: medium-scale DPI. This value is applicable to devices with a DPI range of (120, 160].
- **ldpi**: large-scale DPI. This value is applicable to devices with a DPI range of (160, 240].
- **xldpi**: extra-large-scale DPI. This value is applicable to devices with a DPI range of (240, 320].
- **xxldpi**: extra-extra-large-scale DPI. This value is applicable to devices with a DPI range of (320, 480].
- **xxxldpi**: extra-extra-extra-large-scale DPI. This value is applicable to devices with a DPI range of (480, 640].| Object array| Yes (initial value: left empty)|
| countryCode | Code of the country or region to which the application is to be distributed. The value is subject to the ISO-3166-1 standard. Enumerated definitions of multiple countries and regions are supported.| Object array| Yes (initial value: left empty)|
- **Table 10** apiVersion
-
-| Name| Description| Data Type| Initial Value Allowed|
-| -------- | -------- | -------- | -------- |
-| policy | Rule for the sub-attribute value. Set this attribute to **exclude** or **include**.
- **exclude**: Exclude the matches of the sub-attribute value.
- **include**: Include the matches of the sub-attribute value.| String| No|
-| value | API versions, for example, 4, 5, or 6. Example: If an application comes with two versions developed using API version 5 and API version 6 for the same device model, two installation packages of the entry type can be released for the application.| Array| No|
- **Table 11** screenShape
+ **Table 10** screenShape
| Name| Description| Data Type| Initial Value Allowed|
| -------- | -------- | -------- | -------- |
| policy | Rule for the sub-attribute value. Set this attribute to **exclude** or **include**.
- **exclude**: Exclude the matches of the sub-attribute value.
- **include**: Include the matches of the sub-attribute value.| String| No|
| value | Screen shapes. The value can be **circle**, **rect**, or both. Example: Different HAP files can be provided for a smart watch with a circular face and that with a rectangular face.| String array| No|
- **Table 12** screenWindow
+ **Table 11** screenWindow
| Name| Description| Data Type| Initial Value Allowed|
| -------- | -------- | -------- | -------- |
| policy | Rule for the sub-attribute value. Set this attribute to **exclude** or **include**.
- **exclude**: Exclude the matches of the sub-attribute value.
- **include**: Include the matches of the sub-attribute value.| String| No|
| value | Screen width and height, in pixels. The value an array of supported width and height pairs, each in the "width * height" format, for example, **"454 * 454"**.| String array| No|
- **Table 13** screenDensity
+ **Table 12** screenDensity
| Name| Description| Data Type| Initial Value Allowed|
| -------- | -------- | -------- | -------- |
| policy | Rule for the sub-attribute value. Set this attribute to **exclude** or **include**.
- **exclude**: Exclude the matches of the sub-attribute value.
- **include**: Include the matches of the sub-attribute value.| String| No|
| value | Pixel density of the screen, in DPI.| String array| No|
- **Table 14** countryCode
+ **Table 13** countryCode
| Name| Description| Data Type| Initial Value Allowed|
| -------- | -------- | -------- | -------- |
@@ -552,14 +544,7 @@ Configure the **distro_filter_config.json** file (this file name is customizable
```json
{
- "distroFilter": {
- "apiVersion": {
- "policy": "include",
- "value": [
- 3,
- 4
- ]
- },
+ "distributionFilter": {
"screenShape": {
"policy": "include",
"value": [
@@ -614,7 +599,7 @@ Configure **metadata** in the **module** tag in the **module.json5** file.
The **testRunner** tag represents the supported test runner.
- **Table 15** testRunner
+ **Table 14** testRunner
| Name| Description| Data Type| Initial Value Allowed|
| -------- | -------- | -------- | -------- |
diff --git a/en/application-dev/quick-start/multi-hap-build-view.md b/en/application-dev/quick-start/multi-hap-build-view.md
index 3266828fdbda2b969668410a98ce4b64cce54411..a2c2a530ce1e4edbb4681ff1400398f997c23daa 100644
--- a/en/application-dev/quick-start/multi-hap-build-view.md
+++ b/en/application-dev/quick-start/multi-hap-build-view.md
@@ -3,25 +3,27 @@
DevEco Studio allows you to develop and build multiple HAP files in one application project, as shown below.
+ **Figure 1** Multi-HAP build view
- **Figure 1** Multi-HAP build view

1. Development view in DevEco Studio
- - AppScope folder
- - [app.json5](app-configuration-file.md): application-wide configuration, such as the application bundle name, version number, application icon, application name, and dependent SDK version number.
+ - **AppScope** folder
+
+ - **[app.json5](app-configuration-file.md)**: stores application-wide configuration, such as the application bundle name, version number, application icon, application name, and dependent SDK version number.
- **resources** folder: stores application icon resources and application name string resources.
-
- **NOTE**
- - The folder is automatically generated by DevEco Studio and its name cannot be changed.
- - The file names in the **AppScope** folder cannot be the same as those in the entry- or feature-type module directories. Otherwise, DevEco Studio reports an error.
- - Entry- or feature-type module directories (the names are customizable)
- - You implement service logic of your application in these module directories. In this example, the module folders are **entry.hap** and **feature.hap**.
- - **resources** directory: stores the resources used by the module.
+
+ **NOTE**
+
+ - The folder is automatically generated by DevEco Studio and its name cannot be changed.
+ - The file names in the **AppScope** folder cannot be the same as those in the entry- or feature-type module folder. Otherwise, an error will be reported.
+ - **entry** or **feature** folder (whose name is customizable)
+ - A module folder created by the developer by following the creation wizard of DevEco Studio. It stores the service logic implementation of the application. Multiple module folders can be created. In the preceding figure, **entry** and **feature** are two created module folders.
+ - **resources** folder: stores the resources used by the module.
- **ets** folder: stores the service logic.
- - [module.json5](module-configuration-file.md): module configuration, such as the module name, entry code path of the module, and component information.
-
+ - **[module.json5](module-configuration-file.md)**: stores module configuration, such as the module name, entry code path of the module, and component information.
+
2. View after build and packaging
- After a module is built, a HAP file for deployment is generated. Each module corresponds to a HAP file.
- The **module.json** file in the HAP file is composed of the **app.json5** and **module.json5** files in the development view.
diff --git a/en/application-dev/quick-start/multi-hap-release-deployment.md b/en/application-dev/quick-start/multi-hap-release-deployment.md
index ec688879ebb61ceb595feb974f2276d700479ef5..b4587f2c2125c526b86bfa0646af4b1fcbc9e9d3 100644
--- a/en/application-dev/quick-start/multi-hap-release-deployment.md
+++ b/en/application-dev/quick-start/multi-hap-release-deployment.md
@@ -6,32 +6,40 @@ Below is the process of developing, debugging, releasing, and deploying multiple

## Development
-You can use [DevEco Studio](https://developer.harmonyos.com/en/develop/deveco-studio) to create multiple modules based on service requirements and develop services in independent modules.
+You can use [DevEco Studio](https://developer.harmonyos.com/en/develop/deveco-studio) to create multiple modules as needed and develop services in respective modules.
## Debugging
-You can use DevEco Studio to build code into one or more HAP files. Then, you can debug the HAP files.
+After building code into one or more HAP files and installing or updating these HAP files, you can debug them by using the methods:
* Using DevEco Studio for debugging
Follow the instructions in [Debugging Configuration](https://developer.harmonyos.com/en/docs/documentation/doc-guides/ohos-debugging-and-running-0000001263040487#section10491183521520).
-* Using [hdc_std](../../device-dev/subsystems/subsys-toolchain-hdc-guide.md) for debugging
+* Using [hdc](../../device-dev/subsystems/subsys-toolchain-hdc-guide.md) (which can be obtained in the **toolchains** directory of the OpenHarmony SDK) for debugging
+
+ Before debugging HAP files, install or update them using either of the methods:
+
+ 1. Use hdc to install and update the HAP files.
+
+ When specifying the HAP files, use the paths of the files on the operating system, for example, Windows.
- You can obtain the hdc_std tool from the **toolchains** directory of the SDK. When using this tool to install an HAP file, the HAP file path is the one on the operating platform. In this example, the Windows operating platform is used. The command reference is as follows:
```
// Installation and update: Multiple file paths can be specified.
- hdc_std install C:\entry.hap C:\feature.hap
+ hdc install C:\entry.hap C:\feature.hap
// The execution result is as follows:
install bundle successfully.
// Uninstall
- hdc_std uninstall com.example.myapplication
+ hdc uninstall com.example.myapplication
// The execution result is as follows:
uninstall bundle successfully.
```
+
+ 2. Run the hdc shell command, and then use the Bundle Manager (bm) tool to install and update the HAP files.
-* Using [Bundle Manager (bm)](../../application-dev/tools/bm-tool.md) for debugging
-
- When using bm to install or update an HAP file, the HAP file path is the one on the real device. The command reference is as follows:
+ When specifying the HAP files, use the paths of the files on the real device. The sample code is as follows:
+
```
+ // Run the hdc shell command before using the bm tool.
+ hdc shell
// Installation and update: Multiple file paths can be specified.
bm install -p /data/app/entry.hap /data/app/feature.hap
// The execution result is as follows:
@@ -41,6 +49,8 @@ You can use DevEco Studio to build code into one or more HAP files. Then, you ca
// The execution result is as follows:
uninstall bundle successfully.
```
+ After the HAP files are installed or updated, you can debug them by following the instructions in [Ability Assistant](https://docs.openharmony.cn/pages/v3.2Beta/en/application-dev/tools/aa-tool.md/).
+
## Release
When your application package meets the release requirements, you can package and build it into an App Pack and release it to the application market on the cloud. The application market verifies the signature of the App Pack. If the signature verification is successful, the application market obtains the HAP files from the App Pack, signs them, and distributes the signed HAP files.
diff --git a/en/application-dev/quick-start/multi-hap-rules.md b/en/application-dev/quick-start/multi-hap-rules.md
index 34b7824cb62b7e1ca73232faa9f58685df2077ac..7c2675325cfecd0bfd5a6e5595c947daa8e8085d 100644
--- a/en/application-dev/quick-start/multi-hap-rules.md
+++ b/en/application-dev/quick-start/multi-hap-rules.md
@@ -1,14 +1,14 @@
# Multi-HAP Usage Rules
-- The App Pack cannot be directly installed on the device. It is only a unit that is released to AppGallery.
+- The App Pack cannot be directly installed on a device. It is only used to be released to the application market.
- All HAP files in the App Pack must share the same **bundleName** value in the configuration files.
- All HAP files in the App Pack must share the same **versionCode** value in the configuration files.
-- In an application, each type of device supports only one HAP of the entry type. Each application can contain zero, one, or more HAP files of the feature type.
+- In an App Pack, each type of device supports only one HAP file of the entry type and zero, one, or more HAP files of the feature type.
-- Each HAP file in the App Pack must have **moduleName** configured. The **moduleName** value corresponding to all HAP files of the same device type must be unique.
+- Each HAP file in the App Pack must have **moduleName** configured. Among HAP files of the same device type, the **moduleName** value must be unique.
-- The signing certificates of all HAP files in the same application must be the same. Applications are released to the application market in the form of App Pack after being signed. Before distribution, the application market splits an App Pack into HAP files and resigns them to ensure the consistency of all HAP file signing certificates. Before installing HAP files on a device through the CLI or DevEco Studio for debugging, you must ensure that their signing certificates are the same. Otherwise, the installation will fail.
+- The signing certificates of all HAP files in the same application must be the same. Applications are released to the application market in the form of App Pack after being signed. Before distribution, the application market splits an App Pack into HAP files and resigns them to ensure the consistency of HAP file signing certificates. Before installing HAP files on a device through the CLI or DevEco Studio for debugging, ensure that their signing certificates are the same. Otherwise, the installation will fail.
diff --git a/en/application-dev/quick-start/resource-categories-and-access.md b/en/application-dev/quick-start/resource-categories-and-access.md
index 56e8209a5c19e353a21b80ff8b34dd51885db310..aa5e53ae90c1794125f5b6ae8a8f7a5115128743 100644
--- a/en/application-dev/quick-start/resource-categories-and-access.md
+++ b/en/application-dev/quick-start/resource-categories-and-access.md
@@ -35,7 +35,7 @@ resources
| Category | base Subdirectory | Qualifiers Subdirectory | rawfile Subdirectory |
| ---- | ---------------------------------------- | ---------------------------------------- | ---------------------------------------- |
-| Structure| The **base** subdirectory is a default directory. If no qualifiers subdirectories in the **resources** directory of the application match the device status, the resource file in the **base** subdirectory will be automatically referenced.
Resource group subdirectories are located at the second level of subdirectories to store basic elements such as strings, colors, and boolean values, as well as resource files such as media, animations, and layouts. For details, see [Resource Group Subdirectories](#resource-group-subdirectories).| You need to create qualifiers subdirectories on your own. Each directory name consists of one or more qualifiers that represent the application scenarios or device characteristics. For details, see [Qualifiers Subdirectories](#qualifiers-subdirectories).
Resource group subdirectories are located at the second level of subdirectories to store basic elements such as strings, colors, and boolean values, as well as resource files such as media, animations, and layouts. For details, see [Resource Group Subdirectories](#resource-group-subdirectories). | You can create multiple levels of subdirectories with custom directory names. They can be used to store various resource files.
However, resource files in the **rawfile** subdirectory will not be matched based on the device status.|
+| Structure| The **base** subdirectory is a default directory. If no qualifiers subdirectories in the **resources** directory of the application match the device status, the resource file in the **base** subdirectory will be automatically referenced.
Resource group subdirectories are located at the second level of subdirectories to store basic elements such as strings, colors, and boolean values, as well as resource files such as media, animations, and layouts. For details, see [Resource Group Subdirectories](#resource-group-subdirectories).| You need to create qualifiers subdirectories on your own. Each directory name consists of one or more qualifiers that represent the application scenarios or device characteristics. For details, see [Qualifiers Subdirectories](#qualifiers-subdirectories).
Resource group subdirectories are located at the second level of subdirectories to store basic elements such as strings, colors, and boolean values, as well as resource files such as media, animations, and layouts. For details, see [Resource Group Subdirectories](#resource-group-subdirectories).| You can create multiple levels of subdirectories with custom directory names. They can be used to store various resource files.
However, resource files in the **rawfile** subdirectory will not be matched based on the device status.|
| Compilation| Resource files in the subdirectory are compiled into binary files, and each resource file is assigned an ID. | Resource files in the subdirectory are compiled into binary files, and each resource file is assigned an ID. | Resource files in the subdirectory are directly packed into the application without being compiled, and no IDs will be assigned to the resource files. |
| Reference| Resource files in the subdirectory are referenced based on the resource type and resource name. | Resource files in the subdirectory are referenced based on the resource type and resource name. | Resource files in the subdirectory are referenced based on the file path and file name. |
@@ -81,9 +81,9 @@ You can create resource group subdirectories (including element, media, and prof
| Resource Group Subdirectory | Description | Resource File |
| ------- | ---------------------------------------- | ---------------------------------------- |
-| element | Indicates element resources. Each type of data is represented by a JSON file. The options are as follows:
- **boolean**: boolean data
- **color**: color data
- **float**: floating-point data
- **intarray**: array of integers
- **integer**: integer data
- **pattern**: pattern data
- **plural**: plural form data
- **strarray**: array of strings
- **string**: string data| It is recommended that files in the **element** subdirectory be named the same as the following files, each of which can contain only data of the same type:
- boolean.json
- color.json
- float.json
- intarray.json
- integer.json
- pattern.json
- plural.json
- strarray.json
- string.json |
-| media | Indicates media resources, including non-text files such as images, audios, and videos. | The file name can be customized, for example, **icon.png**. |
-| profile | Indicates a user-defined configuration file. You can obtain the file content by using the [getProfileByAbility](../reference/apis/js-apis-bundleManager.md#bundlemanagergetprofilebyability) API. | The file name can be customized, for example, **test_profile.json**. |
+| element | Indicates element resources. Each type of data is represented by a JSON file. (Only files are supported in this directory.) The options are as follows:
- **boolean**: boolean data
- **color**: color data
- **float**: floating-point data
- **intarray**: array of integers
- **integer**: integer data
- **pattern**: pattern data
- **plural**: plural form data
- **strarray**: array of strings
- **string**: string data| It is recommended that files in the **element** subdirectory be named the same as the following files, each of which can contain only data of the same type:
- boolean.json
- color.json
- float.json
- intarray.json
- integer.json
- pattern.json
- plural.json
- strarray.json
- string.json |
+| media | Indicates media resources, including non-text files such as images, audios, and videos. (Only files are supported in this directory.) | The file name can be customized, for example, **icon.png**. |
+| profile | Indicates a custom configuration file. You can obtain the file content by using the [getProfileByAbility](../reference/apis/js-apis-bundleManager.md#bundlemanagergetprofilebyability) API. (Only files are supported in this directory.) | The file name can be customized, for example, **test_profile.json**. |
| rawfile | Indicates other types of files, which are stored in their raw formats after the application is built as an HAP file. They will not be integrated into the **resources.index** file.| The file name can be customized. |
**Media Resource Types**
@@ -229,7 +229,7 @@ When referencing resources in the **rawfile** subdirectory, use the **"$rawfile(
>
> Resource descriptors accept only strings, such as **'app.type.name'**, and cannot be combined.
>
-> The return value of **$r** is a **Resource** object. You can obtain the corresponding string by using the [getStringValue](../reference/apis/js-apis-resource-manager.md) API.
+> The return value of **$r** is a **Resource** object. You can obtain the corresponding string by using the [getStringValue](../reference/apis/js-apis-resource-manager.md#getstringvalue9) API.
In the **.ets** file, you can use the resources defined in the **resources** directory. The following is a resource usage example based on the resource file examples in [Resource Group Sub-directories](#resource-group-subdirectories):
@@ -252,7 +252,6 @@ Text($r('app.string.message_arrive', "five'o clock"))
Text($r('app.plural.eat_apple', 5, 5))
.fontColor($r('app.color.color_world'))
.fontSize($r('app.float.font_world'))
-}
Image($r('app.media.my_background_image')) // Reference media resources.
diff --git a/en/application-dev/reference/apis/Readme-EN.md b/en/application-dev/reference/apis/Readme-EN.md
index 906daa5313d94afe26b059802e891295326a5783..497dcf4054e62ec63f27d4ca2067b1cb6b82b1d6 100644
--- a/en/application-dev/reference/apis/Readme-EN.md
+++ b/en/application-dev/reference/apis/Readme-EN.md
@@ -19,13 +19,9 @@
- [@ohos.application.DataShareExtensionAbility (DataShare Extension Ability)](js-apis-application-dataShareExtensionAbility.md)
- [@ohos.application.StaticSubscriberExtensionAbility (StaticSubscriberExtensionAbility)](js-apis-application-staticSubscriberExtensionAbility.md)
- Stage Model (To Be Deprecated Soon)
- - [@ohos.application.Ability (Ability)](js-apis-application-ability.md)
- [@ohos.application.AbilityConstant (AbilityConstant)](js-apis-application-abilityConstant.md)
- - [@ohos.application.AbilityLifecycleCallback (AbilityLifecycleCallback)](js-apis-application-abilityLifecycleCallback.md)
- [@ohos.application.AbilityStage (AbilityStage)](js-apis-application-abilityStage.md)
- - [@ohos.application.context (Context)](js-apis-application-context.md)
- [@ohos.application.EnvironmentCallback (EnvironmentCallback)](js-apis-application-environmentCallback.md)
- - [@ohos.application.ExtensionAbility (ExtensionAbility)](js-apis-application-extensionAbility.md)
- [@ohos.application.FormExtension (FormExtension)](js-apis-application-formExtension.md)
- [@ohos.application.ServiceExtensionAbility (ServiceExtensionAbility)](js-apis-application-serviceExtensionAbility.md)
- [@ohos.application.StartOptions (StartOptions)](js-apis-application-startOptions.md)
@@ -59,7 +55,6 @@
- [@ohos.application.appManager (appManager)](js-apis-application-appManager.md)
- [@ohos.application.Configuration (Configuration)](js-apis-application-configuration.md)
- [@ohos.application.ConfigurationConstant (ConfigurationConstant)](js-apis-application-configurationConstant.md)
- - [@ohos.application.errorManager (ErrorManager)](js-apis-application-errorManager.md)
- [@ohos.application.formBindingData (formBindingData)](js-apis-application-formBindingData.md)
- [@ohos.application.formError (FormError)](js-apis-application-formError.md)
- [@ohos.application.formHost (FormHost)](js-apis-application-formHost.md)
@@ -82,7 +77,6 @@
- [context](js-apis-inner-app-context.md)
- [processInfo](js-apis-inner-app-processInfo.md)
- application
- - [AbilityContext](js-apis-ability-context.md)
- [abilityDelegator](js-apis-inner-application-abilityDelegator.md)
- [abilityDelegatorArgs](js-apis-inner-application-abilityDelegatorArgs.md)
- [abilityMonitor](js-apis-inner-application-abilityMonitor.md)
@@ -146,6 +140,7 @@
- [abilityInfo](js-apis-bundleManager-abilityInfo.md)
- [applicationInfo](js-apis-bundleManager-applicationInfo.md)
- [bundleInfo](js-apis-bundleManager-bundleInfo.md)
+ - [BundlePackInfo](js-apis-bundleManager-BundlePackInfo.md)
- [dispatchInfo](js-apis-bundleManager-dispatchInfo.md)
- [elementName](js-apis-bundleManager-elementName.md)
- [extensionAbilityInfo](js-apis-bundleManager-extensionAbilityInfo.md)
@@ -222,10 +217,11 @@
- [@ohos.file.hash (File Hash Processing)](js-apis-file-hash.md)
- [@ohos.file.securityLabel (Data Label)](js-apis-file-securityLabel.md)
- [@ohos.file.statvfs (File System Space Statistics)](js-apis-file-statvfs.md)
+ - [@ohos.file.storageStatistics (Application Storage Statistics)](js-apis-file-storage-statistics.md)
+ - [@ohos.file.volumeManager (Volume Management)](js-apis-file-volumemanager.md)
- [@ohos.filemanagement.userFileManager (User Data Management)](js-apis-userFileManager.md)
- [@ohos.multimedia.medialibrary (Media Library Management)](js-apis-medialibrary.md)
- - [@ohos.storageStatistics (Application Storage Statistics)](js-apis-storage-statistics.md)
- - [@ohos.volumeManager (Volume Management)](js-apis-volumemanager.md)
+
- Telephony Service
- [@ohos.contact (Contacts)](js-apis-contact.md)
- [@ohos.telephony.call (Call)](js-apis-call.md)
@@ -277,7 +273,7 @@
- [@ohos.InputMethodSubtype (Input Method Subtype)](js-apis-inputmethod-subtype.md)
- [@ohos.pasteboard (Pasteboard)](js-apis-pasteboard.md)
- [@ohos.screenLock (Screenlock)](js-apis-screen-lock.md)
- - [@ohos.systemTime (System Time and Time Zone)](js-apis-system-time.md)
+ - [@ohos.systemDateTime (System Time and Time Zone)](js-apis-system-date-time.md)
- [@ohos.systemTimer (System Timer)](js-apis-system-timer.md)
- [@ohos.wallpaper (Wallpaper)](js-apis-wallpaper.md)
- [@ohos.web.webview (Webview)](js-apis-webview.md)
@@ -369,6 +365,7 @@
- [@ohos.reminderAgent (Reminder Agent)](js-apis-reminderAgent.md)
- [@ohos.statfs (statfs)](js-apis-statfs.md)
- [@ohos.systemParameter (System Parameter)](js-apis-system-parameter.md)
+ - [@ohos.systemTime (System Time and Time Zone)](js-apis-system-time.md)
- [@ohos.usb (USB Management)](js-apis-usb-deprecated.md)
- [@ohos.usbV9 (USB Management)](js-apis-usb.md)
- [@system.app (Application Context)](js-apis-system-app.md)
diff --git a/en/application-dev/reference/apis/figures/Colorsucker.png b/en/application-dev/reference/apis/figures/Colorsucker.png
new file mode 100644
index 0000000000000000000000000000000000000000..40e19e94e129682fdeb461cceef0f0a57c64d66d
Binary files /dev/null and b/en/application-dev/reference/apis/figures/Colorsucker.png differ
diff --git a/en/application-dev/reference/apis/figures/Copy.png b/en/application-dev/reference/apis/figures/Copy.png
new file mode 100644
index 0000000000000000000000000000000000000000..212517131bf176661ae85c7513def022dbb50559
Binary files /dev/null and b/en/application-dev/reference/apis/figures/Copy.png differ
diff --git a/en/application-dev/reference/apis/figures/Cross.png b/en/application-dev/reference/apis/figures/Cross.png
new file mode 100644
index 0000000000000000000000000000000000000000..58625855d1cd96ea8a29ab9c3c201d90ac717e83
Binary files /dev/null and b/en/application-dev/reference/apis/figures/Cross.png differ
diff --git a/en/application-dev/reference/apis/figures/Default.png b/en/application-dev/reference/apis/figures/Default.png
new file mode 100644
index 0000000000000000000000000000000000000000..6308171fe9d612050376f6a5dfdc870e51bc92db
Binary files /dev/null and b/en/application-dev/reference/apis/figures/Default.png differ
diff --git a/en/application-dev/reference/apis/figures/East.png b/en/application-dev/reference/apis/figures/East.png
new file mode 100644
index 0000000000000000000000000000000000000000..4942bc948a17e78c68538ccc3ae886bc0a548737
Binary files /dev/null and b/en/application-dev/reference/apis/figures/East.png differ
diff --git a/en/application-dev/reference/apis/figures/Forbid.png b/en/application-dev/reference/apis/figures/Forbid.png
new file mode 100644
index 0000000000000000000000000000000000000000..c5c43d4b4b8aaf6d53931586e519a583d064fec7
Binary files /dev/null and b/en/application-dev/reference/apis/figures/Forbid.png differ
diff --git a/en/application-dev/reference/apis/figures/Hand_Grabbing.png b/en/application-dev/reference/apis/figures/Hand_Grabbing.png
new file mode 100644
index 0000000000000000000000000000000000000000..09ab3121d15e27a975fbaa228aadb2399e4492b9
Binary files /dev/null and b/en/application-dev/reference/apis/figures/Hand_Grabbing.png differ
diff --git a/en/application-dev/reference/apis/figures/Hand_Open.png b/en/application-dev/reference/apis/figures/Hand_Open.png
new file mode 100644
index 0000000000000000000000000000000000000000..e1cb7a972ec2d372f0d75cbe80159c4a66e74e10
Binary files /dev/null and b/en/application-dev/reference/apis/figures/Hand_Open.png differ
diff --git a/en/application-dev/reference/apis/figures/Hand_Pointing.png b/en/application-dev/reference/apis/figures/Hand_Pointing.png
new file mode 100644
index 0000000000000000000000000000000000000000..f0daa0dad6154a1846fb9fe4b7f441b3ab6f8b5b
Binary files /dev/null and b/en/application-dev/reference/apis/figures/Hand_Pointing.png differ
diff --git a/en/application-dev/reference/apis/figures/Help.png b/en/application-dev/reference/apis/figures/Help.png
new file mode 100644
index 0000000000000000000000000000000000000000..ffea2f1c072f1682ca8e837ddb947352a553917e
Binary files /dev/null and b/en/application-dev/reference/apis/figures/Help.png differ
diff --git a/en/application-dev/reference/apis/figures/MID_Btn_East.png b/en/application-dev/reference/apis/figures/MID_Btn_East.png
new file mode 100644
index 0000000000000000000000000000000000000000..921cd4ceea8d97ffb6d4c45008d6428cda998cce
Binary files /dev/null and b/en/application-dev/reference/apis/figures/MID_Btn_East.png differ
diff --git a/en/application-dev/reference/apis/figures/MID_Btn_North.png b/en/application-dev/reference/apis/figures/MID_Btn_North.png
new file mode 100644
index 0000000000000000000000000000000000000000..5769575ddb435f5e8f5f8993d9edc13749376293
Binary files /dev/null and b/en/application-dev/reference/apis/figures/MID_Btn_North.png differ
diff --git a/en/application-dev/reference/apis/figures/MID_Btn_North_East.png b/en/application-dev/reference/apis/figures/MID_Btn_North_East.png
new file mode 100644
index 0000000000000000000000000000000000000000..3daf141241dec309c98ae10266bb153af163f3d9
Binary files /dev/null and b/en/application-dev/reference/apis/figures/MID_Btn_North_East.png differ
diff --git a/en/application-dev/reference/apis/figures/MID_Btn_North_South.png b/en/application-dev/reference/apis/figures/MID_Btn_North_South.png
new file mode 100644
index 0000000000000000000000000000000000000000..1f56c4cd8f1498293f5fc4a5ab2c321159fb07dd
Binary files /dev/null and b/en/application-dev/reference/apis/figures/MID_Btn_North_South.png differ
diff --git a/en/application-dev/reference/apis/figures/MID_Btn_North_South_West_East.png b/en/application-dev/reference/apis/figures/MID_Btn_North_South_West_East.png
new file mode 100644
index 0000000000000000000000000000000000000000..b45dbde27e59121bdfc4e1752759176fb835027c
Binary files /dev/null and b/en/application-dev/reference/apis/figures/MID_Btn_North_South_West_East.png differ
diff --git a/en/application-dev/reference/apis/figures/MID_Btn_North_West.png b/en/application-dev/reference/apis/figures/MID_Btn_North_West.png
new file mode 100644
index 0000000000000000000000000000000000000000..bde82d08f7a098106b4f4c31d55a84a989e25a8d
Binary files /dev/null and b/en/application-dev/reference/apis/figures/MID_Btn_North_West.png differ
diff --git a/en/application-dev/reference/apis/figures/MID_Btn_South.png b/en/application-dev/reference/apis/figures/MID_Btn_South.png
new file mode 100644
index 0000000000000000000000000000000000000000..e7d5afb6f8f8b1b2939b9e18bdb8b8b3d9729f4d
Binary files /dev/null and b/en/application-dev/reference/apis/figures/MID_Btn_South.png differ
diff --git a/en/application-dev/reference/apis/figures/MID_Btn_South_East.png b/en/application-dev/reference/apis/figures/MID_Btn_South_East.png
new file mode 100644
index 0000000000000000000000000000000000000000..44284a6e04a19ca8453b46ea81db099ad84cfaa2
Binary files /dev/null and b/en/application-dev/reference/apis/figures/MID_Btn_South_East.png differ
diff --git a/en/application-dev/reference/apis/figures/MID_Btn_South_West.png b/en/application-dev/reference/apis/figures/MID_Btn_South_West.png
new file mode 100644
index 0000000000000000000000000000000000000000..c8632f09160c51ca573d58d3ffb1370058b880ce
Binary files /dev/null and b/en/application-dev/reference/apis/figures/MID_Btn_South_West.png differ
diff --git a/en/application-dev/reference/apis/figures/MID_Btn_West.png b/en/application-dev/reference/apis/figures/MID_Btn_West.png
new file mode 100644
index 0000000000000000000000000000000000000000..7460bc18d63e000689755b39b8ead3c3609ee4f5
Binary files /dev/null and b/en/application-dev/reference/apis/figures/MID_Btn_West.png differ
diff --git a/en/application-dev/reference/apis/figures/Move.png b/en/application-dev/reference/apis/figures/Move.png
new file mode 100644
index 0000000000000000000000000000000000000000..00f64e54dca0d0731b595b4ddc9e0f7294c40c72
Binary files /dev/null and b/en/application-dev/reference/apis/figures/Move.png differ
diff --git a/en/application-dev/reference/apis/figures/North.png b/en/application-dev/reference/apis/figures/North.png
new file mode 100644
index 0000000000000000000000000000000000000000..b022ac2e92d4cfb07efde7f3bf4b7ada8454e594
Binary files /dev/null and b/en/application-dev/reference/apis/figures/North.png differ
diff --git a/en/application-dev/reference/apis/figures/North_East.png b/en/application-dev/reference/apis/figures/North_East.png
new file mode 100644
index 0000000000000000000000000000000000000000..f6134237f38cd681b319c95bf1b77017bc1524b4
Binary files /dev/null and b/en/application-dev/reference/apis/figures/North_East.png differ
diff --git a/en/application-dev/reference/apis/figures/North_East_South_West.png b/en/application-dev/reference/apis/figures/North_East_South_West.png
new file mode 100644
index 0000000000000000000000000000000000000000..908886aeb3f8df976bb67b2261e8e52e7222e622
Binary files /dev/null and b/en/application-dev/reference/apis/figures/North_East_South_West.png differ
diff --git a/en/application-dev/reference/apis/figures/North_South.png b/en/application-dev/reference/apis/figures/North_South.png
new file mode 100644
index 0000000000000000000000000000000000000000..b15678a6b178ca0d9b13f7c7f58d025ab7a1ce12
Binary files /dev/null and b/en/application-dev/reference/apis/figures/North_South.png differ
diff --git a/en/application-dev/reference/apis/figures/North_West.png b/en/application-dev/reference/apis/figures/North_West.png
new file mode 100644
index 0000000000000000000000000000000000000000..cfbe4c8910575c12afde4b5904d79b5beda0c162
Binary files /dev/null and b/en/application-dev/reference/apis/figures/North_West.png differ
diff --git a/en/application-dev/reference/apis/figures/North_West_South_East.png b/en/application-dev/reference/apis/figures/North_West_South_East.png
new file mode 100644
index 0000000000000000000000000000000000000000..09fa728fbb45082a0524c284b8906b91d7b3a6f7
Binary files /dev/null and b/en/application-dev/reference/apis/figures/North_West_South_East.png differ
diff --git a/en/application-dev/reference/apis/figures/Resize_Left_Right.png b/en/application-dev/reference/apis/figures/Resize_Left_Right.png
new file mode 100644
index 0000000000000000000000000000000000000000..83e7671e3ffea65260bdb36d8b392fa78d55cd4e
Binary files /dev/null and b/en/application-dev/reference/apis/figures/Resize_Left_Right.png differ
diff --git a/en/application-dev/reference/apis/figures/Resize_Up_Down.png b/en/application-dev/reference/apis/figures/Resize_Up_Down.png
new file mode 100644
index 0000000000000000000000000000000000000000..db8bccf89b6e5260db3875a22b5200fabd30c23c
Binary files /dev/null and b/en/application-dev/reference/apis/figures/Resize_Up_Down.png differ
diff --git a/en/application-dev/reference/apis/figures/Screenshot_Cross.png b/en/application-dev/reference/apis/figures/Screenshot_Cross.png
new file mode 100644
index 0000000000000000000000000000000000000000..27460c082507e71082d11cd8a20eee2fc24da28d
Binary files /dev/null and b/en/application-dev/reference/apis/figures/Screenshot_Cross.png differ
diff --git a/en/application-dev/reference/apis/figures/Screenshot_Cursor.png b/en/application-dev/reference/apis/figures/Screenshot_Cursor.png
new file mode 100644
index 0000000000000000000000000000000000000000..71abea4ca351988a92b8a5b2b2228321df31aecc
Binary files /dev/null and b/en/application-dev/reference/apis/figures/Screenshot_Cursor.png differ
diff --git a/en/application-dev/reference/apis/figures/South.png b/en/application-dev/reference/apis/figures/South.png
new file mode 100644
index 0000000000000000000000000000000000000000..205f5cf5f59ce8318357e168eee0d66c119c233d
Binary files /dev/null and b/en/application-dev/reference/apis/figures/South.png differ
diff --git a/en/application-dev/reference/apis/figures/South_East.png b/en/application-dev/reference/apis/figures/South_East.png
new file mode 100644
index 0000000000000000000000000000000000000000..f4a70d2d068271bfe10e4ce724ae27e4e5ba96d9
Binary files /dev/null and b/en/application-dev/reference/apis/figures/South_East.png differ
diff --git a/en/application-dev/reference/apis/figures/South_West.png b/en/application-dev/reference/apis/figures/South_West.png
new file mode 100644
index 0000000000000000000000000000000000000000..2ae8e9a9fa396bb6ed0f385b7b99b66830357a40
Binary files /dev/null and b/en/application-dev/reference/apis/figures/South_West.png differ
diff --git a/en/application-dev/reference/apis/figures/Text_Cursor.png b/en/application-dev/reference/apis/figures/Text_Cursor.png
new file mode 100644
index 0000000000000000000000000000000000000000..7cd8d2200bc7455e562da003069702832db4eb20
Binary files /dev/null and b/en/application-dev/reference/apis/figures/Text_Cursor.png differ
diff --git a/en/application-dev/reference/apis/figures/West.png b/en/application-dev/reference/apis/figures/West.png
new file mode 100644
index 0000000000000000000000000000000000000000..2cad91aca31f2e2b257c523e80e6fc2d71fa2cee
Binary files /dev/null and b/en/application-dev/reference/apis/figures/West.png differ
diff --git a/en/application-dev/reference/apis/figures/West_East.png b/en/application-dev/reference/apis/figures/West_East.png
new file mode 100644
index 0000000000000000000000000000000000000000..6be4aa9d05f22a10cd00fa6aec36f95aee2b332d
Binary files /dev/null and b/en/application-dev/reference/apis/figures/West_East.png differ
diff --git a/en/application-dev/reference/apis/figures/Zoom_In.png b/en/application-dev/reference/apis/figures/Zoom_In.png
new file mode 100644
index 0000000000000000000000000000000000000000..2e928ec070fcd05a44cd9b1abd041128287b0528
Binary files /dev/null and b/en/application-dev/reference/apis/figures/Zoom_In.png differ
diff --git a/en/application-dev/reference/apis/figures/Zoom_Out.png b/en/application-dev/reference/apis/figures/Zoom_Out.png
new file mode 100644
index 0000000000000000000000000000000000000000..d675d0e517ba436724540a39f60dfa75c256f0d0
Binary files /dev/null and b/en/application-dev/reference/apis/figures/Zoom_Out.png differ
diff --git a/en/application-dev/reference/apis/figures/en-us_image_0000001219864133.PNG b/en/application-dev/reference/apis/figures/en-us_image_0000001219864133.PNG
index 14f81499ff0b1b8ef46257bc35a79e94775cd2ba..54be7ed38fa40349036e18b962ee52deb579a033 100644
Binary files a/en/application-dev/reference/apis/figures/en-us_image_0000001219864133.PNG and b/en/application-dev/reference/apis/figures/en-us_image_0000001219864133.PNG differ
diff --git a/en/application-dev/reference/apis/js-apis-Bundle.md b/en/application-dev/reference/apis/js-apis-Bundle.md
index 50434235f4adc01b997d0f990728e81512c3560e..8c9e825557ee1d899e7004fb9109ff7b7ea7a5da 100644
--- a/en/application-dev/reference/apis/js-apis-Bundle.md
+++ b/en/application-dev/reference/apis/js-apis-Bundle.md
@@ -156,7 +156,7 @@ bundle.getApplicationInfo(bundleName, bundleFlags, (err, data) => {
> This API is deprecated since API version 9. You are advised to use [bundleManager.getAllBundleInfo](js-apis-bundleManager.md#bundlemanagergetallbundleinfo) instead.
-getAllBundleInfo(bundleFlag: BundleFlag, userId?: number): Promise>
+getAllBundleInfo(bundleFlag: BundleFlag, userId?: number): Promise\\>
Obtains the information of all bundles of the specified user. This API uses a promise to return the result.
@@ -199,7 +199,7 @@ bundle.getAllBundleInfo(bundleFlag, userId)
> This API is deprecated since API version 9. You are advised to use [bundleManager.getAllBundleInfo](js-apis-bundleManager.md#bundlemanagergetallbundleinfo) instead.
-getAllBundleInfo(bundleFlag: BundleFlag, callback: AsyncCallback>): void
+getAllBundleInfo(bundleFlag: BundleFlag, callback: AsyncCallback\\>): void
Obtains the information of all bundles of the current user. This API uses an asynchronous callback to return the result.
@@ -236,7 +236,7 @@ bundle.getAllBundleInfo(bundleFlag, (err, data) => {
> This API is deprecated since API version 9. You are advised to use [bundleManager.getAllBundleInfo](js-apis-bundleManager.md#bundlemanagergetallbundleinfo) instead.
-getAllBundleInfo(bundleFlag: BundleFlag, userId: number, callback: AsyncCallback>): void
+getAllBundleInfo(bundleFlag: BundleFlag, userId: number, callback: AsyncCallback\\>): void
Obtains the information of all bundles of the specified user. This API uses an asynchronous callback to return the result.
@@ -822,7 +822,7 @@ bundle.getPermissionDef(permissionName).then((data) => {
> This API is deprecated since API version 9. You are advised to use [bundleManager.getAllApplicationInfo](js-apis-bundleManager.md#bundlemanagergetallapplicationinfo) instead.
-getAllApplicationInfo(bundleFlags: number, userId?: number): Promise>
+getAllApplicationInfo(bundleFlags: number, userId?: number): Promise\\>
Obtains the information about all applications of the specified user. This API uses a promise to return the result.
@@ -864,7 +864,7 @@ bundle.getAllApplicationInfo(bundleFlags, userId)
> This API is deprecated since API version 9. You are advised to use [bundleManager.getAllApplicationInfo](js-apis-bundleManager.md#bundlemanagergetallapplicationinfo) instead.
-getAllApplicationInfo(bundleFlags: number, userId: number, callback: AsyncCallback>): void
+getAllApplicationInfo(bundleFlags: number, userId: number, callback: AsyncCallback\\>): void
Obtains the information about all applications. This API uses an asynchronous callback to return the result.
@@ -1230,7 +1230,7 @@ SystemCapability.BundleManager.BundleFramework
| Name | Type | Mandatory| Description |
| -------- | -------------------------------------------- | ---- | ----------------------- |
| info | [AbilityInfo](js-apis-bundle-AbilityInfo.md) | Yes | Ability information. |
-| callback | AsyncCallback\ | Yes | Callback used to return the result. The value **true** means that the ability is enabled, and **false** means the opposite.|
+| callback | AsyncCallback\ | Yes | Callback used to return the result. If the ability is enabled, **true** will be returned; otherwise, **false** will be returned.|
**Example**
@@ -1320,7 +1320,7 @@ bundle.isApplicationEnabled(bundleName, (err, data) => {
> This API is deprecated since API version 9. You are advised to use [bundleManager.queryAbilityInfo](js-apis-bundleManager.md#bundlemanagerqueryabilityinfo) instead.
-queryAbilityByWant(want: Want, bundleFlags: number, userId?: number): Promise>
+queryAbilityByWant(want: Want, bundleFlags: number, userId?: number): Promise\\>
Obtains the ability information based on given Want. This API uses a promise to return the result.
@@ -1371,7 +1371,7 @@ bundle.queryAbilityByWant(want, bundleFlags, userId)
> This API is deprecated since API version 9. You are advised to use [bundleManager.queryAbilityInfo](js-apis-bundleManager.md#bundlemanagerqueryabilityinfo) instead.
-queryAbilityByWant(want: Want, bundleFlags: number, userId: number, callback: AsyncCallback>): void
+queryAbilityByWant(want: Want, bundleFlags: number, userId: number, callback: AsyncCallback\\>): void
Obtains the ability information of the specified user based on given Want. This API uses an asynchronous callback to return the result.
@@ -1416,7 +1416,7 @@ bundle.queryAbilityByWant(want, bundleFlags, userId, (err, data) => {
> This API is deprecated since API version 9. You are advised to use [bundleManager.queryAbilityInfo](js-apis-bundleManager.md#bundlemanagerqueryabilityinfo) instead.
-queryAbilityByWant(want: Want, bundleFlags: number, callback: AsyncCallback>): void;
+queryAbilityByWant(want: Want, bundleFlags: number, callback: AsyncCallback\\>): void;
Obtains the ability information based on given Want. This API uses an asynchronous callback to return the result.
@@ -1603,7 +1603,7 @@ bundle.getNameForUid(uid, (err, data) => {
## bundle.getAbilityIcon8+ deprecated
-> This API is deprecated since API version 9. You are advised to use [bundleManager.getAbilityIcon](js-apis-bundleManager.md#bundlemanagergetabilityicon) instead.
+> This API is deprecated since API version 9. You are advised to use [resourceManager.getMediaContent](js-apis-resource-manager.md#getmediacontent9) instead.
getAbilityIcon(bundleName: string, abilityName: string): Promise\;
@@ -1646,7 +1646,7 @@ bundle.getAbilityIcon(bundleName, abilityName)
## bundle.getAbilityIcon8+ deprecated
-> This API is deprecated since API version 9. You are advised to use [bundleManager.getAbilityIcon](js-apis-bundleManager.md#bundlemanagergetabilityicon) instead.
+> This API is deprecated since API version 9. You are advised to use [resourceManager.getMediaContent](js-apis-resource-manager.md#getmediacontent9) instead.
getAbilityIcon(bundleName: string, abilityName: string, callback: AsyncCallback\): void;
diff --git a/en/application-dev/reference/apis/js-apis-ability-ability.md b/en/application-dev/reference/apis/js-apis-ability-ability.md
index 37bf04c704a91f0580fddf99b14f9f52fb94d683..fe5b7cfde18961802383469c3d2558f8c8381f67 100644
--- a/en/application-dev/reference/apis/js-apis-ability-ability.md
+++ b/en/application-dev/reference/apis/js-apis-ability-ability.md
@@ -10,7 +10,7 @@ The **Ability** module provides all level-2 module APIs for developers to export
## Modules to Import
```ts
-import ability from '@ohos.ability.ability'
+import ability from '@ohos.ability.ability';
```
**System capability**: SystemCapability.Ability.AbilityBase
diff --git a/en/application-dev/reference/apis/js-apis-ability-context.md b/en/application-dev/reference/apis/js-apis-ability-context.md
deleted file mode 100644
index d345bbb9db0739da16156ecfc0bd4fe344989149..0000000000000000000000000000000000000000
--- a/en/application-dev/reference/apis/js-apis-ability-context.md
+++ /dev/null
@@ -1,1921 +0,0 @@
-# AbilityContext
-
-The **AbilityContext** module, inherited from **Context**, implements the context for abilities.
-
-This module provides APIs for accessing ability-specific resources. You can use the APIs to start and terminate an ability, obtain the caller interface, and request permissions from users by displaying a dialog box.
-
-> **NOTE**
->
-> - The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version.
-> - The APIs of this module can be used only in the stage model.
-
-## Usage
-
-Before using the **AbilityContext** module, you must define a child class that inherits from **Ability**.
-
-```ts
-import UIAbility from '@ohos.app.ability.UIAbility';
-
-let context = undefined;
-class EntryAbility extends UIAbility {
- onWindowStageCreate(windowStage) {
- context = this.context;
- }
-}
-```
-
-## Attributes
-
-**System capability**: SystemCapability.Ability.AbilityRuntime.Core
-
-| Name| Type| Readable| Writable| Description|
-| -------- | -------- | -------- | -------- | -------- |
-| abilityInfo | [AbilityInfo](js-apis-bundleManager-abilityInfo.md) | Yes| No| Ability information.|
-| currentHapModuleInfo | [HapModuleInfo](js-apis-bundleManager-hapModuleInfo.md) | Yes| No| Information about the current HAP.|
-| config | [Configuration](js-apis-application-configuration.md) | Yes| No| Configuration information.|
-
-## AbilityContext.startAbility
-
-startAbility(want: Want, callback: AsyncCallback<void>): void;
-
-Starts an ability. This API uses an asynchronous callback to return the result.
-
-Observe the following when using this API:
- - If an application running in the background needs to call this API to start an ability, it must have the **ohos.permission.START_ABILITIES_FROM_BACKGROUND** permission.
- - If **visible** of the target ability is **false** in cross-application scenarios, the caller must have the **ohos.permission.START_INVISIBLE_ABILITY** permission.
- - For details about the startup rules for the components in the stage model, see [Component Startup Rules (Stage Model)](../../application-models/component-startup-rules.md).
-
-**System capability**: SystemCapability.Ability.AbilityRuntime.Core
-
-**Parameters**
-
-| Name| Type| Mandatory| Description|
-| -------- | -------- | -------- | -------- |
-| want | [Want](js-apis-application-want.md) | Yes| Want information about the target ability.|
-| callback | AsyncCallback<void> | Yes| Callback used to return the result.|
-
-**Error codes**
-
-| ID| Error Message|
-| ------- | -------------------------------- |
-| 401 | If the input parameter is not valid parameter. |
-
-For details about the error codes, see [Ability Error Codes](../errorcodes/errorcode-ability.md).
-
-**Example**
-
- ```ts
- var want = {
- bundleName: "com.example.myapplication",
- abilityName: "MyAbility"
- };
-
- try {
- this.context.startAbility(want, (error) => {
- if (error.code) {
- // Process service logic errors.
- console.log('startAbility failed, error.code: ' + JSON.stringify(error.code) +
- ' error.message: ' + JSON.stringify(error.message));
- return;
- }
- // Carry out normal service processing.
- console.log('startAbility succeed');
- });
- } catch (paramError) {
- // Process input parameter errors.
- console.log('error.code: ' + JSON.stringify(paramError.code) +
- ' error.message: ' + JSON.stringify(paramError.message));
- }
- ```
-
-
-## AbilityContext.startAbility
-
-startAbility(want: Want, options: StartOptions, callback: AsyncCallback<void>): void;
-
-Starts an ability with the start options specified. This API uses an asynchronous callback to return the result.
-
-Observe the following when using this API:
- - If an application running in the background needs to call this API to start an ability, it must have the **ohos.permission.START_ABILITIES_FROM_BACKGROUND** permission.
- - If **visible** of the target ability is **false** in cross-application scenarios, the caller must have the **ohos.permission.START_INVISIBLE_ABILITY** permission.
- - For details about the startup rules for the components in the stage model, see [Component Startup Rules (Stage Model)](../../application-models/component-startup-rules.md).
-
-**System capability**: SystemCapability.Ability.AbilityRuntime.Core
-
-**Parameters**
-
-| Name| Type| Mandatory| Description|
-| -------- | -------- | -------- | -------- |
-| want | [Want](js-apis-application-want.md) | Yes| Want information about the target ability.|
-| options | [StartOptions](js-apis-application-startOptions.md) | Yes| Parameters used for starting the ability.|
-| callback | AsyncCallback<void> | Yes| Callback used to return the result.|
-
-**Error codes**
-
-| ID| Error Message|
-| ------- | -------------------------------- |
-| 401 | If the input parameter is not valid parameter. |
-
-For details about the error codes, see [Ability Error Codes](../errorcodes/errorcode-ability.md).
-
-**Example**
-
- ```ts
- var want = {
- deviceId: "",
- bundleName: "com.example.myapplication",
- abilityName: "EntryAbility"
- };
- var options = {
- windowMode: 0
- };
-
- try {
- this.context.startAbility(want, options, (error) => {
- if (error.code) {
- // Process service logic errors.
- console.log('startAbility failed, error.code: ' + JSON.stringify(error.code) +
- ' error.message: ' + JSON.stringify(error.message));
- return;
- }
- // Carry out normal service processing.
- console.log('startAbility succeed');
- });
- } catch (paramError) {
- // Process input parameter errors.
- console.log('error.code: ' + JSON.stringify(paramError.code) +
- ' error.message: ' + JSON.stringify(paramError.message));
- }
- ```
-
-## AbilityContext.startAbility
-
-startAbility(want: Want, options?: StartOptions): Promise<void>;
-
-Starts an ability. This API uses a promise to return the result.
-
-Observe the following when using this API:
- - If an application running in the background needs to call this API to start an ability, it must have the **ohos.permission.START_ABILITIES_FROM_BACKGROUND** permission.
- - If **visible** of the target ability is **false** in cross-application scenarios, the caller must have the **ohos.permission.START_INVISIBLE_ABILITY** permission.
- - For details about the startup rules for the components in the stage model, see [Component Startup Rules (Stage Model)](../../application-models/component-startup-rules.md).
-
-**System capability**: SystemCapability.Ability.AbilityRuntime.Core
-
-**Parameters**
-
-| Name| Type| Mandatory| Description|
-| -------- | -------- | -------- | -------- |
-| want | [Want](js-apis-application-want.md) | Yes| Want information about the target ability.|
-| options | [StartOptions](js-apis-application-startOptions.md) | No| Parameters used for starting the ability.|
-
-**Return value**
-
-| Type| Description|
-| -------- | -------- |
-| Promise<void> | Promise used to return the result.|
-
-**Error codes**
-
-| ID| Error Message|
-| ------- | -------------------------------- |
-| 401 | If the input parameter is not valid parameter. |
-
-For details about the error codes, see [Ability Error Codes](../errorcodes/errorcode-ability.md).
-
-**Example**
-
- ```ts
- var want = {
- bundleName: "com.example.myapplication",
- abilityName: "MyAbility"
- };
- var options = {
- windowMode: 0,
- };
-
- try {
- this.context.startAbility(want, options)
- .then((data) => {
- // Carry out normal service processing.
- console.log('startAbility succeed');
- })
- .catch((error) => {
- // Process service logic errors.
- console.log('startAbility failed, error.code: ' + JSON.stringify(error.code) +
- ' error.message: ' + JSON.stringify(error.message));
- });
- } catch (paramError) {
- // Process input parameter errors.
- console.log('error.code: ' + JSON.stringify(paramError.code) +
- ' error.message: ' + JSON.stringify(paramError.message));
- }
- ```
-
-
-## AbilityContext.startAbilityForResult
-
-startAbilityForResult(want: Want, callback: AsyncCallback<AbilityResult>): void;
-
-Starts an ability. After the ability is started, you can call [terminateSelfWithResult](#abilitycontextterminateselfwithresult) to terminate the ability and return the result to the caller. If an exception occurs, for example, the ability is killed, exception information is returned to the caller. This API uses an asynchronous callback to return the result.
-
-Observe the following when using this API:
- - If an application running in the background needs to call this API to start an ability, it must have the **ohos.permission.START_ABILITIES_FROM_BACKGROUND** permission.
- - If **visible** of the target ability is **false** in cross-application scenarios, the caller must have the **ohos.permission.START_INVISIBLE_ABILITY** permission.
- - For details about the startup rules for the components in the stage model, see [Component Startup Rules (Stage Model)](../../application-models/component-startup-rules.md).
-
-**System capability**: SystemCapability.Ability.AbilityRuntime.Core
-
-**Parameters**
-
-| Name| Type| Mandatory| Description|
-| -------- | -------- | -------- | -------- |
-| want |[Want](js-apis-application-want.md) | Yes| Want information about the target ability.|
-| callback | AsyncCallback<[AbilityResult](js-apis-inner-ability-abilityResult.md)> | Yes| Callback used to return the result.|
-
-**Error codes**
-
-| ID| Error Message|
-| ------- | -------------------------------- |
-| 401 | If the input parameter is not valid parameter. |
-
-For details about the error codes, see [Ability Error Codes](../errorcodes/errorcode-ability.md).
-
-**Example**
-
- ```ts
- var want = {
- deviceId: "",
- bundleName: "com.example.myapplication",
- abilityName: "EntryAbility"
- };
-
- try {
- this.context.startAbilityForResult(want, (error, result) => {
- if (error.code) {
- // Process service logic errors.
- console.log('startAbilityForResult failed, error.code: ' + JSON.stringify(error.code) +
- ' error.message: ' + JSON.stringify(error.message));
- return;
- }
- // Carry out normal service processing.
- console.log("startAbilityForResult succeed, result.resultCode = " +
- result.resultCode)
- });
- } catch (paramError) {
- // Process input parameter errors.
- console.log('error.code: ' + JSON.stringify(paramError.code) +
- ' error.message: ' + JSON.stringify(paramError.message));
- }
- ```
-
-## AbilityContext.startAbilityForResult
-
-startAbilityForResult(want: Want, options: StartOptions, callback: AsyncCallback<AbilityResult>): void;
-
-Starts an ability with the start options specified. After the ability is started, you can call [terminateSelfWithResult](#abilitycontextterminateselfwithresult) to terminate the ability and return the result to the caller. If an exception occurs, for example, the ability is killed, exception information is returned to the caller. This API uses an asynchronous callback to return the result.
-
-Observe the following when using this API:
- - If an application running in the background needs to call this API to start an ability, it must have the **ohos.permission.START_ABILITIES_FROM_BACKGROUND** permission.
- - If **visible** of the target ability is **false** in cross-application scenarios, the caller must have the **ohos.permission.START_INVISIBLE_ABILITY** permission.
- - For details about the startup rules for the components in the stage model, see [Component Startup Rules (Stage Model)](../../application-models/component-startup-rules.md).
-
-**System capability**: SystemCapability.Ability.AbilityRuntime.Core
-
-**Parameters**
-
-| Name| Type| Mandatory| Description|
-| -------- | -------- | -------- | -------- |
-| want |[Want](js-apis-application-want.md) | Yes| Want information about the target ability.|
-| options | [StartOptions](js-apis-application-startOptions.md) | Yes| Parameters used for starting the ability.|
-| callback | AsyncCallback<[AbilityResult](js-apis-inner-ability-abilityResult.md)> | Yes| Callback used to return the result.|
-
-**Error codes**
-
-| ID| Error Message|
-| ------- | -------------------------------- |
-| 401 | If the input parameter is not valid parameter. |
-
-For details about the error codes, see [Ability Error Codes](../errorcodes/errorcode-ability.md).
-
-**Example**
-
- ```ts
- var want = {
- deviceId: "",
- bundleName: "com.example.myapplication",
- abilityName: "EntryAbility"
- };
- var options = {
- windowMode: 0,
- };
-
- try {
- this.context.startAbilityForResult(want, options, (error, result) => {
- if (error.code) {
- // Process service logic errors.
- console.log('startAbilityForResult failed, error.code: ' + JSON.stringify(error.code) +
- ' error.message: ' + JSON.stringify(error.message));
- return;
- }
- // Carry out normal service processing.
- console.log("startAbilityForResult succeed, result.resultCode = " +
- result.resultCode)
- });
- } catch (paramError) {
- // Process input parameter errors.
- console.log('error.code: ' + JSON.stringify(paramError.code) +
- ' error.message: ' + JSON.stringify(paramError.message));
- }
- ```
-
-
-## AbilityContext.startAbilityForResult
-
-startAbilityForResult(want: Want, options?: StartOptions): Promise<AbilityResult>;
-
-Starts an ability. After the ability is started, you can call [terminateSelfWithResult](#abilitycontextterminateselfwithresult) to terminate the ability and return the result to the caller. If an exception occurs, for example, the ability is killed, exception information is returned to the caller. This API uses a promise to return the result.
-
-Observe the following when using this API:
- - If an application running in the background needs to call this API to start an ability, it must have the **ohos.permission.START_ABILITIES_FROM_BACKGROUND** permission.
- - If **visible** of the target ability is **false** in cross-application scenarios, the caller must have the **ohos.permission.START_INVISIBLE_ABILITY** permission.
- - For details about the startup rules for the components in the stage model, see [Component Startup Rules (Stage Model)](../../application-models/component-startup-rules.md).
-
-**System capability**: SystemCapability.Ability.AbilityRuntime.Core
-
-**Parameters**
-
-| Name| Type| Mandatory| Description|
-| -------- | -------- | -------- | -------- |
-| want | [Want](js-apis-application-want.md) | Yes| Want information about the target ability.|
-| options | [StartOptions](js-apis-application-startOptions.md) | No| Parameters used for starting the ability.|
-
-
-**Return value**
-
-| Type| Description|
-| -------- | -------- |
-| Promise<[AbilityResult](js-apis-inner-ability-abilityResult.md)> | Promise used to return the result.|
-
-**Error codes**
-
-| ID| Error Message|
-| ------- | -------------------------------- |
-| 401 | If the input parameter is not valid parameter. |
-
-For details about the error codes, see [Ability Error Codes](../errorcodes/errorcode-ability.md).
-
-**Example**
-
- ```ts
- var want = {
- bundleName: "com.example.myapplication",
- abilityName: "MyAbility"
- };
- var options = {
- windowMode: 0,
- };
-
- try {
- this.context.startAbilityForResult(want, options)
- .then((result) => {
- // Carry out normal service processing.
- console.log("startAbilityForResult succeed, result.resultCode = " + result.resultCode);
- })
- .catch((error) => {
- // Process service logic errors.
- console.log('startAbilityForResult failed, error.code: ' + JSON.stringify(error.code) +
- ' error.message: ' + JSON.stringify(error.message));
- });
- } catch (paramError) {
- // Process input parameter errors.
- console.log('error.code: ' + JSON.stringify(paramError.code) +
- ' error.message: ' + JSON.stringify(paramError.message));
- }
- ```
-
-## AbilityContext.startAbilityForResultWithAccount
-
-startAbilityForResultWithAccount(want: Want, accountId: number, callback: AsyncCallback\): void;
-
-Starts an ability with the account ID specified. This API uses an asynchronous callback to return the result when the ability is terminated.
-
-Observe the following when using this API:
- - If an application running in the background needs to call this API to start an ability, it must have the **ohos.permission.START_ABILITIES_FROM_BACKGROUND** permission.
- - If **visible** of the target ability is **false** in cross-application scenarios, the caller must have the **ohos.permission.START_INVISIBLE_ABILITY** permission.
- - For details about the startup rules for the components in the stage model, see [Component Startup Rules (Stage Model)](../../application-models/component-startup-rules.md).
-
-**Required permissions**: ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS (required only when the account ID is not the current user)
-
-**System capability**: SystemCapability.Ability.AbilityRuntime.Core
-
-**System API**: This is a system API and cannot be called by third-party applications.
-
-**Parameters**
-
-| Name| Type| Mandatory| Description|
-| -------- | -------- | -------- | -------- |
-| want | [Want](js-apis-application-want.md) | Yes| Want information about the target ability.|
-| accountId | number | Yes| ID of a system account. For details, see [getCreatedOsAccountsCount](js-apis-osAccount.md#getosaccountlocalidfromprocess).|
-| callback | AsyncCallback\<[AbilityResult](js-apis-inner-ability-abilityResult.md)\> | Yes| Callback used to return the result.|
-
-**Error codes**
-
-| ID| Error Message|
-| ------- | -------------------------------- |
-| 401 | If the input parameter is not valid parameter. |
-
-For details about the error codes, see [Ability Error Codes](../errorcodes/errorcode-ability.md).
-
-**Example**
-
- ```ts
- var want = {
- deviceId: "",
- bundleName: "com.example.myapplication",
- abilityName: "EntryAbility"
- };
- var accountId = 100;
-
- try {
- this.context.startAbilityForResultWithAccount(want, accountId, (error, result) => {
- if (error.code) {
- // Process service logic errors.
- console.log('startAbilityForResultWithAccount failed, error.code: ' + JSON.stringify(error.code) +
- ' error.message: ' + JSON.stringify(error.message));
- return;
- }
- // Carry out normal service processing.
- console.log("startAbilityForResultWithAccount succeed, result.resultCode = " +
- result.resultCode)
- });
- } catch (paramError) {
- // Process input parameter errors.
- console.log('error.code: ' + JSON.stringify(paramError.code) +
- ' error.message: ' + JSON.stringify(paramError.message));
- }
- ```
-
-
-## AbilityContext.startAbilityForResultWithAccount
-
-startAbilityForResultWithAccount(want: Want, accountId: number, options: StartOptions, callback: AsyncCallback\): void;
-
-Starts an ability with the start options and account ID specified. This API uses an asynchronous callback to return the result when the ability is terminated.
-
-Observe the following when using this API:
- - If an application running in the background needs to call this API to start an ability, it must have the **ohos.permission.START_ABILITIES_FROM_BACKGROUND** permission.
- - If **visible** of the target ability is **false** in cross-application scenarios, the caller must have the **ohos.permission.START_INVISIBLE_ABILITY** permission.
- - For details about the startup rules for the components in the stage model, see [Component Startup Rules (Stage Model)](../../application-models/component-startup-rules.md).
-
-**Required permissions**: ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS (required only when the account ID is not the current user)
-
-**System capability**: SystemCapability.Ability.AbilityRuntime.Core
-
-**System API**: This is a system API and cannot be called by third-party applications.
-
-**Parameters**
-
-| Name| Type| Mandatory| Description|
-| -------- | -------- | -------- | -------- |
-| want | [Want](js-apis-application-want.md) | Yes| Want information about the target ability.|
-| accountId | number | Yes| ID of a system account. For details, see [getCreatedOsAccountsCount](js-apis-osAccount.md#getosaccountlocalidfromprocess).|
-| options | [StartOptions](js-apis-application-startOptions.md) | Yes| Parameters used for starting the ability.|
-| callback | AsyncCallback\ | Yes| Callback used to return the result.|
-
-**Error codes**
-
-| ID| Error Message|
-| ------- | -------------------------------- |
-| 401 | If the input parameter is not valid parameter. |
-
-For details about the error codes, see [Ability Error Codes](../errorcodes/errorcode-ability.md).
-
-**Example**
-
- ```ts
- var want = {
- deviceId: "",
- bundleName: "com.example.myapplication",
- abilityName: "EntryAbility"
- };
- var accountId = 100;
- var options = {
- windowMode: 0
- };
-
- try {
- this.context.startAbilityForResultWithAccount(want, accountId, options, (error, result) => {
- if (error.code) {
- // Process service logic errors.
- console.log('startAbilityForResultWithAccount failed, error.code: ' + JSON.stringify(error.code) +
- ' error.message: ' + JSON.stringify(error.message));
- return;
- }
- // Carry out normal service processing.
- console.log("startAbilityForResultWithAccount succeed, result.resultCode = " +
- result.resultCode)
- });
- } catch (paramError) {
- // Process input parameter errors.
- console.log('error.code: ' + JSON.stringify(paramError.code) +
- ' error.message: ' + JSON.stringify(paramError.message));
- }
- ```
-
-
-## AbilityContext.startAbilityForResultWithAccount
-
-startAbilityForResultWithAccount(want: Want, accountId: number, options?: StartOptions): Promise\;
-
-Starts an ability with the account ID specified. This API uses a promise to return the result when the ability is terminated.
-
-Observe the following when using this API:
- - If an application running in the background needs to call this API to start an ability, it must have the **ohos.permission.START_ABILITIES_FROM_BACKGROUND** permission.
- - If **visible** of the target ability is **false** in cross-application scenarios, the caller must have the **ohos.permission.START_INVISIBLE_ABILITY** permission.
- - For details about the startup rules for the components in the stage model, see [Component Startup Rules (Stage Model)](../../application-models/component-startup-rules.md).
-
-**Required permissions**: ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS (required only when the account ID is not the current user)
-
-**System capability**: SystemCapability.Ability.AbilityRuntime.Core
-
-**System API**: This is a system API and cannot be called by third-party applications.
-
-**Parameters**
-
-| Name| Type| Mandatory| Description|
-| -------- | -------- | -------- | -------- |
-| want | [Want](js-apis-application-want.md) | Yes| Want information about the target ability.|
-| accountId | number | Yes| ID of a system account. For details, see [getCreatedOsAccountsCount](js-apis-osAccount.md#getosaccountlocalidfromprocess).|
-| options | [StartOptions](js-apis-application-startOptions.md) | No| Parameters used for starting the ability.|
-
-**Return value**
-
-| Type| Description|
-| -------- | -------- |
-| Promise<[AbilityResult](js-apis-inner-ability-abilityResult.md)> | Promise used to return the result.|
-
-**Error codes**
-
-| ID| Error Message|
-| ------- | -------------------------------- |
-| 401 | If the input parameter is not valid parameter. |
-
-For details about the error codes, see [Ability Error Codes](../errorcodes/errorcode-ability.md).
-
-**Example**
-
- ```ts
- var want = {
- deviceId: "",
- bundleName: "com.example.myapplication",
- abilityName: "EntryAbility"
- };
- var accountId = 100;
- var options = {
- windowMode: 0
- };
-
- try {
- this.context.startAbilityForResultWithAccount(want, accountId, options)
- .then((result) => {
- // Carry out normal service processing.
- console.log("startAbilityForResultWithAccount succeed, result.resultCode = " +
- result.resultCode)
- })
- .catch((error) => {
- // Process service logic errors.
- console.log('startAbilityForResultWithAccount failed, error.code: ' + JSON.stringify(error.code) +
- ' error.message: ' + JSON.stringify(error.message));
- });
- } catch (paramError) {
- // Process input parameter errors.
- console.log('error.code: ' + JSON.stringify(paramError.code) +
- ' error.message: ' + JSON.stringify(paramError.message));
- }
- ```
-## AbilityContext.startServiceExtensionAbility
-
-startServiceExtensionAbility(want: Want, callback: AsyncCallback\): void;
-
-Starts a ServiceExtensionAbility. This API uses an asynchronous callback to return the result.
-
-**System capability**: SystemCapability.Ability.AbilityRuntime.Core
-
-**System API**: This is a system API and cannot be called by third-party applications.
-
-**Parameters**
-
-| Name| Type| Mandatory| Description|
-| -------- | -------- | -------- | -------- |
-| want | [Want](js-apis-application-want.md) | Yes| Want information about the target ability.|
-| callback | AsyncCallback\ | Yes| Callback used to return the result.|
-
-**Error codes**
-
-| ID| Error Message|
-| ------- | -------------------------------- |
-| 401 | If the input parameter is not valid parameter. |
-
-For details about the error codes, see [Ability Error Codes](../errorcodes/errorcode-ability.md).
-
-**Example**
-
- ```ts
- var want = {
- deviceId: "",
- bundleName: "com.example.myapplication",
- abilityName: "EntryAbility"
- };
-
- try {
- this.context.startServiceExtensionAbility(want, (error) => {
- if (error.code) {
- // Process service logic errors.
- console.log('startServiceExtensionAbility failed, error.code: ' + JSON.stringify(error.code) +
- ' error.message: ' + JSON.stringify(error.message));
- return;
- }
- // Carry out normal service processing.
- console.log('startServiceExtensionAbility succeed');
- });
- } catch (paramError) {
- // Process input parameter errors.
- console.log('error.code: ' + JSON.stringify(paramError.code) +
- ' error.message: ' + JSON.stringify(paramError.message));
- }
- ```
-
-## AbilityContext.startServiceExtensionAbility
-
-startServiceExtensionAbility(want: Want): Promise\;
-
-Starts a ServiceExtensionAbility. This API uses a promise to return the result.
-
-**System capability**: SystemCapability.Ability.AbilityRuntime.Core
-
-**System API**: This is a system API and cannot be called by third-party applications.
-
-**Parameters**
-
-| Name| Type| Mandatory| Description|
-| -------- | -------- | -------- | -------- |
-| want | [Want](js-apis-application-want.md) | Yes| Want information about the target ability.|
-
-**Error codes**
-
-| ID| Error Message|
-| ------- | -------------------------------- |
-| 401 | If the input parameter is not valid parameter. |
-
-For details about the error codes, see [Ability Error Codes](../errorcodes/errorcode-ability.md).
-
-**Example**
-
- ```ts
- var want = {
- deviceId: "",
- bundleName: "com.example.myapplication",
- abilityName: "EntryAbility"
- };
-
- try {
- this.context.startServiceExtensionAbility(want)
- .then((data) => {
- // Carry out normal service processing.
- console.log('startServiceExtensionAbility succeed');
- })
- .catch((error) => {
- // Process service logic errors.
- console.log('startServiceExtensionAbility failed, error.code: ' + JSON.stringify(error.code) +
- ' error.message: ' + JSON.stringify(error.message));
- });
- } catch (paramError) {
- // Process input parameter errors.
- console.log('error.code: ' + JSON.stringify(paramError.code) +
- ' error.message: ' + JSON.stringify(paramError.message));
- }
- ```
-
-## AbilityContext.startServiceExtensionAbilityWithAccount
-
-startServiceExtensionAbilityWithAccount(want: Want, accountId: number, callback: AsyncCallback\): void;
-
-Starts a ServiceExtensionAbility with the account ID specified. This API uses an asynchronous callback to return the result.
-
-**Required permissions**: ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS (required only when the account ID is not the current user)
-
-**System capability**: SystemCapability.Ability.AbilityRuntime.Core
-
-**System API**: This is a system API and cannot be called by third-party applications.
-
-**Parameters**
-
-| Name| Type| Mandatory| Description|
-| -------- | -------- | -------- | -------- |
-| want | [Want](js-apis-application-want.md) | Yes| Want information about the target ability.|
-| accountId | number | Yes| ID of a system account. For details, see [getCreatedOsAccountsCount](js-apis-osAccount.md#getosaccountlocalidfromprocess).|
-| callback | AsyncCallback\ | Yes| Callback used to return the result.|
-
-**Error codes**
-
-| ID| Error Message|
-| ------- | -------------------------------- |
-| 401 | If the input parameter is not valid parameter. |
-
-For details about the error codes, see [Ability Error Codes](../errorcodes/errorcode-ability.md).
-
-**Example**
-
- ```ts
- var want = {
- deviceId: "",
- bundleName: "com.example.myapplication",
- abilityName: "EntryAbility"
- };
- var accountId = 100;
-
- try {
- this.context.startServiceExtensionAbilityWithAccount(want, accountId, (error) => {
- if (error.code) {
- // Process service logic errors.
- console.log('startServiceExtensionAbilityWithAccount failed, error.code: ' + JSON.stringify(error.code) +
- ' error.message: ' + JSON.stringify(error.message));
- return;
- }
- // Carry out normal service processing.
- console.log('startServiceExtensionAbilityWithAccount succeed');
- });
- } catch (paramError) {
- // Process input parameter errors.
- console.log('error.code: ' + JSON.stringify(paramError.code) +
- ' error.message: ' + JSON.stringify(paramError.message));
- }
- ```
-
-## AbilityContext.startServiceExtensionAbilityWithAccount
-
-startServiceExtensionAbilityWithAccount(want: Want, accountId: number): Promise\;
-
-Starts a ServiceExtensionAbility with the account ID specified. This API uses a promise to return the result.
-
-**Required permissions**: ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS (required only when the account ID is not the current user)
-
-**System capability**: SystemCapability.Ability.AbilityRuntime.Core
-
-**System API**: This is a system API and cannot be called by third-party applications.
-
-**Parameters**
-
-| Name| Type| Mandatory| Description|
-| -------- | -------- | -------- | -------- |
-| want | [Want](js-apis-application-want.md) | Yes| Want information about the target ability.|
-| accountId | number | Yes| ID of a system account. For details, see [getCreatedOsAccountsCount](js-apis-osAccount.md#getosaccountlocalidfromprocess).|
-
-**Error codes**
-
-| ID| Error Message|
-| ------- | -------------------------------- |
-| 401 | If the input parameter is not valid parameter. |
-
-For details about the error codes, see [Ability Error Codes](../errorcodes/errorcode-ability.md).
-
-**Example**
-
- ```ts
- var want = {
- deviceId: "",
- bundleName: "com.example.myapplication",
- abilityName: "EntryAbility"
- };
- var accountId = 100;
-
- try {
- this.context.startServiceExtensionAbilityWithAccount(want, accountId)
- .then((data) => {
- // Carry out normal service processing.
- console.log('startServiceExtensionAbilityWithAccount succeed');
- })
- .catch((error) => {
- // Process service logic errors.
- console.log('startServiceExtensionAbilityWithAccount failed, error.code: ' + JSON.stringify(error.code) +
- ' error.message: ' + JSON.stringify(error.message));
- });
- } catch (paramError) {
- // Process input parameter errors.
- console.log('error.code: ' + JSON.stringify(paramError.code) +
- ' error.message: ' + JSON.stringify(paramError.message));
- }
- ```
-## AbilityContext.stopServiceExtensionAbility
-
-stopServiceExtensionAbility(want: Want, callback: AsyncCallback\): void;
-
-Stops a ServiceExtensionAbility in the same application. This API uses an asynchronous callback to return the result.
-
-**System capability**: SystemCapability.Ability.AbilityRuntime.Core
-
-**System API**: This is a system API and cannot be called by third-party applications.
-
-**Parameters**
-
-| Name| Type| Mandatory| Description|
-| -------- | -------- | -------- | -------- |
-| want | [Want](js-apis-application-want.md) | Yes| Want information about the target ability.|
-| callback | AsyncCallback\ | Yes| Callback used to return the result.|
-
-**Error codes**
-
-| ID| Error Message|
-| ------- | -------------------------------- |
-| 401 | If the input parameter is not valid parameter. |
-
-For details about the error codes, see [Ability Error Codes](../errorcodes/errorcode-ability.md).
-
-**Example**
-
- ```ts
- var want = {
- deviceId: "",
- bundleName: "com.example.myapplication",
- abilityName: "EntryAbility"
- };
-
- try {
- this.context.startAbility(want, (error) => {
- if (error.code != 0) {
- console.log("start ability fail, err: " + JSON.stringify(err));
- }
- })
-
- this.context.stopServiceExtensionAbility(want, (error) => {
- if (error.code != 0) {
- // Process service logic errors.
- console.log('stopServiceExtensionAbility failed, error.code: ' + JSON.stringify(error.code) +
- ' error.message: ' + JSON.stringify(error.message));
- return;
- }
- // Carry out normal service processing.
- console.log('stopServiceExtensionAbility succeed');
- });
- } catch (paramError) {
- // Process input parameter errors.
- console.log('error.code: ' + JSON.stringify(paramError.code) +
- ' error.message: ' + JSON.stringify(paramError.message));
- }
- ```
-
-## AbilityContext.stopServiceExtensionAbility
-
-stopServiceExtensionAbility(want: Want): Promise\;
-
-Stops a ServiceExtensionAbility in the same application. This API uses a promise to return the result.
-
-**System capability**: SystemCapability.Ability.AbilityRuntime.Core
-
-**System API**: This is a system API and cannot be called by third-party applications.
-
-**Parameters**
-
-| Name| Type| Mandatory| Description|
-| -------- | -------- | -------- | -------- |
-| want | [Want](js-apis-application-want.md) | Yes| Want information about the target ability.|
-
-**Error codes**
-
-| ID| Error Message|
-| ------- | -------------------------------- |
-| 401 | If the input parameter is not valid parameter. |
-
-For details about the error codes, see [Ability Error Codes](../errorcodes/errorcode-ability.md).
-
-**Example**
-
- ```ts
- var want = {
- deviceId: "",
- bundleName: "com.example.myapplication",
- abilityName: "EntryAbility"
- };
-
- try {
- this.context.startAbility(want, (error) => {
- if (error.code != 0) {
- console.log("start ability fail, err: " + JSON.stringify(err));
- }
- })
-
- this.context.stopServiceExtensionAbility(want)
- .then((data) => {
- // Carry out normal service processing.
- console.log('stopServiceExtensionAbility succeed');
- })
- .catch((error) => {
- // Process service logic errors.
- console.log('stopServiceExtensionAbility failed, error.code: ' + JSON.stringify(error.code) +
- ' error.message: ' + JSON.stringify(error.message));
- });
- } catch (paramError) {
- // Process input parameter errors.
- console.log('error.code: ' + JSON.stringify(paramError.code) +
- ' error.message: ' + JSON.stringify(paramError.message));
- }
- ```
-
-## AbilityContext.stopServiceExtensionAbilityWithAccount
-
-stopServiceExtensionAbilityWithAccount(want: Want, accountId: number, callback: AsyncCallback\): void;
-
-Stops a ServiceExtensionAbility in the same application with the account ID specified. This API uses an asynchronous callback to return the result.
-
-**Required permissions**: ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS (required only when the account ID is not the current user)
-
-**System capability**: SystemCapability.Ability.AbilityRuntime.Core
-
-**System API**: This is a system API and cannot be called by third-party applications.
-
-**Parameters**
-
-| Name| Type| Mandatory| Description|
-| -------- | -------- | -------- | -------- |
-| want | [Want](js-apis-application-want.md) | Yes| Want information about the target ability.|
-| accountId | number | Yes| ID of a system account. For details, see [getCreatedOsAccountsCount](js-apis-osAccount.md#getosaccountlocalidfromprocess).|
-| callback | AsyncCallback\ | Yes| Callback used to return the result.|
-
-**Error codes**
-
-| ID| Error Message|
-| ------- | -------------------------------- |
-| 401 | If the input parameter is not valid parameter. |
-
-For details about the error codes, see [Ability Error Codes](../errorcodes/errorcode-ability.md).
-
-**Example**
-
- ```ts
- var want = {
- deviceId: "",
- bundleName: "com.example.myapplication",
- abilityName: "EntryAbility"
- };
- var accountId = 100;
-
- try {
- this.context.startAbilityWithAccount(want, accountId, (error) => {
- if (error.code != 0) {
- console.log("start ability fail, err: " + JSON.stringify(err));
- }
- })
-
- this.context.stopServiceExtensionAbilityWithAccount(want, accountId, (error) => {
- if (error.code) {
- // Process service logic errors.
- console.log('stopServiceExtensionAbilityWithAccount failed, error.code: ' + JSON.stringify(error.code) +
- ' error.message: ' + JSON.stringify(error.message));
- return;
- }
- // Carry out normal service processing.
- console.log('stopServiceExtensionAbilityWithAccount succeed');
- });
- } catch (paramError) {
- // Process input parameter errors.
- console.log('error.code: ' + JSON.stringify(paramError.code) +
- ' error.message: ' + JSON.stringify(paramError.message));
- }
- ```
-
-## AbilityContext.stopServiceExtensionAbilityWithAccount
-
-stopServiceExtensionAbilityWithAccount(want: Want, accountId: number): Promise\;
-
-Stops a ServiceExtensionAbility in the same application with the account ID specified. This API uses a promise to return the result.
-
-**Required permissions**: ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS (required only when the account ID is not the current user)
-
-**System capability**: SystemCapability.Ability.AbilityRuntime.Core
-
-**System API**: This is a system API and cannot be called by third-party applications.
-
-**Parameters**
-
-| Name| Type| Mandatory| Description|
-| -------- | -------- | -------- | -------- |
-| want | [Want](js-apis-application-want.md) | Yes| Want information about the target ability.|
-| accountId | number | Yes| ID of a system account. For details, see [getCreatedOsAccountsCount](js-apis-osAccount.md#getosaccountlocalidfromprocess).|
-
-**Error codes**
-
-| ID| Error Message|
-| ------- | -------------------------------- |
-| 401 | If the input parameter is not valid parameter. |
-
-For details about the error codes, see [Ability Error Codes](../errorcodes/errorcode-ability.md).
-
-**Example**
-
- ```ts
- var want = {
- deviceId: "",
- bundleName: "com.example.myapplication",
- abilityName: "EntryAbility"
- };
- var accountId = 100;
-
- try {
- this.context.startAbilityWithAccount(want, accountId, (error) => {
- if (error.code != 0) {
- console.log("start ability fail, err: " + JSON.stringify(err));
- }
- })
-
- this.context.stopServiceExtensionAbilityWithAccount(want, accountId)
- .then((data) => {
- // Carry out normal service processing.
- console.log('stopServiceExtensionAbilityWithAccount succeed');
- })
- .catch((error) => {
- // Process service logic errors.
- console.log('stopServiceExtensionAbilityWithAccount failed, error.code: ' + JSON.stringify(error.code) +
- ' error.message: ' + JSON.stringify(error.message));
- });
- } catch (paramError) {
- // Process input parameter errors.
- console.log('error.code: ' + JSON.stringify(paramError.code) +
- ' error.message: ' + JSON.stringify(paramError.message));
- }
- ```
-
-## AbilityContext.terminateSelf
-
-terminateSelf(callback: AsyncCallback<void>): void;
-
-Terminates this ability. This API uses an asynchronous callback to return the result.
-
-**System capability**: SystemCapability.Ability.AbilityRuntime.Core
-
-**Parameters**
-
-| Name| Type| Mandatory| Description|
-| -------- | -------- | -------- | -------- |
-| callback | AsyncCallback<void> | Yes| Callback used to return the result.|
-
-**Error codes**
-
-| ID| Error Message|
-| ------- | -------------------------------- |
-| 401 | If the input parameter is not valid parameter. |
-
-For details about the error codes, see [Ability Error Codes](../errorcodes/errorcode-ability.md).
-
-**Example**
-
- ```ts
- this.context.terminateSelf((error) => {
- if (error.code) {
- // Process service logic errors.
- console.log('terminateSelf failed, error.code: ' + JSON.stringify(error.code) +
- ' error.message: ' + JSON.stringify(error.message));
- return;
- }
- // Carry out normal service processing.
- console.log('terminateSelf succeed');
- });
- ```
-
-
-## AbilityContext.terminateSelf
-
-terminateSelf(): Promise<void>;
-
-Terminates this ability. This API uses a promise to return the result.
-
-**System capability**: SystemCapability.Ability.AbilityRuntime.Core
-
-**Return value**
-
-| Type| Description|
-| -------- | -------- |
-| Promise<void> | Promise used to return the result.|
-
-**Error codes**
-
-| ID| Error Message|
-| ------- | -------------------------------- |
-| 401 | If the input parameter is not valid parameter. |
-
-For details about the error codes, see [Ability Error Codes](../errorcodes/errorcode-ability.md).
-
-**Example**
-
- ```ts
- this.context.terminateSelf().then((data) => {
- // Carry out normal service processing.
- console.log('terminateSelf succeed');
- }).catch((error) => {
- // Process service logic errors.
- console.log('terminateSelf failed, error.code: ' + JSON.stringify(error.code) +
- ' error.message: ' + JSON.stringify(error.message));
- });
- ```
-
-
-## AbilityContext.terminateSelfWithResult
-
-terminateSelfWithResult(parameter: AbilityResult, callback: AsyncCallback<void>): void;
-
-Terminates this ability. If the ability is started by calling [startAbilityForResult](#abilitycontextstartabilityforresult), the result is returned to the caller in the form of a callback when **terminateSelfWithResult** is called. Otherwise, no result is returned to the caller when **terminateSelfWithResult** is called.
-
-**System capability**: SystemCapability.Ability.AbilityRuntime.Core
-
-**Parameters**
-
-| Name| Type| Mandatory| Description|
-| -------- | -------- | -------- | -------- |
-| parameter | [AbilityResult](js-apis-inner-ability-abilityResult.md) | Yes| Information returned to the caller.|
-| callback | AsyncCallback<void> | Yes| Callback used to return the result.|
-
-**Error codes**
-
-| ID| Error Message|
-| ------- | -------------------------------- |
-| 401 | If the input parameter is not valid parameter. |
-
-For details about the error codes, see [Ability Error Codes](../errorcodes/errorcode-ability.md).
-
-**Example**
-
- ```ts
- var want = {
- bundleName: "com.extreme.myapplication",
- abilityName: "SecondAbility"
- }
- var resultCode = 100;
- // AbilityResult information returned to the caller.
- var abilityResult = {
- want,
- resultCode
- }
-
- try {
- this.context.terminateSelfWithResult(abilityResult, (error) => {
- if (error.code) {
- // Process service logic errors.
- console.log('terminateSelfWithResult failed, error.code: ' + JSON.stringify(error.code) +
- ' error.message: ' + JSON.stringify(error.message));
- return;
- }
- // Carry out normal service processing.
- console.log('terminateSelfWithResult succeed');
- });
- } catch (paramError) {
- // Process input parameter errors.
- console.log('error.code: ' + JSON.stringify(paramError.code) +
- ' error.message: ' + JSON.stringify(paramError.message));
- }
- ```
-
-
-## AbilityContext.terminateSelfWithResult
-
-terminateSelfWithResult(parameter: AbilityResult): Promise<void>;
-Terminates this ability. If the ability is started by calling [startAbilityForResult](#abilitycontextstartabilityforresult), the result is returned to the caller in the form of a promise when **terminateSelfWithResult** is called. Otherwise, no result is returned to the caller when **terminateSelfWithResult** is called.
-
-**System capability**: SystemCapability.Ability.AbilityRuntime.Core
-
-**Parameters**
-
-| Name| Type| Mandatory| Description|
-| -------- | -------- | -------- | -------- |
-| parameter | [AbilityResult](js-apis-inner-ability-abilityResult.md) | Yes| Information returned to the caller.|
-
-**Return value**
-
-| Type| Description|
-| -------- | -------- |
-| Promise<void> | Promise used to return the result.|
-
-**Error codes**
-
-| ID| Error Message|
-| ------- | -------------------------------- |
-| 401 | If the input parameter is not valid parameter. |
-
-For details about the error codes, see [Ability Error Codes](../errorcodes/errorcode-ability.md).
-
-
-**Example**
-
- ```ts
- var want = {
- bundleName: "com.extreme.myapplication",
- abilityName: "SecondAbility"
- }
- var resultCode = 100;
- // AbilityResult information returned to the caller.
- var abilityResult = {
- want,
- resultCode
- }
-
- try {
- this.context.terminateSelfWithResult(abilityResult)
- .then((data) => {
- // Carry out normal service processing.
- console.log('terminateSelfWithResult succeed');
- })
- .catch((error) => {
- // Process service logic errors.
- console.log('terminateSelfWithResult failed, error.code: ' + JSON.stringify(error.code) +
- ' error.message: ' + JSON.stringify(error.message));
- });
- } catch (paramError) {
- // Process input parameter errors.
- console.log('error.code: ' + JSON.stringify(paramError.code) +
- ' error.message: ' + JSON.stringify(paramError.message));
- }
- ```
-
-## AbilityContext.connectServiceExtensionAbility
-
-connectServiceExtensionAbility(want: Want, options: ConnectOptions): number;
-
-Uses the **AbilityInfo.AbilityType.SERVICE** template to connect this ability to another ability.
-
-**System capability**: SystemCapability.Ability.AbilityRuntime.Core
-
-**System API**: This is a system API and cannot be called by third-party applications.
-
-**Parameters**
-
-| Name| Type| Mandatory| Description|
-| -------- | -------- | -------- | -------- |
-| want | [Want](js-apis-application-want.md) | Yes| Want information about the target ability.|
-| options | [ConnectOptions](js-apis-inner-ability-connectOptions.md) | Yes| Parameters for the connection.|
-
-**Return value**
-
-| Type| Description|
-| -------- | -------- |
-| number | Result code of the ability connection.|
-
-**Error codes**
-
-| ID| Error Message|
-| ------- | -------------------------------- |
-| 401 | If the input parameter is not valid parameter. |
-
-For details about the error codes, see [Ability Error Codes](../errorcodes/errorcode-ability.md).
-
-**Example**
-
- ```ts
- var want = {
- deviceId: "",
- bundleName: "com.example.myapplication",
- abilityName: "EntryAbility"
- };
- var options = {
- onConnect(elementName, remote) { console.log('----------- onConnect -----------') },
- onDisconnect(elementName) { console.log('----------- onDisconnect -----------') },
- onFailed(code) { console.log('----------- onFailed -----------') }
- }
-
- var connection = null;
- try {
- connection = this.context.connectServiceExtensionAbility(want, options);
- } catch (paramError) {
- // Process input parameter errors.
- console.log('error.code: ' + JSON.stringify(paramError.code) +
- ' error.message: ' + JSON.stringify(paramError.message));
- }
- ```
-
-
-## AbilityContext.connectServiceExtensionAbilityWithAccount
-
-connectServiceExtensionAbilityWithAccount(want: Want, accountId: number, options: ConnectOptions): number;
-
-Uses the **AbilityInfo.AbilityType.SERVICE** template to connect this ability to another ability with the account ID specified.
-
-**Required permissions**: ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS (required only when the account ID is not the current user)
-
-**System capability**: SystemCapability.Ability.AbilityRuntime.Core
-
-**System API**: This is a system API and cannot be called by third-party applications.
-
-**Parameters**
-
-| Name| Type| Mandatory| Description|
-| -------- | -------- | -------- | -------- |
-| want | [Want](js-apis-application-want.md) | Yes| Want information about the target ability.|
-| accountId | number | Yes| ID of a system account. For details, see [getCreatedOsAccountsCount](js-apis-osAccount.md#getosaccountlocalidfromprocess).|
-| options | [ConnectOptions](js-apis-inner-ability-connectOptions.md) | Yes| Parameters for the connection.|
-
-**Return value**
-
-| Type| Description|
-| -------- | -------- |
-| number | Result code of the ability connection.|
-
-**Error codes**
-
-| ID| Error Message|
-| ------- | -------------------------------- |
-| 401 | If the input parameter is not valid parameter. |
-
-For details about the error codes, see [Ability Error Codes](../errorcodes/errorcode-ability.md).
-
-**Example**
-
- ```ts
- var want = {
- deviceId: "",
- bundleName: "com.example.myapplication",
- abilityName: "EntryAbility"
- };
- var accountId = 100;
- var options = {
- onConnect(elementName, remote) { console.log('----------- onConnect -----------') },
- onDisconnect(elementName) { console.log('----------- onDisconnect -----------') },
- onFailed(code) { console.log('----------- onFailed -----------') }
- }
-
- var connection = null;
- try {
- connection = this.context.connectServiceExtensionAbilityWithAccount(want, accountId, options);
- } catch (paramError) {
- // Process input parameter errors.
- console.log('error.code: ' + JSON.stringify(paramError.code) +
- ' error.message: ' + JSON.stringify(paramError.message));
- }
- ```
-
-## AbilityContext.disconnectServiceExtensionAbility
-
-disconnectServiceExtensionAbility(connection: number): Promise\;
-
-Disconnects a connection. This API uses a promise to return the result.
-
-**System capability**: SystemCapability.Ability.AbilityRuntime.Core
-
-**Parameters**
-
-| Name| Type| Mandatory| Description|
-| -------- | -------- | -------- | -------- |
-| connection | number | Yes| Result code of the ability connection.|
-
-**Return value**
-
-| Type| Description|
-| -------- | -------- |
-| Promise\ | Promise used to return the result.|
-
-**Error codes**
-
-| ID| Error Message|
-| ------- | -------------------------------- |
-| 401 | If the input parameter is not valid parameter. |
-
-For details about the error codes, see [Ability Error Codes](../errorcodes/errorcode-ability.md).
-
-**Example**
-
- ```ts
- // connection is the return value of connectServiceExtensionAbility.
- var connection = 1;
-
- try {
- this.context.disconnectServiceExtensionAbility(connection)
- .then((data) => {
- // Carry out normal service processing.
- console.log('disconnectServiceExtensionAbility succeed');
- })
- .catch((error) => {
- // Process service logic errors.
- console.log('disconnectServiceExtensionAbility failed, error.code: ' + JSON.stringify(error.code) +
- ' error.message: ' + JSON.stringify(error.message));
- });
- } catch (paramError) {
- // Process input parameter errors.
- console.log('error.code: ' + JSON.stringify(paramError.code) +
- ' error.message: ' + JSON.stringify(paramError.message));
- }
- ```
-
-## AbilityContext.disconnectServiceExtensionAbility
-
-disconnectServiceExtensionAbility(connection: number, callback:AsyncCallback\): void;
-
-Disconnects a connection. This API uses an asynchronous callback to return the result.
-
-**System capability**: SystemCapability.Ability.AbilityRuntime.Core
-
-**Parameters**
-
-| Name| Type| Mandatory| Description|
-| -------- | -------- | -------- | -------- |
-| connection | number | Yes| Result code of the ability connection.|
-| callback | AsyncCallback\ | Yes| Callback used to return the result.|
-
-**Error codes**
-
-| ID| Error Message|
-| ------- | -------------------------------- |
-| 401 | If the input parameter is not valid parameter. |
-
-For details about the error codes, see [Ability Error Codes](../errorcodes/errorcode-ability.md).
-
-**Example**
-
- ```ts
- // connection is the return value of connectServiceExtensionAbility.
- var connection = 1;
-
- try {
- this.context.disconnectServiceExtensionAbility(connection, (error) => {
- if (error.code) {
- // Process service logic errors.
- console.log('disconnectServiceExtensionAbility failed, error.code: ' + JSON.stringify(error.code) +
- ' error.message: ' + JSON.stringify(error.message));
- return;
- }
- // Carry out normal service processing.
- console.log('disconnectServiceExtensionAbility succeed');
- });
- } catch (paramError) {
- // Process input parameter errors.
- console.log('error.code: ' + JSON.stringify(paramError.code) +
- ' error.message: ' + JSON.stringify(paramError.message));
- }
- ```
-
-## AbilityContext.startAbilityByCall
-
-startAbilityByCall(want: Want): Promise<Caller>;
-
-Starts an ability in the foreground or background and obtains the caller object for communicating with the ability.
-
-Observe the following when using this API:
- - If an application running in the background needs to call this API to start an ability, it must have the **ohos.permission.START_ABILITIES_FROM_BACKGROUND** permission.
- - If **visible** of the target ability is **false** in cross-application scenarios, the caller must have the **ohos.permission.START_INVISIBLE_ABILITY** permission.
- - The rules for using this API in the same-device and cross-device scenarios are different. For details, see [Component Startup Rules (Stage Model)](../../application-models/component-startup-rules.md).
-
-**System capability**: SystemCapability.Ability.AbilityRuntime.Core
-
-**System API**: This is a system API and cannot be called by third-party applications.
-
-**Parameters**
-
-| Name| Type| Mandatory| Description|
-| -------- | -------- | -------- | -------- |
-| want | [Want](js-apis-application-want.md) | Yes| Information about the ability to start, including **abilityName**, **moduleName**, **bundleName**, **deviceId** (optional), and **parameters** (optional). If **deviceId** is left blank or null, the local ability is started. If **parameters** is left blank or null, the ability is started in the background.|
-
-**Return value**
-
-| Type| Description|
-| -------- | -------- |
-| Promise<Caller> | Promise used to return the caller object to communicate with.|
-
-**Example**
-
- Start an ability in the background.
-
- ```ts
- var caller = undefined;
-
- // Start an ability in the background by not passing parameters.
- var wantBackground = {
- bundleName: "com.example.myservice",
- moduleName: "entry",
- abilityName: "EntryAbility",
- deviceId: ""
- };
-
- try {
- this.context.startAbilityByCall(wantBackground)
- .then((obj) => {
- // Carry out normal service processing.
- caller = obj;
- console.log('startAbilityByCall succeed');
- }).catch((error) => {
- // Process service logic errors.
- console.log('startAbilityByCall failed, error.code: ' + JSON.stringify(error.code) +
- ' error.message: ' + JSON.stringify(error.message));
- });
- } catch (paramError) {
- // Process input parameter errors.
- console.log('error.code: ' + JSON.stringify(paramError.code) +
- ' error.message: ' + JSON.stringify(paramError.message));
- }
- ```
-
- Start an ability in the foreground.
-
- ```ts
- var caller = undefined;
-
- // Start an ability in the foreground with ohos.aafwk.param.callAbilityToForeground in parameters set to true.
- var wantForeground = {
- bundleName: "com.example.myservice",
- moduleName: "entry",
- abilityName: "EntryAbility",
- deviceId: "",
- parameters: {
- "ohos.aafwk.param.callAbilityToForeground": true
- }
- };
-
- try {
- this.context.startAbilityByCall(wantForeground)
- .then((obj) => {
- // Carry out normal service processing.
- caller = obj;
- console.log('startAbilityByCall succeed');
- }).catch((error) => {
- // Process service logic errors.
- console.log('startAbilityByCall failed, error.code: ' + JSON.stringify(error.code) +
- ' error.message: ' + JSON.stringify(error.message));
- });
- } catch (paramError) {
- // Process input parameter errors.
- console.log('error.code: ' + JSON.stringify(paramError.code) +
- ' error.message: ' + JSON.stringify(paramError.message));
- }
- ```
-
-## AbilityContext.startAbilityWithAccount
-
-startAbilityWithAccount(want: Want, accountId: number, callback: AsyncCallback\): void;
-
-Starts an ability with the account ID specified. This API uses an asynchronous callback to return the result.
-
-Observe the following when using this API:
- - If an application running in the background needs to call this API to start an ability, it must have the **ohos.permission.START_ABILITIES_FROM_BACKGROUND** permission.
- - If **visible** of the target ability is **false** in cross-application scenarios, the caller must have the **ohos.permission.START_INVISIBLE_ABILITY** permission.
- - For details about the startup rules for the components in the stage model, see [Component Startup Rules (Stage Model)](../../application-models/component-startup-rules.md).
-
-**Required permissions**: ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS (required only when the account ID is not the current user)
-
-**System capability**: SystemCapability.Ability.AbilityRuntime.Core
-
-**System API**: This is a system API and cannot be called by third-party applications.
-
-**Parameters**
-
-| Name| Type| Mandatory| Description|
-| -------- | -------- | -------- | -------- |
-| want | [Want](js-apis-application-want.md) | Yes| Want information about the target ability.|
-| accountId | number | Yes| ID of a system account. For details, see [getCreatedOsAccountsCount](js-apis-osAccount.md#getosaccountlocalidfromprocess).|
-| callback | AsyncCallback\ | Yes| Callback used to return the result.|
-
-**Error codes**
-
-| ID| Error Message|
-| ------- | -------------------------------- |
-| 401 | If the input parameter is not valid parameter. |
-
-For details about the error codes, see [Ability Error Codes](../errorcodes/errorcode-ability.md).
-
-**Example**
-
- ```ts
- var want = {
- deviceId: "",
- bundleName: "com.example.myapplication",
- abilityName: "EntryAbility"
- };
- var accountId = 100;
-
- try {
- this.context.startAbilityWithAccount(want, accountId, (error) => {
- if (error.code) {
- // Process service logic errors.
- console.log('startAbilityWithAccount failed, error.code: ' + JSON.stringify(error.code) +
- ' error.message: ' + JSON.stringify(error.message));
- return;
- }
- // Carry out normal service processing.
- console.log('startAbilityWithAccount succeed');
- });
- } catch (paramError) {
- // Process input parameter errors.
- console.log('error.code: ' + JSON.stringify(paramError.code) +
- ' error.message: ' + JSON.stringify(paramError.message));
- }
- ```
-
-
-## AbilityContext.startAbilityWithAccount
-
-startAbilityWithAccount(want: Want, accountId: number, options: StartOptions, callback: AsyncCallback\): void;
-
-Starts an ability with the account ID and start options specified. This API uses an asynchronous callback to return the result.
-
-Observe the following when using this API:
- - If an application running in the background needs to call this API to start an ability, it must have the **ohos.permission.START_ABILITIES_FROM_BACKGROUND** permission.
- - If **visible** of the target ability is **false** in cross-application scenarios, the caller must have the **ohos.permission.START_INVISIBLE_ABILITY** permission.
- - For details about the startup rules for the components in the stage model, see [Component Startup Rules (Stage Model)](../../application-models/component-startup-rules.md).
-
-**Required permissions**: ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS (required only when the account ID is not the current user)
-
-**System capability**: SystemCapability.Ability.AbilityRuntime.Core
-
-**System API**: This is a system API and cannot be called by third-party applications.
-
-**Parameters**
-
-| Name| Type| Mandatory| Description|
-| -------- | -------- | -------- | -------- |
-| want | [Want](js-apis-application-want.md) | Yes| Want information about the target ability.|
-| accountId | number | Yes| ID of a system account. For details, see [getCreatedOsAccountsCount](js-apis-osAccount.md#getosaccountlocalidfromprocess).|
-| options | [StartOptions](js-apis-application-startOptions.md) | Yes| Parameters used for starting the ability.|
-| callback | AsyncCallback\ | Yes| Callback used to return the result.|
-
-**Error codes**
-
-| ID| Error Message|
-| ------- | -------------------------------- |
-| 401 | If the input parameter is not valid parameter. |
-
-For details about the error codes, see [Ability Error Codes](../errorcodes/errorcode-ability.md).
-
-**Example**
-
- ```ts
- var want = {
- deviceId: "",
- bundleName: "com.example.myapplication",
- abilityName: "EntryAbility"
- };
- var accountId = 100;
- var options = {
- windowMode: 0
- };
-
- try {
- this.context.startAbilityWithAccount(want, accountId, options, (error) => {
- if (error.code) {
- // Process service logic errors.
- console.log('startAbilityWithAccount failed, error.code: ' + JSON.stringify(error.code) +
- ' error.message: ' + JSON.stringify(error.message));
- return;
- }
- // Carry out normal service processing.
- console.log('startAbilityWithAccount succeed');
- });
- } catch (paramError) {
- // Process input parameter errors.
- console.log('error.code: ' + JSON.stringify(paramError.code) +
- ' error.message: ' + JSON.stringify(paramError.message));
- }
- ```
-
-
-## AbilityContext.startAbilityWithAccount
-
-startAbilityWithAccount(want: Want, accountId: number, options?: StartOptions): Promise\;
-
-Starts an ability with the account ID specified. This API uses a promise to return the result.
-
-Observe the following when using this API:
- - If an application running in the background needs to call this API to start an ability, it must have the **ohos.permission.START_ABILITIES_FROM_BACKGROUND** permission.
- - If **visible** of the target ability is **false** in cross-application scenarios, the caller must have the **ohos.permission.START_INVISIBLE_ABILITY** permission.
- - For details about the startup rules for the components in the stage model, see [Component Startup Rules (Stage Model)](../../application-models/component-startup-rules.md).
-
-**Required permissions**: ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS (required only when the account ID is not the current user)
-
-**System capability**: SystemCapability.Ability.AbilityRuntime.Core
-
-**System API**: This is a system API and cannot be called by third-party applications.
-
-**Parameters**
-
-| Name| Type| Mandatory| Description|
-| -------- | -------- | -------- | -------- |
-| want | [Want](js-apis-application-want.md) | Yes| Want information about the target ability.|
-| accountId | number | Yes| ID of a system account. For details, see [getCreatedOsAccountsCount](js-apis-osAccount.md#getosaccountlocalidfromprocess).|
-| options | [StartOptions](js-apis-application-startOptions.md) | No| Parameters used for starting the ability.|
-
-**Error codes**
-
-| ID| Error Message|
-| ------- | -------------------------------- |
-| 401 | If the input parameter is not valid parameter. |
-
-For details about the error codes, see [Ability Error Codes](../errorcodes/errorcode-ability.md).
-
-**Example**
-
- ```ts
- var want = {
- deviceId: "",
- bundleName: "com.example.myapplication",
- abilityName: "EntryAbility"
- };
- var accountId = 100;
- var options = {
- windowMode: 0
- };
-
- try {
- this.context.startAbilityWithAccount(want, accountId, options)
- .then((data) => {
- // Carry out normal service processing.
- console.log('startAbilityWithAccount succeed');
- })
- .catch((error) => {
- // Process service logic errors.
- console.log('startAbilityWithAccount failed, error.code: ' + JSON.stringify(error.code) +
- ' error.message: ' + JSON.stringify(error.message));
- });
- } catch (paramError) {
- // Process input parameter errors.
- console.log('error.code: ' + JSON.stringify(paramError.code) +
- ' error.message: ' + JSON.stringify(paramError.message));
- }
- ```
-
-## AbilityContext.setMissionLabel
-
-setMissionLabel(label: string, callback:AsyncCallback<void>): void;
-
-Sets a label for this ability in the mission. This API uses an asynchronous callback to return the result.
-
-**System capability**: SystemCapability.Ability.AbilityRuntime.Core
-
-**Parameters**
-
-| Name| Type| Mandatory| Description|
-| -------- | -------- | -------- | -------- |
-| label | string | Yes| Label of the ability to set.|
-| callback | AsyncCallback<void> | Yes| Callback used to return the result.|
-
-**Example**
-
- ```ts
- this.context.setMissionLabel("test",(result) => {
- console.log('setMissionLabel result:' + JSON.stringify(result));
- });
- ```
-
-
-## AbilityContext.setMissionLabel
-
-setMissionLabel(label: string): Promise<void>;
-
-Sets a label for this ability in the mission. This API uses a promise to return the result.
-
-**System capability**: SystemCapability.Ability.AbilityRuntime.Core
-
-**Parameters**
-
-| Name| Type| Mandatory| Description|
-| -------- | -------- | -------- | -------- |
-| label | string | Yes| Label of the ability to set.|
-
-**Return value**
-
-| Type| Description|
-| -------- | -------- |
-| Promise<void> | Promise used to return the result.|
-
-**Example**
-
- ```ts
- this.context.setMissionLabel("test").then(() => {
- console.log('success');
- }).catch((error) => {
- console.log('failed:' + JSON.stringify(error));
- });
- ```
-## AbilityContext.setMissionIcon
-
-setMissionIcon(icon: image.PixelMap, callback:AsyncCallback\): void;
-
-Sets an icon for this ability in the mission. This API uses an asynchronous callback to return the result.
-
-**System capability**: SystemCapability.Ability.AbilityRuntime.Core
-
-**System API**: This is a system API and cannot be called by third-party applications.
-
-**Parameters**
-
-| Name| Type| Mandatory| Description|
-| -------- | -------- | -------- | -------- |
-| icon | [image.PixelMap](js-apis-image.md#pixelmap7) | Yes| Icon of the ability to set.|
-| callback | AsyncCallback\ | Yes| Callback used to return the result.|
-
-**Example**
-
- ```ts
- import image from '@ohos.multimedia.image';
- var imagePixelMap;
- var color = new ArrayBuffer(0);
- var initializationOptions = {
- size: {
- height: 100,
- width: 100
- }
- };
- image.createPixelMap(color, initializationOptions)
- .then((data) => {
- imagePixelMap = data;
- })
- .catch((err) => {
- console.log('--------- createPixelMap fail, err: ---------', err)
- });
- this.context.setMissionIcon(imagePixelMap, (err) => {
- console.log('---------- setMissionIcon fail, err: -----------', err);
- })
- ```
-
-
-## AbilityContext.setMissionIcon
-
-setMissionIcon(icon: image.PixelMap): Promise\;
-
-Sets an icon for this ability in the mission. This API uses a promise to return the result.
-
-**System capability**: SystemCapability.Ability.AbilityRuntime.Core
-
-**System API**: This is a system API and cannot be called by third-party applications.
-
-**Parameters**
-
-| Name| Type| Mandatory| Description|
-| -------- | -------- | -------- | -------- |
-| icon | [image.PixelMap](js-apis-image.md#pixelmap7) | Yes| Icon of the ability to set.|
-
-**Return value**
-
-| Type| Description|
-| -------- | -------- |
-| Promise<void> | Promise used to return the result.|
-
-**Example**
-
- ```ts
- import image from '@ohos.multimedia.image';
- var imagePixelMap;
- var color = new ArrayBuffer(0);
- var initializationOptions = {
- size: {
- height: 100,
- width: 100
- }
- };
- image.createPixelMap(color, initializationOptions)
- .then((data) => {
- imagePixelMap = data;
- })
- .catch((err) => {
- console.log('--------- createPixelMap fail, err: ---------', err)
- });
- this.context.setMissionIcon(imagePixelMap)
- .then(() => {
- console.log('-------------- setMissionIcon success -------------');
- })
- .catch((err) => {
- console.log('-------------- setMissionIcon fail, err: -------------', err);
- });
- ```
-## AbilityContext.restoreWindowStage
-
-restoreWindowStage(localStorage: LocalStorage) : void;
-
-Restores the window stage data for this ability.
-
-**System capability**: SystemCapability.Ability.AbilityRuntime.Core
-
-**Parameters**
-
-| Name| Type| Mandatory| Description|
-| -------- | -------- | -------- | -------- |
-| localStorage | LocalStorage | Yes| Storage used to store the restored window stage.|
-
-**Example**
-
- ```ts
- var storage = new LocalStorage();
- this.context.restoreWindowStage(storage);
- ```
-
-## AbilityContext.isTerminating
-
-isTerminating(): boolean;
-
-Checks whether this ability is in the terminating state.
-
-**System capability**: SystemCapability.Ability.AbilityRuntime.Core
-
-**Return value**
-
-| Type| Description|
-| -------- | -------- |
-| boolean| The value **true** means that the ability is in the terminating state, and **false** means the opposite.|
-
-**Example**
-
- ```ts
- var isTerminating = this.context.isTerminating();
- console.log('ability state :' + isTerminating);
- ```
diff --git a/en/application-dev/reference/apis/js-apis-ability-dataUriUtils.md b/en/application-dev/reference/apis/js-apis-ability-dataUriUtils.md
index f1301ad877dcf5a0bd2fec5ad5be10452ee88716..0f098c2398a1a3559f3a25873a8fe2cc81c3a898 100644
--- a/en/application-dev/reference/apis/js-apis-ability-dataUriUtils.md
+++ b/en/application-dev/reference/apis/js-apis-ability-dataUriUtils.md
@@ -35,7 +35,7 @@ Obtains the ID attached to the end of a given URI.
**Example**
```ts
-let id = dataUriUtils.getId("com.example.dataUriUtils/1221");
+let id = dataUriUtils.getId('com.example.dataUriUtils/1221');
```
@@ -66,9 +66,9 @@ Attaches an ID to the end of a given URI.
```ts
let id = 1122;
let uri = dataUriUtils.attachId(
- "com.example.dataUriUtils",
+ 'com.example.dataUriUtils',
id,
-)
+);
```
@@ -96,7 +96,7 @@ Deletes the ID from the end of a given URI.
**Example**
```ts
-let uri = dataUriUtils.deleteId("com.example.dataUriUtils/1221")
+let uri = dataUriUtils.deleteId('com.example.dataUriUtils/1221');
```
@@ -127,7 +127,7 @@ Updates the ID in a given URI.
```ts
let id = 1122;
let uri = dataUriUtils.updateId(
- "com.example.dataUriUtils/1221",
+ 'com.example.dataUriUtils/1221',
id
-)
+);
```
diff --git a/en/application-dev/reference/apis/js-apis-ability-errorCode.md b/en/application-dev/reference/apis/js-apis-ability-errorCode.md
index dc0e8ae8928a9191f70b555e84a3f58b09e4b876..143a2344a935a013e664bde170ef615e0f6acfba 100644
--- a/en/application-dev/reference/apis/js-apis-ability-errorCode.md
+++ b/en/application-dev/reference/apis/js-apis-ability-errorCode.md
@@ -9,7 +9,7 @@ The **ErrorCode** module defines the error codes that may be returned when an ab
## Modules to Import
```ts
-import errorCode from '@ohos.ability.errorCode'
+import errorCode from '@ohos.ability.errorCode';
```
## ErrorCode
diff --git a/en/application-dev/reference/apis/js-apis-ability-wantConstant.md b/en/application-dev/reference/apis/js-apis-ability-wantConstant.md
index 87b52688c5bec0a80bc44d9c8dcba63fe00283f2..776faa162b5178cec3bf003aedc018c17ab17084 100644
--- a/en/application-dev/reference/apis/js-apis-ability-wantConstant.md
+++ b/en/application-dev/reference/apis/js-apis-ability-wantConstant.md
@@ -44,7 +44,7 @@ Enumerates the action constants of the **Want** object. **action** specifies the
| INTENT_PARAMS_INTENT | ability.want.params.INTENT | Action of displaying selection options with an action selector. |
| INTENT_PARAMS_TITLE | ability.want.params.TITLE | Title of the character sequence dialog box used with the action selector. |
| ACTION_FILE_SELECT7+ | ohos.action.fileSelect | Action of selecting a file. |
-| PARAMS_STREAM7+ | ability.params.stream | URI of the data stream associated with the target when the data is sent. |
+| PARAMS_STREAM7+ | ability.params.stream | URI of the data stream associated with the target when the data is sent. The value must be an array of the string type. |
| ACTION_APP_ACCOUNT_OAUTH 8+ | ohos.account.appAccount.action.oauth | Action of providing the OAuth service. |
| ACTION_APP_ACCOUNT_AUTH 9+ | account.appAccount.action.auth | Action of providing the authentication service. |
| ACTION_MARKET_DOWNLOAD 9+ | ohos.want.action.marketDownload | Action of downloading an application from the application market.
**System API**: This is a system API and cannot be called by third-party applications. |
diff --git a/en/application-dev/reference/apis/js-apis-app-ability-abilityManager.md b/en/application-dev/reference/apis/js-apis-app-ability-abilityManager.md
index 4f755c8fe2814c4b95e26e106712abc73845fb7d..e508a036945ffac70fd08862585a3d0ea5731aab 100644
--- a/en/application-dev/reference/apis/js-apis-app-ability-abilityManager.md
+++ b/en/application-dev/reference/apis/js-apis-app-ability-abilityManager.md
@@ -21,14 +21,14 @@ Enumerates the ability states. This enum can be used together with [AbilityRunni
**System API**: This enum is an internal definition of a system API and cannot be called by third-party applications.
-| Name| Value| Description|
+| Name| Value| Description|
| -------- | -------- | -------- |
-| INITIAL | 0 | The ability is in the initial state.|
-| FOCUS | 2 | The ability has the focus.|
-| FOREGROUND | 9 | The ability is in the foreground state. |
-| BACKGROUND | 10 | The ability is in the background state. |
-| FOREGROUNDING | 11 | The ability is in the state of being switched to the foreground. |
-| BACKGROUNDING | 12 | The ability is in the state of being switched to the background. |
+| INITIAL | 0 | The ability is in the initial state.|
+| FOCUS | 2 | The ability has the focus. |
+| FOREGROUND | 9 | The ability is in the foreground state. |
+| BACKGROUND | 10 | The ability is in the background state. |
+| FOREGROUNDING | 11 | The ability is in the state of being switched to the foreground. |
+| BACKGROUNDING | 12 | The ability is in the state of being switched to the background. |
## updateConfiguration
@@ -39,7 +39,7 @@ Updates the configuration. This API uses an asynchronous callback to return the
**Permission required**: ohos.permission.UPDATE_CONFIGURATION
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
-
+
**Parameters**
| Name | Type | Mandatory | Description |
@@ -64,7 +64,7 @@ const config = {
language: 'Zh-Hans', // Simplified Chinese.
colorMode: COLOR_MODE_LIGHT, // Light theme.
direction: DIRECTION_VERTICAL, // Vertical direction.
- screenDensity: SCREEN_DENSITY_SDPI, // The screen resolution is SDPI.
+ screenDensity: SCREEN_DENSITY_SDPI, // The screen pixel density is 'sdpi'.
displayId: 1, // The application is displayed on the display with ID 1.
hasPointerDevice: true, // A pointer device is connected.
};
@@ -76,7 +76,7 @@ try {
} else {
console.log('updateConfiguration success.');
}
- })
+ });
} catch (paramError) {
console.log('error.code: ' + JSON.stringify(paramError.code)
+ ' error.message: ' + JSON.stringify(paramError.message));
@@ -122,7 +122,7 @@ const config = {
language: 'Zh-Hans', // Simplified Chinese.
colorMode: COLOR_MODE_LIGHT, // Light theme.
direction: DIRECTION_VERTICAL, // Vertical direction.
- screenDensity: SCREEN_DENSITY_SDPI, // The screen resolution is SDPI.
+ screenDensity: SCREEN_DENSITY_SDPI, // The screen pixel density is 'sdpi'.
displayId: 1, // The application is displayed on the display with ID 1.
hasPointerDevice: true, // A pointer device is connected.
};
@@ -132,7 +132,7 @@ try {
console.log('updateConfiguration success.');
}).catch((err) => {
console.log('updateConfiguration fail, err: ' + JSON.stringify(err));
- })
+ });
} catch (paramError) {
console.log('error.code: ' + JSON.stringify(paramError.code)
+ ' error.message: ' + JSON.stringify(paramError.message));
@@ -153,7 +153,7 @@ Obtains the UIAbility running information. This API uses an asynchronous callbac
| Name | Type | Mandatory | Description |
| --------- | ---------------------------------------- | ---- | -------------- |
-| callback | AsyncCallback\> | Yes | Callback used to return the API call result and the UIAbility running information. You can perform error handling or custom processing in this callback. |
+| callback | AsyncCallback\> | Yes | Callback used to return the API call result and the UIAbility running information. You can perform error handling or custom processing in this callback. |
**Error codes**
@@ -274,7 +274,7 @@ try {
getExtensionRunningInfos(upperLimit: number): Promise\>
Obtains the ExtensionAbility running information. This API uses a promise to return the result.
-
+
**Required permissions**: ohos.permission.GET_RUNNING_INFO
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
@@ -311,7 +311,7 @@ try {
console.log('getExtensionRunningInfos success, data: ' + JSON.stringify(data));
}).catch((err) => {
console.log('getExtensionRunningInfos fail, err: ' + JSON.stringify(err));
- })
+ });
} catch (paramError) {
console.log('error.code: ' + JSON.stringify(paramError.code)
+ ' error.message: ' + JSON.stringify(paramError.message));
@@ -359,7 +359,7 @@ abilityManager.getTopAbility((err, data) => {
getTopAbility(): Promise\;
Obtains the top ability, which is the ability that has the window focus. This API uses a promise to return the result.
-
+
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
**Return value**
@@ -385,5 +385,5 @@ abilityManager.getTopAbility().then((data) => {
console.log('getTopAbility success, data: ' + JSON.stringify(data));
}).catch((err) => {
console.log('getTopAbility fail, err: ' + JSON.stringify(err));
-})
+});
```
diff --git a/en/application-dev/reference/apis/js-apis-app-ability-appManager.md b/en/application-dev/reference/apis/js-apis-app-ability-appManager.md
index 760fb188206cca471e89af5f9788a23e6e32c9a2..26873cfe82321bbb781672e0aac103d1adc328b8 100644
--- a/en/application-dev/reference/apis/js-apis-app-ability-appManager.md
+++ b/en/application-dev/reference/apis/js-apis-app-ability-appManager.md
@@ -45,7 +45,7 @@ appManager.isRunningInStabilityTest((err, flag) => {
} else {
console.log('The result of isRunningInStabilityTest is:' + JSON.stringify(flag));
}
-})
+});
```
@@ -151,7 +151,7 @@ appManager.isRamConstrainedDevice((err, data) => {
} else {
console.log('The result of isRamConstrainedDevice is:' + JSON.stringify(data));
}
-})
+});
```
## appManager.getAppMemorySize
@@ -221,7 +221,7 @@ appManager.getAppMemorySize((err, data) => {
} else {
console.log('The size of app memory is:' + JSON.stringify(data));
}
-})
+});
```
## appManager.getRunningProcessInformation
@@ -295,7 +295,7 @@ appManager.getRunningProcessInformation((err, data) => {
} else {
console.log('The process running information is:' + JSON.stringify(data));
}
-})
+});
```
## appManager.on
@@ -352,7 +352,7 @@ let applicationStateObserver = {
onProcessStateChanged(processData) {
console.log(`[appManager] onProcessStateChanged: ${JSON.stringify(processData)}`);
}
-}
+};
try {
const observerId = appManager.on('applicationState', applicationStateObserver);
console.log(`[appManager] observerCode: ${observerId}`);
@@ -416,7 +416,7 @@ let applicationStateObserver = {
onProcessStateChanged(processData) {
console.log(`[appManager] onProcessStateChanged: ${JSON.stringify(processData)}`);
}
-}
+};
let bundleNameList = ['bundleName1', 'bundleName2'];
try {
const observerId = appManager.on('applicationState', applicationStateObserver, bundleNameList);
@@ -478,7 +478,7 @@ let applicationStateObserver = {
onProcessStateChanged(processData) {
console.log(`[appManager] onProcessStateChanged: ${JSON.stringify(processData)}`);
}
-}
+};
let bundleNameList = ['bundleName1', 'bundleName2'];
try {
observerId = appManager.on('applicationState', applicationStateObserver, bundleNameList);
@@ -559,7 +559,7 @@ let applicationStateObserver = {
onProcessStateChanged(processData) {
console.log(`[appManager] onProcessStateChanged: ${JSON.stringify(processData)}`);
}
-}
+};
let bundleNameList = ['bundleName1', 'bundleName2'];
try {
observerId = appManager.on('applicationState', applicationStateObserver, bundleNameList);
@@ -574,7 +574,7 @@ try {
console.log('unregisterApplicationStateObserver success, data: ' + JSON.stringify(data));
}).catch((err) => {
console.log('unregisterApplicationStateObserver faile, err: ' + JSON.stringify(err));
- })
+ });
} catch (paramError) {
console.log('error: ' + paramError.code + ', ' + paramError.message);
}
@@ -660,7 +660,7 @@ appManager.getForegroundApplications().then((data) => {
console.log('getForegroundApplications success, data: ' + JSON.stringify(data));
}).catch((err) => {
console.log('getForegroundApplications fail, err: ' + JSON.stringify(err));
-})
+});
```
## appManager.killProcessWithAccount
@@ -702,7 +702,7 @@ try {
console.log('killProcessWithAccount success');
}).catch((err) => {
console.error('killProcessWithAccount fail, err: ' + JSON.stringify(err));
- })
+ });
} catch (paramError) {
console.error('error: ' + paramError.code + ', ' + paramError.message);
}
@@ -844,7 +844,7 @@ try {
console.log('killProcessesByBundleName success.');
}).catch((err) => {
console.log('killProcessesByBundleName fail, err: ' + JSON.stringify(err));
- })
+ });
} catch (paramError) {
console.log('error: ' + paramError.code + ', ' + paramError.message);
}
@@ -940,7 +940,7 @@ try {
console.log('clearUpApplicationData success.');
}).catch((err) => {
console.log('clearUpApplicationData fail, err: ' + JSON.stringify(err));
- })
+ });
} catch (paramError) {
console.log('error: ' + paramError.code + ', ' + paramError.message);
}
diff --git a/en/application-dev/reference/apis/js-apis-app-ability-appRecovery.md b/en/application-dev/reference/apis/js-apis-app-ability-appRecovery.md
index 8a5a840b0c6d9723c03ccdb988927f0f296e2971..49a0eb729af46a8426737d868e6138ffd42355ad 100644
--- a/en/application-dev/reference/apis/js-apis-app-ability-appRecovery.md
+++ b/en/application-dev/reference/apis/js-apis-app-ability-appRecovery.md
@@ -21,8 +21,8 @@ Enumerates the application restart flags. This enum is used as an input paramete
| Name | Value | Description |
| ---------- | ---- | ---------- |
| ALWAYS_RESTART | 0 | The application is restarted in all cases.|
-| RESTART_WHEN_JS_CRASH | 0x0001 | The application is restarted in the case of JS_CRASH.|
-| RESTART_WHEN_APP_FREEZE | 0x0002 | The application is restarted in the case of APP_FREEZE.|
+| RESTART_WHEN_JS_CRASH | 0x0001 | The application is restarted in the case of JS_CRASH. |
+| RESTART_WHEN_APP_FREEZE | 0x0002 | The application is restarted in the case of APP_FREEZE. |
| NO_RESTART | 0xFFFF | The application is not restarted in any case.|
## appRecovery.SaveOccasionFlag
diff --git a/en/application-dev/reference/apis/js-apis-app-ability-common.md b/en/application-dev/reference/apis/js-apis-app-ability-common.md
index 5cc9b61b90fb3072aacf530fdaee0ae2633f7ac0..deb8b546e79c77d02785bed821691602098f2280 100644
--- a/en/application-dev/reference/apis/js-apis-app-ability-common.md
+++ b/en/application-dev/reference/apis/js-apis-app-ability-common.md
@@ -10,7 +10,7 @@ The **Common** module provides all level-2 module APIs for developers to export.
## Modules to Import
```ts
-import common from '@ohos.app.ability.common'
+import common from '@ohos.app.ability.common';
```
**System capability**: SystemCapability.Ability.AbilityBase
@@ -33,7 +33,7 @@ import common from '@ohos.app.ability.common'
**Example**
```ts
-import common from '@ohos.app.ability.common'
+import common from '@ohos.app.ability.common';
let uiAbilityContext: common.UIAbilityContext;
let abilityStageContext: common.AbilityStageContext;
diff --git a/en/application-dev/reference/apis/js-apis-app-ability-configuration.md b/en/application-dev/reference/apis/js-apis-app-ability-configuration.md
index 88aab2d4026afac5edaf8c3c7ff58033976e3e66..8680cc4af5ec2f603ff15d6c6452a01d47d058f3 100644
--- a/en/application-dev/reference/apis/js-apis-app-ability-configuration.md
+++ b/en/application-dev/reference/apis/js-apis-app-ability-configuration.md
@@ -1,25 +1,19 @@
# @ohos.app.ability.Configuration (Configuration)
-The **Configuration** module defines environment change information.
+The **Configuration** module defines environment change information. **Configuration** is an interface definition and is used only for field declaration.
> **NOTE**
>
> The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version.
-## Modules to Import
-
-```ts
-import Configuration from '@ohos.app.ability.Configuration'
-```
-
**System capability**: SystemCapability.Ability.AbilityBase
- | Name| Type| Readable| Writable| Description|
+| Name| Type| Readable| Writable| Description|
| -------- | -------- | -------- | -------- | -------- |
| language | string | Yes| Yes| Language of the application, for example, **zh**.|
-| colorMode | [ColorMode](js-apis-app-ability-configurationConstant.md#configurationconstantcolormode) | Yes| Yes| Color mode, which can be **COLOR_MODE_LIGHT** or **COLOR_MODE_DARK**. The default value is **COLOR_MODE_LIGHT**.|
-| direction | [Direction](js-apis-app-ability-configurationConstant.md#configurationconstantdirection) | Yes| No| Screen orientation, which can be **DIRECTION_HORIZONTAL** or **DIRECTION_VERTICAL**.|
-| screenDensity | [ScreenDensity](js-apis-app-ability-configurationConstant.md#configurationconstantscreendensity) | Yes| No| Screen resolution, which can be **SCREEN_DENSITY_SDPI** (120), **SCREEN_DENSITY_MDPI** (160), **SCREEN_DENSITY_LDPI** (240), **SCREEN_DENSITY_XLDPI** (320), **SCREEN_DENSITY_XXLDPI** (480), or **SCREEN_DENSITY_XXXLDPI** (640).|
+| colorMode | [ColorMode](js-apis-app-ability-configurationConstant.md#configurationconstantcolormode) | Yes| Yes| Color mode. The default value is **COLOR_MODE_LIGHT**. The options are as follows:
- **COLOR_MODE_NOT_SET**: The color mode is not set.
- **COLOR_MODE_LIGHT**: light mode.
- **COLOR_MODE_DARK**: dark mode.|
+| direction | [Direction](js-apis-app-ability-configurationConstant.md#configurationconstantdirection) | Yes| No| Screen orientation. The options are as follows:
- **DIRECTION_NOT_SET**: The screen orientation is not set.
- **DIRECTION_HORIZONTAL**: horizontal direction.
- **DIRECTION_VERTICAL**: vertical direction.|
+| screenDensity | [ScreenDensity](js-apis-app-ability-configurationConstant.md#configurationconstantscreendensity) | Yes| No| Pixel density of the screen. The options are as follows:
- **SCREEN_DENSITY_NOT_SET**: The pixel density is not set.
- **SCREEN_DENSITY_SDPI**: 120.
- **SCREEN_DENSITY_MDPI**: 160.
- **SCREEN_DENSITY_LDPI**: 240.
- **SCREEN_DENSITY_XLDPI**: 320.
- **SCREEN_DENSITY_XXLDPI**: 480.
- **SCREEN_DENSITY_XXXLDPI**: 640.|
| displayId | number | Yes| No| ID of the display where the application is located.|
| hasPointerDevice | boolean | Yes| No| Whether a pointer device, such as a keyboard, mouse, or touchpad, is connected.|
@@ -34,7 +28,7 @@ For details about the fields, see the **ohos.app.ability.Configuration.d.ts** fi
onCreate(want, launchParam) {
let envCallback = {
onConfigurationUpdated(config) {
- console.info(`envCallback onConfigurationUpdated success: ${JSON.stringify(config)}`)
+ console.info(`envCallback onConfigurationUpdated success: ${JSON.stringify(config)}`);
let language = config.language;
let colorMode = config.colorMode;
let direction = config.direction;
@@ -45,10 +39,10 @@ For details about the fields, see the **ohos.app.ability.Configuration.d.ts** fi
};
try {
let applicationContext = this.context.getApplicationContext();
- let callbackId = applicationContext.on("environment", envCallback);
- console.log("callbackId: " + callbackId);
+ let callbackId = applicationContext.on('environment', envCallback);
+ console.log('callbackId: ' + callbackId);
} catch (paramError) {
- console.log("error: " + paramError.code + ", " + paramError.message);
+ console.log('error: ' + paramError.code + ', ' + paramError.message);
}
}
}
diff --git a/en/application-dev/reference/apis/js-apis-app-ability-configurationConstant.md b/en/application-dev/reference/apis/js-apis-app-ability-configurationConstant.md
index bd56e256603930f874c9ba2c064462c8fad594a8..7f7fd36c946eb19e33d5fb3649f105aafaae8d23 100644
--- a/en/application-dev/reference/apis/js-apis-app-ability-configurationConstant.md
+++ b/en/application-dev/reference/apis/js-apis-app-ability-configurationConstant.md
@@ -25,7 +25,7 @@ You can obtain the value of this constant by calling the **ConfigurationConstant
| COLOR_MODE_LIGHT | 1 | Light mode.|
-## ConfigurationConstant.Direction
+## ConfigurationConstant.Direction9+
You can obtain the value of this constant by calling the **ConfigurationConstant.Direction** API.
@@ -38,7 +38,7 @@ You can obtain the value of this constant by calling the **ConfigurationConstant
| DIRECTION_HORIZONTAL | 1 | Horizontal direction.|
-## ConfigurationConstant.ScreenDensity
+## ConfigurationConstant.ScreenDensity9+
You can obtain the value of this constant by calling the **ConfigurationConstant.ScreenDensity** API.
@@ -46,10 +46,10 @@ You can obtain the value of this constant by calling the **ConfigurationConstant
| Name| Value| Description|
| -------- | -------- | -------- |
-| SCREEN_DENSITY_NOT_SET | 0 | Unspecified screen resolution.|
-| SCREEN_DENSITY_SDPI | 120 | The screen resolution is sdpi.|
-| SCREEN_DENSITY_MDPI | 160 | The screen resolution is mdpi.|
-| SCREEN_DENSITY_LDPI | 240 | The screen resolution is ldpi.|
-| SCREEN_DENSITY_XLDPI | 320 | The screen resolution is xldpi.|
-| SCREEN_DENSITY_XXLDPI | 480 | The screen resolution is xxldpi.|
-| SCREEN_DENSITY_XXXLDPI | 640 | The screen resolution is xxxldpi.|
+| SCREEN_DENSITY_NOT_SET | 0 | The screen pixel density is not set.|
+| SCREEN_DENSITY_SDPI | 120 | The pixel density of the screen is 'sdpi'.|
+| SCREEN_DENSITY_MDPI | 160 | The pixel density of the screen is 'mdpi'.|
+| SCREEN_DENSITY_LDPI | 240 | The pixel density of the screen is 'ldpi'.|
+| SCREEN_DENSITY_XLDPI | 320 | The pixel density of the screen is 'xldpi'.|
+| SCREEN_DENSITY_XXLDPI | 480 | The pixel density of the screen is 'xxldpi'.|
+| SCREEN_DENSITY_XXXLDPI | 640 | The pixel density of the screen is 'xxxldpi'.|
diff --git a/en/application-dev/reference/apis/js-apis-app-ability-environmentCallback.md b/en/application-dev/reference/apis/js-apis-app-ability-environmentCallback.md
index 0cb95a9abfd6b90f1efacc431070ef6b3397e1e6..e20f8ac51c0e12e56bc31a7f21ee76a763e0fc6a 100644
--- a/en/application-dev/reference/apis/js-apis-app-ability-environmentCallback.md
+++ b/en/application-dev/reference/apis/js-apis-app-ability-environmentCallback.md
@@ -11,7 +11,7 @@ The **EnvironmentCallback** module provides the **onConfigurationUpdated** API f
## Modules to Import
```ts
-import EnvironmentCallback from "@ohos.app.ability.EnvironmentCallback";
+import EnvironmentCallback from '@ohos.app.ability.EnvironmentCallback';
```
@@ -29,33 +29,50 @@ Called when the system environment changes.
| -------- | -------- | -------- | -------- |
| config | [Configuration](js-apis-app-ability-configuration.md) | Yes| **Configuration** object after the change.|
+## EnvironmentCallback.onMemoryLevel
+
+onMemoryLevel(level: AbilityConstant.MemoryLevel): void;
+
+Called when the system memory level changes.
+
+**System capability**: SystemCapability.Ability.AbilityRuntime.Core
+
+**Parameters**
+
+ | Name| Type| Mandatory| Description|
+ | -------- | -------- | -------- | -------- |
+ | level | [AbilityConstant.MemoryLevel](js-apis-app-ability-abilityConstant.md#abilityconstantmemorylevel) | Yes| Memory level that indicates the memory usage status. When the specified memory level is reached, a callback will be invoked and the system will start adjustment.|
+
**Example**
```ts
-import UIAbility from "@ohos.app.ability.Ability";
+import Ability from '@ohos.application.Ability';
-var callbackId;
+let callbackId;
-export default class MyAbility extends UIAbility {
+export default class MyAbility extends Ability {
onCreate() {
- console.log("MyAbility onCreate")
+ console.log('MyAbility onCreate');
globalThis.applicationContext = this.context.getApplicationContext();
let EnvironmentCallback = {
onConfigurationUpdated(config){
- console.log("onConfigurationUpdated config:" + JSON.stringify(config));
+ console.log('onConfigurationUpdated config:' + JSON.stringify(config));
+ },
+ onMemoryLevel(level){
+ console.log('onMemoryLevel level: ${JSON.stringify(level)}');
}
- }
+ };
// 1. Obtain an applicationContext object.
let applicationContext = globalThis.applicationContext;
// 2. Register a listener for the environment changes through the applicationContext object.
callbackId = applicationContext.registerEnvironmentCallback(EnvironmentCallback);
- console.log("registerEnvironmentCallback number: " + JSON.stringify(callbackId));
+ console.log('registerEnvironmentCallback number: ' + JSON.stringify(callbackId));
}
onDestroy() {
let applicationContext = globalThis.applicationContext;
applicationContext.unregisterEnvironmentCallback(callbackId, (error, data) => {
- console.log("unregisterEnvironmentCallback success, err: " + JSON.stringify(error));
+ console.log('unregisterEnvironmentCallback success, err: ' + JSON.stringify(error));
});
}
}
diff --git a/en/application-dev/reference/apis/js-apis-app-ability-errorManager.md b/en/application-dev/reference/apis/js-apis-app-ability-errorManager.md
index e543a93e9ceb5af52f3cdb939a0cfd5d24145968..3cb86447fa75d12370004a0393521cc0f53aa755 100644
--- a/en/application-dev/reference/apis/js-apis-app-ability-errorManager.md
+++ b/en/application-dev/reference/apis/js-apis-app-ability-errorManager.md
@@ -1,19 +1,19 @@
# @ohos.app.ability.errorManager (ErrorManager)
-The **ErrorManager** module provides APIs for registering and deregistering error observers. For example, you can use the APIs to register an observer when your application wants to capture JS crashes.
+The **ErrorManager** module provides APIs for registering and deregistering error observers.
> **NOTE**
>
> The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version.
## Modules to Import
-```ts
+```
import errorManager from '@ohos.app.ability.errorManager'
```
## ErrorManager.on
-on(type: "error", observer: ErrorObserver): number;
+on(type: 'error', observer: ErrorObserver): number;
Registers an error observer.
@@ -23,34 +23,27 @@ Registers an error observer.
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
-| type | string | Yes| Type of the API to call. It is fixed at **"error"**.|
+| type | string | Yes| Type of the API to call.|
| observer | [ErrorObserver](./js-apis-inner-application-errorObserver.md) | Yes| Digital code of the observer.|
-**Return value**
-
- | Type| Description|
- | -------- | -------- |
- | number | Index of the observer.|
-
**Example**
-```ts
-var observer = {
+```js
+let observer = {
onUnhandledException(errorMsg) {
console.log('onUnhandledException, errorMsg: ', errorMsg)
}
-}
-var observerId = -1;
+};
try {
- observerId = errorManager.on("error", observer);
+ errorManager.on('error', observer);
} catch (paramError) {
- console.log("error: " + paramError.code + ", " + paramError.message);
+ console.log('error: ' + paramError.code + ', ' + paramError.message);
}
```
## ErrorManager.off
-off(type: "error", observerId: number, callback: AsyncCallback\): void;
+off(type: 'error', observerId: number, callback: AsyncCallback\): void;
Deregisters an error observer. This API uses an asynchronous callback to return the result.
@@ -60,14 +53,14 @@ Deregisters an error observer. This API uses an asynchronous callback to return
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
-| type | string | Yes| Type of the API to call. It is fixed at **"error"**.|
-| observerId | number | Yes| Index of the observer returned by **on()**.|
+| type | string | Yes| Type of the API to call.|
+| observerId | number | Yes| Digital code of the observer.|
| callback | AsyncCallback\ | Yes| Callback used to return the result.|
**Example**
-```ts
-var observerId = 100;
+```js
+let observerId = 100;
function unregisterErrorObserverCallback(err) {
if (err) {
@@ -75,15 +68,15 @@ function unregisterErrorObserverCallback(err) {
}
}
try {
- errorManager.off("error", observerId, unregisterErrorObserverCallback);
+ errorManager.off('error', observerId, unregisterErrorObserverCallback);
} catch (paramError) {
- console.log("error: " + paramError.code + ", " + paramError.message);
+ console.log('error: ' + paramError.code + ', ' + paramError.message);
}
```
## ErrorManager.off
-off(type: "error", observerId: number): Promise\;
+off(type: 'error', observerId: number): Promise\;
Deregisters an error observer. This API uses a promise to return the result.
@@ -93,8 +86,8 @@ Deregisters an error observer. This API uses a promise to return the result.
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
-| type | string | Yes| Type of the API to call. It is fixed at **"error"**.|
-| observerId | number | Yes| Index of the observer returned by **on()**.|
+| type | string | Yes| Type of the API to call.|
+| observerId | number | Yes| Digital code of the observer.|
**Return value**
@@ -104,18 +97,18 @@ Deregisters an error observer. This API uses a promise to return the result.
**Example**
-```ts
-var observerId = 100;
+```js
+let observerId = 100;
try {
- errorManager.off("error", observerId)
+ errorManager.off('error', observerId)
.then((data) => {
console.log('----------- unregisterErrorObserver success ----------', data);
})
.catch((err) => {
console.log('----------- unregisterErrorObserver fail ----------', err);
- })
+ });
} catch (paramError) {
- console.log("error: " + paramError.code + ", " + paramError.message);
+ console.log('error: ' + paramError.code + ', ' + paramError.message);
}
```
diff --git a/en/application-dev/reference/apis/js-apis-app-ability-missionManager.md b/en/application-dev/reference/apis/js-apis-app-ability-missionManager.md
index 434fb19383e072a36352012300c2a755769d6c1f..4448d79d41f3721b0d218a749757494bb65deb2f 100644
--- a/en/application-dev/reference/apis/js-apis-app-ability-missionManager.md
+++ b/en/application-dev/reference/apis/js-apis-app-ability-missionManager.md
@@ -18,7 +18,7 @@ ohos.permission.MANAGE_MISSIONS
## missionManager.on
-on(type:"mission", listener: MissionListener): number;
+on(type:'mission', listener: MissionListener): number;
Registers a listener to observe the mission status.
@@ -43,69 +43,26 @@ Registers a listener to observe the mission status.
**Example**
```ts
-import missionManager from '@ohos.app.ability.missionManager';
-import UIAbility from '@ohos.app.ability.UIAbility';
-
-var listener = {
- onMissionCreated: function (mission) {console.log("--------onMissionCreated-------")},
- onMissionDestroyed: function (mission) {console.log("--------onMissionDestroyed-------")},
- onMissionSnapshotChanged: function (mission) {console.log("--------onMissionSnapshotChanged-------")},
- onMissionMovedToFront: function (mission) {console.log("--------onMissionMovedToFront-------")},
- onMissionIconUpdated: function (mission, icon) {console.log("--------onMissionIconUpdated-------")},
- onMissionClosed: function (mission) {console.log("--------onMissionClosed-------")},
- onMissionLabelUpdated: function (mission) {console.log("--------onMissionLabelUpdated-------")}
-};
-
-var listenerId = -1;
-
-export default class EntryAbility extends UIAbility {
- onCreate(want, launchParam) {
- console.log("[Demo] EntryAbility onCreate");
- globalThis.abilityWant = want;
- globalThis.context = this.context;
- }
-
- onDestroy() {
- try {
- if (listenerId != -1) {
- missionManager.off("mission", listenerId).catch(function (err) {
- console.log(err);
- });
- }
- } catch (paramError) {
- console.log("error: " + paramError.code + ", " + paramError.message);
- }
- console.log("[Demo] EntryAbility onDestroy")
- }
-
- onWindowStageCreate(windowStage) {
- // The main window is created. Set a main page for this ability.
- console.log("[Demo] EntryAbility onWindowStageCreate")
- try {
- listenerId = missionManager.on("mission", listener);
- } catch (paramError) {
- console.log("error: " + paramError.code + ", " + paramError.message);
- }
-
- windowStage.loadContent("pages/index", (err, data) => {
- if (err.code) {
- console.error('Failed to load the content. Cause:' + JSON.stringify(err));
- return;
- }
- console.info('Succeeded in loading the content. Data: ' + JSON.stringify(data))
- });
-
- if (globalThis.flag) {
- return;
- }
- }
-};
+ let listener = {
+ onMissionCreated: function (mission) {console.log('--------onMissionCreated-------');},
+ onMissionDestroyed: function (mission) {console.log('--------onMissionDestroyed-------');},
+ onMissionSnapshotChanged: function (mission) {console.log('--------onMissionSnapshotChanged-------');},
+ onMissionMovedToFront: function (mission) {console.log('--------onMissionMovedToFront-------');},
+ onMissionIconUpdated: function (mission, icon) {console.log('--------onMissionIconUpdated-------');},
+ onMissionClosed: function (mission) {console.log('--------onMissionClosed-------');}
+ };
+ console.log('registerMissionListener');
+ try {
+ let listenerid = missionManager.on('mission', listener);
+ } catch (paramError) {
+ console.log('error: ' + paramError.code + ', ' + paramError.message);
+ }
```
## missionManager.off
-off(type: "mission", listenerId: number, callback: AsyncCallback<void>): void;
+off(type: 'mission', listenerId: number, callback: AsyncCallback<void>): void;
Deregisters a mission status listener.
@@ -119,75 +76,36 @@ Deregisters a mission status listener.
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
- | listenerId | number | Yes| Index of the mission status listener to deregister. It is returned by **on()**.|
+ | listenerId | number | Yes| Index of the mission status listener to deregister. It is returned by **registerMissionListener()**.|
| callback | AsyncCallback<void> | Yes| Callback used to return the result.|
**Example**
```ts
-import missionManager from '@ohos.app.ability.missionManager';
-import UIAbility from '@ohos.app.ability.UIAbility';
-
-var listener = {
- onMissionCreated: function (mission) {console.log("--------onMissionCreated-------")},
- onMissionDestroyed: function (mission) {console.log("--------onMissionDestroyed-------")},
- onMissionSnapshotChanged: function (mission) {console.log("--------onMissionSnapshotChanged-------")},
- onMissionMovedToFront: function (mission) {console.log("--------onMissionMovedToFront-------")},
- onMissionIconUpdated: function (mission, icon) {console.log("--------onMissionIconUpdated-------")},
- onMissionClosed: function (mission) {console.log("--------onMissionClosed-------")},
- onMissionLabelUpdated: function (mission) {console.log("--------onMissionLabelUpdated-------")}
-};
-
-var listenerId = -1;
-
-export default class EntryAbility extends UIAbility {
- onCreate(want, launchParam) {
- console.log("[Demo] EntryAbility onCreate")
- globalThis.abilityWant = want;
- globalThis.context = this.context;
- }
-
- onDestroy() {
- try {
- if (listenerId != -1) {
- missionManager.off("mission", listenerId, (err) => {
- console.log(err);
- });
- }
- } catch (paramError) {
- console.log("error: " + paramError.code + ", " + paramError.message);
- }
- console.log("[Demo] EntryAbility onDestroy")
- }
-
- onWindowStageCreate(windowStage) {
- // The main window is created. Set a main page for this ability.
- console.log("[Demo] EntryAbility onWindowStageCreate")
- try {
- listenerId = missionManager.on("mission", listener);
- } catch (paramError) {
- console.log("error: " + paramError.code + ", " + paramError.message);
- }
-
- windowStage.loadContent("pages/index", (err, data) => {
- if (err.code) {
- console.error('Failed to load the content. Cause:' + JSON.stringify(err));
- return;
- }
- console.info('Succeeded in loading the content. Data: ' + JSON.stringify(data))
- });
-
- if (globalThis.flag) {
- return;
- }
- }
-};
+ let listener = {
+ onMissionCreated: function (mission) {console.log('--------onMissionCreated-------');},
+ onMissionDestroyed: function (mission) {console.log('--------onMissionDestroyed-------');},
+ onMissionSnapshotChanged: function (mission) {console.log('--------onMissionSnapshotChanged-------');},
+ onMissionMovedToFront: function (mission) {console.log('--------onMissionMovedToFront-------');},
+ onMissionIconUpdated: function (mission, icon) {console.log('--------onMissionIconUpdated-------');},
+ onMissionClosed: function (mission) {console.log('--------onMissionClosed-------');}
+ };
+ console.log('registerMissionListener');
+ try {
+ let listenerid = missionManager.registerMissionListener(listener);
+
+ missionManager.unregisterMissionListener(listenerid, (error) => {
+ console.log('unregisterMissionListener');
+ });
+ } catch (paramError) {
+ console.log('error: ' + paramError.code + ', ' + paramError.message);
+ }
```
## missionManager.off
-off(type: "mission", listenerId: number): Promise<void>;
+off(type: 'mission', listenerId: number): Promise<void>;
Deregisters a mission status listener. This API uses a promise to return the result.
@@ -201,7 +119,7 @@ Deregisters a mission status listener. This API uses a promise to return the res
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
- | listenerId | number | Yes| Index of the mission status listener to deregister. It is returned by **on()**.|
+ | listenerId | number | Yes| Index of the mission status listener to deregister. It is returned by **registerMissionListener()**.|
**Return value**
@@ -212,63 +130,24 @@ Deregisters a mission status listener. This API uses a promise to return the res
**Example**
```ts
-import missionManager from '@ohos.app.ability.missionManager';
-import UIAbility from '@ohos.app.ability.UIAbility';
-
-var listener = {
- onMissionCreated: function (mission) {console.log("--------onMissionCreated-------")},
- onMissionDestroyed: function (mission) {console.log("--------onMissionDestroyed-------")},
- onMissionSnapshotChanged: function (mission) {console.log("--------onMissionSnapshotChanged-------")},
- onMissionMovedToFront: function (mission) {console.log("--------onMissionMovedToFront-------")},
- onMissionIconUpdated: function (mission, icon) {console.log("--------onMissionIconUpdated-------")},
- onMissionClosed: function (mission) {console.log("--------onMissionClosed-------")},
- onMissionLabelUpdated: function (mission) {console.log("--------onMissionLabelUpdated-------")}
-};
-
-var listenerId = -1;
-
-export default class EntryAbility extends UIAbility {
- onCreate(want, launchParam) {
- console.log("[Demo] EntryAbility onCreate")
- globalThis.abilityWant = want;
- globalThis.context = this.context;
- }
-
- onDestroy() {
- try {
- if (listenerId != -1) {
- missionManager.off("mission", listenerId).catch(function (err) {
- console.log(err);
- });
- }
- } catch (paramError) {
- console.log("error: " + paramError.code + ", " + paramError.message);
- }
- console.log("[Demo] EntryAbility onDestroy")
- }
-
- onWindowStageCreate(windowStage) {
- // The main window is created. Set a main page for this ability.
- console.log("[Demo] EntryAbility onWindowStageCreate")
- try {
- listenerId = missionManager.on("mission", listener);
- } catch (paramError) {
- console.log("error: " + paramError.code + ", " + paramError.message);
- }
-
- windowStage.loadContent("pages/index", (err, data) => {
- if (err.code) {
- console.error('Failed to load the content. Cause:' + JSON.stringify(err));
- return;
- }
- console.info('Succeeded in loading the content. Data: ' + JSON.stringify(data))
- });
-
- if (globalThis.flag) {
- return;
- }
- }
-};
+ let listener = {
+ onMissionCreated: function (mission) {console.log('--------onMissionCreated-------');},
+ onMissionDestroyed: function (mission) {console.log('--------onMissionDestroyed-------');},
+ onMissionSnapshotChanged: function (mission) {console.log('--------onMissionSnapshotChanged-------');},
+ onMissionMovedToFront: function (mission) {console.log('--------onMissionMovedToFront-------');},
+ onMissionIconUpdated: function (mission, icon) {console.log('--------onMissionIconUpdated-------');},
+ onMissionClosed: function (mission) {console.log('--------onMissionClosed-------');}
+ };
+ console.log('registerMissionListener');
+ try {
+ let listenerid = missionManager.registerMissionListener(listener);
+
+ missionManager.unregisterMissionListener(listenerid).catch(function (err) {
+ console.log(err);
+ });
+ } catch (paramError) {
+ console.log('error: ' + paramError.code + ', ' + paramError.message);
+ }
```
@@ -297,28 +176,19 @@ Obtains the information about a given mission. This API uses an asynchronous cal
```ts
import missionManager from '@ohos.app.ability.missionManager';
- let testMissionId = 1;
try {
- var allMissions=await missionManager.getMissionInfos("",10).catch(function(err){console.log(err);});
- if (allMissions && allMissions.length > 0) {
- testMissionId = allMissions[0].missionId;
- }
-
- missionManager.getMissionInfo("", testMissionId, (error, mission) => {
- if (error) {
- console.log("getMissionInfo failed, error.code:" + JSON.stringify(error.code) +
- "error.message:" + JSON.stringify(error.message));
- } else {
- console.log("mission.missionId = " + mission.missionId);
- console.log("mission.runningState = " + mission.runningState);
- console.log("mission.lockedState = " + mission.lockedState);
- console.log("mission.timestamp = " + mission.timestamp);
- console.log("mission.label = " + mission.label);
- console.log("mission.iconPath = " + mission.iconPath);
- }
- });
+ let allMissions=missionManager.getMissionInfos('',10).catch(function(err){console.log(err);});
+ missionManager.getMissionInfo('', allMissions[0].missionId, (error, mission) => {
+ console.log('getMissionInfo is called, error.code = ' + error.code);
+ console.log('mission.missionId = ' + mission.missionId);
+ console.log('mission.runningState = ' + mission.runningState);
+ console.log('mission.lockedState = ' + mission.lockedState);
+ console.log('mission.timestamp = ' + mission.timestamp);
+ console.log('mission.label = ' + mission.label);
+ console.log('mission.iconPath = ' + mission.iconPath);
+ });
} catch (paramError) {
- console.log("error: " + paramError.code + ", " + paramError.message);
+ console.log('error: ' + paramError.code + ', ' + paramError.message);
}
```
@@ -350,20 +220,18 @@ Obtains the information about a given mission. This API uses a promise to return
**Example**
-```ts
-import missionManager from '@ohos.app.ability.missionManager';
+ ```ts
+ import missionManager from '@ohos.app.ability.missionManager';
-let testMissionId = 1;
-try {
- missionManager.getMissionInfo("", testMissionId).then((data) => {
- console.info('getMissionInfo successfully. Data: ' + JSON.stringify(data));
- }).catch(error => {
- console.error('getMissionInfo failed. Cause: ' + error.message);
+ try {
+ let mission = missionManager.getMissionInfo('', 10).catch(function (err){
+ console.log(err);
});
-} catch (error) {
- console.error('getMissionInfo failed. Cause: ' + error.message);
-}
-```
+ } catch (paramError) {
+ console.log('error: ' + paramError.code + ', ' + paramError.message);
+ }
+ ```
+
## missionManager.getMissionInfos
@@ -391,17 +259,13 @@ Obtains information about all missions. This API uses an asynchronous callback t
import missionManager from '@ohos.app.ability.missionManager';
try {
- missionManager.getMissionInfos("", 10, (error, missions) => {
- if (error) {
- console.log("getMissionInfos failed, error.code:" + JSON.stringify(error.code) +
- "error.message:" + JSON.stringify(error.message));
- } else {
- console.log("size = " + missions.length);
- console.log("missions = " + JSON.stringify(missions));
- }
- })
+ missionManager.getMissionInfos('', 10, (error, missions) => {
+ console.log('getMissionInfos is called, error.code = ' + error.code);
+ console.log('size = ' + missions.length);
+ console.log('missions = ' + JSON.stringify(missions));
+ });
} catch (paramError) {
- console.log("error: " + paramError.code + ", " + paramError.message);
+ console.log('error: ' + paramError.code + ', ' + paramError.message);
}
```
@@ -433,19 +297,18 @@ Obtains information about all missions. This API uses a promise to return the re
**Example**
-```ts
-import missionManager from '@ohos.app.ability.missionManager';
+ ```ts
+ import missionManager from '@ohos.app.ability.missionManager';
-try {
- missionManager.getMissionInfos("", 10).then((data) => {
- console.info('getMissionInfos successfully. Data: ' + JSON.stringify(data));
- }).catch(error => {
- console.error('getMissionInfos failed. Cause: ' + error.message);
+ try {
+ let allMissions = missionManager.getMissionInfos('', 10).catch(function (err){
+ console.log(err);
});
-} catch (error) {
- console.error('getMissionInfos failed. Cause: ' + error.message);
-}
-```
+ } catch (paramError) {
+ console.log('error: ' + paramError.code + ', ' + paramError.message);
+ }
+ ```
+
## missionManager.getMissionSnapShot
@@ -468,22 +331,27 @@ Obtains the snapshot of a given mission. This API uses an asynchronous callback
| callback | AsyncCallback<[MissionSnapshot](js-apis-inner-application-missionSnapshot.md)> | Yes| Callback used to return the snapshot information obtained.|
**Example**
-```ts
-import missionManager from '@ohos.app.ability.missionManager';
-let testMissionId = 2;
-try {
- missionManager.getMissionSnapShot("", testMissionId, (err, data) => {
- if (err) {
- console.error('getMissionSnapShot failed:' + err.message);
- } else {
- console.info('getMissionSnapShot successfully:' + JSON.stringify(data));
- }
+ ```ts
+ import missionManager from '@ohos.app.ability.missionManager';
+
+ try {
+ missionManager.getMissionInfos('', 10, (error, missions) => {
+ console.log('getMissionInfos is called, error.code = ' + error.code);
+ console.log('size = ' + missions.length);
+ console.log('missions = ' + JSON.stringify(missions));
+ let id = missions[0].missionId;
+
+ missionManager.getMissionSnapShot('', id, (error, snapshot) => {
+ console.log('getMissionSnapShot is called, error.code = ' + error.code);
+ console.log('bundleName = ' + snapshot.ability.bundleName);
+ });
});
-} catch (err) {
- console.error('getMissionSnapShot failed:' + err.message);
-}
-```
+ } catch (paramError) {
+ console.log('error: ' + paramError.code + ', ' + paramError.message);
+ }
+ ```
+
## missionManager.getMissionSnapShot
@@ -511,20 +379,26 @@ Obtains the snapshot of a given mission. This API uses a promise to return the r
| Promise<[MissionSnapshot](js-apis-inner-application-missionSnapshot.md)> | Promise used to return the snapshot information obtained.|
**Example**
-```ts
-import missionManager from '@ohos.app.ability.missionManager';
-let testMissionId = 2;
-try {
- missionManager.getMissionSnapShot("", testMissionId).then((data) => {
- console.info('getMissionSnapShot successfully. Data: ' + JSON.stringify(data));
- }).catch(error => {
- console.error('getMissionSnapShot failed. Cause: ' + error.message);
- });
-} catch (error) {
- console.error('getMissionSnapShot failed. Cause: ' + error.message);
-}
-```
+ ```ts
+ import missionManager from '@ohos.app.ability.missionManager';
+
+ try {
+ let allMissions;
+ missionManager.getMissionInfos('',10).then(function(res){
+ allMissions=res;
+ }).catch(function(err){console.log(err);});
+ console.log('size = ' + allMissions.length);
+ console.log('missions = ' + JSON.stringify(allMissions));
+ let id = allMissions[0].missionId;
+
+ let snapshot = missionManager.getMissionSnapShot('', id).catch(function (err){
+ console.log(err);
+ });
+ } catch (paramError) {
+ console.log('error: ' + paramError.code + ', ' + paramError.message);
+ }
+ ```
## missionManager.getLowResolutionMissionSnapShot
@@ -547,22 +421,27 @@ Obtains the low-resolution snapshot of a given mission. This API uses an asynchr
| callback | AsyncCallback<[MissionSnapshot](js-apis-inner-application-missionSnapshot.md)> | Yes| Callback used to return the snapshot information obtained.|
**Example**
-```ts
-import missionManager from '@ohos.app.ability.missionManager';
-let testMissionId = 2;
-try {
- missionManager.getLowResolutionMissionSnapShot("", testMissionId, (err, data) => {
- if (err) {
- console.error('getLowResolutionMissionSnapShot failed:' + err.message);
- } else {
- console.info('getLowResolutionMissionSnapShot successfully:' + JSON.stringify(data));
- }
+ ```ts
+ import missionManager from '@ohos.app.ability.missionManager';
+
+ try {
+ missionManager.getMissionInfos('', 10, (error, missions) => {
+ console.log('getMissionInfos is called, error.code = ' + error.code);
+ console.log('size = ' + missions.length);
+ console.log('missions = ' + JSON.stringify(missions));
+ let id = missions[0].missionId;
+
+ missionManager.getLowResolutionMissionSnapShot('', id, (error, snapshot) => {
+ console.log('getLowResolutionMissionSnapShot is called, error.code = ' + error.code);
+ console.log('bundleName = ' + snapshot.ability.bundleName);
+ });
});
-} catch (err) {
- console.error('getLowResolutionMissionSnapShot failed:' + err.message);
-}
-```
+ } catch (paramError) {
+ console.log('error: ' + paramError.code + ', ' + paramError.message);
+ }
+ ```
+
## missionManager.getLowResolutionMissionSnapShot
@@ -591,20 +470,25 @@ Obtains the low-resolution snapshot of a given mission. This API uses a promise
**Example**
-```ts
-import missionManager from '@ohos.app.ability.missionManager';
+ ```ts
+ import missionManager from '@ohos.app.ability.missionManager';
-let testMissionId = 2;
-try {
- missionManager.getLowResolutionMissionSnapShot("", testMissionId).then((data) => {
- console.info('getLowResolutionMissionSnapShot successfully. Data: ' + JSON.stringify(data));
- }).catch(error => {
- console.error('getLowResolutionMissionSnapShot failed. Cause: ' + error.message);
- });
-} catch (error) {
- console.error('getLowResolutionMissionSnapShot failed. Cause: ' + error.message);
-}
-```
+ try {
+ let allMissions;
+ missionManager.getMissionInfos('',10).then(function(res){
+ allMissions=res;
+ }).catch(function(err){console.log(err);});
+ console.log('size = ' + allMissions.length);
+ console.log('missions = ' + JSON.stringify(allMissions));
+ let id = allMissions[0].missionId;
+
+ let snapshot = missionManager.getLowResolutionMissionSnapShot('', id).catch(function (err){
+ console.log(err);
+ });
+ } catch (paramError) {
+ console.log('error: ' + paramError.code + ', ' + paramError.message);
+ }
+ ```
## missionManager.lockMission
@@ -628,22 +512,25 @@ Locks a given mission. This API uses an asynchronous callback to return the resu
**Example**
-```ts
-import missionManager from '@ohos.app.ability.missionManager';
+ ```ts
+ import missionManager from '@ohos.app.ability.missionManager';
-let testMissionId = 2;
-try {
- missionManager.lockMission(testMissionId, (err, data) => {
- if (err) {
- console.error('lockMission failed:' + err.message);
- } else {
- console.info('lockMission successfully:' + JSON.stringify(data));
- }
+ try {
+ missionManager.getMissionInfos('', 10, (error, missions) => {
+ console.log('getMissionInfos is called, error.code = ' + error.code);
+ console.log('size = ' + missions.length);
+ console.log('missions = ' + JSON.stringify(missions));
+ let id = missions[0].missionId;
+
+ missionManager.lockMission(id).then(() => {
+ console.log('lockMission is called ');
+ });
});
-} catch (err) {
- console.error('lockMission failed:' + err.message);
-}
-```
+ } catch (paramError) {
+ console.log('error: ' + paramError.code + ', ' + paramError.message);
+ }
+ ```
+
## missionManager.lockMission
@@ -670,20 +557,27 @@ Locks a given mission. This API uses a promise to return the result.
| Promise<void> | Promise used to return the result.|
**Example**
-```ts
-import missionManager from '@ohos.app.ability.missionManager';
-let testMissionId = 2;
-try {
- missionManager.lockMission(testMissionId).then((data) => {
- console.info('lockMission successfully. Data: ' + JSON.stringify(data));
- }).catch(error => {
- console.error('lockMission failed. Cause: ' + error.message);
+ ```ts
+ import missionManager from '@ohos.app.ability.missionManager';
+
+ try {
+ let allMissions;
+ missionManager.getMissionInfos('',10).then(function(res){
+ allMissions=res;
+ }).catch(function(err){console.log(err);});
+ console.log('size = ' + allMissions.length);
+ console.log('missions = ' + JSON.stringify(allMissions));
+ let id = allMissions[0].missionId;
+
+ missionManager.lockMission(id).catch(function (err){
+ console.log(err);
});
-} catch (error) {
- console.error('lockMission failed. Cause: ' + error.message);
-}
-```
+ } catch (paramError) {
+ console.log('error: ' + paramError.code + ', ' + paramError.message);
+ }
+ ```
+
## missionManager.unlockMission
@@ -705,22 +599,26 @@ Unlocks a given mission. This API uses an asynchronous callback to return the re
| callback | AsyncCallback<void> | Yes| Callback used to return the result.|
**Example**
-```ts
-import missionManager from '@ohos.app.ability.missionManager';
-let testMissionId = 2;
-try {
- missionManager.unlockMission(testMissionId, (err, data) => {
- if (err) {
- console.error('unlockMission failed:' + err.message);
- } else {
- console.info('unlockMission successfully:' + JSON.stringify(data));
- }
+ ```ts
+ import missionManager from '@ohos.app.ability.missionManager';
+
+ try {
+ missionManager.getMissionInfos('', 10, (error, missions) => {
+ console.log('getMissionInfos is called, error.code = ' + error.code);
+ console.log('size = ' + missions.length);
+ console.log('missions = ' + JSON.stringify(missions));
+ let id = missions[0].missionId;
+
+ missionManager.unlockMission(id).then(() => {
+ console.log('unlockMission is called ');
+ });
});
-} catch (err) {
- console.error('unlockMission failed:' + err.message);
-}
-```
+ } catch (paramError) {
+ console.log('error: ' + paramError.code + ', ' + paramError.message);
+ }
+ ```
+
## missionManager.unlockMission
@@ -748,20 +646,29 @@ Unlocks a given mission. This API uses a promise to return the result.
**Example**
-```ts
-import missionManager from '@ohos.app.ability.missionManager';
+ ```ts
+ import missionManager from '@ohos.app.ability.missionManager';
-let testMissionId = 2;
-try {
- missionManager.unlockMission(testMissionId).then((data) => {
- console.info('unlockMission successfully. Data: ' + JSON.stringify(data));
- }).catch(error => {
- console.error('unlockMission failed. Cause: ' + error.message);
+ try {
+ let allMissions;
+ missionManager.getMissionInfos('',10).then(function(res){
+ allMissions=res;
+ }).catch(function(err){console.log(err);});
+ console.log('size = ' + allMissions.length);
+ console.log('missions = ' + JSON.stringify(allMissions));
+ let id = allMissions[0].missionId;
+
+ missionManager.lockMission(id).catch(function (err){
+ console.log(err);
});
-} catch (error) {
- console.error('unlockMission failed. Cause: ' + error.message);
-}
-```
+ missionManager.unlockMission(id).catch(function (err){
+ console.log(err);
+ });
+ } catch (paramError) {
+ console.log('error: ' + paramError.code + ', ' + paramError.message);
+ }
+ ```
+
## missionManager.clearMission
@@ -784,22 +691,24 @@ Clears a given mission, regardless of whether it is locked. This API uses an asy
**Example**
-```ts
-import missionManager from '@ohos.app.ability.missionManager';
+ ```ts
+ import missionManager from '@ohos.app.ability.missionManager';
-let testMissionId = 2;
-try {
- missionManager.clearMission(testMissionId, (err, data) => {
- if (err) {
- console.error('clearMission failed:' + err.message);
- } else {
- console.info('clearMission successfully:' + JSON.stringify(data));
- }
+ try {
+ missionManager.getMissionInfos('', 10, (error, missions) => {
+ console.log('getMissionInfos is called, error.code = ' + error.code);
+ console.log('size = ' + missions.length);
+ console.log('missions = ' + JSON.stringify(missions));
+ let id = missions[0].missionId;
+
+ missionManager.clearMission(id).then(() => {
+ console.log('clearMission is called ');
+ });
});
-} catch (err) {
- console.error('clearMission failed:' + err.message);
-}
-```
+ } catch (paramError) {
+ console.log('error: ' + paramError.code + ', ' + paramError.message);
+ }
+ ```
## missionManager.clearMission
@@ -828,20 +737,26 @@ Clears a given mission, regardless of whether it is locked. This API uses a prom
**Example**
-```ts
-import missionManager from '@ohos.app.ability.missionManager';
+ ```ts
+ import missionManager from '@ohos.app.ability.missionManager';
-let testMissionId = 2;
-try {
- missionManager.clearMission(testMissionId).then((data) => {
- console.info('clearMission successfully. Data: ' + JSON.stringify(data));
- }).catch(error => {
- console.error('clearMission failed. Cause: ' + error.message);
+ try {
+ let allMissions;
+ missionManager.getMissionInfos('',10).then(function(res){
+ allMissions=res;
+ }).catch(function(err){console.log(err);});
+ console.log('size = ' + allMissions.length);
+ console.log('missions = ' + JSON.stringify(allMissions));
+ let id = allMissions[0].missionId;
+
+ missionManager.clearMission(id).catch(function (err){
+ console.log(err);
});
-} catch (error) {
- console.error('clearMission failed. Cause: ' + error.message);
-}
-```
+ } catch (paramError) {
+ console.log('error: ' + paramError.code + ', ' + paramError.message);
+ }
+ ```
+
## missionManager.clearAllMissions
@@ -857,21 +772,14 @@ Clears all unlocked missions. This API uses an asynchronous callback to return t
**Example**
-```ts
-import missionManager from '@ohos.app.ability.missionManager';
+ ```ts
+ import missionManager from '@ohos.app.ability.missionManager';
+
+ missionManager.clearAllMissions().then(() => {
+ console.log('clearAllMissions is called ');
+ });
+ ```
-try {
- missionManager.clearAllMissions(err => {
- if (err) {
- console.error('clearAllMissions failed:' + err.message);
- } else {
- console.info('clearAllMissions successfully.');
- }
- });
-} catch (err) {
- console.error('clearAllMissions failed:' + err.message);
-}
-```
## missionManager.clearAllMissions
@@ -893,19 +801,13 @@ Clears all unlocked missions. This API uses a promise to return the result.
**Example**
-```ts
-import missionManager from '@ohos.app.ability.missionManager';
+ ```ts
+ import missionManager from '@ohos.app.ability.missionManager';
+ missionManager.clearAllMissions().catch(function (err){
+ console.log(err);
+ });
+ ```
-try {
- missionManager.clearAllMissions(bundleName).then(() => {
- console.info('clearAllMissions successfully.');
- }).catch(err => {
- console.error('clearAllMissions failed:' + err.message);
- });
-} catch (err) {
- console.error('clearAllMissions failed:' + err.message);
-}
-```
## missionManager.moveMissionToFront
@@ -928,22 +830,25 @@ Switches a given mission to the foreground. This API uses an asynchronous callba
**Example**
-```ts
-import missionManager from '@ohos.app.ability.missionManager';
+ ```ts
+ import missionManager from '@ohos.app.ability.missionManager';
-let testMissionId = 2;
-try {
- missionManager.moveMissionToFront(testMissionId, (err, data) => {
- if (err) {
- console.error('moveMissionToFront failed:' + err.message);
- } else {
- console.info('moveMissionToFront successfully:' + JSON.stringify(data));
- }
+ try {
+ missionManager.getMissionInfos('', 10, (error, missions) => {
+ console.log('getMissionInfos is called, error.code = ' + error.code);
+ console.log('size = ' + missions.length);
+ console.log('missions = ' + JSON.stringify(missions));
+ let id = missions[0].missionId;
+
+ missionManager.moveMissionToFront(id).then(() => {
+ console.log('moveMissionToFront is called ');
+ });
});
-} catch (err) {
- console.error('moveMissionToFront failed:' + err.message);
-}
-```
+ } catch (paramError) {
+ console.log('error: ' + paramError.code + ', ' + paramError.message);
+ }
+ ```
+
## missionManager.moveMissionToFront
@@ -967,22 +872,25 @@ Switches a given mission to the foreground, with the startup parameters for the
**Example**
-```ts
-import missionManager from '@ohos.app.ability.missionManager';
+ ```ts
+ import missionManager from '@ohos.app.ability.missionManager';
-let testMissionId = 2;
-try {
- missionManager.moveMissionToFront(testMissionId, {windowMode : 101}, (err, data) => {
- if (err) {
- console.error('moveMissionToFront failed:' + err.message);
- } else {
- console.info('moveMissionToFront successfully:' + JSON.stringify(data));
- }
+ try {
+ missionManager.getMissionInfos('', 10, (error, missions) => {
+ console.log('getMissionInfos is called, error.code = ' + error.code);
+ console.log('size = ' + missions.length);
+ console.log('missions = ' + JSON.stringify(missions));
+ let id = missions[0].missionId;
+
+ missionManager.moveMissionToFront(id,{windowMode : 101}).then(() => {
+ console.log('moveMissionToFront is called ');
+ });
});
-} catch (err) {
- console.error('moveMissionToFront failed:' + err.message);
-}
-```
+ } catch (paramError) {
+ console.log('error: ' + paramError.code + ', ' + paramError.message);
+ }
+ ```
+
## missionManager.moveMissionToFront
@@ -1011,17 +919,22 @@ Switches a given mission to the foreground, with the startup parameters for the
**Example**
-```ts
-import missionManager from '@ohos.app.ability.missionManager';
+ ```ts
+ import missionManager from '@ohos.app.ability.missionManager';
-let testMissionId = 2;
-try {
- missionManager.moveMissionToFront(testMissionId).then((data) => {
- console.info('moveMissionToFront successfully. Data: ' + JSON.stringify(data));
- }).catch(error => {
- console.error('moveMissionToFront failed. Cause: ' + error.message);
+ try {
+ let allMissions;
+ missionManager.getMissionInfos('',10).then(function(res){
+ allMissions=res;
+ }).catch(function(err){console.log(err);});
+ console.log('size = ' + allMissions.length);
+ console.log('missions = ' + JSON.stringify(allMissions));
+ let id = allMissions[0].missionId;
+
+ missionManager.moveMissionToFront(id).catch(function (err){
+ console.log(err);
});
-} catch (error) {
- console.error('moveMissionToFront failed. Cause: ' + error.message);
-}
-```
+ } catch (paramError) {
+ console.log('error: ' + paramError.code + ', ' + paramError.message);
+ }
+ ```
diff --git a/en/application-dev/reference/apis/js-apis-app-ability-quickFixManager.md b/en/application-dev/reference/apis/js-apis-app-ability-quickFixManager.md
index a2090ed00e60cac1b5452bf6357f47cfb3c7be2e..ac26642228b5cdc386b65d8c9e2e1c429fdb9819 100644
--- a/en/application-dev/reference/apis/js-apis-app-ability-quickFixManager.md
+++ b/en/application-dev/reference/apis/js-apis-app-ability-quickFixManager.md
@@ -3,7 +3,7 @@
The **quickFixManager** module provides APIs for quick fix. With quick fix, you can fix bugs in your application by applying patches, which is more efficient than by updating the entire application.
> **NOTE**
->
+>
> The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version.
## Modules to Import
@@ -24,7 +24,7 @@ Defines the quick fix information at the HAP file level.
| ----------- | -------------------- | ---- | ------------------------------------------------------------ |
| moduleName | string | Yes | Name of the HAP file. |
| originHapHash | string | Yes | Hash value of the HAP file. |
-| quickFixFilePath | string | Yes | Installation path of the quick fix file. |
+| quickFixFilePath | string | Yes | Installation path of the quick fix patch file. |
## ApplicationQuickFixInfo
@@ -57,25 +57,31 @@ Applies a quick fix patch. This API uses an asynchronous callback to return the
**Parameters**
- | Parameter| Type| Mandatory| Description|
- | -------- | -------- | -------- | -------- |
- | hapModuleQuickFixFiles | Array\ | Yes| Quick fix files, each of which must contain a valid file path.|
- | callback | AsyncCallback\ | Yes| Callback used to return the result.|
+| Parameter| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| hapModuleQuickFixFiles | Array\ | Yes| Quick fix patch files, each of which must contain a valid file path.|
+| callback | AsyncCallback\ | Yes| Callback used to return the result.|
+
+> **NOTE**
+>
+> The file path passed in the API must be an application sandbox path. For details about how to obtain the sandbox path, see [Obtaining the Sandbox Path](js-apis-bundle-BundleInstaller.md#obtaining-the-sandbox-path). The path mapped to the device is **/proc/<*applicationProcessId*>/root/*sandboxPath***.
**Example**
-
+
```ts
+ import quickFixManager from '@ohos.app.ability.quickFixManager';
+
try {
- let hapModuleQuickFixFiles = ["/data/storage/el2/base/entry.hqf"]
+ let hapModuleQuickFixFiles = ['/data/storage/el2/base/entry.hqf'];
quickFixManager.applyQuickFix(hapModuleQuickFixFiles, (error) => {
if (error) {
- console.info( `applyQuickFix failed with error + ${error}`)
+ console.info( `applyQuickFix failed with error + ${error}`);
} else {
- console.info( 'applyQuickFix success')
+ console.info( 'applyQuickFix success');
}
- })
+ });
} catch (paramError) {
- console.log("error: " + paramError.code + ", " + paramError.message);
+ console.log('error: ' + paramError.code + ', ' + paramError.message);
}
```
@@ -93,28 +99,30 @@ Applies a quick fix patch. This API uses a promise to return the result.
**Parameters**
- | Parameter| Type| Mandatory| Description|
- | -------- | -------- | -------- | -------- |
- | hapModuleQuickFixFiles | Array\ | Yes| Quick fix files, each of which must contain a valid file path.|
+| Parameter| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| hapModuleQuickFixFiles | Array\ | Yes| Quick fix patch files, each of which must contain a valid file path.|
**Return value**
- | Type| Description|
- | -------- | -------- |
- | Promise\ | Promise used to return the result.|
+| Type| Description|
+| -------- | -------- |
+| Promise\ | Promise used to return the result.|
**Example**
-
+
```ts
- let hapModuleQuickFixFiles = ["/data/storage/el2/base/entry.hqf"]
+ import quickFixManager from '@ohos.app.ability.quickFixManager';
+
+ let hapModuleQuickFixFiles = ['/data/storage/el2/base/entry.hqf'];
try {
quickFixManager.applyQuickFix(hapModuleQuickFixFiles).then(() => {
- console.info('applyQuickFix success')
+ console.info('applyQuickFix success');
}).catch((error) => {
- console.info(`applyQuickFix err: + ${error}`)
- })
+ console.info(`applyQuickFix err: + ${error}`);
+ });
} catch (paramError) {
- console.log("error: " + paramError.code + ", " + paramError.message);
+ console.log('error: ' + paramError.code + ', ' + paramError.message);
}
```
@@ -138,20 +146,22 @@ Obtains the quick fix information of the application. This API uses an asynchron
| callback | AsyncCallback\<[ApplicationQuickFixInfo](#applicationquickfixinfo)> | Yes| Callback used to return the quick fix information.|
**Example**
-
+
```ts
+ import quickFixManager from '@ohos.app.ability.quickFixManager';
+
try {
- let bundleName = "bundleName"
+ let bundleName = 'bundleName'
quickFixManager.getApplicationQuickFixInfo(bundleName, (error, data) => {
if (error) {
- console.info(`getApplicationQuickFixInfo error: + ${error}`)
+ console.info(`getApplicationQuickFixInfo error: + ${error}`);
} else {
- console.info(`getApplicationQuickFixInfo success: + ${data}`)
+ console.info(`getApplicationQuickFixInfo success: + ${data}`);
}
- })
+ });
} catch (paramError) {
- console.log("error: " + paramError.code + ", " + paramError.message);
- }
+ console.log('error: ' + paramError.code + ', ' + paramError.message);
+ }
```
## quickFixManager.getApplicationQuickFixInfo
@@ -174,21 +184,23 @@ Obtains the quick fix information of the application. This API uses a promise to
**Return value**
- | Type| Description|
- | -------- | -------- |
- | Promise\<[ApplicationQuickFixInfo](#applicationquickfixinfo)> | Promise used to return the quick fix information.|
+| Type| Description|
+| -------- | -------- |
+| Promise\<[ApplicationQuickFixInfo](#applicationquickfixinfo)> | Promise used to return the quick fix information.|
**Example**
```ts
+ import quickFixManager from '@ohos.app.ability.quickFixManager';
+
try {
- let bundleName = "bundleName"
+ let bundleName = 'bundleName';
quickFixManager.getApplicationQuickFixInfo(bundleName).then((data) => {
- console.info(`getApplicationQuickFixInfo success: + ${data}`)
+ console.info(`getApplicationQuickFixInfo success: + ${data}`);
}).catch((error) => {
- console.info(`getApplicationQuickFixInfo err: + ${error}`)
- })
+ console.info(`getApplicationQuickFixInfo err: + ${error}`);
+ });
} catch (paramError) {
- console.log("error: " + paramError.code + ", " + paramError.message);
+ console.log('error: ' + paramError.code + ', ' + paramError.message);
}
- ```
+```
diff --git a/en/application-dev/reference/apis/js-apis-app-ability-serviceExtensionAbility.md b/en/application-dev/reference/apis/js-apis-app-ability-serviceExtensionAbility.md
index 0efdb59d5eaed4c2b70e5ff666b0c9d63b11212f..effff8a5277344b18c274847808dae7897c85866 100644
--- a/en/application-dev/reference/apis/js-apis-app-ability-serviceExtensionAbility.md
+++ b/en/application-dev/reference/apis/js-apis-app-ability-serviceExtensionAbility.md
@@ -1,10 +1,10 @@
# @ohos.app.ability.ServiceExtensionAbility (ServiceExtensionAbility)
-The **ServiceExtensionAbility** module provides lifecycle callbacks when a ServiceExtensionAbility (background service) is created, destroyed, connected, or disconnected.
+The **ServiceExtensionAbility** module provides APIs for ServiceExtensionAbilities.
> **NOTE**
>
-> The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version.
+> The APIs of this module are supported since API version 9 and are deprecated in versions later than API version 9. You are advised to use [@ohos.app.ability.ServiceExtensionAbility](js-apis-app-ability-serviceExtensionAbility.md) instead. Newly added APIs will be marked with a superscript to indicate their earliest API version.
> The APIs of this module can be used only in the stage model.
## Modules to Import
@@ -80,7 +80,7 @@ Called when this ServiceExtensionAbility is destroyed to clear resources.
onRequest(want: Want, startId: number): void;
-Called following **onCreate()** when a ServiceExtensionAbility is started by calling **startAbility()**. The value of **startId** is incremented for each ability that is started.
+Called following **onCreate()** when a ServiceExtensionAbility is started by calling **startAbility()** or **startServiceExtensionAbility()**. The value of **startId** is incremented for each ability that is started.
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
@@ -129,7 +129,7 @@ Called following **onCreate()** when a ServiceExtensionAbility is started by cal
**Example**
```ts
- import rpc from '@ohos.rpc'
+ import rpc from '@ohos.rpc';
class StubTest extends rpc.RemoteObject{
constructor(des) {
super(des);
@@ -140,7 +140,7 @@ Called following **onCreate()** when a ServiceExtensionAbility is started by cal
class ServiceExt extends ServiceExtension {
onConnect(want) {
console.log('onConnect , want:' + want.abilityName);
- return new StubTest("test");
+ return new StubTest('test');
}
}
```
@@ -150,7 +150,7 @@ Called following **onCreate()** when a ServiceExtensionAbility is started by cal
onDisconnect(want: Want): void;
-Called when a client is disconnected from this ServiceExtensionAbility.
+Called when this ServiceExtensionAbility is disconnected.
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
@@ -176,7 +176,7 @@ Called when a client is disconnected from this ServiceExtensionAbility.
onReconnect(want: Want): void;
-Called when a new client attempts to connect to this ServiceExtensionAbility after all previous clients are disconnected. This capability is reserved.
+Called when this ServiceExtensionAbility is reconnected.
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
@@ -246,7 +246,8 @@ Dumps the client information.
class ServiceExt extends ServiceExtension {
onDump(params) {
console.log('dump, params:' + JSON.stringify(params));
- return ["params"]
+ return ['params'];
}
}
```
+
diff --git a/en/application-dev/reference/apis/js-apis-app-ability-uiAbility.md b/en/application-dev/reference/apis/js-apis-app-ability-uiAbility.md
index 38d9f5428c37873ae9f786ed0f391142f30a011b..127add25d18fbeda45b6bd44bd82f3dd74a5540b 100644
--- a/en/application-dev/reference/apis/js-apis-app-ability-uiAbility.md
+++ b/en/application-dev/reference/apis/js-apis-app-ability-uiAbility.md
@@ -1,9 +1,10 @@
# @ohos.app.ability.UIAbility (UIAbility)
-UIAbility is an application component that has the UI. The **UIAbility** module provides lifecycle callback such as component creation, destruction, and foreground/background switching. It also provides the following capabilities related to component collaboration:
+The **Ability** module manages the ability lifecycle and context, such as creating and destroying an ability, and dumping client information.
-- [Caller](#caller): an object returned by [startAbilityByCall](js-apis-inner-application-uiAbilityContext.md#uiabilitycontextstartabilitybycall). The CallerAbility (caller) uses this object to communicate with the CalleeAbility (callee).
-- [Callee](#callee): an internal object of UIAbility. The CalleeAbility (callee) uses this object to communicate with the CallerAbility (caller).
+This module provides the following common ability-related functions:
+- [Caller](#caller): implements sending of sequenceable data to the target ability when an ability (caller ability) invokes the target ability (callee ability).
+- [Callee](#callee): implements callbacks for registration and deregistration of caller notifications.
> **NOTE**
>
@@ -13,7 +14,7 @@ UIAbility is an application component that has the UI. The **UIAbility** module
## Modules to Import
```ts
-import UIAbility from '@ohos.app.ability.UIAbility';
+import Ability from '@ohos.app.ability.UIAbility';
```
## Attributes
@@ -22,16 +23,16 @@ import UIAbility from '@ohos.app.ability.UIAbility';
| Name| Type| Readable| Writable| Description|
| -------- | -------- | -------- | -------- | -------- |
-| context | [UIAbilityContext](js-apis-inner-application-uiAbilityContext.md) | Yes| No| Context of the UIAbility.|
-| launchWant | [Want](js-apis-app-ability-want.md) | Yes| No| Parameters for starting the UIAbility.|
-| lastRequestWant | [Want](js-apis-app-ability-want.md) | Yes| No| Parameters used when the UIAbility was started last time.|
+| context | [UIAbilityContext](js-apis-inner-application-uiAbilityContext.md) | Yes| No| Context of the ability.|
+| launchWant | [Want](js-apis-app-ability-want.md) | Yes| No| Parameters for starting the ability.|
+| lastRequestWant | [Want](js-apis-app-ability-want.md) | Yes| No| Parameters used when the ability was started last time.|
| callee | [Callee](#callee) | Yes| No| Object that invokes the stub service.|
-## UIAbility.onCreate
+## Ability.onCreate
onCreate(want: Want, param: AbilityConstant.LaunchParam): void;
-Called to initialize the service logic when a UIAbility is created.
+Called to initialize the service logic when an ability is created.
**System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore
@@ -39,13 +40,13 @@ Called to initialize the service logic when a UIAbility is created.
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
-| want | [Want](js-apis-app-ability-want.md) | Yes| Information related to this UIAbility, including the ability name and bundle name.|
-| param | [AbilityConstant.LaunchParam](js-apis-app-ability-abilityConstant.md#abilityconstantlaunchparam) | Yes| Parameters for starting the UIAbility, and the reason for the last abnormal exit.|
+| want | [Want](js-apis-app-ability-want.md) | Yes| Information related to this ability, including the ability name and bundle name.|
+| param | [AbilityConstant.LaunchParam](js-apis-app-ability-abilityConstant.md#abilityconstantlaunchparam) | Yes| Parameters for starting the ability, and the reason for the last abnormal exit.|
**Example**
```ts
- class MyUIAbility extends UIAbility {
+ class myAbility extends Ability {
onCreate(want, param) {
console.log('onCreate, want:' + want.abilityName);
}
@@ -53,11 +54,11 @@ Called to initialize the service logic when a UIAbility is created.
```
-## UIAbility.onWindowStageCreate
+## Ability.onWindowStageCreate
onWindowStageCreate(windowStage: window.WindowStage): void
-Called when a **WindowStage** is created for this UIAbility.
+Called when a **WindowStage** is created for this ability.
**System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore
@@ -70,7 +71,7 @@ Called when a **WindowStage** is created for this UIAbility.
**Example**
```ts
- class MyUIAbility extends UIAbility {
+ class myAbility extends Ability {
onWindowStageCreate(windowStage) {
console.log('onWindowStageCreate');
}
@@ -78,18 +79,18 @@ Called when a **WindowStage** is created for this UIAbility.
```
-## UIAbility.onWindowStageDestroy
+## Ability.onWindowStageDestroy
onWindowStageDestroy(): void
-Called when the **WindowStage** is destroyed for this UIAbility.
+Called when the **WindowStage** is destroyed for this ability.
**System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore
**Example**
```ts
- class MyUIAbility extends UIAbility {
+ class myAbility extends Ability {
onWindowStageDestroy() {
console.log('onWindowStageDestroy');
}
@@ -97,11 +98,11 @@ Called when the **WindowStage** is destroyed for this UIAbility.
```
-## UIAbility.onWindowStageRestore
+## Ability.onWindowStageRestore
onWindowStageRestore(windowStage: window.WindowStage): void
-Called when the **WindowStage** is restored during the migration of this UIAbility, which is a multi-instance ability.
+Called when the **WindowStage** is restored during the migration of this ability, which is a multi-instance ability.
**System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore
@@ -114,7 +115,7 @@ Called when the **WindowStage** is restored during the migration of this UIAbili
**Example**
```ts
- class MyUIAbility extends UIAbility {
+ class myAbility extends Ability {
onWindowStageRestore(windowStage) {
console.log('onWindowStageRestore');
}
@@ -122,18 +123,18 @@ Called when the **WindowStage** is restored during the migration of this UIAbili
```
-## UIAbility.onDestroy
+## Ability.onDestroy
onDestroy(): void;
-Called when this UIAbility is destroyed to clear resources.
+Called when this ability is destroyed to clear resources.
**System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore
**Example**
```ts
- class MyUIAbility extends UIAbility {
+ class myAbility extends Ability {
onDestroy() {
console.log('onDestroy');
}
@@ -141,18 +142,18 @@ Called when this UIAbility is destroyed to clear resources.
```
-## UIAbility.onForeground
+## Ability.onForeground
onForeground(): void;
-Called when this UIAbility is switched from the background to the foreground.
+Called when this ability is switched from the background to the foreground.
**System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore
**Example**
```ts
- class MyUIAbility extends UIAbility {
+ class myAbility extends Ability {
onForeground() {
console.log('onForeground');
}
@@ -160,18 +161,18 @@ Called when this UIAbility is switched from the background to the foreground.
```
-## UIAbility.onBackground
+## Ability.onBackground
onBackground(): void;
-Called when this UIAbility is switched from the foreground to the background.
+Called when this ability is switched from the foreground to the background.
**System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore
**Example**
```ts
- class MyUIAbility extends UIAbility {
+ class myAbility extends Ability {
onBackground() {
console.log('onBackground');
}
@@ -179,7 +180,7 @@ Called when this UIAbility is switched from the foreground to the background.
```
-## UIAbility.onContinue
+## Ability.onContinue
onContinue(wantParam : {[key: string]: any}): AbilityConstant.OnContinueResult;
@@ -202,22 +203,22 @@ Called to save data during the ability migration preparation process.
**Example**
```ts
- import AbilityConstant from "@ohos.app.ability.AbilityConstant"
+ import AbilityConstant from '@ohos.app.ability.AbilityConstant';
class MyUIAbility extends UIAbility {
onContinue(wantParams) {
console.log('onContinue');
- wantParams["myData"] = "my1234567";
+ wantParams['myData'] = 'my1234567';
return AbilityConstant.OnContinueResult.AGREE;
}
}
```
-## UIAbility.onNewWant
+## Ability.onNewWant
onNewWant(want: Want, launchParams: AbilityConstant.LaunchParam): void;
-Called when a new Want is passed in and this UIAbility is started again.
+Called when a new Want is passed in and this ability is started again.
**System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore
@@ -226,20 +227,20 @@ Called when a new Want is passed in and this UIAbility is started again.
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| want | [Want](js-apis-app-ability-want.md) | Yes| Want information, such as the ability name and bundle name.|
-| launchParams | [AbilityConstant.LaunchParam](js-apis-app-ability-abilityConstant.md#abilityconstantlaunchparam) | Yes| Reason for the UIAbility startup and the last abnormal exit.|
+| launchParams | [AbilityConstant.LaunchParam](js-apis-app-ability-abilityConstant.md#abilityconstantlaunchparam) | Yes| Reason for the ability startup and the last abnormal exit.|
**Example**
```ts
- class MyUIAbility extends UIAbility {
+ class MyUIAbility extends UIAbility {
onNewWant(want, launchParams) {
console.log('onNewWant, want:' + want.abilityName);
console.log('onNewWant, launchParams:' + JSON.stringify(launchParams));
- }
- }
+ }
+ }
```
-## UIAbility.onDump
+## Ability.onDump
onDump(params: Array\): Array\;
@@ -256,20 +257,20 @@ Dumps client information.
**Example**
```ts
- class MyUIAbility extends UIAbility {
+ class myAbility extends Ability {
onDump(params) {
console.log('dump, params:' + JSON.stringify(params));
- return ["params"]
+ return ['params'];
}
}
```
-## UIAbility.onSaveState
+## Ability.onSaveState
onSaveState(reason: AbilityConstant.StateType, wantParam : {[key: string]: any}): AbilityConstant.OnSaveResult;
-Called when the framework automatically saves the UIAbility state in the case of an application fault. This API is used together with [appRecovery](js-apis-app-ability-appRecovery.md). If automatic state saving is enabled, **onSaveState** is called to save the state of this UIAbility.
+Called when the framework automatically saves the ability state in the case of an application fault. This API is used together with [appRecovery](js-apis-app-ability-appRecovery.md). If automatic state saving is enabled, **onSaveState** is called to save the state of this ability.
**System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore
@@ -277,24 +278,24 @@ Called when the framework automatically saves the UIAbility state in the case of
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
-| reason | [AbilityConstant.StateType](js-apis-app-ability-abilityConstant.md#abilityconstantstatetype) | Yes| Reason for triggering the callback to save the UIAbility state.|
+| reason | [AbilityConstant.StateType](js-apis-application-abilityConstant.md#abilityconstantstatetype) | Yes| Reason for triggering the callback to save the ability state.|
| wantParam | {[key: string]: any} | Yes| **want** parameter.|
**Return value**
| Type| Description|
| -------- | -------- |
-| [AbilityConstant.OnSaveResult](js-apis-app-ability-abilityConstant.md#abilityconstantonsaveresult) | Whether the UIAbility state is saved.|
+| AbilityConstant.OnSaveResult | Whether the ability state is saved.|
**Example**
```ts
-import AbilityConstant from '@ohos.app.ability.AbilityConstant'
+import AbilityConstant from '@ohos.app.ability.AbilityConstant';
class MyUIAbility extends UIAbility {
onSaveState(reason, wantParam) {
console.log('onSaveState');
- wantParam["myData"] = "my1234567";
+ wantParam['myData'] = 'my1234567';
return AbilityConstant.OnSaveResult.RECOVERY_AGREE;
}
}
@@ -338,9 +339,10 @@ For details about the error codes, see [Ability Error Codes](../errorcodes/error
**Example**
```ts
- class MyMessageAble{ // Custom sequenceable data structure.
- name:""
- str:""
+ import Ability from '@ohos.app.ability.UIAbility';
+ class MyMessageAble{ // ԶSequenceableݽṹ
+ name:''
+ str:''
num: 1
constructor(name, str) {
this.name = name;
@@ -359,17 +361,18 @@ For details about the error codes, see [Ability Error Codes](../errorcodes/error
return true;
}
};
- var method = 'call_Function'; // Notification message string negotiated by the two abilities.
- var caller;
- export default class MainUIAbility extends UIAbility {
+ let method = 'call_Function'; // Notification message string negotiated by the two abilities.
+ let caller;
+ export default class MainAbility extends Ability {
onWindowStageCreate(windowStage) {
- this.context.startUIAbilityByCall({
- bundleName: "com.example.myservice",
- abilityName: "MainUIAbility",
- deviceId: ""
+ this.context.startAbilityByCall({
+ bundleName: 'com.example.myservice',
+ abilityName: 'MainAbility',
+ deviceId: ''
}).then((obj) => {
caller = obj;
- let msg = new MyMessageAble("msg", "world"); // See the definition of Sequenceable.
+ let msg = new MyMessageAble('msg', 'world'); // See the definition of Sequenceable.
+
caller.call(method, msg)
.then(() => {
console.log('Caller call() called');
@@ -419,9 +422,10 @@ For details about the error codes, see [Ability Error Codes](../errorcodes/error
**Example**
```ts
+ import Ability from '@ohos.app.ability.UIAbility';
class MyMessageAble{
- name:""
- str:""
+ name:''
+ str:''
num: 1
constructor(name, str) {
this.name = name;
@@ -440,21 +444,21 @@ For details about the error codes, see [Ability Error Codes](../errorcodes/error
return true;
}
};
- var method = 'call_Function';
- var caller;
- export default class MainUIAbility extends UIAbility {
+ let method = 'call_Function';
+ let caller;
+ export default class MainAbility extends Ability {
onWindowStageCreate(windowStage) {
- this.context.startUIAbilityByCall({
- bundleName: "com.example.myservice",
- abilityName: "MainUIAbility",
- deviceId: ""
+ this.context.startAbilityByCall({
+ bundleName: 'com.example.myservice',
+ abilityName: 'MainAbility',
+ deviceId: ''
}).then((obj) => {
caller = obj;
- let msg = new MyMessageAble(1, "world");
+ let msg = new MyMessageAble(1, 'world');
caller.callWithResult(method, msg)
.then((data) => {
console.log('Caller callWithResult() called');
- let retmsg = new MyMessageAble(0, "");
+ let retmsg = new MyMessageAble(0, '');
data.readSequenceable(retmsg);
})
.catch((callErr) => {
@@ -490,13 +494,14 @@ Releases the caller interface of the target ability.
**Example**
```ts
- var caller;
- export default class MainUIAbility extends UIAbility {
+ import Ability from '@ohos.app.ability.UIAbility';
+ let caller;
+ export default class MainAbility extends Ability {
onWindowStageCreate(windowStage) {
- this.context.startUIAbilityByCall({
- bundleName: "com.example.myservice",
- abilityName: "MainUIAbility",
- deviceId: ""
+ this.context.startAbilityByCall({
+ bundleName: 'com.example.myservice',
+ abilityName: 'MainAbility',
+ deviceId: ''
}).then((obj) => {
caller = obj;
try {
@@ -525,18 +530,19 @@ Registers a callback that is invoked when the stub on the target ability is disc
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
-| callback | [OnReleaseCallBack](#onreleasecallback) | Yes| Callback used for the **onRelease** API.|
+| callback | [OnReleaseCallBack](#onreleasecallback) | Yes| Callback used to return the result.|
**Example**
```ts
- var caller;
- export default class MainUIAbility extends UIAbility {
+ import Ability from '@ohos.application.Ability';
+ let caller;
+ export default class MainAbility extends Ability {
onWindowStageCreate(windowStage) {
- this.context.startUIAbilityByCall({
- bundleName: "com.example.myservice",
- abilityName: "MainUIAbility",
- deviceId: ""
+ this.context.startAbilityByCall({
+ bundleName: 'com.example.myservice',
+ abilityName: 'MainAbility',
+ deviceId: ''
}).then((obj) => {
caller = obj;
try {
@@ -544,7 +550,7 @@ Registers a callback that is invoked when the stub on the target ability is disc
console.log(' Caller OnRelease CallBack is called ' + str);
});
} catch (error) {
- console.log('Caller.on catch error, error.code: ' + JSON.stringify(error.code) +
+ console.log('Caller.onRelease catch error, error.code: ' + JSON.stringify(error.code) +
' error.message: ' + JSON.stringify(error.message));
}
}).catch((err) => {
@@ -557,7 +563,7 @@ Registers a callback that is invoked when the stub on the target ability is disc
## Caller.on
- on(type: "release", callback: OnReleaseCallback): void;
+ on(type: 'release', callback: OnReleaseCallback): void;
Registers a callback that is invoked when the stub on the target ability is disconnected.
@@ -568,7 +574,7 @@ Registers a callback that is invoked when the stub on the target ability is disc
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| type | string | Yes| Event type. The value is fixed at **release**.|
-| callback | [OnReleaseCallBack](#onreleasecallback) | Yes| Callback used for the **onRelease** API.|
+| callback | [OnReleaseCallBack](#onreleasecallback) | Yes| Callback used to return the result.|
**Error codes**
@@ -581,17 +587,18 @@ For details about the error codes, see [Ability Error Codes](../errorcodes/error
**Example**
```ts
- var caller;
- export default class MainUIAbility extends UIAbility {
+ import Ability from '@ohos.app.ability.UIAbility';
+ let caller;
+ export default class MainAbility extends Ability {
onWindowStageCreate(windowStage) {
- this.context.startUIAbilityByCall({
- bundleName: "com.example.myservice",
- abilityName: "MainUIAbility",
- deviceId: ""
+ this.context.startAbilityByCall({
+ bundleName: 'com.example.myservice',
+ abilityName: 'MainAbility',
+ deviceId: ''
}).then((obj) => {
caller = obj;
try {
- caller.on("release", (str) => {
+ caller.on('release', (str) => {
console.log(' Caller OnRelease CallBack is called ' + str);
});
} catch (error) {
@@ -606,6 +613,108 @@ For details about the error codes, see [Ability Error Codes](../errorcodes/error
}
```
+## Caller.off
+
+off(type: 'release', callback: OnReleaseCallback): void;
+
+Deregisters a callback that is invoked when the stub on the target ability is disconnected. This capability is reserved.
+
+**System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore
+
+**Parameters**
+
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| type | string | Yes| Event type. The value is fixed at **release**.|
+| callback | [OnReleaseCallBack](#onreleasecallback) | Yes| Callback used to return the result.|
+
+**Error codes**
+
+| ID| Error Message|
+| ------- | -------------------------------- |
+| 401 | If the input parameter is not valid parameter. |
+For other IDs, see [Ability Error Codes](../errorcodes/errorcode-ability.md).
+
+**Example**
+
+ ```ts
+ let caller;
+ export default class MainUIAbility extends UIAbility {
+ onWindowStageCreate(windowStage) {
+ this.context.startAbilityByCall({
+ bundleName: 'com.example.myservice',
+ abilityName: 'MainUIAbility',
+ deviceId: ''
+ }).then((obj) => {
+ caller = obj;
+ try {
+ let onReleaseCallBack = (str) => {
+ console.log(' Caller OnRelease CallBack is called ' + str);
+ };
+ caller.on('release', onReleaseCallBack);
+ caller.off('release', onReleaseCallBack);
+ } catch (error) {
+ console.log('Caller.on or Caller.off catch error, error.code: ' + JSON.stringify(error.code) +
+ ' error.message: ' + JSON.stringify(error.message));
+ }
+ }).catch((err) => {
+ console.log('Caller GetCaller error, error.code: ' + JSON.stringify(err.code) +
+ ' error.message: ' + JSON.stringify(err.message));
+ });
+ }
+ }
+ ```
+
+## Caller.off
+
+off(type: 'release'): void;
+
+Deregisters a callback that is invoked when the stub on the target ability is disconnected. This capability is reserved.
+
+**System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore
+
+**Parameters**
+
+| Name| Type| Mandatory| Description|
+| -------- | -------- | -------- | -------- |
+| type | string | Yes| Event type. The value is fixed at **release**.|
+
+**Error codes**
+
+| ID| Error Message|
+| ------- | -------------------------------- |
+| 401 | If the input parameter is not valid parameter. |
+For other IDs, see [Ability Error Codes](../errorcodes/errorcode-ability.md).
+
+**Example**
+
+ ```ts
+ let caller;
+ export default class MainUIAbility extends UIAbility {
+ onWindowStageCreate(windowStage) {
+ this.context.startAbilityByCall({
+ bundleName: 'com.example.myservice',
+ abilityName: 'MainUIAbility',
+ deviceId: ''
+ }).then((obj) => {
+ caller = obj;
+ try {
+ let onReleaseCallBack = (str) => {
+ console.log(' Caller OnRelease CallBack is called ' + str);
+ };
+ caller.on('release', onReleaseCallBack);
+ caller.off('release');
+ } catch (error) {
+ console.error('Caller.on or Caller.off catch error, error.code: ' + JSON.stringify(error.code) +
+ ' error.message: ' + JSON.stringify(error.message));
+ }
+ }).catch((err) => {
+ console.error('Caller GetCaller error, error.code: ' + JSON.stringify(err.code) +
+ ' error.message: ' + JSON.stringify(err.message));
+ });
+ }
+ }
+ ```
## Callee
@@ -624,7 +733,7 @@ Registers a caller notification callback, which is invoked when the target abili
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| method | string | Yes| Notification message string negotiated between the two abilities.|
-| callback | [CalleeCallback](#calleecallback) | Yes| JS notification synchronization callback of the [rpc.MessageParcel](js-apis-rpc.md#messageparceldeprecated) type. The callback must return at least one empty [rpc.Sequenceable](js-apis-rpc.md#sequenceabledeprecated) object. Otherwise, the function execution fails.|
+| callback | [CalleeCallback](#calleecallback) | Yes| JS notification synchronization callback of the [rpc.MessageParcel](js-apis-rpc.md#sequenceabledeprecated) type. The callback must return at least one empty [rpc.Sequenceable](js-apis-rpc.md#sequenceabledeprecated) object. Otherwise, the function execution fails.|
**Error codes**
@@ -637,9 +746,10 @@ For details about the error codes, see [Ability Error Codes](../errorcodes/error
**Example**
```ts
+ import Ability from '@ohos.app.ability.UIAbility';
class MyMessageAble{
- name:""
- str:""
+ name:''
+ str:''
num: 1
constructor(name, str) {
this.name = name;
@@ -658,14 +768,14 @@ For details about the error codes, see [Ability Error Codes](../errorcodes/error
return true;
}
};
- var method = 'call_Function';
+ let method = 'call_Function';
function funcCallBack(pdata) {
console.log('Callee funcCallBack is called ' + pdata);
- let msg = new MyMessageAble("test", "");
+ let msg = new MyMessageAble('test', '');
pdata.readSequenceable(msg);
- return new MyMessageAble("test1", "Callee test");
+ return new MyMessageAble('test1', 'Callee test');
}
- export default class MainUIAbility extends UIAbility {
+ export default class MainAbility extends Ability {
onCreate(want, launchParam) {
console.log('Callee onCreate is called');
try {
@@ -704,8 +814,9 @@ For details about the error codes, see [Ability Error Codes](../errorcodes/error
**Example**
```ts
- var method = 'call_Function';
- export default class MainUIAbility extends UIAbility {
+ import Ability from '@ohos.app.ability.UIAbility';
+ let method = 'call_Function';
+ export default class MainAbility extends Ability {
onCreate(want, launchParam) {
console.log('Callee onCreate is called');
try {
@@ -736,4 +847,4 @@ For details about the error codes, see [Ability Error Codes](../errorcodes/error
| Name| Readable| Writable| Type| Description|
| -------- | -------- | -------- | -------- | -------- |
-| (indata: [rpc.MessageParcel](js-apis-rpc.md#messageparceldeprecated)) | Yes| No| [rpc.Sequenceable](js-apis-rpc.md#sequenceabledeprecated) | Prototype of the listener function registered by the callee.|
+| (indata: [rpc.MessageParcel](js-apis-rpc.md#sequenceabledeprecated)) | Yes| No| [rpc.Sequenceable](js-apis-rpc.md#sequenceabledeprecated) | Prototype of the listener function registered by the callee.|
diff --git a/en/application-dev/reference/apis/js-apis-app-ability-want.md b/en/application-dev/reference/apis/js-apis-app-ability-want.md
index c96e29d90f3a10a563df41bc8a545cb42dfdeba4..072650fbf9da660338776689f4db051d2e417af0 100644
--- a/en/application-dev/reference/apis/js-apis-app-ability-want.md
+++ b/en/application-dev/reference/apis/js-apis-app-ability-want.md
@@ -18,119 +18,118 @@ import Want from '@ohos.app.ability.Want';
| Name | Type | Mandatory| Description |
| ----------- | -------------------- | ---- | ------------------------------------------------------------ |
-| deviceId | string | No | ID of the device running the ability. If this field is unspecified, the local device is used. |
-| bundleName | string | No | Bundle name of the ability.|
-| moduleName | string | No| Name of the module to which the ability belongs.|
+| deviceId | string | No | ID of the device running the ability. |
+| bundleName | string | No | Bundle name of the ability. If both **bundleName** and **abilityName** are specified in a **Want** object, the **Want** object can match a specific ability. |
| abilityName | string | No | Name of the ability. If both **bundleName** and **abilityName** are specified in a **Want** object, the **Want** object can match a specific ability. The value of **abilityName** must be unique in an application.|
-| [action](js-apis-app-ability-wantConstant.md#wantconstantaction) | string | No | Action to take, such as viewing and sharing application details. In implicit Want, you can define this field and use it together with **uri** or **parameters** to specify the operation to be performed on the data. For details about the definition and matching rules of implicit Want, see [Matching Rules of Explicit Want and Implicit Want](../../application-models/explicit-implicit-want-mappings.md). |
-| [entities](js-apis-app-ability-wantConstant.md#wantconstantentity) | Array\ | No| Additional category information (such as browser and video player) of the ability. It is a supplement to the **action** field for implicit Want. and is used to filter ability types.|
-| uri | string | No| Data carried. This field is used together with **type** to specify the data type. If **uri** is specified in a Want, the Want will match the specified URI information, including **scheme**, **schemeSpecificPart**, **authority**, and **path**.|
-| type | string | No| MIME type, that is, the type of the file to open, for example, **text/xml** and **image/***. For details about the MIME type definition, see https://www.iana.org/assignments/media-types/media-types.xhtml?utm_source=ld246.com.|
-| parameters | {[key: string]: any} | No | Want parameters in the form of custom key-value (KV) pairs. By default, the following keys are carried:
- **ohos.aafwk.callerPid**: PID of the caller.
- **ohos.aafwk.param.callerToken**: token of the caller.
- **ohos.aafwk.param.callerUid**: UID in [BundleInfo](js-apis-bundleManager-bundleInfo.md#bundleinfo-1), that is, the application UID in the bundle information. |
-| [flags](js-apis-ability-wantConstant.md#wantconstantflags) | number | No| How the **Want** object will be handled. By default, a number is passed in.
For example, **wantConstant.Flags.FLAG_ABILITY_CONTINUATION** specifies whether to start the ability in cross-device migration scenarios.|
+| uri | string | No| If **uri** is specified in a **Want**, the **Want** will match the specified URI information, including **scheme**, **schemeSpecificPart**, **authority**, and **path** components.|
+| type | string | No| MIME type, that is, the type of the file to open, for example, **'text/xml'** and **'image/*'**. For details about the MIME type definition, see https://www.iana.org/assignments/media-types/media-types.xhtml?utm_source=ld246.com.|
+| flags | number | No| How the **Want** object will be handled. By default, a number is passed in. For details, see [flags](js-apis-ability-wantConstant.md#wantConstant.Flags). |
+| action | string | No | Action to take, such as viewing and sharing application details. In implicit Want, you can define this field and use it together with **uri** or **parameters** to specify the operation to be performed on the data. |
+| parameters | {[key: string]: any} | No | Want parameters in the form of custom key-value (KV) pairs. By default, the following keys are carried:
- **ohos.aafwk.callerPid**: PID of the caller.
- **ohos.aafwk.param.callerToken**: token of the caller.
- **ohos.aafwk.param.callerUid**: UID in [BundleInfo](js-apis-bundleManager-bundleInfo.md#bundleinfo-1), that is, the application UID in the bundle information.
- **component.startup.newRules**: whether to enable the new control rule.
- **moduleName**: module name of the caller. No matter what this field is set to, the correct module name will be sent to the peer.
- **ohos.dlp.params.sandbox**: available only for DLP files. |
+| entities | Array\ | No| Additional category information (such as browser and video player) of the ability. It is a supplement to the **action** field for implicit Want. and is used to filter ability types.|
+| moduleName | string | | Module to which the ability belongs. |
**Example**
-- Basic usage (called in a UIAbility object, where context in the example is the context object of the UIAbility).
+- Basic usage
```ts
let want = {
- "deviceId": "", // An empty deviceId indicates the local device.
- "bundleName": "com.example.myapplication",
- "abilityName": "FuncAbility",
- "moduleName": "entry" // moduleName is optional.
+ 'deviceId': '', // An empty deviceId indicates the local device.
+ 'bundleName': 'com.extreme.test',
+ 'abilityName': 'MainAbility',
+ 'moduleName': 'entry' // moduleName is optional
};
this.context.startAbility(want, (error) => {
// Start an ability explicitly. The bundleName, abilityName, and moduleName parameters work together to uniquely identify an ability.
- console.log("error.code = " + error.code)
+ console.log('error.code = ' + error.code);
})
```
-- Data is transferred through user-defined fields. The following data types are supported (called in a UIAbility object, where context in the example is the context object of the UIAbility):
+- Data is transferred through user-defined fields. The following data types are supported:
* String
```ts
let want = {
- bundleName: "com.example.myapplication",
- abilityName: "FuncAbility",
+ bundleName: 'com.example.demo',
+ abilityName: 'com.example.demo.MainAbility',
parameters: {
- keyForString: "str",
+ keyForString: 'str',
},
- }
+ };
```
* Number
```ts
let want = {
- bundleName: "com.example.myapplication",
- abilityName: "FuncAbility",
+ bundleName: 'com.example.demo',
+ abilityName: 'com.example.demo.MainAbility',
parameters: {
keyForInt: 100,
keyForDouble: 99.99,
},
- }
+ };
```
* Boolean
```ts
let want = {
- bundleName: "com.example.myapplication",
- abilityName: "FuncAbility",
+ bundleName: 'com.example.demo',
+ abilityName: 'com.example.demo.MainAbility',
parameters: {
keyForBool: true,
},
- }
+ };
```
* Object
```ts
let want = {
- bundleName: "com.example.myapplication",
- abilityName: "FuncAbility",
+ bundleName: 'com.example.demo',
+ abilityName: 'com.example.demo.MainAbility',
parameters: {
keyForObject: {
- keyForObjectString: "str",
+ keyForObjectString: 'str',
keyForObjectInt: -200,
keyForObjectDouble: 35.5,
keyForObjectBool: false,
},
},
- }
+ };
```
* Array
```ts
let want = {
- bundleName: "com.example.myapplication",
- abilityName: "FuncAbility",
+ bundleName: 'com.example.demo',
+ abilityName: 'com.example.demo.MainAbility',
parameters: {
- keyForArrayString: ["str1", "str2", "str3"],
+ keyForArrayString: ['str1', 'str2', 'str3'],
keyForArrayInt: [100, 200, 300, 400],
keyForArrayDouble: [0.1, 0.2],
- keyForArrayObject: [{obj1: "aaa"}, {obj2: 100}],
+ keyForArrayObject: [{obj1: 'aaa'}, {obj2: 100}],
},
- }
+ };
```
* File descriptor (FD)
```ts
- import fileio from '@ohos.fileio';
- let fd;
- try {
- fd = fileio.openSync("/data/storage/el2/base/haps/pic.png");
- } catch(e) {
- console.log("openSync fail:" + JSON.stringify(e));
- }
- let want = {
- "deviceId": "", // An empty deviceId indicates the local device.
- "bundleName": "com.example.myapplication",
- "abilityName": "FuncAbility",
- "moduleName": "entry", // moduleName is optional.
- "parameters": {
- "keyFd":{"type":"FD", "value":fd}
+ import fileio from '@ohos.fileio';
+ let fd;
+ try {
+ fd = fileio.openSync('/data/storage/el2/base/haps/pic.png');
+ } catch(e) {
+ console.log('openSync fail:' + JSON.stringify(e));
}
- };
- this.context.startAbility(want, (error) => {
+ let want = {
+ 'deviceId': '', // An empty deviceId indicates the local device.
+ 'bundleName': 'com.extreme.test',
+ 'abilityName': 'MainAbility',
+ 'moduleName': 'entry', // moduleName is optional.
+ 'parameters': {
+ 'keyFd':{'type':'FD', 'value':fd} // {'type':'FD', 'value':fd} is a fixed usage, indicating that the data is a file descriptor.
+ }
+ };
+ this.context.startAbility(want, (error) => {
// Start an ability explicitly. The bundleName, abilityName, and moduleName parameters work together to uniquely identify an ability.
- console.log("error.code = " + error.code)
- })
+ console.log('error.code = ' + error.code);
+ });
```
-- For more details and examples, see [Want](../../application-models/want-overview.md).
-
+
diff --git a/en/application-dev/reference/apis/js-apis-app-ability-wantAgent.md b/en/application-dev/reference/apis/js-apis-app-ability-wantAgent.md
index 43b95743b25c34bdae9457c1e1ed1cf01f8e986e..f65d9971dc55689ee2df76bdc32cf80ffb1e010d 100644
--- a/en/application-dev/reference/apis/js-apis-app-ability-wantAgent.md
+++ b/en/application-dev/reference/apis/js-apis-app-ability-wantAgent.md
@@ -1,6 +1,6 @@
# @ohos.app.ability.wantAgent (WantAgent)
-The **app.ability.WantAgent** module provides APIs for creating and comparing **WantAgent** objects, and obtaining the user ID and bundle name of a **WantAgent** object. You are advised to use this module, since it will replace the [@ohos.wantAgent](js-apis-wantAgent.md) module in the near future.
+The **WantAgent** module provides APIs for creating and comparing **WantAgent** objects, and obtaining the user ID and bundle name of a **WantAgent** object. You are advised to use this module, since it will replace the [@ohos.wantAgent](js-apis-wantAgent.md) module in the near future.
> **NOTE**
>
@@ -8,7 +8,7 @@ The **app.ability.WantAgent** module provides APIs for creating and comparing **
## Modules to Import
-```ts
+```js
import WantAgent from '@ohos.app.ability.wantAgent';
```
@@ -16,7 +16,7 @@ import WantAgent from '@ohos.app.ability.wantAgent';
getWantAgent(info: WantAgentInfo, callback: AsyncCallback\): void
-Obtains a **WantAgent** object. This API uses an asynchronous callback to return the result.
+Obtains a **WantAgent** object. This API uses an asynchronous callback to return the result. If the creation fails, a null **WantAgent** object is returned.
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
@@ -27,45 +27,22 @@ Obtains a **WantAgent** object. This API uses an asynchronous callback to return
| info | [WantAgentInfo](js-apis-inner-wantAgent-wantAgentInfo.md) | Yes | Information about the **WantAgent** object to obtain. |
| callback | AsyncCallback\ | Yes | Callback used to return the **WantAgent** object.|
-**Error codes**
-For details about the error codes, see [Ability Error Codes](../errorcodes/errorcode-ability.md).
-| ID | Error Message |
-|-----------|--------------------|
-| 16000001 | Input error. The specified ability name does not exist. |
-| 16000002 | Ability type error. The specified ability type is wrong.|
-| 16000003 | Input error. The specified id does not exist.|
-| 16000004 | Visibility verification failed.|
-| 16000006 | Can not cross user operations.|
-| 16000007 | Service busyness. There are concurrent tasks, waiting for retry.|
-| 16000008 | Crowdtest App Expiration.|
-| 16000009 | Can not start ability in wukong mode.|
-| 16000010 | Can not operation with continue flag.|
-| 16000011 | Context does not exist.|
-| 16000050 | Internal Error.|
-| 16000051 | Network error. The network is abnormal.|
-| 16000052 | Free install not support. The application does not support free install.|
-| 16000053 | Not top ability. The application is not top ability.|
-| 16000054 | Free install busyness. There are concurrent tasks, waiting for retry.|
-| 16000055 | Free install timeout.|
-| 16000056 | Can not free install other ability.|
-| 16000057 | Not support cross device free install.|
-| 16000101 | execute shell command failed.|
-| 16000151 | Invalid wantagent object.|
-| 16000152 | wantAgent object not found.|
-| 16000153 | wangAgent object canceled.|
-
**Example**
-```ts
-// WantAgent object
-let wantAgent;
+```js
+import WantAgent from '@ohos.app.ability.wantAgent';
+
+// getWantAgent callback
+function getWantAgentCallback(err, data) {
+ console.info('==========================>getWantAgentCallback=======================>');
+}
// WantAgentInfo object
let wantAgentInfo = {
wants: [
{
deviceId: 'deviceId',
- bundleName: 'com.example.myapplication',
- abilityName: 'EntryAbility',
+ bundleName: 'com.neu.setResultOnAbilityResultTest1',
+ abilityName: 'com.example.test.MainAbility',
action: 'action1',
entities: ['entity1'],
type: 'MIMETYPE',
@@ -85,20 +62,12 @@ let wantAgentInfo = {
operationType: WantAgent.OperationType.START_ABILITIES,
requestCode: 0,
wantAgentFlags:[WantAgent.WantAgentFlags.UPDATE_PRESENT_FLAG]
-}
+};
-// getWantAgent callback
-function getWantAgentCallback(err, data) {
- if (err === undefined) {
- wantAgent = data;
- } else {
- console.info('getWantAgent failed' + JSON.stringify(err));
- }
-}
try {
WantAgent.getWantAgent(wantAgentInfo, getWantAgentCallback);
-} catch(err) {
- console.info('getWantAgent failed!' + JSON.stringify(err.code) + JSON.stringify(err.message));
+} catch (paramError) {
+ console.log('error: ' + paramError.code + ', ' + paramError.message);
}
```
@@ -108,7 +77,7 @@ try {
getWantAgent(info: WantAgentInfo): Promise\
-Obtains a **WantAgent** object. This API uses a promise to return the result.
+Obtains a **WantAgent** object. This API uses a promise to return the result. If the creation fails, a null **WantAgent** object is returned.
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
@@ -124,43 +93,19 @@ Obtains a **WantAgent** object. This API uses a promise to return the result.
| ----------------------------------------------------------- | ------------------------------------------------------------ |
| Promise\ | Promise used to return the **WantAgent** object.|
-**Error codes**
-For details about the error codes, see [Ability Error Codes](../errorcodes/errorcode-ability.md).
-| ID | Error Message |
-|-----------|--------------------|
-| 16000001 | Input error. The specified ability name does not exist. |
-| 16000002 | Ability type error. The specified ability type is wrong.|
-| 16000003 | Input error. The specified id does not exist.|
-| 16000004 | Visibility verification failed.|
-| 16000006 | Can not cross user operations.|
-| 16000007 | Service busyness. There are concurrent tasks, waiting for retry.|
-| 16000008 | Crowdtest App Expiration.|
-| 16000009 | Can not start ability in wukong mode.|
-| 16000010 | Can not operation with continue flag.|
-| 16000011 | Context does not exist.|
-| 16000050 | Internal Error.|
-| 16000051 | Network error. The network is abnormal.|
-| 16000052 | Free install not support. The application does not support free install.|
-| 16000053 | Not top ability. The application is not top ability.|
-| 16000054 | Free install busyness. There are concurrent tasks, waiting for retry.|
-| 16000055 | Free install timeout.|
-| 16000056 | Can not free install other ability.|
-| 16000057 | Not support cross device free install.|
-| 16000101 | execute shell command failed.|
-| 16000151 | Invalid wantagent object.|
-| 16000152 | wantAgent object not found.|
-| 16000153 | wangAgent object canceled.|
-
**Example**
-```ts
+```js
+import WantAgent from '@ohos.app.ability.wantAgent';
+
+
// WantAgentInfo object
let wantAgentInfo = {
wants: [
{
deviceId: 'deviceId',
- bundleName: 'com.example.myapplication',
- abilityName: 'EntryAbility',
+ bundleName: 'com.neu.setResultOnAbilityResultTest1',
+ abilityName: 'com.example.test.MainAbility',
action: 'action1',
entities: ['entity1'],
type: 'MIMETYPE',
@@ -180,16 +125,14 @@ let wantAgentInfo = {
operationType: WantAgent.OperationType.START_ABILITIES,
requestCode: 0,
wantAgentFlags:[WantAgent.WantAgentFlags.UPDATE_PRESENT_FLAG]
-}
+};
try {
WantAgent.getWantAgent(wantAgentInfo).then((data) => {
- wantAgent = data;
-}).catch((err) => {
- console.info('getWantAgent failed!' + JSON.stringify(err.code) + JSON.stringify(err.message));
-});
-} catch (err) {
- console.info('getWantAgent failed!' + JSON.stringify(err.code) + JSON.stringify(err.message));
+ console.info('==========================>getWantAgentCallback=======================>');
+ });
+} catch (paramError) {
+ console.log('error: ' + paramError.code + ', ' + paramError.message);
}
```
@@ -210,45 +153,31 @@ Obtains the bundle name of a **WantAgent** object. This API uses an asynchronous
| agent | WantAgent | Yes | Target **WantAgent** object. |
| callback | AsyncCallback\ | Yes | Callback used to return the bundle name.|
-**Error codes**
-For details about the error codes, see [Ability Error Codes](../errorcodes/errorcode-ability.md).
-| ID | Error Message |
-|-----------|--------------------|
-| 16000001 | Input error. The specified ability name does not exist. |
-| 16000002 | Ability type error. The specified ability type is wrong.|
-| 16000003 | Input error. The specified id does not exist.|
-| 16000004 | Visibility verification failed.|
-| 16000006 | Can not cross user operations.|
-| 16000007 | Service busyness. There are concurrent tasks, waiting for retry.|
-| 16000008 | Crowdtest App Expiration.|
-| 16000009 | Can not start ability in wukong mode.|
-| 16000010 | Can not operation with continue flag.|
-| 16000011 | Context does not exist.|
-| 16000050 | Internal Error.|
-| 16000051 | Network error. The network is abnormal.|
-| 16000052 | Free install not support. The application does not support free install.|
-| 16000053 | Not top ability. The application is not top ability.|
-| 16000054 | Free install busyness. There are concurrent tasks, waiting for retry.|
-| 16000055 | Free install timeout.|
-| 16000056 | Can not free install other ability.|
-| 16000057 | Not support cross device free install.|
-| 16000101 | execute shell command failed.|
-| 16000151 | Invalid wantagent object.|
-| 16000152 | wantAgent object not found.|
-| 16000153 | wangAgent object canceled.|
-
**Example**
-```ts
-// WantAgent object
+```js
+import WantAgent from '@ohos.app.ability.wantAgent';
+
+
+// wantAgent object
let wantAgent;
+
+//getWantAgent callback
+function getWantAgentCallback(err, data) {
+ console.info('==========================>getWantAgentCallback=======================>');
+ if (err.code == 0) {
+ wantAgent = data;
+ } else {
+ console.info('----getWantAgent failed!----');
+ }
+}
// WantAgentInfo object
let wantAgentInfo = {
wants: [
{
deviceId: 'deviceId',
- bundleName: 'com.example.myapplication',
- abilityName: 'EntryAbility',
+ bundleName: 'com.neu.setResultOnAbilityResultTest1',
+ abilityName: 'com.example.test.MainAbility',
action: 'action1',
entities: ['entity1'],
type: 'MIMETYPE',
@@ -268,33 +197,18 @@ let wantAgentInfo = {
operationType: WantAgent.OperationType.START_ABILITIES,
requestCode: 0,
wantAgentFlags:[WantAgent.WantAgentFlags.UPDATE_PRESENT_FLAG]
-}
+};
+
+try {
+ WantAgent.getWantAgent(wantAgentInfo, getWantAgentCallback);
-// getWantAgent callback
-function getWantAgentCallback(err, data) {
- if (err === undefined) {
- wantAgent = data;
- } else {
- console.info('getWantAgent failed' + JSON.stringify(wantAgent));
- }
// getBundleName callback
function getBundleNameCallback(err, data) {
- if(err) {
- console.info('getBundleName failed!' + JSON.stringify(err.code) + JSON.stringify(err.message));
- } else {
- console.info('getBundleName ok!' + JSON.stringify(data));
- }
- }
- try {
- WantAgent.getBundleName(wantAgent, getBundleNameCallback);
- } catch(err) {
- console.info('getBundleName failed!' + JSON.stringify(err.code) + JSON.stringify(err.message));
+ console.info('==========================>getBundleNameCallback=======================>');
}
-}
-try {
- WantAgent.getWantAgent(wantAgentInfo, getWantAgentCallback);
-} catch(err) {
- console.info('getWantAgent failed!' + JSON.stringify(err.code) + JSON.stringify(err.message));
+ WantAgent.getBundleName(wantAgent, getBundleNameCallback);
+} catch (paramError) {
+ console.log('error: ' + paramError.code + ', ' + paramError.message);
}
```
@@ -320,45 +234,22 @@ Obtains the bundle name of a **WantAgent** object. This API uses a promise to re
| ----------------------------------------------------------- | ------------------------------------------------------------ |
| Promise\ | Promise used to return the bundle name.|
-**Error codes**
-For details about the error codes, see [Ability Error Codes](../errorcodes/errorcode-ability.md).
-| ID | Error Message |
-|-----------|--------------------|
-| 16000001 | Input error. The specified ability name does not exist. |
-| 16000002 | Ability type error. The specified ability type is wrong.|
-| 16000003 | Input error. The specified id does not exist.|
-| 16000004 | Visibility verification failed.|
-| 16000006 | Can not cross user operations.|
-| 16000007 | Service busyness. There are concurrent tasks, waiting for retry.|
-| 16000008 | Crowdtest App Expiration.|
-| 16000009 | Can not start ability in wukong mode.|
-| 16000010 | Can not operation with continue flag.|
-| 16000011 | Context does not exist.|
-| 16000050 | Internal Error.|
-| 16000051 | Network error. The network is abnormal.|
-| 16000052 | Free install not support. The application does not support free install.|
-| 16000053 | Not top ability. The application is not top ability.|
-| 16000054 | Free install busyness. There are concurrent tasks, waiting for retry.|
-| 16000055 | Free install timeout.|
-| 16000056 | Can not free install other ability.|
-| 16000057 | Not support cross device free install.|
-| 16000101 | execute shell command failed.|
-| 16000151 | Invalid wantagent object.|
-| 16000152 | wantAgent object not found.|
-| 16000153 | wangAgent object canceled.|
-
**Example**
-```ts
- // WantAgent object
+```js
+import WantAgent from '@ohos.app.ability.wantAgent';
+
+
+// wantAgent object
let wantAgent;
-// WantAgentInfo object
+
+//WantAgentInfo object
let wantAgentInfo = {
wants: [
{
deviceId: 'deviceId',
- bundleName: 'com.example.myapplication',
- abilityName: 'EntryAbility',
+ bundleName: 'com.neu.setResultOnAbilityResultTest1',
+ abilityName: 'com.example.test.MainAbility',
action: 'action1',
entities: ['entity1'],
type: 'MIMETYPE',
@@ -378,29 +269,19 @@ let wantAgentInfo = {
operationType: WantAgent.OperationType.START_ABILITIES,
requestCode: 0,
wantAgentFlags:[WantAgent.WantAgentFlags.UPDATE_PRESENT_FLAG]
-}
+};
-// getWantAgent callback
-function getWantAgentCallback(err, data) {
- if (err === undefined) {
- wantAgent = data;
- } else {
- console.info('getWantAgent failed!' + JSON.stringify(wantAgent));
- }
- try {
- WantAgent.getBundleName(wantAgent).then((data)=>{
- console.info('getBundleName ok!' + JSON.stringify(data));
- }).catch((err)=>{
- console.info('getBundleName failed!' + JSON.stringify(err.code) + JSON.stringify(err.message));
- })
- } catch(err){
- console.info('getBundleName failed!' + JSON.stringify(err.code) + JSON.stringify(err.message));
- }
-}
try {
- WantAgent.getWantAgent(wantAgentInfo, getWantAgentCallback);
-} catch(err) {
- console.info('getWantAgent failed!' + JSON.stringify(err.code) + JSON.stringify(err.message));
+ WantAgent.getWantAgent(wantAgentInfo).then((data) => {
+ console.info('==========================>getWantAgentCallback=======================>');
+ wantAgent = data;
+ });
+
+ WantAgent.getBundleName(wantAgent).then((data) => {
+ console.info('==========================>getBundleNameCallback=======================>');
+ });
+} catch (paramError) {
+ console.log('error: ' + paramError.code + ', ' + paramError.message);
}
```
@@ -421,46 +302,31 @@ Obtains the user ID of a **WantAgent** object. This API uses an asynchronous cal
| agent | WantAgent | Yes | Target **WantAgent** object. |
| callback | AsyncCallback\ | Yes | Callback used to return the user ID.|
-**Error codes**
-For details about the error codes, see [Ability Error Codes](../errorcodes/errorcode-ability.md).
-| ID | Error Message |
-|-----------|--------------------|
-| 16000001 | Input error. The specified ability name does not exist. |
-| 16000002 | Ability type error. The specified ability type is wrong.|
-| 16000003 | Input error. The specified id does not exist.|
-| 16000004 | Visibility verification failed.|
-| 16000006 | Can not cross user operations.|
-| 16000007 | Service busyness. There are concurrent tasks, waiting for retry.|
-| 16000008 | Crowdtest App Expiration.|
-| 16000009 | Can not start ability in wukong mode.|
-| 16000010 | Can not operation with continue flag.|
-| 16000011 | Context does not exist.|
-| 16000050 | Internal Error.|
-| 16000051 | Network error. The network is abnormal.|
-| 16000052 | Free install not support. The application does not support free install.|
-| 16000053 | Not top ability. The application is not top ability.|
-| 16000054 | Free install busyness. There are concurrent tasks, waiting for retry.|
-| 16000055 | Free install timeout.|
-| 16000056 | Can not free install other ability.|
-| 16000057 | Not support cross device free install.|
-| 16000101 | execute shell command failed.|
-| 16000151 | Invalid wantagent object.|
-| 16000152 | wantAgent object not found.|
-| 16000153 | wangAgent object canceled.|
-
**Example**
-```ts
+```js
import WantAgent from '@ohos.app.ability.wantAgent';
-// WantAgent object
+
+
+// wantAgent object
let wantAgent;
+
+// getWantAgent callback
+function getWantAgentCallback(err, data) {
+ console.info('==========================>getWantAgentCallback=======================>');
+ if (err.code == 0) {
+ wantAgent = data;
+ } else {
+ console.info('----getWantAgent failed!----');
+ }
+}
// WantAgentInfo object
let wantAgentInfo = {
wants: [
{
deviceId: 'deviceId',
- bundleName: 'com.example.myapplication',
- abilityName: 'EntryAbility',
+ bundleName: 'com.neu.setResultOnAbilityResultTest1',
+ abilityName: 'com.example.test.MainAbility',
action: 'action1',
entities: ['entity1'],
type: 'MIMETYPE',
@@ -480,33 +346,18 @@ let wantAgentInfo = {
operationType: WantAgent.OperationType.START_ABILITIES,
requestCode: 0,
wantAgentFlags:[WantAgent.WantAgentFlags.UPDATE_PRESENT_FLAG]
-}
+};
+
+try {
+ WantAgent.getWantAgent(wantAgentInfo, getWantAgentCallback);
-// getWantAgent callback
-function getWantAgentCallback(err, data) {
- if (err === undefined) {
- wantAgent = data;
- } else {
- console.info('getWantAgent failed' + JSON.stringify(err));
- }
// getUid callback
function getUidCallback(err, data) {
- if(err) {
- console.info('getUid failed!' + JSON.stringify(err.code) + JSON.stringify(err.message));
- } else {
- console.info('getUid ok!' + JSON.stringify(data));
- }
- }
- try {
- WantAgent.getUid(wantAgent, getUidCallback);
- } catch(err) {
- console.info('getUid failed!' + JSON.stringify(err.code) + JSON.stringify(err.message));
+ console.info('==========================>getUidCallback=======================>');
}
-}
-try {
- WantAgent.getWantAgent(wantAgentInfo, getWantAgentCallback);
-} catch(err) {
- console.info('getWantAgent failed!' + JSON.stringify(err.code) + JSON.stringify(err.message));
+ WantAgent.getUid(wantAgent, getUidCallback);
+} catch (paramError) {
+ console.log('error: ' + paramError.code + ', ' + paramError.message);
}
```
@@ -532,45 +383,22 @@ Obtains the user ID of a **WantAgent** object. This API uses a promise to return
| ----------------------------------------------------------- | ------------------------------------------------------------ |
| Promise\ | Promise used to return the user ID.|
-**Error codes**
-For details about the error codes, see [Ability Error Codes](../errorcodes/errorcode-ability.md).
-| ID | Error Message |
-|-----------|--------------------|
-| 16000001 | Input error. The specified ability name does not exist. |
-| 16000002 | Ability type error. The specified ability type is wrong.|
-| 16000003 | Input error. The specified id does not exist.|
-| 16000004 | Visibility verification failed.|
-| 16000006 | Can not cross user operations.|
-| 16000007 | Service busyness. There are concurrent tasks, waiting for retry.|
-| 16000008 | Crowdtest App Expiration.|
-| 16000009 | Can not start ability in wukong mode.|
-| 16000010 | Can not operation with continue flag.|
-| 16000011 | Context does not exist.|
-| 16000050 | Internal Error.|
-| 16000051 | Network error. The network is abnormal.|
-| 16000052 | Free install not support. The application does not support free install.|
-| 16000053 | Not top ability. The application is not top ability.|
-| 16000054 | Free install busyness. There are concurrent tasks, waiting for retry.|
-| 16000055 | Free install timeout.|
-| 16000056 | Can not free install other ability.|
-| 16000057 | Not support cross device free install.|
-| 16000101 | execute shell command failed.|
-| 16000151 | Invalid wantagent object.|
-| 16000152 | wantAgent object not found.|
-| 16000153 | wangAgent object canceled.|
-
**Example**
-```ts
-// WantAgent object
+```js
+import WantAgent from '@ohos.app.ability.wantAgent';
+
+
+// wantAgent object
let wantAgent;
+
// WantAgentInfo object
let wantAgentInfo = {
wants: [
{
deviceId: 'deviceId',
- bundleName: 'com.example.myapplication',
- abilityName: 'EntryAbility',
+ bundleName: 'com.neu.setResultOnAbilityResultTest1',
+ abilityName: 'com.example.test.MainAbility',
action: 'action1',
entities: ['entity1'],
type: 'MIMETYPE',
@@ -590,33 +418,24 @@ let wantAgentInfo = {
operationType: WantAgent.OperationType.START_ABILITIES,
requestCode: 0,
wantAgentFlags:[WantAgent.WantAgentFlags.UPDATE_PRESENT_FLAG]
-}
+};
-// getWantAgent callback
-function getWantAgentCallback(err, data) {
- if (err === undefined) {
- wantAgent = data;
- } else {
- console.info('getWantAgent failed!' + JSON.stringify(wantAgent));
- }
- try {
- WantAgent.getUid(wantAgent).then((data)=>{
- console.info('getUid ok!' + JSON.stringify(data));
- }).catch((err)=>{
- console.info('getUid failed!' + JSON.stringify(err.code) + JSON.stringify(err.message));
- })
- } catch(err){
- console.info('getUid failed!' + JSON.stringify(err.code) + JSON.stringify(err.message));
- }
-}
try {
- WantAgent.getWantAgent(wantAgentInfo, getWantAgentCallback);
-} catch(err) {
- console.info('getWantAgent failed!' + JSON.stringify(err.code) + JSON.stringify(err.message));
+ WantAgent.getWantAgent(wantAgentInfo).then((data) => {
+ console.info('==========================>getWantAgentCallback=======================>');
+ wantAgent = data;
+ });
+
+ WantAgent.getUid(wantAgent).then((data) => {
+ console.info('==========================>getUidCallback=======================>');
+ });
+} catch (paramError) {
+ console.log('error: ' + paramError.code + ', ' + paramError.message);
}
```
+
## WantAgent.getWant
getWant(agent: WantAgent, callback: AsyncCallback\): void
@@ -634,45 +453,31 @@ Obtains the want in a **WantAgent** object. This API uses an asynchronous callba
| agent | WantAgent | Yes | Target **WantAgent** object. |
| callback | AsyncCallback\<[Want](js-apis-app-ability-want.md)\> | Yes | Callback used to return the want.|
-**Error codes**
-For details about the error codes, see [Ability Error Codes](../errorcodes/errorcode-ability.md).
-| ID | Error Message |
-|-----------|--------------------|
-| 16000001 | Input error. The specified ability name does not exist. |
-| 16000002 | Ability type error. The specified ability type is wrong.|
-| 16000003 | Input error. The specified id does not exist.|
-| 16000004 | Visibility verification failed.|
-| 16000006 | Can not cross user operations.|
-| 16000007 | Service busyness. There are concurrent tasks, waiting for retry.|
-| 16000008 | Crowdtest App Expiration.|
-| 16000009 | Can not start ability in wukong mode.|
-| 16000010 | Can not operation with continue flag.|
-| 16000011 | Context does not exist.|
-| 16000050 | Internal Error.|
-| 16000051 | Network error. The network is abnormal.|
-| 16000052 | Free install not support. The application does not support free install.|
-| 16000053 | Not top ability. The application is not top ability.|
-| 16000054 | Free install busyness. There are concurrent tasks, waiting for retry.|
-| 16000055 | Free install timeout.|
-| 16000056 | Can not free install other ability.|
-| 16000057 | Not support cross device free install.|
-| 16000101 | execute shell command failed.|
-| 16000151 | Invalid wantagent object.|
-| 16000152 | wantAgent object not found.|
-| 16000153 | wangAgent object canceled.|
-
**Example**
-```ts
-// WantAgent object
+```js
+import WantAgent from '@ohos.app.ability.wantAgent';
+
+
+// wantAgent object
let wantAgent;
+
+// getWantAgent callback
+function getWantAgentCallback(err, data) {
+ console.info('==========================>getWantAgentCallback=======================>');
+ if (err.code == 0) {
+ wantAgent = data;
+ } else {
+ console.info('----getWantAgent failed!----');
+ }
+}
// WantAgentInfo object
let wantAgentInfo = {
wants: [
{
deviceId: 'deviceId',
- bundleName: 'com.example.myapplication',
- abilityName: 'EntryAbility',
+ bundleName: 'com.neu.setResultOnAbilityResultTest1',
+ abilityName: 'com.example.test.MainAbility',
action: 'action1',
entities: ['entity1'],
type: 'MIMETYPE',
@@ -692,33 +497,18 @@ let wantAgentInfo = {
operationType: WantAgent.OperationType.START_ABILITIES,
requestCode: 0,
wantAgentFlags:[WantAgent.WantAgentFlags.UPDATE_PRESENT_FLAG]
-}
+};
-// getWantAgent callback
-function getWantAgentCallback(err, data) {
- if (err === undefined) {
- wantAgent = data;
- } else {
- console.info('getWantAgent failed' + JSON.stringify(wantAgent));
- }
- // getUid callback
- function getWantCallback(err, data) {
- if(err) {
- console.info('getWant failed!' + JSON.stringify(err.code) + JSON.stringify(err.message));
- } else {
- console.info('getWant ok!' + JSON.stringify(data));
- }
- }
- try {
- WantAgent.getWant(wantAgent, getBundleNameCallback);
- } catch(err) {
- console.info('getWant failed!' + JSON.stringify(err.code) + JSON.stringify(err.message));
- }
-}
try {
WantAgent.getWantAgent(wantAgentInfo, getWantAgentCallback);
-} catch(err) {
- console.info('getWantAgent failed!' + JSON.stringify(err.code) + JSON.stringify(err.message));
+
+ // getWant callback
+ function getWantCallback(err, data) {
+ console.info('==========================>getWantCallback=======================>');
+ }
+ WantAgent.getWant(wantAgent, getWantCallback);
+} catch (paramError) {
+ console.log('error: ' + paramError.code + ', ' + paramError.message);
}
```
@@ -746,45 +536,22 @@ Obtains the want in a **WantAgent** object. This API uses a promise to return th
| ----------------------------------------------------------- | ------------------------------------------------------------ |
| Promise\ | Promise used to return the want.|
-**Error codes**
-For details about the error codes, see [Ability Error Codes](../errorcodes/errorcode-ability.md).
-| ID | Error Message |
-|-----------|--------------------|
-| 16000001 | Input error. The specified ability name does not exist. |
-| 16000002 | Ability type error. The specified ability type is wrong.|
-| 16000003 | Input error. The specified id does not exist.|
-| 16000004 | Visibility verification failed.|
-| 16000006 | Can not cross user operations.|
-| 16000007 | Service busyness. There are concurrent tasks, waiting for retry.|
-| 16000008 | Crowdtest App Expiration.|
-| 16000009 | Can not start ability in wukong mode.|
-| 16000010 | Can not operation with continue flag.|
-| 16000011 | Context does not exist.|
-| 16000050 | Internal Error.|
-| 16000051 | Network error. The network is abnormal.|
-| 16000052 | Free install not support. The application does not support free install.|
-| 16000053 | Not top ability. The application is not top ability.|
-| 16000054 | Free install busyness. There are concurrent tasks, waiting for retry.|
-| 16000055 | Free install timeout.|
-| 16000056 | Can not free install other ability.|
-| 16000057 | Not support cross device free install.|
-| 16000101 | execute shell command failed.|
-| 16000151 | Invalid wantagent object.|
-| 16000152 | wantAgent object not found.|
-| 16000153 | wangAgent object canceled.|
-
**Example**
-```ts
-// WantAgent object
+```js
+import WantAgent from '@ohos.app.ability.wantAgent';
+
+
+// wantAgent object
let wantAgent;
+
// WantAgentInfo object
let wantAgentInfo = {
wants: [
{
deviceId: 'deviceId',
- bundleName: 'com.example.myapplication',
- abilityName: 'EntryAbility',
+ bundleName: 'com.neu.setResultOnAbilityResultTest1',
+ abilityName: 'com.example.test.MainAbility',
action: 'action1',
entities: ['entity1'],
type: 'MIMETYPE',
@@ -804,29 +571,19 @@ let wantAgentInfo = {
operationType: WantAgent.OperationType.START_ABILITIES,
requestCode: 0,
wantAgentFlags:[WantAgent.WantAgentFlags.UPDATE_PRESENT_FLAG]
-}
+};
-// getWantAgent callback
-function getWantAgentCallback(err, data) {
- if (err === undefined) {
- wantAgent = data;
- } else {
- console.info('getWantAgent failed!' + JSON.stringify(wantAgent));
- }
- try {
- WantAgent.getUid(wantAgent).then((data)=>{
- console.info('getUid ok!' + JSON.stringify(data));
- }).catch((err)=>{
- console.info('getUid failed!' + JSON.stringify(err.code) + JSON.stringify(err.message));
- })
- } catch(err){
- console.info('getUid failed!' + JSON.stringify(err.code) + JSON.stringify(err.message));
- }
-}
try {
- WantAgent.getWantAgent(wantAgentInfo, getWantAgentCallback);
-} catch(err) {
- console.info('getWantAgent failed!' + JSON.stringify(err.code) + JSON.stringify(err.message));
+ WantAgent.getWantAgent(wantAgentInfo).then((data) => {
+ console.info('==========================>getWantAgentCallback=======================>');
+ wantAgent = data;
+ });
+
+ WantAgent.getWant(wantAgent).then((data) => {
+ console.info('==========================>getWantCallback=======================>');
+ });
+} catch (paramError) {
+ console.log('error: ' + paramError.code + ', ' + paramError.message);
}
```
@@ -847,45 +604,31 @@ Cancels a **WantAgent** object. This API uses an asynchronous callback to return
| agent | WantAgent | Yes | Target **WantAgent** object. |
| callback | AsyncCallback\ | Yes | Callback used to return the result.|
-**Error codes**
-For details about the error codes, see [Ability Error Codes](../errorcodes/errorcode-ability.md).
-| ID | Error Message |
-|-----------|--------------------|
-| 16000001 | Input error. The specified ability name does not exist. |
-| 16000002 | Ability type error. The specified ability type is wrong.|
-| 16000003 | Input error. The specified id does not exist.|
-| 16000004 | Visibility verification failed.|
-| 16000006 | Can not cross user operations.|
-| 16000007 | Service busyness. There are concurrent tasks, waiting for retry.|
-| 16000008 | Crowdtest App Expiration.|
-| 16000009 | Can not start ability in wukong mode.|
-| 16000010 | Can not operation with continue flag.|
-| 16000011 | Context does not exist.|
-| 16000050 | Internal Error.|
-| 16000051 | Network error. The network is abnormal.|
-| 16000052 | Free install not support. The application does not support free install.|
-| 16000053 | Not top ability. The application is not top ability.|
-| 16000054 | Free install busyness. There are concurrent tasks, waiting for retry.|
-| 16000055 | Free install timeout.|
-| 16000056 | Can not free install other ability.|
-| 16000057 | Not support cross device free install.|
-| 16000101 | execute shell command failed.|
-| 16000151 | Invalid wantagent object.|
-| 16000152 | wantAgent object not found.|
-| 16000153 | wangAgent object canceled.|
-
**Example**
-```ts
-// WantAgent object
+```js
+import WantAgent from '@ohos.app.ability.wantAgent';
+
+
+// wantAgent object
let wantAgent;
+
+// getWantAgent callback
+function getWantAgentCallback(err, data) {
+ console.info('==========================>getWantAgentCallback=======================>');
+ if (err.code == 0) {
+ wantAgent = data;
+ } else {
+ console.info('----getWantAgent failed!----');
+ }
+}
// WantAgentInfo object
let wantAgentInfo = {
wants: [
{
deviceId: 'deviceId',
- bundleName: 'com.example.myapplication',
- abilityName: 'EntryAbility',
+ bundleName: 'com.neu.setResultOnAbilityResultTest1',
+ abilityName: 'com.example.test.MainAbility',
action: 'action1',
entities: ['entity1'],
type: 'MIMETYPE',
@@ -905,33 +648,18 @@ let wantAgentInfo = {
operationType: WantAgent.OperationType.START_ABILITIES,
requestCode: 0,
wantAgentFlags:[WantAgent.WantAgentFlags.UPDATE_PRESENT_FLAG]
-}
+};
-// getWantAgent callback
-function getWantAgentCallback(err, data) {
- if (err === undefined) {
- wantAgent = data;
- } else {
- console.info('getWantAgent failed' + JSON.stringify(wantAgent));
- }
- // getUid callback
- function cancelCallback(err, data) {
- if(err) {
- console.info('cancel failed!' + JSON.stringify(err.code) + JSON.stringify(err.message));
- } else {
- console.info('cancel ok!');
- }
- }
- try {
- WantAgent.cancel(wantAgent, getBundleNameCallback);
- } catch(err) {
- console.info('cancel failed!' + JSON.stringify(err.code) + JSON.stringify(err.message));
- }
-}
try {
WantAgent.getWantAgent(wantAgentInfo, getWantAgentCallback);
-} catch(err) {
- console.info('getWantAgent failed!' + JSON.stringify(err.code) + JSON.stringify(err.message));
+
+ // cancel callback
+ function cancelCallback(err, data) {
+ console.info('==========================>cancelCallback=======================>');
+ }
+ WantAgent.cancel(wantAgent, cancelCallback);
+} catch (paramError) {
+ console.log('error: ' + paramError.code + ', ' + paramError.message);
}
```
@@ -957,45 +685,22 @@ Cancels a **WantAgent** object. This API uses a promise to return the result.
| --------------- | ------------------------------- |
| Promise\ | Promise used to return the result.|
-**Error codes**
-For details about the error codes, see [Ability Error Codes](../errorcodes/errorcode-ability.md).
-| ID | Error Message |
-|-----------|--------------------|
-| 16000001 | Input error. The specified ability name does not exist. |
-| 16000002 | Ability type error. The specified ability type is wrong.|
-| 16000003 | Input error. The specified id does not exist.|
-| 16000004 | Visibility verification failed.|
-| 16000006 | Can not cross user operations.|
-| 16000007 | Service busyness. There are concurrent tasks, waiting for retry.|
-| 16000008 | Crowdtest App Expiration.|
-| 16000009 | Can not start ability in wukong mode.|
-| 16000010 | Can not operation with continue flag.|
-| 16000011 | Context does not exist.|
-| 16000050 | Internal Error.|
-| 16000051 | Network error. The network is abnormal.|
-| 16000052 | Free install not support. The application does not support free install.|
-| 16000053 | Not top ability. The application is not top ability.|
-| 16000054 | Free install busyness. There are concurrent tasks, waiting for retry.|
-| 16000055 | Free install timeout.|
-| 16000056 | Can not free install other ability.|
-| 16000057 | Not support cross device free install.|
-| 16000101 | execute shell command failed.|
-| 16000151 | Invalid wantagent object.|
-| 16000152 | wantAgent object not found.|
-| 16000153 | wangAgent object canceled.|
-
**Example**
-```ts
-// WantAgent object
+```js
+import WantAgent from '@ohos.app.ability.wantAgent';
+
+
+// wantAgent object
let wantAgent;
+
// WantAgentInfo object
let wantAgentInfo = {
wants: [
{
deviceId: 'deviceId',
- bundleName: 'com.example.myapplication',
- abilityName: 'EntryAbility',
+ bundleName: 'com.neu.setResultOnAbilityResultTest1',
+ abilityName: 'com.example.test.MainAbility',
action: 'action1',
entities: ['entity1'],
type: 'MIMETYPE',
@@ -1015,32 +720,24 @@ let wantAgentInfo = {
operationType: WantAgent.OperationType.START_ABILITIES,
requestCode: 0,
wantAgentFlags:[WantAgent.WantAgentFlags.UPDATE_PRESENT_FLAG]
-}
+};
-// getWantAgent callback
-function getWantAgentCallback(err, data) {
- if (err === undefined) {
- wantAgent = data;
- } else {
- console.info('getWantAgent failed!' + JSON.stringify(wantAgent));
- }
- try {
- WantAgent.cancel(wantAgent).then((data)=>{
- console.info('cancel ok!');
- }).catch((err)=>{
- console.info('cancel failed!' + JSON.stringify(err.code) + JSON.stringify(err.message));
- })
- } catch(err){
- console.info('cancel failed!' + JSON.stringify(err.code) + JSON.stringify(err.message));
- }
-}
try {
- WantAgent.getWantAgent(wantAgentInfo, getWantAgentCallback);
-} catch(err) {
- console.info('getWantAgent failed!' + JSON.stringify(err.code) + JSON.stringify(err.message));
+ WantAgent.getWantAgent(wantAgentInfo).then((data) => {
+ console.info('==========================>getWantAgentCallback=======================>');
+ wantAgent = data;
+ });
+
+ WantAgent.cancel(wantAgent).then((data) => {
+ console.info('==========================>cancelCallback=======================>');
+ });
+} catch (paramError) {
+ console.log('error: ' + paramError.code + ', ' + paramError.message);
}
```
+
+
## WantAgent.trigger
trigger(agent: WantAgent, triggerInfo: TriggerInfo, callback?: AsyncCallback\): void
@@ -1054,52 +751,33 @@ Triggers a **WantAgent** object. This API uses an asynchronous callback to retur
| Name | Type | Mandatory| Description |
| ----------- | ----------------------------- | ---- | ------------------------------- |
| agent | WantAgent | Yes | Target **WantAgent** object. |
-| triggerInfo | [TriggerInfo](js-apis-inner-wantAgent-triggerInfo.md) | Yes | **TriggerInfo** object. |
+| triggerInfo | TriggerInfo | Yes | **TriggerInfo** object. |
| callback | AsyncCallback\<[CompleteData](#completedata)\> | No | Callback used to return the result.|
-**Error codes**
-For details about the error codes, see [Ability Error Codes](../errorcodes/errorcode-ability.md).
-| ID | Error Message |
-|-----------|--------------------|
-| 16000001 | Input error. The specified ability name does not exist. |
-| 16000002 | Ability type error. The specified ability type is wrong.|
-| 16000003 | Input error. The specified id does not exist.|
-| 16000004 | Visibility verification failed.|
-| 16000006 | Can not cross user operations.|
-| 16000007 | Service busyness. There are concurrent tasks, waiting for retry.|
-| 16000008 | Crowdtest App Expiration.|
-| 16000009 | Can not start ability in wukong mode.|
-| 16000010 | Can not operation with continue flag.|
-| 16000011 | Context does not exist.|
-| 16000050 | Internal Error.|
-| 16000051 | Network error. The network is abnormal.|
-| 16000052 | Free install not support. The application does not support free install.|
-| 16000053 | Not top ability. The application is not top ability.|
-| 16000054 | Free install busyness. There are concurrent tasks, waiting for retry.|
-| 16000055 | Free install timeout.|
-| 16000056 | Can not free install other ability.|
-| 16000057 | Not support cross device free install.|
-| 16000101 | execute shell command failed.|
-| 16000151 | Invalid wantagent object.|
-| 16000152 | wantAgent object not found.|
-| 16000153 | wangAgent object canceled.|
-**Example**
+```js
+import WantAgent from '@ohos.app.ability.wantAgent';
+
-```ts
-// WantAgent object
+// wantAgent object
let wantAgent;
-// triggerInfo
-let triggerInfo = {
- code: 0 // Custom result code.
+
+// getWantAgent callback
+function getWantAgentCallback(err, data) {
+ console.info('==========================>getWantAgentCallback=======================>');
+ if (err.code == 0) {
+ wantAgent = data;
+ } else {
+ console.info('----getWantAgent failed!----');
}
+}
// WantAgentInfo object
let wantAgentInfo = {
wants: [
{
deviceId: 'deviceId',
- bundleName: 'com.example.myapplication',
- abilityName: 'EntryAbility',
+ bundleName: 'com.neu.setResultOnAbilityResultTest1',
+ abilityName: 'com.example.test.MainAbility',
action: 'action1',
entities: ['entity1'],
type: 'MIMETYPE',
@@ -1119,33 +797,23 @@ let wantAgentInfo = {
operationType: WantAgent.OperationType.START_ABILITIES,
requestCode: 0,
wantAgentFlags:[WantAgent.WantAgentFlags.UPDATE_PRESENT_FLAG]
-}
+};
-// getWantAgent callback
-function getWantAgentCallback(err, data) {
- if (err === undefined) {
- wantAgent = data;
- } else {
- console.info('getWantAgent failed' + JSON.stringify(wantAgent));
- }
- // getUid callback
- function triggerCallback(err, data) {
- if(err) {
- console.info('getUid failed!' + JSON.stringify(err.code) + JSON.stringify(err.message));
- } else {
- console.info('getUid ok!' + JSON.stringify(data));
- }
- }
- try {
- WantAgent.trigger(wantAgent, triggerInfo, triggerCallback);
- } catch(err) {
- console.info('getUid failed!' + JSON.stringify(err.code) + JSON.stringify(err.message));
- }
-}
try {
WantAgent.getWantAgent(wantAgentInfo, getWantAgentCallback);
-} catch(err) {
- console.info('getWantAgent failed!' + JSON.stringify(err.code) + JSON.stringify(err.message));
+
+ // trigger callback
+ function triggerCallback(data) {
+ console.info('==========================>triggerCallback=======================>');
+ }
+
+
+ let triggerInfo = {
+ code:0
+ };
+ WantAgent.trigger(wantAgent, triggerInfo, triggerCallback);
+} catch (paramError) {
+ console.log('error: ' + paramError.code + ', ' + paramError.message);
}
```
@@ -1167,46 +835,33 @@ Checks whether two **WantAgent** objects are equal to determine whether the same
| otherAgent | WantAgent | Yes | The second **WantAgent** object. |
| callback | AsyncCallback\ | Yes | Callback used to return the result.|
-**Error codes**
-For details about the error codes, see [Ability Error Codes](../errorcodes/errorcode-ability.md).
-| ID | Error Message |
-|-----------|--------------------|
-| 16000001 | Input error. The specified ability name does not exist. |
-| 16000002 | Ability type error. The specified ability type is wrong.|
-| 16000003 | Input error. The specified id does not exist.|
-| 16000004 | Visibility verification failed.|
-| 16000006 | Can not cross user operations.|
-| 16000007 | Service busyness. There are concurrent tasks, waiting for retry.|
-| 16000008 | Crowdtest App Expiration.|
-| 16000009 | Can not start ability in wukong mode.|
-| 16000010 | Can not operation with continue flag.|
-| 16000011 | Context does not exist.|
-| 16000050 | Internal Error.|
-| 16000051 | Network error. The network is abnormal.|
-| 16000052 | Free install not support. The application does not support free install.|
-| 16000053 | Not top ability. The application is not top ability.|
-| 16000054 | Free install busyness. There are concurrent tasks, waiting for retry.|
-| 16000055 | Free install timeout.|
-| 16000056 | Can not free install other ability.|
-| 16000057 | Not support cross device free install.|
-| 16000101 | execute shell command failed.|
-| 16000151 | Invalid wantagent object.|
-| 16000152 | wantAgent object not found.|
-| 16000153 | wangAgent object canceled.|
-
**Example**
-```ts
-// WantAgent object
+```js
+import WantAgent from '@ohos.app.ability.wantAgent';
+
+
+// wantAgent object
let wantAgent1;
let wantAgent2;
+
+// getWantAgent callback
+function getWantAgentCallback(err, data) {
+ console.info('==========================>getWantAgentCallback=======================>');
+ if (err.code == 0) {
+ wantAgent1 = data;
+ wantAgent2 = data;
+ } else {
+ console.info('----getWantAgent failed!----');
+ }
+}
// WantAgentInfo object
let wantAgentInfo = {
wants: [
{
deviceId: 'deviceId',
- bundleName: 'com.example.myapplication',
- abilityName: 'EntryAbility',
+ bundleName: 'com.neu.setResultOnAbilityResultTest1',
+ abilityName: 'com.example.test.MainAbility',
action: 'action1',
entities: ['entity1'],
type: 'MIMETYPE',
@@ -1226,34 +881,18 @@ let wantAgentInfo = {
operationType: WantAgent.OperationType.START_ABILITIES,
requestCode: 0,
wantAgentFlags:[WantAgent.WantAgentFlags.UPDATE_PRESENT_FLAG]
-}
+};
-// getWantAgent callback
-function getWantAgentCallback(err, data) {
- if (err === undefined) {
- wantAgent1 = data;
- wantAgent2 = data;
- } else {
- console.info('getWantAgent failed' + JSON.stringify(wantAgent));
- }
- // getUid callback
- function equalCallback(err, data) {
- if(err) {
- console.info('equal failed!' + JSON.stringify(err.code) + JSON.stringify(err.message));
- } else {
- console.info('equal ok!' + JSON.stringify(data));
- }
- }
- try {
- WantAgent.equal(wantAgent1,wantAgent2,equalCallback);
- } catch(err) {
- console.info('equal failed!' + JSON.stringify(err.code) + JSON.stringify(err.message));
- }
-}
try {
WantAgent.getWantAgent(wantAgentInfo, getWantAgentCallback);
-} catch(err) {
- console.info('getWantAgent failed!' + JSON.stringify(err.code) + JSON.stringify(err.message));
+
+ // equal callback
+ function equalCallback(err, data) {
+ console.info('==========================>equalCallback=======================>');
+ }
+ WantAgent.equal(wantAgent1, wantAgent2, equalCallback);
+} catch (paramError) {
+ console.log('error: ' + paramError.code + ', ' + paramError.message);
}
```
@@ -1280,46 +919,23 @@ Checks whether two **WantAgent** objects are equal to determine whether the same
| ----------------------------------------------------------- | ------------------------------------------------------------ |
| Promise\ | Promise used to return the result.|
-**Error codes**
-For details about the error codes, see [Ability Error Codes](../errorcodes/errorcode-ability.md).
-| ID | Error Message |
-|-----------|--------------------|
-| 16000001 | Input error. The specified ability name does not exist. |
-| 16000002 | Ability type error. The specified ability type is wrong.|
-| 16000003 | Input error. The specified id does not exist.|
-| 16000004 | Visibility verification failed.|
-| 16000006 | Can not cross user operations.|
-| 16000007 | Service busyness. There are concurrent tasks, waiting for retry.|
-| 16000008 | Crowdtest App Expiration.|
-| 16000009 | Can not start ability in wukong mode.|
-| 16000010 | Can not operation with continue flag.|
-| 16000011 | Context does not exist.|
-| 16000050 | Internal Error.|
-| 16000051 | Network error. The network is abnormal.|
-| 16000052 | Free install not support. The application does not support free install.|
-| 16000053 | Not top ability. The application is not top ability.|
-| 16000054 | Free install busyness. There are concurrent tasks, waiting for retry.|
-| 16000055 | Free install timeout.|
-| 16000056 | Can not free install other ability.|
-| 16000057 | Not support cross device free install.|
-| 16000101 | execute shell command failed.|
-| 16000151 | Invalid wantagent object.|
-| 16000152 | wantAgent object not found.|
-| 16000153 | wangAgent object canceled.|
-
**Example**
-```ts
-// WantAgent object
+```js
+import WantAgent from '@ohos.app.ability.wantAgent';
+
+
+// wantAgent object
let wantAgent1;
let wantAgent2;
+
// WantAgentInfo object
let wantAgentInfo = {
wants: [
{
deviceId: 'deviceId',
- bundleName: 'com.example.myapplication',
- abilityName: 'EntryAbility',
+ bundleName: 'com.neu.setResultOnAbilityResultTest1',
+ abilityName: 'com.example.test.MainAbility',
action: 'action1',
entities: ['entity1'],
type: 'MIMETYPE',
@@ -1339,30 +955,20 @@ let wantAgentInfo = {
operationType: WantAgent.OperationType.START_ABILITIES,
requestCode: 0,
wantAgentFlags:[WantAgent.WantAgentFlags.UPDATE_PRESENT_FLAG]
-}
+};
-// getWantAgent callback
-function getWantAgentCallback(err, data) {
- if (err === undefined) {
+try {
+ WantAgent.getWantAgent(wantAgentInfo).then((data) => {
+ console.info('==========================>getWantAgentCallback=======================>');
wantAgent1 = data;
wantAgent2 = data;
- } else {
- console.info('getWantAgent failed!' + JSON.stringify(wantAgent));
- }
- try {
- WantAgent.equal(wantAgent1,wantAgent2).then((data)=>{
- console.info('equal ok!' + JSON.stringify(data));
- }).catch((err)=>{
- console.info('equal failed!' + JSON.stringify(err.code) + JSON.stringify(err.message));
- })
- } catch(err){
- console.info('equal failed!' + JSON.stringify(err.code) + JSON.stringify(err.message));
- }
-}
-try {
- WantAgent.getWantAgent(wantAgentInfo, getWantAgentCallback);
-} catch(err) {
- console.info('getWantAgent failed!' + JSON.stringify(err.code) + JSON.stringify(err.message));
+ });
+
+ WantAgent.equal(wantAgent1, wantAgent2).then((data) => {
+ console.info('==========================>equalCallback=======================>');
+ });
+} catch (paramError) {
+ console.log('error: ' + paramError.code + ', ' + paramError.message);
}
```
@@ -1381,45 +987,21 @@ Obtains the operation type of a **WantAgent** object. This API uses an asynchron
| agent | WantAgent | Yes | Target **WantAgent** object. |
| callback | AsyncCallback\ | Yes | Callback used to return the operation type.|
-**Error codes**
-For details about the error codes, see [Ability Error Codes](../errorcodes/errorcode-ability.md).
-| ID | Error Message |
-|-----------|--------------------|
-| 16000001 | Input error. The specified ability name does not exist. |
-| 16000002 | Ability type error. The specified ability type is wrong.|
-| 16000003 | Input error. The specified id does not exist.|
-| 16000004 | Visibility verification failed.|
-| 16000006 | Can not cross user operations.|
-| 16000007 | Service busyness. There are concurrent tasks, waiting for retry.|
-| 16000008 | Crowdtest App Expiration.|
-| 16000009 | Can not start ability in wukong mode.|
-| 16000010 | Can not operation with continue flag.|
-| 16000011 | Context does not exist.|
-| 16000050 | Internal Error.|
-| 16000051 | Network error. The network is abnormal.|
-| 16000052 | Free install not support. The application does not support free install.|
-| 16000053 | Not top ability. The application is not top ability.|
-| 16000054 | Free install busyness. There are concurrent tasks, waiting for retry.|
-| 16000055 | Free install timeout.|
-| 16000056 | Can not free install other ability.|
-| 16000057 | Not support cross device free install.|
-| 16000101 | execute shell command failed.|
-| 16000151 | Invalid wantagent object.|
-| 16000152 | wantAgent object not found.|
-| 16000153 | wangAgent object canceled.|
-
**Example**
-```ts
-// WantAgent object
+```js
+import WantAgent from '@ohos.app.ability.wantAgent';
+
+// wantAgent object
let wantAgent;
+
// WantAgentInfo object
let wantAgentInfo = {
wants: [
{
deviceId: 'deviceId',
- bundleName: 'com.example.myapplication',
- abilityName: 'EntryAbility',
+ bundleName: 'com.neu.setResultOnAbilityResultTest1',
+ abilityName: 'com.example.test.MainAbility',
action: 'action1',
entities: ['entity1'],
type: 'MIMETYPE',
@@ -1439,33 +1021,19 @@ let wantAgentInfo = {
operationType: WantAgent.OperationType.START_ABILITIES,
requestCode: 0,
wantAgentFlags:[WantAgent.WantAgentFlags.UPDATE_PRESENT_FLAG]
-}
+};
-// getWantAgent callback
-function getWantAgentCallback(err, data) {
- if (err === undefined) {
- wantAgent = data;
- } else {
- console.info('getWantAgent failed' + JSON.stringify(wantAgent));
- }
- // getUid callback
- function getOperationTypeCallback(err, data) {
- if(err) {
- console.info('getOperationType failed!' + JSON.stringify(err.code) + JSON.stringify(err.message));
- } else {
- console.info('getOperationType ok!' + JSON.stringify(data));
- }
- }
- try {
- WantAgent.getOperationTypeCallback(wantAgent, getBundleNameCallback);
- } catch(err) {
- console.info('getOperationTypeCallback failed!' + JSON.stringify(err.code) + JSON.stringify(err.message));
- }
-}
try {
- WantAgent.getWantAgent(wantAgentInfo, getWantAgentCallback);
-} catch(err) {
- console.info('getWantAgent failed!' + JSON.stringify(err.code) + JSON.stringify(err.message));
+ WantAgent.getWantAgent(wantAgentInfo).then((data) => {
+ console.info('==========================>getWantAgentCallback=======================>');
+ wantAgent = data;
+ });
+
+ WantAgent.getOperationType(wantAgent, (OperationType) => {
+ console.log('----------- getOperationType ----------, OperationType: ' + OperationType);
+ })
+} catch (paramError) {
+ console.log('error: ' + paramError.code + ', ' + paramError.message);
}
```
@@ -1489,45 +1057,21 @@ Obtains the operation type of a **WantAgent** object. This API uses a promise to
| ----------------------------------------------------------- | ------------------------------------------------------------ |
| Promise\ | Promise used to return the operation type.|
-**Error codes**
-For details about the error codes, see [Ability Error Codes](../errorcodes/errorcode-ability.md).
-| ID | Error Message |
-|-----------|--------------------|
-| 16000001 | Input error. The specified ability name does not exist. |
-| 16000002 | Ability type error. The specified ability type is wrong.|
-| 16000003 | Input error. The specified id does not exist.|
-| 16000004 | Visibility verification failed.|
-| 16000006 | Can not cross user operations.|
-| 16000007 | Service busyness. There are concurrent tasks, waiting for retry.|
-| 16000008 | Crowdtest App Expiration.|
-| 16000009 | Can not start ability in wukong mode.|
-| 16000010 | Can not operation with continue flag.|
-| 16000011 | Context does not exist.|
-| 16000050 | Internal Error.|
-| 16000051 | Network error. The network is abnormal.|
-| 16000052 | Free install not support. The application does not support free install.|
-| 16000053 | Not top ability. The application is not top ability.|
-| 16000054 | Free install busyness. There are concurrent tasks, waiting for retry.|
-| 16000055 | Free install timeout.|
-| 16000056 | Can not free install other ability.|
-| 16000057 | Not support cross device free install.|
-| 16000101 | execute shell command failed.|
-| 16000151 | Invalid wantagent object.|
-| 16000152 | wantAgent object not found.|
-| 16000153 | wangAgent object canceled.|
-
**Example**
-```ts
-// WantAgent object
+```js
+import WantAgent from '@ohos.app.ability.wantAgent';
+
+// wantAgent object
let wantAgent;
+
// WantAgentInfo object
let wantAgentInfo = {
wants: [
{
deviceId: 'deviceId',
- bundleName: 'com.example.myapplication',
- abilityName: 'EntryAbility',
+ bundleName: 'com.neu.setResultOnAbilityResultTest1',
+ abilityName: 'com.example.test.MainAbility',
action: 'action1',
entities: ['entity1'],
type: 'MIMETYPE',
@@ -1547,29 +1091,21 @@ let wantAgentInfo = {
operationType: WantAgent.OperationType.START_ABILITIES,
requestCode: 0,
wantAgentFlags:[WantAgent.WantAgentFlags.UPDATE_PRESENT_FLAG]
-}
+};
-// getWantAgent callback
-function getWantAgentCallback(err, data) {
- if (err === undefined) {
- wantAgent = data;
- } else {
- console.info('getWantAgent failed!' + JSON.stringify(wantAgent));
- }
- try {
- WantAgent.getOperationType(wantAgent).then((data)=>{
- console.info('getOperationType ok!' + JSON.stringify(data));
- }).catch((err)=>{
- console.info('getOperationType failed!' + JSON.stringify(err.code) + JSON.stringify(err.message));
- })
- } catch(err){
- console.info('getOperationType failed!' + JSON.stringify(err.code) + JSON.stringify(err.message));
- }
-}
try {
- WantAgent.getWantAgent(wantAgentInfo, getWantAgentCallback);
-} catch(err) {
- console.info('getWantAgent failed!' + JSON.stringify(err.code) + JSON.stringify(err.message));
+ WantAgent.getWantAgent(wantAgentInfo).then((data) => {
+ console.info('==========================>getWantAgentCallback=======================>');
+ wantAgent = data;
+ });
+
+ WantAgent.getOperationType(wantAgent).then((OperationType) => {
+ console.log('getOperationType success, OperationType: ' + OperationType);
+ }).catch((err) => {
+ console.log('getOperationType fail, err: ' + err);
+ })
+} catch (paramError) {
+ console.log('error: ' + paramError.code + ', ' + paramError.message);
}
```
@@ -1615,5 +1151,6 @@ try {
| info | WantAgent | Yes | A triggered **WantAgent** object. |
| want | Want | Yes | An existing triggered **want**. |
| finalCode | number | Yes | Request code that triggers the **WantAgent** object.|
-| finalData | string | No | Final data collected by the common event. |
+| finalData | string | Yes | Final data collected by the common event. |
| extraInfo | {[key: string]: any} | No | Extra information. |
+
diff --git a/en/application-dev/reference/apis/js-apis-app-ability-wantConstant.md b/en/application-dev/reference/apis/js-apis-app-ability-wantConstant.md
index 4d7a483eab8a55c91d4dbb89287fa611f980ef34..4503f37fa5dd7950c2090a8d452d8d52eb22dcc1 100644
--- a/en/application-dev/reference/apis/js-apis-app-ability-wantConstant.md
+++ b/en/application-dev/reference/apis/js-apis-app-ability-wantConstant.md
@@ -8,7 +8,7 @@ The **wantConstant** module provides the actions, entities, and flags used in **
## Modules to Import
-```js
+```ts
import wantConstant from '@ohos.app.ability.wantConstant';
```
@@ -79,4 +79,4 @@ Enumerates the entity constants of the **Want** object. **entity** specifies add
| ------------------------------------ | ---------- | ------------------------------------------------------------ |
| FLAG_AUTH_READ_URI_PERMISSION | 0x00000001 | Indicates the permission to read the URI. |
| FLAG_AUTH_WRITE_URI_PERMISSION | 0x00000002 | Indicates the permission to write data to the URI. |
-| FLAG_INSTALL_ON_DEMAND | 0x00000800 | Indicates that the specific ability will be installed if it has not been installed. |
+| FLAG_INSTALL_ON_DEMAND | 0x00000800 | Indicates that the specific ability will be installed if it has not been installed. |
diff --git a/en/application-dev/reference/apis/js-apis-app-form-formBindingData.md b/en/application-dev/reference/apis/js-apis-app-form-formBindingData.md
index 51637975d72ea807f428f235aec90310f69b197f..39cfb8e3349b07ee745c1756cefb4ea66f189b39 100644
--- a/en/application-dev/reference/apis/js-apis-app-form-formBindingData.md
+++ b/en/application-dev/reference/apis/js-apis-app-form-formBindingData.md
@@ -35,7 +35,7 @@ Creates a **FormBindingData** object.
| Name| Type | Mandatory| Description |
| ------ | -------------- | ---- | ------------------------------------------------------------ |
-| obj | Object\|string | No | Data to be displayed on the JS widget. The value can be an object containing multiple key-value pairs or a string in JSON format. The image data is identified by "formImages", and the content is multiple key-value pairs, each of which consists of an image identifier and image file descriptor. The final format is {"formImages": {"key1": fd1, "key2": fd2}}.|
+| obj | Object\|string | No | Data to be displayed on the JS widget. The value can be an object containing multiple key-value pairs or a string in JSON format. The image data is identified by **'formImages'**, and the content is multiple key-value pairs, each of which consists of an image identifier and image file descriptor. The final format is {'formImages': {'key1': fd1, 'key2': fd2}}.|
**Return value**
@@ -48,17 +48,20 @@ Creates a **FormBindingData** object.
**Example**
```ts
-import fs from '@ohos.file.fs';
-import formBindingData from '@ohos.app.form.formBindingData';
-
-try {
- let fd = fs.openSync('/path/to/form.png')
+import featureAbility from '@ohos.ability.featureAbility';
+import fileio from '@ohos.fileio';
+let context=featureAbility.getContext();
+context.getOrCreateLocalDir((err,data)=>{
+ let path=data+'/xxx.jpg';
+ let fd = fileio.openSync(path);
let obj = {
- "temperature": "21°",
- "formImages": { "image": fd }
+ 'temperature': '21°',
+ 'formImages': {'image': fd}
};
- formBindingData.createFormBindingData(obj);
-} catch (error) {
- console.log(`catch error, code: ${error.code}, message: ${error.message}`);
-}
+ try {
+ formBindingData.createFormBindingData(obj);
+ } catch (error) {
+ console.log(`catch err->${JSON.stringify(err)}`);
+ }
+})
```
diff --git a/en/application-dev/reference/apis/js-apis-app-form-formHost.md b/en/application-dev/reference/apis/js-apis-app-form-formHost.md
index e78cf3647a1298ed77b4993d811393ede4e2e5b6..c8c8ca6389aa86a7f2a065c98e125c5b1faaca29 100644
--- a/en/application-dev/reference/apis/js-apis-app-form-formHost.md
+++ b/en/application-dev/reference/apis/js-apis-app-form-formHost.md
@@ -1,6 +1,6 @@
-# @ohos.app.form.formHost (formHost)
+# @ohos.app.form.formHost (FormHost)
-The **formHost** module provides APIs related to the widget host, which is an application that displays the widget content and controls the position where the widget is displayed. You can use the APIs to delete, release, and update widgets installed by the same user, and obtain widget information and status.
+The **FormHost** module provides APIs related to the widget host, which is an application that displays the widget content and controls the position where the widget is displayed. You can use the APIs to delete, release, and update widgets installed by the same user, and obtain widget information and status.
> **NOTE**
>
@@ -34,26 +34,25 @@ Deletes a widget. After this API is called, the application can no longer use th
| Error Code ID| Error Message|
| -------- | -------- |
-| 401 | Incorrect input parameter.|
+| 401 | If the input parameter is not valid parameter. |
|For details about the error codes, see [Form Error Codes](../errorcodes/errorcode-form.md).|
**Example**
```ts
-import formHost from '@ohos.app.form.formHost';
-
try {
- let formId = "12400633174999288";
- formHost.deleteForm(formId, (error) => {
+ var formId = '12400633174999288';
+ formHost.deleteForm(formId, (error, data) => {
if (error) {
- console.log(`error, code: ${error.code}, message: ${error.message}`);
+ console.log('formHost deleteForm, error:' + JSON.stringify(error));
} else {
console.log('formHost deleteForm success');
}
});
} catch (error) {
- console.log(`catch error, code: ${error.code}, message: ${error.message}`);
+ console.log(`catch err->${JSON.stringify(error)}`);
}
+
```
## deleteForm
@@ -83,23 +82,21 @@ Deletes a widget. After this API is called, the application can no longer use th
| Error Code ID| Error Message|
| -------- | -------- |
-| 401 | Incorrect input parameter.|
+| 401 | If the input parameter is not valid parameter. |
|For details about the error codes, see [Form Error Codes](../errorcodes/errorcode-form.md).|
**Parameters**
```ts
-import formHost from '@ohos.app.form.formHost';
-
try {
- let formId = "12400633174999288";
+ var formId = '12400633174999288';
formHost.deleteForm(formId).then(() => {
console.log('formHost deleteForm success');
}).catch((error) => {
- console.log(`error, code: ${error.code}, message: ${error.message}`);
+ console.log('formHost deleteForm, error:' + JSON.stringify(error));
});
} catch(error) {
- console.log(`catch error, code: ${error.code}, message: ${error.message}`);
+ console.log(`catch err->${JSON.stringify(error)}`);
}
```
@@ -124,23 +121,21 @@ Releases a widget. After this API is called, the application can no longer use t
| Error Code ID| Error Message|
| -------- | -------- |
-| 401 | Incorrect input parameter.|
+| 401 | If the input parameter is not valid parameter. |
|For details about the error codes, see [Form Error Codes](../errorcodes/errorcode-form.md).|
**Example**
```ts
-import formHost from '@ohos.app.form.formHost';
-
try {
- let formId = "12400633174999288";
- formHost.releaseForm(formId, (error) => {
+ var formId = '12400633174999288';
+ formHost.releaseForm(formId, (error, data) => {
if (error) {
- console.log(`error, code: ${error.code}, message: ${error.message}`);
+ console.log('formHost releaseForm, error:' + JSON.stringify(error));
}
});
} catch(error) {
- console.log(`catch error, code: ${error.code}, message: ${error.message}`);
+ console.log(`catch err->${JSON.stringify(error)}`);
}
```
@@ -166,23 +161,21 @@ Releases a widget. After this API is called, the application can no longer use t
| Error Code ID| Error Message|
| -------- | -------- |
-| 401 | Incorrect input parameter.|
+| 401 | If the input parameter is not valid parameter. |
|For details about the error codes, see [Form Error Codes](../errorcodes/errorcode-form.md).|
**Example**
```ts
-import formHost from '@ohos.app.form.formHost';
-
try {
- let formId = "12400633174999288";
- formHost.releaseForm(formId, true, (error) => {
+ var formId = '12400633174999288';
+ formHost.releaseForm(formId, true, (error, data) => {
if (error) {
- console.log(`error, code: ${error.code}, message: ${error.message}`);
+ console.log('formHost releaseForm, error:' + JSON.stringify(error));
}
});
} catch(error) {
- console.log(`catch error, code: ${error.code}, message: ${error.message}`);
+ console.log(`catch err->${JSON.stringify(error)}`);
}
```
@@ -213,23 +206,21 @@ Releases a widget. After this API is called, the application can no longer use t
| Error Code ID| Error Message|
| -------- | -------- |
-| 401 | Incorrect input parameter.|
+| 401 | If the input parameter is not valid parameter. |
|For details about the error codes, see [Form Error Codes](../errorcodes/errorcode-form.md).|
**Example**
```ts
-import formHost from '@ohos.app.form.formHost';
-
try {
- let formId = "12400633174999288";
+ var formId = '12400633174999288';
formHost.releaseForm(formId, true).then(() => {
console.log('formHost releaseForm success');
}).catch((error) => {
- console.log(`error, code: ${error.code}, message: ${error.message}`);
+ console.log('formHost releaseForm, error:' + JSON.stringify(error));
});
} catch(error) {
- console.log(`catch error, code: ${error.code}, message: ${error.message}`);
+ console.log(`catch err->${JSON.stringify(error)}`);
}
```
@@ -254,23 +245,21 @@ Requests a widget update. This API uses an asynchronous callback to return the r
| Error Code ID| Error Message|
| -------- | -------- |
-| 401 | Incorrect input parameter.|
+| 401 | If the input parameter is not valid parameter. |
|For details about the error codes, see [Form Error Codes](../errorcodes/errorcode-form.md).|
**Example**
```ts
-import formHost from '@ohos.app.form.formHost';
-
try {
- let formId = "12400633174999288";
- formHost.requestForm(formId, (error) => {
+ var formId = '12400633174999288';
+ formHost.requestForm(formId, (error, data) => {
if (error) {
- console.log(`error, code: ${error.code}, message: ${error.message}`);
+ console.log('formHost requestForm, error:' + JSON.stringify(error));
}
});
} catch(error) {
- console.log(`catch error, code: ${error.code}, message: ${error.message}`);
+ console.log(`catch err->${JSON.stringify(error)}`);
}
```
@@ -300,23 +289,21 @@ Requests a widget update. This API uses a promise to return the result.
| Error Code ID| Error Message|
| -------- | -------- |
-| 401 | Incorrect input parameter.|
+| 401 | If the input parameter is not valid parameter. |
|For details about the error codes, see [Form Error Codes](../errorcodes/errorcode-form.md).|
**Example**
```ts
-import formHost from '@ohos.app.form.formHost';
-
try {
- let formId = "12400633174999288";
+ var formId = '12400633174999288';
formHost.requestForm(formId).then(() => {
console.log('formHost requestForm success');
}).catch((error) => {
- console.log(`error, code: ${error.code}, message: ${error.message}`);
+ console.log('formHost requestForm, error:' + JSON.stringify(error));
});
} catch(error) {
- console.log(`catch error, code: ${error.code}, message: ${error.message}`);
+ console.log(`catch err->${JSON.stringify(error)}`);
}
```
@@ -342,23 +329,21 @@ Converts a temporary widget to a normal one. This API uses an asynchronous callb
| Error Code ID| Error Message|
| -------- | -------- |
-| 401 | Incorrect input parameter.|
+| 401 | If the input parameter is not valid parameter. |
|For details about the error codes, see [Form Error Codes](../errorcodes/errorcode-form.md).|
**Example**
```ts
-import formHost from '@ohos.app.form.formHost';
-
try {
- let formId = "12400633174999288";
- formHost.castToNormalForm(formId, (error) => {
+ var formId = '12400633174999288';
+ formHost.castToNormalForm(formId, (error, data) => {
if (error) {
- console.log(`error, code: ${error.code}, message: ${error.message}`);
+ console.log('formHost castTempForm, error:' + JSON.stringify(error));
}
});
} catch(error) {
- console.log(`catch error, code: ${error.code}, message: ${error.message}`);
+ console.log(`catch err->${JSON.stringify(error)}`);
}
```
@@ -388,23 +373,21 @@ Converts a temporary widget to a normal one. This API uses a promise to return t
| Error Code ID| Error Message|
| -------- | -------- |
-| 401 | Incorrect input parameter.|
+| 401 | If the input parameter is not valid parameter. |
|For details about the error codes, see [Form Error Codes](../errorcodes/errorcode-form.md).|
**Example**
```ts
-import formHost from '@ohos.app.form.formHost';
-
try {
- let formId = "12400633174999288";
+ var formId = '12400633174999288';
formHost.castToNormalForm(formId).then(() => {
console.log('formHost castTempForm success');
}).catch((error) => {
- console.log(`error, code: ${error.code}, message: ${error.message}`);
+ console.log('formHost castTempForm, error:' + JSON.stringify(error));
});
} catch(error) {
- console.log(`catch error, code: ${error.code}, message: ${error.message}`);
+ console.log(`catch err->${JSON.stringify(error)}`);
}
```
@@ -429,23 +412,21 @@ Instructs the widget framework to make a widget visible. After this API is calle
| Error Code ID| Error Message|
| -------- | -------- |
-| 401 | Incorrect input parameter.|
+| 401 | If the input parameter is not valid parameter. |
|For details about the error codes, see [Form Error Codes](../errorcodes/errorcode-form.md).|
**Example**
```ts
-import formHost from '@ohos.app.form.formHost';
-
try {
- let formId = ["12400633174999288"];
- formHost.notifyVisibleForms(formId, (error) => {
+ var formId = ['12400633174999288'];
+ formHost.notifyVisibleForms(formId, (error, data) => {
if (error) {
- console.log(`error, code: ${error.code}, message: ${error.message}`);
+ console.log('formHost notifyVisibleForms, error:' + JSON.stringify(error));
}
});
} catch(error) {
- console.log(`catch error, code: ${error.code}, message: ${error.message}`);
+ console.log(`catch err->${JSON.stringify(error)}`);
}
```
@@ -475,23 +456,21 @@ Instructs the widget framework to make a widget visible. After this API is calle
| Error Code ID| Error Message|
| -------- | -------- |
-| 401 | Incorrect input parameter.|
+| 401 | If the input parameter is not valid parameter. |
|For details about the error codes, see [Form Error Codes](../errorcodes/errorcode-form.md).|
**Example**
```ts
-import formHost from '@ohos.app.form.formHost';
-
try {
- let formId = ["12400633174999288"];
+ var formId = ['12400633174999288'];
formHost.notifyVisibleForms(formId).then(() => {
console.log('formHost notifyVisibleForms success');
}).catch((error) => {
- console.log(`error, code: ${error.code}, message: ${error.message}`);
+ console.log('formHost notifyVisibleForms, error:' + JSON.stringify(error));
});
} catch(error) {
- console.log(`catch error, code: ${error.code}, message: ${error.message}`);
+ console.log(`catch err->${JSON.stringify(error)}`);
}
```
@@ -516,23 +495,21 @@ Instructs the widget framework to make a widget invisible. After this API is cal
| Error Code ID| Error Message|
| -------- | -------- |
-| 401 | Incorrect input parameter.|
+| 401 | If the input parameter is not valid parameter. |
|For details about the error codes, see [Form Error Codes](../errorcodes/errorcode-form.md).|
**Example**
```ts
-import formHost from '@ohos.app.form.formHost';
-
try {
- let formId = ["12400633174999288"];
- formHost.notifyInvisibleForms(formId, (error) => {
+ var formId = ['12400633174999288'];
+ formHost.notifyInvisibleForms(formId, (error, data) => {
if (error) {
- console.log(`error, code: ${error.code}, message: ${error.message}`);
+ console.log('formHost notifyInvisibleForms, error:' + JSON.stringify(error));
}
});
} catch(error) {
- console.log(`catch error, code: ${error.code}, message: ${error.message}`);
+ console.log(`catch err->${JSON.stringify(error)}`);
}
```
@@ -562,23 +539,21 @@ Instructs the widget framework to make a widget invisible. After this API is cal
| Error Code ID| Error Message|
| -------- | -------- |
-| 401 | Incorrect input parameter.|
+| 401 | If the input parameter is not valid parameter. |
|For details about the error codes, see [Form Error Codes](../errorcodes/errorcode-form.md).|
**Example**
```ts
-import formHost from '@ohos.app.form.formHost';
-
try {
- let formId = ["12400633174999288"];
+ var formId = ['12400633174999288'];
formHost.notifyInvisibleForms(formId).then(() => {
console.log('formHost notifyInvisibleForms success');
}).catch((error) => {
- console.log(`error, code: ${error.code}, message: ${error.message}`);
+ console.log('formHost notifyInvisibleForms, error:' + JSON.stringify(error));
});
} catch(error) {
- console.log(`catch error, code: ${error.code}, message: ${error.message}`);
+ console.log(`catch err->${JSON.stringify(error)}`);
}
```
@@ -603,23 +578,21 @@ Instructs the widget framework to make a widget updatable. After this API is cal
| Error Code ID| Error Message|
| -------- | -------- |
-| 401 | Incorrect input parameter.|
+| 401 | If the input parameter is not valid parameter. |
|For details about the error codes, see [Form Error Codes](../errorcodes/errorcode-form.md).|
**Example**
```ts
-import formHost from '@ohos.app.form.formHost';
-
try {
- let formId = ["12400633174999288"];
- formHost.enableFormsUpdate(formId, (error) => {
+ var formId = ['12400633174999288'];
+ formHost.enableFormsUpdate(formId, (error, data) => {
if (error) {
- console.log(`error, code: ${error.code}, message: ${error.message}`);
+ console.log('formHost enableFormsUpdate, error:' + JSON.stringify(error));
}
});
} catch(error) {
- console.log(`catch error, code: ${error.code}, message: ${error.message}`);
+ console.log(`catch err->${JSON.stringify(error)}`);
}
```
@@ -649,23 +622,21 @@ Instructs the widget framework to make a widget updatable. After this API is cal
| Error Code ID| Error Message|
| -------- | -------- |
-| 401 | Incorrect input parameter.|
+| 401 | If the input parameter is not valid parameter. |
|For details about the error codes, see [Form Error Codes](../errorcodes/errorcode-form.md).|
**Example**
```ts
-import formHost from '@ohos.app.form.formHost';
-
try {
- let formId = ["12400633174999288"];
+ var formId = ['12400633174999288'];
formHost.enableFormsUpdate(formId).then(() => {
console.log('formHost enableFormsUpdate success');
}).catch((error) => {
- console.log(`error, code: ${error.code}, message: ${error.message}`);
+ console.log('formHost enableFormsUpdate, error:' + JSON.stringify(error));
});
} catch(error) {
- console.log(`catch error, code: ${error.code}, message: ${error.message}`);
+ console.log(`catch err->${JSON.stringify(error)}`);
}
```
@@ -690,23 +661,21 @@ Instructs the widget framework to make a widget not updatable. After this API is
| Error Code ID| Error Message|
| -------- | -------- |
-| 401 | Incorrect input parameter.|
+| 401 | If the input parameter is not valid parameter. |
|For details about the error codes, see [Form Error Codes](../errorcodes/errorcode-form.md).|
**Example**
```ts
-import formHost from '@ohos.app.form.formHost';
-
try {
- let formId = ["12400633174999288"];
- formHost.disableFormsUpdate(formId, (error) => {
+ var formId = ['12400633174999288'];
+ formHost.disableFormsUpdate(formId, (error, data) => {
if (error) {
- console.log(`error, code: ${error.code}, message: ${error.message}`);
+ console.log('formHost disableFormsUpdate, error:' + JSON.stringify(error));
}
});
} catch(error) {
- console.log(`catch error, code: ${error.code}, message: ${error.message}`);
+ console.log(`catch err->${JSON.stringify(error)}`);
}
```
@@ -736,23 +705,21 @@ Instructs the widget framework to make a widget not updatable. After this API is
| Error Code ID| Error Message|
| -------- | -------- |
-| 401 | Incorrect input parameter.|
+| 401 | If the input parameter is not valid parameter. |
|For details about the error codes, see [Form Error Codes](../errorcodes/errorcode-form.md).|
**Example**
```ts
-import formHost from '@ohos.app.form.formHost';
-
try {
- let formId = ["12400633174999288"];
+ var formId = ['12400633174999288'];
formHost.disableFormsUpdate(formId).then(() => {
console.log('formHost disableFormsUpdate success');
}).catch((error) => {
- console.log(`error, code: ${error.code}, message: ${error.message}`);
+ console.log('formHost disableFormsUpdate, error:' + JSON.stringify(error));
});
} catch(error) {
- console.log(`catch error, code: ${error.code}, message: ${error.message}`);
+ console.log(`catch err->${JSON.stringify(error)}`);
}
```
@@ -773,16 +740,15 @@ Checks whether the system is ready. This API uses an asynchronous callback to re
**Example**
```ts
-import formHost from '@ohos.app.form.formHost';
-
try {
+ var formId = '12400633174999288';
formHost.isSystemReady((error, data) => {
if (error) {
- console.log(`error, code: ${error.code}, message: ${error.message}`);
+ console.log('formHost isSystemReady, error:' + JSON.stringify(error));
}
});
} catch(error) {
- console.log(`catch error, code: ${error.code}, message: ${error.message}`);
+ console.log(`catch err->${JSON.stringify(error)}`);
}
```
@@ -803,16 +769,15 @@ Checks whether the system is ready. This API uses a promise to return the result
**Example**
```ts
-import formHost from '@ohos.app.form.formHost';
-
try {
+ var formId = '12400633174999288';
formHost.isSystemReady().then(() => {
console.log('formHost isSystemReady success');
}).catch((error) => {
- console.log(`error, code: ${error.code}, message: ${error.message}`);
+ console.log('formHost isSystemReady, error:' + JSON.stringify(error));
});
} catch(error) {
- console.log(`catch error, code: ${error.code}, message: ${error.message}`);
+ console.log(`catch err->${JSON.stringify(error)}`);
}
```
@@ -830,23 +795,21 @@ Obtains the widget information provided by all applications on the device. This
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ------- |
-| callback | AsyncCallback<Array<[formInfo.FormInfo](js-apis-app-form-formInfo.md)>> | Yes| Callback used to return the result. If the widget information is obtained, **error** is undefined and **data** is the information obtained; otherwise, **error** is an error object.|
+| callback | AsyncCallback<Array<[FormInfo](js-apis-app-form-formInfo.md)>> | Yes| Callback used to return the result. If the widget information is obtained, **error** is undefined and **data** is the information obtained; otherwise, **error** is an error object.|
**Example**
```ts
-import formHost from '@ohos.app.form.formHost';
-
try {
formHost.getAllFormsInfo((error, data) => {
if (error) {
- console.log(`error, code: ${error.code}, message: ${error.message}`);
+ console.log('formHost getAllFormsInfo, error:' + JSON.stringify(error));
} else {
console.log('formHost getAllFormsInfo, data:' + JSON.stringify(data));
}
});
} catch(error) {
- console.log(`catch error, code: ${error.code}, message: ${error.message}`);
+ console.log(`catch err->${JSON.stringify(error)}`);
}
```
@@ -864,21 +827,19 @@ Obtains the widget information provided by all applications on the device. This
| Type | Description |
| :----------------------------------------------------------- | :---------------------------------- |
-| Promise<Array<[formInfo.FormInfo](js-apis-app-form-formInfo.md)>> | Promise used to return the information obtained.|
+| Promise<Array<[FormInfo](js-apis-app-form-formInfo.md)>> | Promise used to return the information obtained.|
**Example**
```ts
-import formHost from '@ohos.app.form.formHost';
-
try {
formHost.getAllFormsInfo().then((data) => {
- console.log('formHost getAllFormsInfo data:' + JSON.stringify(data));
+ console.log('formHost getAllFormsInfo data:' + JSON.stringify(data));
}).catch((error) => {
- console.log(`error, code: ${error.code}, message: ${error.message}`);
+ console.log('formHost getAllFormsInfo, error:' + JSON.stringify(error));
});
} catch(error) {
- console.log(`catch error, code: ${error.code}, message: ${error.message}`);
+ console.log(`catch err->${JSON.stringify(error)}`);
}
```
@@ -903,24 +864,22 @@ Obtains the widget information provided by a given application on the device. Th
| Error Code ID| Error Message|
| -------- | -------- |
-| 401 | Incorrect input parameter.|
+| 401 | If the input parameter is not valid parameter. |
|For details about the error codes, see [Form Error Codes](../errorcodes/errorcode-form.md).|
**Example**
```ts
-import formHost from '@ohos.app.form.formHost';
-
try {
- formHost.getFormsInfo("com.example.ohos.formjsdemo", (error, data) => {
+ formHost.getFormsInfo('com.example.ohos.formjsdemo', (error, data) => {
if (error) {
- console.log(`error, code: ${error.code}, message: ${error.message}`);
+ console.log('formHost getFormsInfo, error:' + JSON.stringify(error));
} else {
console.log('formHost getFormsInfo, data:' + JSON.stringify(data));
}
});
} catch(error) {
- console.log(`catch error, code: ${error.code}, message: ${error.message}`);
+ console.log(`catch err->${JSON.stringify(error)}`);
}
```
@@ -946,24 +905,22 @@ Obtains the widget information provided by a given application on the device. Th
| Error Code ID| Error Message|
| -------- | -------- |
-| 401 | Incorrect input parameter.|
+| 401 | If the input parameter is not valid parameter. |
|For details about the error codes, see [Form Error Codes](../errorcodes/errorcode-form.md).|
**Example**
```ts
-import formHost from '@ohos.app.form.formHost';
-
try {
- formHost.getFormsInfo("com.example.ohos.formjsdemo", "entry", (error, data) => {
+ formHost.getFormsInfo('com.example.ohos.formjsdemo', 'entry', (error, data) => {
if (error) {
- console.log(`error, code: ${error.code}, message: ${error.message}`);
+ console.log('formHost getFormsInfo, error:' + JSON.stringify(error));
} else {
- console.log('formHost getFormsInfo, data:' + JSON.stringify(data));
+ console.log('formHost getFormsInfo, data:' + JSON.stringify(data));
}
});
} catch(error) {
- console.log(`catch error, code: ${error.code}, message: ${error.message}`);
+ console.log(`catch err->${JSON.stringify(error)}`);
}
```
@@ -988,28 +945,26 @@ Obtains the widget information provided by a given application on the device. Th
| Type | Description |
| :----------------------------------------------------------- | :---------------------------------- |
-| Promise<Array<[formInfo.FormInfo](js-apis-app-form-formInfo.md)>> | Promise used to return the information obtained.|
+| Promise<Array<[FormInfo](js-apis-app-form-formInfo.md)>> | Promise used to return the information obtained.|
**Error codes**
| Error Code ID| Error Message|
| -------- | -------- |
-| 401 | Incorrect input parameter.|
+| 401 | If the input parameter is not valid parameter. |
|For details about the error codes, see [Form Error Codes](../errorcodes/errorcode-form.md).|
**Example**
```ts
-import formHost from '@ohos.app.form.formHost';
-
try {
- formHost.getFormsInfo("com.example.ohos.formjsdemo", "entry").then((data) => {
+ formHost.getFormsInfo('com.example.ohos.formjsdemo', 'entry').then((data) => {
console.log('formHost getFormsInfo, data:' + JSON.stringify(data));
}).catch((error) => {
- console.log(`error, code: ${error.code}, message: ${error.message}`);
+ console.log('formHost getFormsInfo, error:' + JSON.stringify(error));
});
} catch(error) {
- console.log(`catch error, code: ${error.code}, message: ${error.message}`);
+ console.log(`catch err->${JSON.stringify(error)}`);
}
```
@@ -1033,19 +988,17 @@ Deletes invalid widgets from the list. This API uses an asynchronous callback to
**Example**
```ts
-import formHost from '@ohos.app.form.formHost';
-
try {
- let formIds = new Array("12400633174999288", "12400633174999289");
+ var formIds = new Array('12400633174999288', '12400633174999289');
formHost.deleteInvalidForms(formIds, (error, data) => {
if (error) {
- console.log(`error, code: ${error.code}, message: ${error.message}`);
+ console.log('formHost deleteInvalidForms, error:' + JSON.stringify(error));
} else {
console.log('formHost deleteInvalidForms, data:' + JSON.stringify(data));
}
});
} catch(error) {
- console.log(`catch error, code: ${error.code}, message: ${error.message}`);
+ console.log(`catch err->${JSON.stringify(error)}`);
}
```
@@ -1074,17 +1027,15 @@ Deletes invalid widgets from the list. This API uses a promise to return the res
**Example**
```ts
-import formHost from '@ohos.app.form.formHost';
-
try {
- let formIds = new Array("12400633174999288", "12400633174999289");
+ var formIds = new Array('12400633174999288', '12400633174999289');
formHost.deleteInvalidForms(formIds).then((data) => {
console.log('formHost deleteInvalidForms, data:' + JSON.stringify(data));
}).catch((error) => {
- console.log(`error, code: ${error.code}, message: ${error.message}`);
+ console.log('formHost deleteInvalidForms, error:' + JSON.stringify(error));
});
} catch(error) {
- console.log(`catch error, code: ${error.code}, message: ${error.message}`);
+ console.log(`catch err->${JSON.stringify(error)}`);
}
```
@@ -1103,40 +1054,38 @@ Obtains the widget state. This API uses an asynchronous callback to return the r
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ------- |
| want | [Want](js-apis-application-want.md) | Yes | **Want** information carried to query the widget state. The information must contain the bundle name, ability name, module name, widget name, and widget dimensions.|
-| callback | AsyncCallback<[formInfo.FormStateInfo](js-apis-app-form-formInfo.md#formstateinfo)> | Yes| Callback used to return the result. If the widget state is obtained, **error** is undefined and **data** is the widget state obtained; otherwise, **error** is an error object.|
+| callback | AsyncCallback<[FormInfo](js-apis-app-form-formInfo.md#formstateinfo)> | Yes| Callback used to return the result. If the widget state is obtained, **error** is undefined and **data** is the widget state obtained; otherwise, **error** is an error object.|
**Error codes**
| Error Code ID| Error Message|
| -------- | -------- |
-| 401 | Incorrect input parameter.|
+| 401 | If the input parameter is not valid parameter. |
|For details about the error codes, see [Form Error Codes](../errorcodes/errorcode-form.md).|
**Example**
```ts
-import formHost from '@ohos.app.form.formHost';
-
-let want = {
- "deviceId": "",
- "bundleName": "ohos.samples.FormApplication",
- "abilityName": "FormAbility",
- "parameters": {
- "ohos.extra.param.key.module_name": "entry",
- "ohos.extra.param.key.form_name": "widget",
- "ohos.extra.param.key.form_dimension": 2
+var want = {
+ 'deviceId': '',
+ 'bundleName': 'ohos.samples.FormApplication',
+ 'abilityName': 'FormAbility',
+ 'parameters': {
+ 'ohos.extra.param.key.module_name': 'entry',
+ 'ohos.extra.param.key.form_name': 'widget',
+ 'ohos.extra.param.key.form_dimension': 2
}
};
try {
formHost.acquireFormState(want, (error, data) => {
if (error) {
- console.log(`error, code: ${error.code}, message: ${error.message}`);
+ console.log('formHost acquireFormState, error:' + JSON.stringify(error));
} else {
console.log('formHost acquireFormState, data:' + JSON.stringify(data));
}
});
} catch(error) {
- console.log(`catch error, code: ${error.code}, message: ${error.message}`);
+ console.log(`catch err->${JSON.stringify(error)}`);
}
```
@@ -1160,44 +1109,42 @@ Obtains the widget state. This API uses a promise to return the result.
| Type | Description |
| :------------ | :---------------------------------- |
-| Promise<[formInfo.FormStateInfo](js-apis-app-form-formInfo.md#formstateinfo)> | Promise used to return the widget state obtained.|
+| Promise<[FormStateInfo](js-apis-app-form-formInfo.md#formstateinfo)> | Promise used to return the widget state obtained.|
**Error codes**
| Error Code ID| Error Message|
| -------- | -------- |
-| 401 | Incorrect input parameter.|
+| 401 | If the input parameter is not valid parameter. |
|For details about the error codes, see [Form Error Codes](../errorcodes/errorcode-form.md).|
**Example**
```ts
-import formHost from '@ohos.app.form.formHost';
-
-let want = {
- "deviceId": "",
- "bundleName": "ohos.samples.FormApplication",
- "abilityName": "FormAbility",
- "parameters": {
- "ohos.extra.param.key.module_name": "entry",
- "ohos.extra.param.key.form_name": "widget",
- "ohos.extra.param.key.form_dimension": 2
+var want = {
+ 'deviceId': '',
+ 'bundleName': 'ohos.samples.FormApplication',
+ 'abilityName': 'FormAbility',
+ 'parameters': {
+ 'ohos.extra.param.key.module_name': 'entry',
+ 'ohos.extra.param.key.form_name': 'widget',
+ 'ohos.extra.param.key.form_dimension': 2
}
};
try {
formHost.acquireFormState(want).then((data) => {
console.log('formHost acquireFormState, data:' + JSON.stringify(data));
}).catch((error) => {
- console.log(`error, code: ${error.code}, message: ${error.message}`);
+ console.log('formHost acquireFormState, error:' + JSON.stringify(error));
});
} catch(error) {
- console.log(`catch error, code: ${error.code}, message: ${error.message}`);
+ console.log(`catch err->${JSON.stringify(error)}`);
}
```
-## on("formUninstall")
+## on('formUninstall')
-on(type: "formUninstall", callback: Callback<string>): void
+on(type: 'formUninstall', callback: Callback<string>): void
Subscribes to widget uninstall events. This API uses an asynchronous callback to return the result.
@@ -1207,23 +1154,21 @@ Subscribes to widget uninstall events. This API uses an asynchronous callback to
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ------- |
-| type | string | Yes | Event type. The value **formUninstall** indicates a widget uninstallation event.|
+| type | string | Yes | Event type. The value **'formUninstall'** indicates a widget uninstallation event.|
| callback | Callback<string> | Yes| Callback used to return the widget ID.|
**Example**
```ts
-import formHost from '@ohos.app.form.formHost';
-
let callback = function(formId) {
console.log('formHost on formUninstall, formId:' + formId);
}
-formHost.on("formUninstall", callback);
+formHost.on('formUninstall', callback);
```
-## off("formUninstall")
+## off('formUninstall')
-off(type: "formUninstall", callback?: Callback<string>): void
+off(type: 'formUninstall', callback?: Callback<string>): void
Unsubscribes from widget uninstall events. This API uses an asynchronous callback to return the result.
@@ -1233,18 +1178,16 @@ Unsubscribes from widget uninstall events. This API uses an asynchronous callbac
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ------- |
-| type | string | Yes | Event type. The value **formUninstall** indicates a widget uninstallation event.|
-| callback | Callback<string> | No| Callback used to return the widget ID. If it is left unspecified, it indicates the callback for all the events that have been subscribed.
The value must be the same as that in **on("formUninstall")**.|
+| type | string | Yes | Event type. The value **'formUninstall'** indicates a widget uninstallation event.|
+| callback | Callback<string> | No| Callback used to return the widget ID. If it is left unspecified, it indicates the callback for all the events that have been subscribed.
The value must be the same as that in **on('formUninstall')**.|
**Example**
```ts
-import formHost from '@ohos.app.form.formHost';
-
let callback = function(formId) {
console.log('formHost on formUninstall, formId:' + formId);
}
-formHost.off("formUninstall", callback);
+formHost.off('formUninstall', callback);
```
## notifyFormsVisible
@@ -1269,23 +1212,21 @@ Instructs the widgets to make themselves visible. This API uses an asynchronous
| Error Code ID| Error Message|
| -------- | -------- |
-| 401 | Incorrect input parameter.|
+| 401 | If the input parameter is not valid parameter. |
|For details about the error codes, see [Form Error Codes](../errorcodes/errorcode-form.md).|
**Example**
```ts
-import formHost from '@ohos.app.form.formHost';
-
-let formIds = new Array("12400633174999288", "12400633174999289");
+var formIds = new Array('12400633174999288', '12400633174999289');
try {
- formHost.notifyFormsVisible(formIds, true, (error) => {
+ formHost.notifyFormsVisible(formIds, true, (error, data) => {
if (error) {
- console.log(`error, code: ${error.code}, message: ${error.message}`);
+ console.log('formHost notifyFormsVisible, error:' + JSON.stringify(error));
}
});
} catch(error) {
- console.log(`catch error, code: ${error.code}, message: ${error.message}`);
+ console.log(`catch err->${JSON.stringify(error)}`);
}
```
@@ -1316,23 +1257,21 @@ Instructs the widgets to make themselves visible. This API uses a promise to ret
| Error Code ID| Error Message|
| -------- | -------- |
-| 401 | Incorrect input parameter.|
+| 401 | If the input parameter is not valid parameter. |
|For details about the error codes, see [Form Error Codes](../errorcodes/errorcode-form.md).|
**Example**
```ts
-import formHost from '@ohos.app.form.formHost';
-
-let formIds = new Array("12400633174999288", "12400633174999289");
+var formIds = new Array('12400633174999288', '12400633174999289');
try {
formHost.notifyFormsVisible(formIds, true).then(() => {
console.log('formHost notifyFormsVisible success');
}).catch((error) => {
- console.log(`error, code: ${error.code}, message: ${error.message}`);
+ console.log('formHost notifyFormsVisible, error:' + JSON.stringify(error));
});
} catch(error) {
- console.log(`catch error, code: ${error.code}, message: ${error.message}`);
+ console.log(`catch err->${JSON.stringify(error)}`);
}
```
@@ -1358,23 +1297,21 @@ Instructs the widgets to enable or disable updates. This API uses an asynchronou
| Error Code ID| Error Message|
| -------- | -------- |
-| 401 | Incorrect input parameter.|
+| 401 | If the input parameter is not valid parameter. |
|For details about the error codes, see [Form Error Codes](../errorcodes/errorcode-form.md).|
**Example**
```ts
-import formHost from '@ohos.app.form.formHost';
-
-let formIds = new Array("12400633174999288", "12400633174999289");
+var formIds = new Array('12400633174999288', '12400633174999289');
try {
- formHost.notifyFormsEnableUpdate(formIds, true, (error) => {
+ formHost.notifyFormsEnableUpdate(formIds, true, (error, data) => {
if (error) {
- console.log(`error, code: ${error.code}, message: ${error.message}`);
+ console.log('formHost notifyFormsEnableUpdate, error:' + JSON.stringify(error));
}
});
} catch(error) {
- console.log(`catch error, code: ${error.code}, message: ${error.message}`);
+ console.log(`catch err->${JSON.stringify(error)}`);
}
```
@@ -1405,23 +1342,21 @@ Instructs the widgets to enable or disable updates. This API uses a promise to r
| Error Code ID| Error Message|
| -------- | -------- |
-| 401 | Incorrect input parameter.|
+| 401 | If the input parameter is not valid parameter. |
|For details about the error codes, see [Form Error Codes](../errorcodes/errorcode-form.md).|
**Example**
```ts
-import formHost from '@ohos.app.form.formHost';
-
-let formIds = new Array("12400633174999288", "12400633174999289");
+var formIds = new Array('12400633174999288', '12400633174999289');
try {
formHost.notifyFormsEnableUpdate(formIds, true).then(() => {
console.log('formHost notifyFormsEnableUpdate success');
}).catch((error) => {
- console.log(`error, code: ${error.code}, message: ${error.message}`);
+ console.log('formHost notifyFormsEnableUpdate, error:' + JSON.stringify(error));
});
} catch(error) {
- console.log(`catch error, code: ${error.code}, message: ${error.message}`);
+ console.log(`catch err->${JSON.stringify(error)}`);
}
```
## shareForm
@@ -1446,24 +1381,23 @@ Shares a specified widget with a remote device. This API uses an asynchronous ca
| Error Code ID| Error Message|
| -------- | -------- |
-| 401 | Incorrect input parameter.|
+| 401 | If the input parameter is not valid parameter. |
|For details about the error codes, see [Form Error Codes](../errorcodes/errorcode-form.md).|
+
**Example**
```ts
-import formHost from '@ohos.app.form.formHost';
-
-let formId = "12400633174999288";
-let deviceId = "EFC11C0C53628D8CC2F8CB5052477E130D075917034613B9884C55CD22B3DEF2";
+var formId = '12400633174999288';
+var deviceId = 'EFC11C0C53628D8CC2F8CB5052477E130D075917034613B9884C55CD22B3DEF2';
try {
- formHost.shareForm(formId, deviceId, (error) => {
+ formHost.shareForm(formId, deviceId, (error, data) => {
if (error) {
- console.log(`error, code: ${error.code}, message: ${error.message}`);
+ console.log('formHost shareForm, error:' + JSON.stringify(error));
}
});
} catch(error) {
- console.log(`catch error, code: ${error.code}, message: ${error.message}`);
+ console.log(`catch err->${JSON.stringify(error)}`);
}
```
@@ -1494,24 +1428,22 @@ Shares a specified widget with a remote device. This API uses a promise to retur
| Error Code ID| Error Message|
| -------- | -------- |
-| 401 | Incorrect input parameter.|
+| 401 | If the input parameter is not valid parameter. |
|For details about the error codes, see [Form Error Codes](../errorcodes/errorcode-form.md).|
**Example**
```ts
-import formHost from '@ohos.app.form.formHost';
-
-let formId = "12400633174999288";
-let deviceId = "EFC11C0C53628D8CC2F8CB5052477E130D075917034613B9884C55CD22B3DEF2";
+var formId = '12400633174999288';
+var deviceId = 'EFC11C0C53628D8CC2F8CB5052477E130D075917034613B9884C55CD22B3DEF2';
try {
formHost.shareForm(formId, deviceId).then(() => {
console.log('formHost shareForm success');
}).catch((error) => {
- console.log(`error, code: ${error.code}, message: ${error.message}`);
+ console.log('formHost shareForm, error:' + JSON.stringify(error));
});
} catch(error) {
- console.log(`catch error, code: ${error.code}, message: ${error.message}`);
+ console.log(`catch err->${JSON.stringify(error)}`);
}
```
@@ -1529,75 +1461,18 @@ Notifies that the privacy protection status of the specified widgets changes. Th
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ------- |
-| formIds | Array\ | Yes | ID of the widgets.|
-| isProtected | boolean | Yes | Whether privacy protection is enabled.|
-| callback | AsyncCallback\ | Yes| Callback used to return the result. If privacy protection is set successfully, **error** is undefined; otherwise, **error** is an error object.|
-
-**Error codes**
-
-| Error Code ID | Error Message |
-| ------------------------------------------------------------ | ------------------ |
-| 401 | Incorrect input parameter.|
-| For details about the error codes, see [Form Error Codes](../errorcodes/errorcode-form.md).| |
-
-**Example**
-
-```ts
-import formHost from '@ohos.app.form.formHost';
-
-let formIds = new Array("12400633174999288", "12400633174999289");
-try {
- formHost.notifyFormsPrivacyProtected(formIds, true, (error) => {
- if (error) {
- console.log(`error, code: ${error.code}, message: ${error.message}`);
- }
- });
-} catch(error) {
- console.log(`catch error, code: ${error.code}, message: ${error.message}`);
-}
-```
-
-## notifyFormsPrivacyProtected
-
-function notifyFormsPrivacyProtected(formIds: Array\, isProtected: boolean): Promise\;
-
-Notifies that the privacy protection status of the specified widgets changes. This API uses a promise to return the result.
-
-**Required permissions**: ohos.permission.REQUIRE_FORM
-
-**System capability**: SystemCapability.Ability.Form
-
-**Parameters**
-
-| Name | Type | Mandatory| Description |
-| ----------- | --------------- | ---- | -------------------------------- |
-| formIds | Array\ | Yes | ID of the widgets.|
-| isProtected | boolean | Yes | Whether privacy protection is enabled. |
-
-**Return value**
-
-| Type | Description |
-| ------------------- | ------------------------- |
-| Promise<void> | Promise that returns no value.|
-
-**Error codes**
-
-| Error Code ID | Error Message |
-| ------------------------------------------------------------ | ------------------ |
-| 401 | Incorrect input parameter.|
-| For details about the error codes, see [Form Error Codes](../errorcodes/errorcode-form.md).| |
+| formId | string | Yes | Widget ID.|
+| deviceId | string | Yes | Remote device ID. |
```ts
-import formHost from '@ohos.app.form.formHost';
-
-let formIds = new Array("12400633174999288", "12400633174999289");
+var formIds = new Array('12400633174999288', '12400633174999289');
try {
formHost.notifyFormsPrivacyProtected(formIds, true).then(() => {
- console.log('formHost notifyFormsPrivacyProtected success');
+ console.log('formHost shareForm success');
}).catch((error) => {
- console.log(`error, code: ${error.code}, message: ${error.message}`);
+ console.log('formHost shareForm, error:' + JSON.stringify(error));
});
} catch(error) {
- console.log(`catch error, code: ${error.code}, message: ${error.message}`);
+ console.log(`catch err->${JSON.stringify(error)}`);
}
```
diff --git a/en/application-dev/reference/apis/js-apis-app-form-formProvider.md b/en/application-dev/reference/apis/js-apis-app-form-formProvider.md
index d61484f86b36bafd74ded1860272ac1a4b86089a..51b4fa42a1704ed9cf451daff6e2416a491db4a9 100644
--- a/en/application-dev/reference/apis/js-apis-app-form-formProvider.md
+++ b/en/application-dev/reference/apis/js-apis-app-form-formProvider.md
@@ -1,4 +1,4 @@
-# @ohos.app.form.formProvider (formProvider)
+# @ohos.app.form.formProvider (FormProvider)
The **FormProvider** module provides APIs related to the widget provider. You can use the APIs to update a widget, set the next refresh time for a widget, obtain widget information, and request a widget release.
@@ -31,25 +31,23 @@ Sets the next refresh time for a widget. This API uses an asynchronous callback
| Error Code ID| Error Message|
| -------- | -------- |
-| 401 | Incorrect input parameter.|
+| 401 | If the input parameter is not valid parameter. |
|For details about the error codes, see [Form Error Codes](../errorcodes/errorcode-form.md).|
**Example**
```ts
-import formProvider from '@ohos.app.form.formProvider';
-
-let formId = "12400633174999288";
+var formId = '12400633174999288';
try {
formProvider.setFormNextRefreshTime(formId, 5, (error, data) => {
if (error) {
- console.log(`callback error, code: ${error.code}, message: ${error.message})`);
+ console.log('formProvider setFormNextRefreshTime, error:' + JSON.stringify(error));
} else {
console.log(`formProvider setFormNextRefreshTime success`);
}
});
} catch (error) {
- console.log(`catch error, code: ${error.code}, message: ${error.message})`);
+ console.log('error' + JSON.stringify(error))
}
```
@@ -78,23 +76,21 @@ Sets the next refresh time for a widget. This API uses a promise to return the r
| Error Code ID| Error Message|
| -------- | -------- |
-| 401 | Incorrect input parameter.|
+| 401 | If the input parameter is not valid parameter. |
|For details about the error codes, see [Form Error Codes](../errorcodes/errorcode-form.md).|
**Example**
```ts
-import formProvider from '@ohos.app.form.formProvider';
-
-let formId = "12400633174999288";
+var formId = '12400633174999288';
try {
formProvider.setFormNextRefreshTime(formId, 5).then(() => {
- console.log(`formProvider setFormNextRefreshTime success`);
+ console.log('formProvider setFormNextRefreshTime success');
}).catch((error) => {
- console.log(`promise error, code: ${error.code}, message: ${error.message})`);
+ console.log('formProvider setFormNextRefreshTime, error:' + JSON.stringify(error));
});
} catch (error) {
- console.log(`catch error, code: ${error.code}, message: ${error.message})`);
+ console.log(`catch err->${JSON.stringify(error)}`);
}
```
@@ -118,27 +114,25 @@ Updates a widget. This API uses an asynchronous callback to return the result.
| Error Code ID| Error Message|
| -------- | -------- |
-| 401 | Incorrect input parameter.|
+| 401 | If the input parameter is not valid parameter. |
|For details about the error codes, see [Form Error Codes](../errorcodes/errorcode-form.md).|
**Example**
```ts
import formBindingData from '@ohos.application.formBindingData';
-import formProvider from '@ohos.app.form.formProvider';
-
-let formId = "12400633174999288";
+var formId = '12400633174999288';
try {
- let obj = formBindingData.createFormBindingData({temperature:"22c", time:"22:00"});
+ let obj = formBindingData.createFormBindingData({temperature:'22c', time:'22:00'});
formProvider.updateForm(formId, obj, (error, data) => {
if (error) {
- console.log(`callback error, code: ${error.code}, message: ${error.message})`);
+ console.log('formProvider updateForm, error:' + JSON.stringify(error));
} else {
console.log(`formProvider updateForm success`);
}
});
} catch (error) {
- console.log(`catch error, code: ${error.code}, message: ${error.message})`);
+ console.log(`catch err->${JSON.stringify(error)}`);
}
```
@@ -167,25 +161,23 @@ Updates a widget. This API uses a promise to return the result.
| Error Code ID| Error Message|
| -------- | -------- |
-| 401 | Incorrect input parameter.|
+| 401 | If the input parameter is not valid parameter. |
|For details about the error codes, see [Form Error Codes](../errorcodes/errorcode-form.md).|
**Example**
```ts
import formBindingData from '@ohos.application.formBindingData';
-import formProvider from '@ohos.app.form.formProvider';
-
-let formId = "12400633174999288";
-let obj = formBindingData.createFormBindingData({ temperature: "22c", time: "22:00" });
+var formId = '12400633174999288';
+let obj = formBindingData.createFormBindingData({temperature:'22c', time:'22:00'});
try {
formProvider.updateForm(formId, obj).then(() => {
- console.log(`formProvider updateForm success`);
+ console.log('formProvider updateForm success');
}).catch((error) => {
- console.log(`promise error, code: ${error.code}, message: ${error.message})`);
+ console.log('formProvider updateForm, error:' + JSON.stringify(error));
});
} catch (error) {
- console.log(`catch error, code: ${error.code}, message: ${error.message})`);
+ console.log(`catch err->${JSON.stringify(error)}`);
}
```
@@ -201,31 +193,29 @@ Obtains the application's widget information on the device. This API uses an asy
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ------- |
-| callback | AsyncCallback<Array<[formInfo.FormInfo](js-apis-app-form-formInfo.md)>> | Yes| Callback used to return the information obtained.|
+| callback | AsyncCallback<Array<[FormInfo](js-apis-app-form-formInfo.md)>> | Yes| Callback used to return the information obtained.|
**Error codes**
| Error Code ID| Error Message|
| -------- | -------- |
-| 401 | Incorrect input parameter.|
+| 401 | If the input parameter is not valid parameter. |
|For details about the error codes, see [Form Error Codes](../errorcodes/errorcode-form.md).|
**Example**
```ts
-import formProvider from '@ohos.app.form.formProvider';
-
try {
formProvider.getFormsInfo((error, data) => {
if (error) {
- console.log(`callback error, code: ${error.code}, message: ${error.message})`);
+ console.log('formProvider getFormsInfo, error:' + JSON.stringify(error));
} else {
- console.log('formProvider getFormsInfo, data: ' + JSON.stringify(data));
+ console.log('formProvider getFormsInfo, data:' + JSON.stringify(data));
}
});
} catch (error) {
- console.log(`catch error, code: ${error.code}, message: ${error.message})`);
+ console.log(`catch err->${JSON.stringify(error)}`);
}
```
## getFormsInfo
@@ -241,35 +231,33 @@ Obtains the application's widget information that meets a filter criterion on th
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ------- |
| filter | [formInfo.FormInfoFilter](js-apis-app-form-formInfo.md#forminfofilter) | Yes| Filter criterion.|
-| callback | AsyncCallback<Array<[formInfo.FormInfo](js-apis-app-form-formInfo.md)>> | Yes| Callback used to return the information obtained.|
+| callback | AsyncCallback<Array<[FormInfo](js-apis-app-form-formInfo.md)>> | Yes| Callback used to return the information obtained.|
**Error codes**
| Error Code ID| Error Message|
| -------- | -------- |
-| 401 | Incorrect input parameter.|
+| 401 | If the input parameter is not valid parameter. |
|For details about the error codes, see [Form Error Codes](../errorcodes/errorcode-form.md).|
**Example**
```ts
-import formInfo from '@ohos.app.form.formInfo';
-import formProvider from '@ohos.app.form.formProvider';
-
-const filter: formInfo.FormInfoFilter = {
- // get info of forms belong to module entry.
- moduleName: "entry"
+import formInfo from '@ohos.application.formInfo';
+const filter : formInfo.FormInfoFilter = {
+ // get info of forms belong to module entry.
+ moduleName : 'entry'
};
try {
formProvider.getFormsInfo(filter, (error, data) => {
if (error) {
- console.log(`callback error, code: ${error.code}, message: ${error.message})`);
+ console.log('formProvider getFormsInfo, error:' + JSON.stringify(error));
} else {
- console.log('formProvider getFormsInfo, data: ' + JSON.stringify(data));
+ console.log('formProvider getFormsInfo, data:' + JSON.stringify(data));
}
});
-} catch (error) {
- console.log(`catch error, code: ${error.code}, message: ${error.message})`);
+} catch(error) {
+ console.log(`catch err->${JSON.stringify(error)}`);
}
```
@@ -291,33 +279,31 @@ Obtains the application's widget information on the device. This API uses a prom
| Type | Description |
| :------------ | :---------------------------------- |
-| Promise<Array<[formInfo.FormInfo](js-apis-app-form-formInfo.md)>> | Promise used to return the information obtained.|
+| Promise<Array<[FormInfo](js-apis-app-form-formInfo.md)>> | Promise used to return the information obtained.|
**Error codes**
| Error Code ID| Error Message|
| -------- | -------- |
-| 401 | Incorrect input parameter.|
+| 401 | If the input parameter is not valid parameter. |
|For details about the error codes, see [Form Error Codes](../errorcodes/errorcode-form.md).|
**Example**
```ts
-import formInfo from '@ohos.app.form.formInfo';
-import formProvider from '@ohos.app.form.formProvider';
-
-const filter: formInfo.FormInfoFilter = {
- // get info of forms belong to module entry.
- moduleName: "entry"
+import formInfo from '@ohos.application.formInfo';
+const filter : formInfo.FormInfoFilter = {
+ // get info of forms belong to module entry.
+ moduleName : 'entry'
};
try {
formProvider.getFormsInfo(filter).then((data) => {
console.log('formProvider getFormsInfo, data:' + JSON.stringify(data));
}).catch((error) => {
- console.log(`promise error, code: ${error.code}, message: ${error.message})`);
+ console.log('formProvider getFormsInfo, error:' + JSON.stringify(error));
});
} catch (error) {
- console.log(`catch error, code: ${error.code}, message: ${error.message})`);
+ console.log(`catch err->${JSON.stringify(error)}`);
}
```
@@ -335,42 +321,40 @@ Requests to publish a widget carrying data to the widget host. This API uses an
| Name| Type | Mandatory| Description |
| ------ | ---------------------------------------------------------------------- | ---- | ---------------- |
-| want | [Want](js-apis-application-want.md) | Yes | Request used for publishing. The following fields must be included:
Information about the target widget.
**abilityName**: ability of the target widget.
**parameters**:
"ohos.extra.param.key.form_dimension"
"ohos.extra.param.key.form_name"
"ohos.extra.param.key.module_name" |
-| formBindingData | [formBindingData.FormBindingData](js-apis-app-form-formBindingData.md#formbindingdata) | Yes | Data used for creating the widget.|
+| want | [Want](js-apis-application-want.md) | Yes | Request used for publishing. The following fields must be included:
Information about the target widget.
**abilityName**: ability of the target widget.
**parameters**:
'ohos.extra.param.key.form_dimension'
'ohos.extra.param.key.form_name'
'ohos.extra.param.key.module_name' |
+| formBindingData.FormBindingData | [FormBindingData](js-apis-app-form-formBindingData.md#formbindingdata) | Yes | Data used for creating the widget.|
| callback | AsyncCallback<string> | Yes| Callback used to return the widget ID.|
**Error codes**
| Error Code ID| Error Message|
| -------- | -------- |
-| 401 | Incorrect input parameter.|
+| 401 | If the input parameter is not valid parameter. |
|For details about the error codes, see [Form Error Codes](../errorcodes/errorcode-form.md).|
**Example**
```ts
import formBindingData from '@ohos.application.formBindingData';
-import formProvider from '@ohos.app.form.formProvider';
-
-let want = {
- abilityName: "FormAbility",
+var want = {
+ abilityName: 'FormAbility',
parameters: {
- "ohos.extra.param.key.form_dimension": 2,
- "ohos.extra.param.key.form_name": "widget",
- "ohos.extra.param.key.module_name": "entry"
+ 'ohos.extra.param.key.form_dimension': 2,
+ 'ohos.extra.param.key.form_name': 'widget',
+ 'ohos.extra.param.key.module_name': 'entry'
}
};
try {
- let obj = formBindingData.createFormBindingData({ temperature: "22c", time: "22:00" });
+ let obj = formBindingData.createFormBindingData({temperature:'22c', time:'22:00'});
formProvider.requestPublishForm(want, obj, (error, data) => {
if (error) {
- console.log(`callback error, code: ${error.code}, message: ${error.message})`);
+ console.log('formProvider requestPublishForm, error: ' + JSON.stringify(error));
} else {
console.log('formProvider requestPublishForm, form ID is: ' + JSON.stringify(data));
}
});
} catch (error) {
- console.log(`catch error, code: ${error.code}, message: ${error.message})`);
+ console.log(`catch err->${JSON.stringify(error)}`);
}
```
@@ -388,40 +372,39 @@ Requests to publish a widget to the widget host. This API uses an asynchronous c
| Name | Type | Mandatory| Description |
| -------- | ----------------------------------- | ---- | ------------------------------------------------------------ |
-| want | [Want](js-apis-application-want.md) | Yes | Request used for publishing. The following fields must be included:
Information about the target widget.
**abilityName**: ability of the target widget.
**parameters**:
"ohos.extra.param.key.form_dimension"
"ohos.extra.param.key.form_name"
"ohos.extra.param.key.module_name" |
+| want | [Want](js-apis-application-want.md) | Yes | Request used for publishing. The following fields must be included:
Information about the target widget.
**abilityName**: ability of the target widget.
**parameters**:
'ohos.extra.param.key.form_dimension'
'ohos.extra.param.key.form_name'
'ohos.extra.param.key.module_name' |
| callback | AsyncCallback<string> | Yes | Callback used to return the widget ID.|
**Error codes**
| Error Code ID| Error Message|
| -------- | -------- |
-| 401 | Incorrect input parameter.|
+| 401 | If the input parameter is not valid parameter. |
|For details about the error codes, see [Form Error Codes](../errorcodes/errorcode-form.md).|
**Example**
```ts
-import formProvider from '@ohos.app.form.formProvider';
-
-let want = {
- abilityName: "FormAbility",
+var want = {
+ abilityName: 'FormAbility',
parameters: {
- "ohos.extra.param.key.form_dimension": 2,
- "ohos.extra.param.key.form_name": "widget",
- "ohos.extra.param.key.module_name": "entry"
+ 'ohos.extra.param.key.form_dimension': 2,
+ 'ohos.extra.param.key.form_name': 'widget',
+ 'ohos.extra.param.key.module_name': 'entry'
}
};
try {
formProvider.requestPublishForm(want, (error, data) => {
if (error) {
- console.log(`callback error, code: ${error.code}, message: ${error.message})`);
+ console.log('formProvider requestPublishForm, error: ' + JSON.stringify(error));
} else {
console.log('formProvider requestPublishForm, form ID is: ' + JSON.stringify(data));
}
});
} catch (error) {
- console.log(`catch error, code: ${error.code}, message: ${error.message})`);
+ console.log(`catch err->${JSON.stringify(error)}`);
}
+
```
## requestPublishForm
@@ -438,8 +421,8 @@ Requests to publish a widget to the widget host. This API uses a promise to retu
| Name | Type | Mandatory| Description |
| --------------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
-| want | [Want](js-apis-application-want.md) | Yes | Request used for publishing. The following fields must be included:
Information about the target widget.
**abilityName**: ability of the target widget.
**parameters**:
"ohos.extra.param.key.form_dimension"
"ohos.extra.param.key.form_name"
"ohos.extra.param.key.module_name" |
-| formBindingData | [formBindingData.FormBindingData](js-apis-app-form-formBindingData.md#formbindingdata) | No | Data used for creating the widget. |
+| want | [Want](js-apis-application-want.md) | Yes | Request used for publishing. The following fields must be included:
Information about the target widget.
**abilityName**: ability of the target widget.
**parameters**:
'ohos.extra.param.key.form_dimension'
'ohos.extra.param.key.form_name'
'ohos.extra.param.key.module_name' |
+| formBindingData.FormBindingData | [FormBindingData](js-apis-app-form-formBindingData.md#formbindingdata) | No | Data used for creating the widget. |
**Return value**
@@ -451,30 +434,28 @@ Requests to publish a widget to the widget host. This API uses a promise to retu
| Error Code ID| Error Message|
| -------- | -------- |
-| 401 | Incorrect input parameter.|
+| 401 | If the input parameter is not valid parameter. |
|For details about the error codes, see [Form Error Codes](../errorcodes/errorcode-form.md).|
**Example**
```ts
-import formProvider from '@ohos.app.form.formProvider';
-
-let want = {
- abilityName: "FormAbility",
+var want = {
+ abilityName: 'FormAbility',
parameters: {
- "ohos.extra.param.key.form_dimension": 2,
- "ohos.extra.param.key.form_name": "widget",
- "ohos.extra.param.key.module_name": "entry"
+ 'ohos.extra.param.key.form_dimension': 2,
+ 'ohos.extra.param.key.form_name': 'widget',
+ 'ohos.extra.param.key.module_name': 'entry'
}
};
try {
formProvider.requestPublishForm(want).then((data) => {
console.log('formProvider requestPublishForm success, form ID is :' + JSON.stringify(data));
}).catch((error) => {
- console.log(`promise error, code: ${error.code}, message: ${error.message})`);
+ console.log('formProvider requestPublishForm, error: ' + JSON.stringify(error));
});
} catch (error) {
- console.log(`catch error, code: ${error.code}, message: ${error.message})`);
+ console.log(`catch err->${JSON.stringify(error)}`);
}
```
@@ -497,38 +478,37 @@ Checks whether a widget can be published to the widget host. This API uses an as
**Example**
```ts
-import formProvider from '@ohos.app.form.formProvider';
-
try {
formProvider.isRequestPublishFormSupported((error, isSupported) => {
- if (error) {
- console.log(`callback error, code: ${error.code}, message: ${error.message})`);
- } else {
- if (isSupported) {
- var want = {
- abilityName: "FormAbility",
- parameters: {
- "ohos.extra.param.key.form_dimension": 2,
- "ohos.extra.param.key.form_name": "widget",
- "ohos.extra.param.key.module_name": "entry"
+ if (error) {
+ console.log('formProvider isRequestPublishFormSupported, error:' + JSON.stringify(error));
+ } else {
+ if (isSupported) {
+ var want = {
+ abilityName: 'FormAbility',
+ parameters: {
+ 'ohos.extra.param.key.form_dimension': 2,
+ 'ohos.extra.param.key.form_name': 'widget',
+ 'ohos.extra.param.key.module_name': 'entry'
+ }
+ };
+ try {
+ formProvider.requestPublishForm(want, (error, data) => {
+ if (error) {
+ console.log('formProvider requestPublishForm, error: ' + JSON.stringify(error));
+ } else {
+ console.log('formProvider requestPublishForm, form ID is: ' + JSON.stringify(data));
}
- };
- try {
- formProvider.requestPublishForm(want, (error, data) => {
- if (error) {
- console.log(`callback error, code: ${error.code}, message: ${error.message})`);
- } else {
- console.log('formProvider requestPublishForm, form ID is: ' + JSON.stringify(data));
- }
- });
- } catch (error) {
- console.log(`catch error, code: ${error.code}, message: ${error.message})`);
- }
+ });
+ } catch (error) {
+ console.log(`catch err->${JSON.stringify(error)}`);
}
+
}
- });
+ }
+});
} catch (error) {
- console.log(`catch error, code: ${error.code}, message: ${error.message})`);
+ console.log(`catch err->${JSON.stringify(error)}`);
}
```
@@ -551,33 +531,32 @@ Checks whether a widget can be published to the widget host. This API uses a pro
**Example**
```ts
-import formProvider from '@ohos.app.form.formProvider';
-
try {
formProvider.isRequestPublishFormSupported().then((isSupported) => {
if (isSupported) {
var want = {
- abilityName: "FormAbility",
- parameters: {
- "ohos.extra.param.key.form_dimension": 2,
- "ohos.extra.param.key.form_name": "widget",
- "ohos.extra.param.key.module_name": "entry"
- }
+ abilityName: 'FormAbility',
+ parameters: {
+ 'ohos.extra.param.key.form_dimension': 2,
+ 'ohos.extra.param.key.form_name': 'widget',
+ 'ohos.extra.param.key.module_name': 'entry'
+ }
};
try {
formProvider.requestPublishForm(want).then((data) => {
console.log('formProvider requestPublishForm success, form ID is :' + JSON.stringify(data));
}).catch((error) => {
- console.log(`promise error, code: ${error.code}, message: ${error.message})`);
+ console.log('formProvider requestPublishForm, error: ' + JSON.stringify(error));
});
} catch (error) {
- console.log(`catch error, code: ${error.code}, message: ${error.message})`);
+ console.log(`catch err->${JSON.stringify(error)}`);
}
+
}
}).catch((error) => {
- console.log(`promise error, code: ${error.code}, message: ${error.message})`);
+ console.log('formProvider isRequestPublishFormSupported, error:' + JSON.stringify(error));
});
} catch (error) {
- console.log(`catch error, code: ${error.code}, message: ${error.message})`);
+ console.log(`catch err->${JSON.stringify(error)}`);
}
```
diff --git a/en/application-dev/reference/apis/js-apis-appAccount.md b/en/application-dev/reference/apis/js-apis-appAccount.md
index 7c2974d0c8fc4eef7a911523fdeb96c596304c94..31760e1af22ae08fca02d78213a2703389c66ae3 100644
--- a/en/application-dev/reference/apis/js-apis-appAccount.md
+++ b/en/application-dev/reference/apis/js-apis-appAccount.md
@@ -1,4 +1,4 @@
-# @ohos.account.appAccount (App Account Management)
+# @ohos.account.appAccount (App Account Management)
The **appAccount** module provides APIs for adding, deleting, modifying, and querying app account information, and supports inter-app authentication and distributed data synchronization.
@@ -198,18 +198,23 @@ Creates an app account implicitly based on the specified account owner. This API
**Example**
```js
- import featureAbility from '@ohos.ability.featureAbility';
-
function onResultCallback(code, result) {
console.log("resultCode: " + code);
console.log("result: " + JSON.stringify(result));
}
function onRequestRedirectedCallback(request) {
- let abilityStartSetting = {want: request};
- featureAbility.startAbility(abilityStartSetting, (err) => {
+ let wantInfo = {
+ deviceId: '',
+ bundleName: 'com.example.accountjsdemo',
+ action: 'ohos.want.action.viewData',
+ entities: ['entity.system.default'],
+ }
+ this.context.startAbility(wantInfo).then(() => {
+ console.log("startAbility successfully");
+ }).catch((err) => {
console.log("startAbility err: " + JSON.stringify(err));
- });
+ })
}
try {
@@ -252,18 +257,23 @@ Creates an app account implicitly based on the specified account owner and optio
**Example**
```js
- import featureAbility from '@ohos.ability.featureAbility';
-
function onResultCallback(code, result) {
console.log("resultCode: " + code);
console.log("result: " + JSON.stringify(result));
}
function onRequestRedirectedCallback(request) {
- let abilityStartSetting = {want: request};
- featureAbility.startAbility(abilityStartSetting, (err) => {
+ let wantInfo = {
+ deviceId: '',
+ bundleName: 'com.example.accountjsdemo',
+ action: 'ohos.want.action.viewData',
+ entities: ['entity.system.default'],
+ }
+ this.context.startAbility(wantInfo).then(() => {
+ console.log("startAbility successfully");
+ }).catch((err) => {
console.log("startAbility err: " + JSON.stringify(err));
- });
+ })
}
let options = {
@@ -1090,7 +1100,8 @@ getAllAccounts(callback: AsyncCallback<Array<AppAccountInfo>>): void
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
+**Required permissions**: ohos.permission.GET_ALL_APP_ACCOUNTS
+
**System capability**: SystemCapability.Account.AppAccount
**Parameters**
@@ -1127,7 +1138,8 @@ getAllAccounts(): Promise<Array<AppAccountInfo>>
Obtains information about all accessible app accounts. This API uses a promise to return the result.
-**Required Permissions**: ohos.permission.GET_ALL_APP_ACCOUNTS
+**Required permissions**: ohos.permission.GET_ALL_APP_ACCOUNTS
+
**System capability**: SystemCapability.Account.AppAccount
**Return value**
@@ -1162,7 +1174,8 @@ getAccountsByOwner(owner: string, callback: AsyncCallback<Array<AppAccount
Obtains the app accounts that can be accessed by the invoker based on the app account owner. This API uses an asynchronous callback to return the result.
-**Required Permissions**: ohos.permission.GET_ALL_APP_ACCOUNTS
+**Required permissions**: ohos.permission.GET_ALL_APP_ACCOUNTS
+
**System capability**: SystemCapability.Account.AppAccount
**Parameters**
@@ -1201,8 +1214,8 @@ Obtains the app accounts that can be accessed by the invoker based on the app ac
getAccountsByOwner(owner: string): Promise<Array<AppAccountInfo>>
Obtains the app accounts that can be accessed by the invoker based on the app account owner. This API uses a promise to return the result.
+**Required permissions**: ohos.permission.GET_ALL_APP_ACCOUNTS
-**Required Permissions**: ohos.permission.GET_ALL_APP_ACCOUNTS
**System capability**: SystemCapability.Account.AppAccount
**Parameters**
@@ -1303,7 +1316,7 @@ Unsubscribes from account information changes.
**Example**
```js
- function changeOnCallback(data) {
+ function changeOnCallback(data){
console.log("receive change data:" + JSON.stringify(data));
}
try{
@@ -1350,7 +1363,7 @@ Authenticates an app account. This API uses an asynchronous callback to return t
**Example**
```js
- import featureAbility from '@ohos.ability.featureAbility';
+
function onResultCallback(code, authResult) {
console.log("resultCode: " + code);
@@ -1358,10 +1371,17 @@ Authenticates an app account. This API uses an asynchronous callback to return t
}
function onRequestRedirectedCallback(request) {
- let abilityStartSetting = {want: request};
- featureAbility.startAbility(abilityStartSetting, (err) => {
- console.log("startAbility err: " + JSON.stringify(err));
- });
+ let wantInfo = {
+ deviceId: '',
+ bundleName: 'com.example.accountjsdemo',
+ action: 'ohos.want.action.viewData',
+ entities: ['entity.system.default'],
+ }
+ this.context.startAbility(wantInfo).then(() => {
+ console.log("startAbility successfully");
+ }).catch((err) => {
+ console.log("startAbility err: " + JSON.stringify(err));
+ })
}
try {
@@ -1406,7 +1426,7 @@ Authenticates an app account with customized options. This API uses an asynchron
**Example**
```js
- import featureAbility from '@ohos.ability.featureAbility';
+
function onResultCallback(code, authResult) {
console.log("resultCode: " + code);
@@ -1414,10 +1434,17 @@ Authenticates an app account with customized options. This API uses an asynchron
}
function onRequestRedirectedCallback(request) {
- let abilityStartSetting = {want: request};
- featureAbility.startAbility(abilityStartSetting, (err) => {
- console.log("startAbility err: " + JSON.stringify(err));
- });
+ let wantInfo = {
+ deviceId: '',
+ bundleName: 'com.example.accountjsdemo',
+ action: 'ohos.want.action.viewData',
+ entities: ['entity.system.default'],
+ }
+ this.context.startAbility(wantInfo).then(() => {
+ console.log("startAbility successfully");
+ }).catch((err) => {
+ console.log("startAbility err: " + JSON.stringify(err));
+ })
}
let options = {
@@ -1622,7 +1649,7 @@ Deletes the authorization token of the specified authentication type for an app
| name | string | Yes | Name of the target app account. |
| owner | string | Yes | Owner of the app account. The value is the bundle name of the app. |
| authType | string | Yes | Authentication type. |
-| token | string | Yes | Token to delete.|
+| token | string | Yes | Authorization token to delete.|
| callback | AsyncCallback<void> | Yes | Callback invoked to return the result. If the operation is successful, **err** is **null**. Otherwise, **err** is an error object. |
**Error codes**
@@ -1665,7 +1692,7 @@ Deletes the authorization token of the specified authentication type for an app
| name | string | Yes | Name of the target app account. |
| owner | string | Yes | Owner of the app account. The value is the bundle name of the app. |
| authType | string | Yes | Authentication type. |
-| token | string | Yes | Token to delete.|
+| token | string | Yes | Authorization token to delete.|
**Return value**
@@ -2710,7 +2737,7 @@ Adds an app account. This API uses an asynchronous callback to return the result
| Name | Type | Mandatory | Description |
| -------- | ------------------------- | ---- | -------------------- |
-| name | string | Yes | Name of the target app account. |
+| name | string | Yes | Name of the app account to add. |
| callback | AsyncCallback<void> | Yes | Callback invoked to return the result. If the operation is successful, **err** is **null**. Otherwise, **err** is an error object.|
**Example**
@@ -2755,8 +2782,7 @@ addAccount(name: string, extraInfo?: string): Promise<void>
Adds an app account name and additional information. This API uses an asynchronous callback to return the result. This API uses a promise to return the result.
-> **NOTE**
->
+> **NOTE**
> This API is supported since API version 7 and deprecated since API version 9. You are advised to use [createAccount](#createaccount9-2).
**System capability**: SystemCapability.Account.AppAccount
@@ -2808,7 +2834,7 @@ Adds an app account implicitly based on the specified owner. This API uses an as
**Example**
```js
- import featureAbility from '@ohos.ability.featureAbility';
+
function onResultCallback(code, result) {
console.log("resultCode: " + code);
@@ -2816,10 +2842,17 @@ Adds an app account implicitly based on the specified owner. This API uses an as
}
function onRequestRedirectedCallback(request) {
- let abilityStartSetting = {want: request};
- featureAbility.startAbility(abilityStartSetting, (err)=>{
+ let wantInfo = {
+ deviceId: '',
+ bundleName: 'com.example.accountjsdemo',
+ action: 'ohos.want.action.viewData',
+ entities: ['entity.system.default'],
+ }
+ this.context.startAbility(wantInfo).then(() => {
+ console.log("startAbility successfully");
+ }).catch((err) => {
console.log("startAbility err: " + JSON.stringify(err));
- });
+ })
}
appAccountManager.addAccountImplicitly("com.example.accountjsdemo", "getSocialData", {}, {
@@ -2844,7 +2877,7 @@ Deletes an app account. This API uses an asynchronous callback to return the res
| Name | Type | Mandatory | Description |
| -------- | ------------------------- | ---- | ---------------- |
-| name | string | Yes | Name of the target app account. |
+| name | string | Yes | Name of the app account to delete. |
| callback | AsyncCallback<void> | Yes | Callback invoked to return the result. If the operation is successful, **err** is **null**. Otherwise, **err** is an error object.|
**Example**
@@ -2871,7 +2904,7 @@ Deletes an app account. This API uses a promise to return the result.
| Name | Type | Mandatory | Description |
| ---- | ------ | ---- | ----------- |
-| name | string | Yes | Name of the target app account.|
+| name | string | Yes | Name of the app account to delete.|
**Return value**
@@ -3756,18 +3789,23 @@ Authenticates an app account with customized options. This API uses an asynchron
**Example**
```js
- import featureAbility from '@ohos.ability.featureAbility';
-
function onResultCallback(code, result) {
console.log("resultCode: " + code);
console.log("result: " + JSON.stringify(result));
}
function onRequestRedirectedCallback(request) {
- let abilityStartSetting = {want: request};
- featureAbility.startAbility(abilityStartSetting, (err)=>{
- console.log("startAbility err: " + JSON.stringify(err));
- });
+ let wantInfo = {
+ deviceId: '',
+ bundleName: 'com.example.accountjsdemo',
+ action: 'ohos.want.action.viewData',
+ entities: ['entity.system.default'],
+ }
+ this.context.startAbility(wantInfo).then(() => {
+ console.log("startAbility successfully");
+ }).catch((err) => {
+ console.log("startAbility err: " + JSON.stringify(err));
+ })
}
appAccountManager.authenticate("LiSi", "com.example.accountjsdemo", "getSocialData", {}, {
@@ -4526,10 +4564,13 @@ Enumerates the constants.
| KEY_REQUIRED_LABELS9+ | "requiredLabels" | Required labels. |
| KEY_BOOLEAN_RESULT9+ | "booleanResult" | Return value of the Boolean type. |
-## ResultCode8+
+## ResultCode(deprecated)
Enumerates the result codes.
+> **NOTE**
+> This enum is supported since API version 8 and deprecated since API version 9. Error codes are used from API version 9. For details, see [Account Management Error Codes](../errorcodes/errorcode-account.md).
+
**System capability**: SystemCapability.Account.AppAccount
| Name | Value | Description |
@@ -4765,7 +4806,7 @@ Creates an app account implicitly based on the specified account owner. This API
| Name | Type | Mandatory | Description |
| ---------------- | --------------------- | ---- | --------------- |
-| options | [CreateAccountImplicitlyOptions](#createaccountimplicitlyoptions9) | Yes | Options for implicitly creating the account. |
+| options | [CreateAccountImplicitlyOptions](#createaccountimplicitlyoptions9) | Yes | Options for implicitly creating an account. |
| callback | [AuthCallback](#authcallback9) | Yes | Authenticator callback invoked to return the result.|
### addAccountImplicitly(deprecated)
@@ -4876,9 +4917,9 @@ Checks the account labels. This API uses an asynchronous callback to return the
| labels | Array<string> | Yes | Labels to check. |
| callback | [AuthCallback](#authcallback9) | Yes | Authenticator callback invoked to return the check result.|
-### isAccountRemovable9+
+### checkAccountRemovable9+
-isAccountRemovable(name: string, callback: AuthCallback): void;
+checkAccountRemovable(name: string, callback: AuthCallback): void;
Checks whether an app account can be deleted. This API uses an asynchronous callback to return the result.
@@ -4936,7 +4977,7 @@ Obtains the remote object of an authenticator. This API cannot be overloaded.
callback.onResult(account_appAccount.ResultCode.SUCCESS, result);
}
- isAccountRemovable(name, callback) {
+ checkAccountRemovable(name, callback) {
var result = {[account_appAccount.Constants.KEY_BOOLEAN_RESULT]: true};
callback.onResult(account_appAccount.ResultCode.SUCCESS, result);
}
diff --git a/en/application-dev/reference/apis/js-apis-application-ability.md b/en/application-dev/reference/apis/js-apis-application-ability.md
deleted file mode 100644
index efba928564b2c9aa34e35b2af7485674ea99274d..0000000000000000000000000000000000000000
--- a/en/application-dev/reference/apis/js-apis-application-ability.md
+++ /dev/null
@@ -1,756 +0,0 @@
-# @ohos.application.Ability (Ability)
-
-The **Ability** module manages the ability lifecycle and context, such as creating and destroying an ability, and dumping client information.
-
-This module provides the following common ability-related functions:
-
-- [Caller](#caller): implements sending of sequenceable data to the target ability when an ability (caller ability) invokes the target ability (callee ability).
-- [Callee](#callee): implements callbacks for registration and deregistration of caller notifications.
-
-> **NOTE**
->
-> The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version.
-> The APIs of this module can be used only in the stage model.
-
-## Modules to Import
-
-```ts
-import UIAbility from '@ohos.app.ability.UIAbility';
-```
-
-## Attributes
-
-**System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore
-
-| Name| Type| Readable| Writable| Description|
-| -------- | -------- | -------- | -------- | -------- |
-| context | [UIAbilityContext](js-apis-inner-application-uiAbilityContext.md) | Yes| No| Context of an ability.|
-| launchWant | [Want](js-apis-app-ability-want.md) | Yes| No| Parameters for starting the ability.|
-| lastRequestWant | [Want](js-apis-app-ability-want.md) | Yes| No| Parameters used when the ability was started last time.|
-| callee | [Callee](#callee) | Yes| No| Object that invokes the stub service.|
-
-## Ability.onCreate
-
-onCreate(want: Want, param: AbilityConstant.LaunchParam): void;
-
-Called to initialize the service logic when an ability is created.
-
-**System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore
-
-**Parameters**
-
- | Name| Type| Mandatory| Description|
- | -------- | -------- | -------- | -------- |
- | want | [Want](js-apis-app-ability-want.md) | Yes| Information related to this ability, including the ability name and bundle name.|
- | param | AbilityConstant.LaunchParam | Yes| Parameters for starting the ability, and the reason for the last abnormal exit.|
-
-**Example**
-
- ```ts
- export default class EntryAbility extends UIAbility {
- onCreate(want, param) {
- console.log('onCreate, want:' + want.abilityName);
- }
- }
- ```
-
-
-## Ability.onWindowStageCreate
-
-onWindowStageCreate(windowStage: window.WindowStage): void
-
-Called when a **WindowStage** is created for this ability.
-
-**System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore
-
-**Parameters**
-
- | Name| Type| Mandatory| Description|
- | -------- | -------- | -------- | -------- |
- | windowStage | [window.WindowStage](js-apis-window.md#windowstage9) | Yes| **WindowStage** information.|
-
-**Example**
-
- ```ts
- class myAbility extends Ability {
- onWindowStageCreate(windowStage) {
- console.log('onWindowStageCreate');
- }
- }
- ```
-
-
-## Ability.onWindowStageDestroy
-
-onWindowStageDestroy(): void
-
-Called when the **WindowStage** is destroyed for this ability.
-
-**System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore
-
-**Example**
-
- ```ts
- class myAbility extends Ability {
- onWindowStageDestroy() {
- console.log('onWindowStageDestroy');
- }
- }
- ```
-
-
-## Ability.onWindowStageRestore
-
-onWindowStageRestore(windowStage: window.WindowStage): void
-
-Called when the **WindowStage** is restored during the migration of this ability, which is a multi-instance ability.
-
-**System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore
-
-**Parameters**
-
- | Name| Type| Mandatory| Description|
- | -------- | -------- | -------- | -------- |
- | windowStage | [window.WindowStage](js-apis-window.md#windowstage9) | Yes| **WindowStage** information.|
-
-**Example**
-
- ```ts
- class myAbility extends Ability {
- onWindowStageRestore(windowStage) {
- console.log('onWindowStageRestore');
- }
- }
- ```
-
-
-## Ability.onDestroy
-
-onDestroy(): void;
-
-Called when this ability is destroyed to clear resources.
-
-**System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore
-
-**Example**
-
- ```ts
- class myAbility extends Ability {
- onDestroy() {
- console.log('onDestroy');
- }
- }
- ```
-
-
-## Ability.onForeground
-
-onForeground(): void;
-
-Called when this ability is switched from the background to the foreground.
-
-**System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore
-
-**Example**
-
- ```ts
- class myAbility extends Ability {
- onForeground() {
- console.log('onForeground');
- }
- }
- ```
-
-
-## Ability.onBackground
-
-onBackground(): void;
-
-Called when this ability is switched from the foreground to the background.
-
-**System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore
-
-**Example**
-
- ```ts
- class myAbility extends Ability {
- onBackground() {
- console.log('onBackground');
- }
- }
- ```
-
-
-## Ability.onContinue
-
-onContinue(wantParam : {[key: string]: any}): AbilityConstant.OnContinueResult;
-
-Called to save data during the ability migration preparation process.
-
-**System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore
-
-**Parameters**
-
- | Name| Type| Mandatory| Description|
- | -------- | -------- | -------- | -------- |
- | wantParam | {[key: string]: any} | Yes| **want** parameter.|
-
-**Return value**
-
- | Type| Description|
- | -------- | -------- |
- | AbilityConstant.OnContinueResult | Continuation result.|
-
-**Example**
-
- ```ts
- import AbilityConstant from "@ohos.application.AbilityConstant"
- class myAbility extends Ability {
- onContinue(wantParams) {
- console.log('onContinue');
- wantParams["myData"] = "my1234567";
- return AbilityConstant.OnContinueResult.AGREE;
- }
- }
- ```
-
-
-## Ability.onNewWant
-
-onNewWant(want: Want, launchParams: AbilityConstant.LaunchParam): void;
-
-Called when a new Want is passed in and this UIAbility is started again.
-
-**System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore
-
-**Parameters**
-
-| Name| Type| Mandatory| Description|
-| -------- | -------- | -------- | -------- |
-| want | [Want](js-apis-application-want.md) | Yes| Want information, such as the ability name and bundle name.|
-| launchParams | AbilityConstant.LaunchParam | Yes| Reason for the ability startup and the last abnormal exit.|
-
-**Example**
-
- ```ts
- class myAbility extends Ability {
- onNewWant(want, launchParams) {
- console.log('onNewWant, want:' + want.abilityName);
- console.log('onNewWant, launchParams:' + JSON.stringify(launchParams));
- }
- }
- ```
-
-## Ability.onConfigurationUpdated
-
-onConfigurationUpdated(config: Configuration): void;
-
-Called when the global configuration is updated.
-
-**System capability**: SystemCapability.Ability.AbilityRuntime.Core
-
-**Parameters**
-
- | Name| Type| Mandatory| Description|
- | -------- | -------- | -------- | -------- |
- | config | [Configuration](js-apis-application-configuration.md) | Yes| Callback invoked when the global configuration is updated. The global configuration indicates the configuration of the environment where the application is running and includes the language and color mode.|
-
-**Example**
-
- ```ts
- class myAbility extends Ability {
- onConfigurationUpdated(config) {
- console.log('onConfigurationUpdated, language:' + config.language);
- }
- }
- ```
-
-## Ability.dump
-
-dump(params: Array\): Array\;
-
-Dumps client information.
-
-**System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore
-
-**Parameters**
-
- | Name| Type| Mandatory| Description|
- | -------- | -------- | -------- | -------- |
- | params | Array\ | Yes| Parameters in the form of a command.|
-
-**Example**
-
- ```ts
- class myAbility extends Ability {
- dump(params) {
- console.log('dump, params:' + JSON.stringify(params));
- return ["params"]
- }
- }
- ```
-
-## Ability.onMemoryLevel
-
-onMemoryLevel(level: AbilityConstant.MemoryLevel): void;
-
-Called when the system has decided to adjust the memory level. For example, this API can be used when there is not enough memory to run as many background processes as possible.
-
-**System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore
-
-**Parameters**
-
- | Name| Type| Mandatory| Description|
- | -------- | -------- | -------- | -------- |
- | level | [AbilityConstant.MemoryLevel](js-apis-application-abilityConstant.md#abilityconstantmemorylevel) | Yes| Memory level that indicates the memory usage status. When the specified memory level is reached, a callback will be invoked and the system will start adjustment.|
-
-**Example**
-
- ```ts
- class myAbility extends Ability {
- onMemoryLevel(level) {
- console.log('onMemoryLevel, level:' + JSON.stringify(level));
- }
- }
- ```
-
-## Ability.onSaveState
-
-onSaveState(reason: AbilityConstant.StateType, wantParam : {[key: string]: any}): AbilityConstant.OnSaveResult;
-
-Called when the framework automatically saves the ability state in the case of an application fault. This API is used together with [appRecovery](js-apis-app-ability-appRecovery.md).
-
-**System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore
-
-**Parameters**
-
- | Name| Type| Mandatory| Description|
- | -------- | -------- | -------- | -------- |
- | reason | [AbilityConstant.StateType](js-apis-application-abilityConstant.md#abilityconstantstatetype) | Yes| Reason for triggering the callback to save the ability state.|
- | wantParam | {[key: string]: any} | Yes| **want** parameter.|
-
-**Return value**
-
- | Type| Description|
- | -------- | -------- |
- | AbilityConstant.OnSaveResult | Whether the ability state is saved.|
-
-**Example**
-
- ```ts
-import AbilityConstant from '@ohos.application.AbilityConstant'
-
-class myAbility extends Ability {
- onSaveState(reason, wantParam) {
- console.log('onSaveState');
- wantParam["myData"] = "my1234567";
- return AbilityConstant.OnSaveResult.RECOVERY_AGREE;
- }
-}
- ```
-
-
-
-## Caller
-
-Implements sending of sequenceable data to the target ability when an ability (caller ability) invokes the target ability (callee ability).
-
-## Caller.call
-
-call(method: string, data: rpc.Sequenceable): Promise<void>;
-
-Sends sequenceable data to the target ability.
-
-**System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore
-
-**Parameters**
-
- | Name| Type| Mandatory| Description|
- | -------- | -------- | -------- | -------- |
- | method | string | Yes| Notification message string negotiated between the two abilities. The message is used to instruct the callee to register a function to receive the sequenceable data.|
- | data | rpc.Sequenceable | Yes| Sequenceable data. You need to customize the data.|
-
-**Return value**
-
- | Type| Description|
- | -------- | -------- |
- | Promise<void> | Promise used to return a response.|
-
-**Error codes**
-
-| ID| Error Message|
-| ------- | -------------------------------- |
-| 201 | The application does not have permission to call the interface. |
-| 401 | Invalid input parameter. |
-| 16200001 | Caller released. The caller has been released. |
-| 16200002 | Callee invalid. The callee does not exist. |
-| 16000050 | Internal Error. |
-
-**Example**
-
- ```ts
- import UIAbility from '@ohos.app.ability.UIAbility';
-
- class MyMessageAble{ // Custom sequenceable data structure.
- name:""
- str:""
- num: 1
- constructor(name, str) {
- this.name = name;
- this.str = str;
- }
- marshalling(messageParcel) {
- messageParcel.writeInt(this.num);
- messageParcel.writeString(this.str);
- console.log('MyMessageAble marshalling num[' + this.num + '] str[' + this.str + ']');
- return true;
- }
- unmarshalling(messageParcel) {
- this.num = messageParcel.readInt();
- this.str = messageParcel.readString();
- console.log('MyMessageAble unmarshalling num[' + this.num + '] str[' + this.str + ']');
- return true;
- }
- };
- var method = 'call_Function'; // Notification message string negotiated by the two abilities
- var caller;
- export default class EntryAbility extends UIAbility {
- onWindowStageCreate(windowStage) {
- this.context.startAbilityByCall({
- bundleName: "com.example.myservice",
- abilityName: "EntryAbility",
- deviceId: ""
- }).then((obj) => {
- caller = obj;
- let msg = new MyMessageAble("msg", "world"); // See the definition of Sequenceable.
- caller.call(method, msg)
- .then(() => {
- console.log('Caller call() called');
- })
- .catch((callErr) => {
- console.log('Caller.call catch error, error.code: ' + JSON.stringify(callErr.code) +
- ' error.message: ' + JSON.stringify(callErr.message));
- });
- }).catch((err) => {
- console.log('Caller GetCaller error, error.code: ' + JSON.stringify(err.code) +
- ' error.message: ' + JSON.stringify(err.message));
- });
- }
- }
- ```
-
-
-## Caller.callWithResult
-
-callWithResult(method: string, data: rpc.Sequenceable): Promise<rpc.MessageParcel>;
-
-Sends sequenceable data to the target ability and obtains the sequenceable data returned by the target ability.
-
-**System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore
-
-**Parameters**
-
- | Name| Type| Mandatory| Description|
- | -------- | -------- | -------- | -------- |
- | method | string | Yes| Notification message string negotiated between the two abilities. The message is used to instruct the callee to register a function to receive the sequenceable data.|
- | data | rpc.Sequenceable | Yes| Sequenceable data. You need to customize the data.|
-
-**Return value**
-
- | Type| Description|
- | -------- | -------- |
- | Promise<rpc.MessageParcel> | Promise used to return the sequenceable data from the target ability.|
-
-**Error codes**
-
-| ID| Error Message|
-| ------- | -------------------------------- |
-| 201 | The application does not have permission to call the interface. |
-| 401 | Invalid input parameter. |
-| 16200001 | Caller released. The caller has been released. |
-| 16200002 | Callee invalid. The callee does not exist. |
-| 16000050 | Internal Error. |
-
-**Example**
-
- ```ts
- import UIAbility from '@ohos.app.ability.UIAbility';
-
- class MyMessageAble{
- name:""
- str:""
- num: 1
- constructor(name, str) {
- this.name = name;
- this.str = str;
- }
- marshalling(messageParcel) {
- messageParcel.writeInt(this.num);
- messageParcel.writeString(this.str);
- console.log('MyMessageAble marshalling num[' + this.num + '] str[' + this.str + ']');
- return true;
- }
- unmarshalling(messageParcel) {
- this.num = messageParcel.readInt();
- this.str = messageParcel.readString();
- console.log('MyMessageAble unmarshalling num[' + this.num + '] str[' + this.str + ']');
- return true;
- }
- };
- var method = 'call_Function';
- var caller;
- export default class EntryAbility extends UIAbility {
- onWindowStageCreate(windowStage) {
- this.context.startAbilityByCall({
- bundleName: "com.example.myservice",
- abilityName: "EntryAbility",
- deviceId: ""
- }).then((obj) => {
- caller = obj;
- let msg = new MyMessageAble(1, "world");
- caller.callWithResult(method, msg)
- .then((data) => {
- console.log('Caller callWithResult() called');
- let retmsg = new MyMessageAble(0, "");
- data.readSequenceable(retmsg);
- })
- .catch((callErr) => {
- console.log('Caller.callWithResult catch error, error.code: ' + JSON.stringify(callErr.code) +
- ' error.message: ' + JSON.stringify(callErr.message));
- });
- }).catch((err) => {
- console.log('Caller GetCaller error, error.code: ' + JSON.stringify(err.code) +
- ' error.message: ' + JSON.stringify(err.message));
- });
- }
- }
- ```
-
-
-## Caller.release
-
-release(): void;
-
-Releases the caller interface of the target ability.
-
-**System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore
-
-**Error codes**
-
-| ID| Error Message|
-| ------- | -------------------------------- |
-| 401 | Invalid input parameter. |
-| 16200001 | Caller released. The caller has been released. |
-| 16200002 | Callee invalid. The callee does not exist. |
-| 16000050 | Internal Error. |
-
-**Example**
-
-
- ```ts
- import UIAbility from '@ohos.app.ability.UIAbility';
-
- var caller;
-
- export default class EntryAbility extends UIAbility {
- onWindowStageCreate(windowStage) {
- this.context.startAbilityByCall({
- bundleName: "com.example.myservice",
- abilityName: "EntryAbility",
- deviceId: ""
- }).then((obj) => {
- caller = obj;
- try {
- caller.release();
- } catch (releaseErr) {
- console.log('Caller.release catch error, error.code: ' + JSON.stringify(releaseErr.code) +
- ' error.message: ' + JSON.stringify(releaseErr.message));
- }
- }).catch((err) => {
- console.log('Caller GetCaller error, error.code: ' + JSON.stringify(err.code) +
- ' error.message: ' + JSON.stringify(err.message));
- });
- }
- }
- ```
-
-## Caller.onRelease
-
- onRelease(callback: OnReleaseCallBack): void;
-
-Registers a callback that is invoked when the stub on the target ability is disconnected.
-
-**System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore
-
-**Parameters**
-
- | Name| Type| Mandatory| Description|
- | -------- | -------- | -------- | -------- |
- | callback | OnReleaseCallBack | Yes| Callback used for the **onRelease** API.|
-
-**Example**
-
- ```ts
- import UIAbility from '@ohos.app.ability.UIAbility';
-
- var caller;
-
- export default class EntryAbility extends UIAbility {
- onWindowStageCreate(windowStage) {
- this.context.startAbilityByCall({
- bundleName: "com.example.myservice",
- abilityName: "EntryAbility",
- deviceId: ""
- }).then((obj) => {
- caller = obj;
- try {
- caller.onRelease((str) => {
- console.log(' Caller OnRelease CallBack is called ' + str);
- });
- } catch (error) {
- console.log('Caller.on catch error, error.code: ' + JSON.stringify(error.code) +
- ' error.message: ' + JSON.stringify(error.message));
- }
- }).catch((err) => {
- console.log('Caller GetCaller error, error.code: ' + JSON.stringify(err.code) +
- ' error.message: ' + JSON.stringify(err.message));
- });
- }
- }
- ```
-
-
-## Callee
-
-Implements callbacks for caller notification registration and deregistration.
-
-## Callee.on
-
-on(method: string, callback: CalleeCallBack): void;
-
-Registers a caller notification callback, which is invoked when the target ability registers a function.
-
-**System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore
-
-**Parameters**
-
- | Name| Type| Mandatory| Description|
- | -------- | -------- | -------- | -------- |
- | method | string | Yes| Notification message string negotiated between the two abilities.|
- | callback | CalleeCallBack | Yes| JS notification synchronization callback of the **rpc.MessageParcel** type. The callback must return at least one empty **rpc.Sequenceable** object. Otherwise, the function execution fails.|
-
-**Error codes**
-
-| ID| Error Message|
-| ------- | -------------------------------- |
-| 401 | Invalid input parameter. |
-| 16200004 | Method registered. The method has registered. |
-| 16000050 | Internal Error. |
-
-**Example**
-
- ```ts
- import UIAbility from '@ohos.app.ability.UIAbility';
- class MyMessageAble{
- name:""
- str:""
- num: 1
- constructor(name, str) {
- this.name = name;
- this.str = str;
- }
- marshalling(messageParcel) {
- messageParcel.writeInt(this.num);
- messageParcel.writeString(this.str);
- console.log('MyMessageAble marshalling num[' + this.num + '] str[' + this.str + ']');
- return true;
- }
- unmarshalling(messageParcel) {
- this.num = messageParcel.readInt();
- this.str = messageParcel.readString();
- console.log('MyMessageAble unmarshalling num[' + this.num + '] str[' + this.str + ']');
- return true;
- }
- };
- var method = 'call_Function';
- function funcCallBack(pdata) {
- console.log('Callee funcCallBack is called ' + pdata);
- let msg = new MyMessageAble("test", "");
- pdata.readSequenceable(msg);
- return new MyMessageAble("test1", "Callee test");
- }
- export default class EntryAbility extends UIAbility {
- onCreate(want, launchParam) {
- console.log('Callee onCreate is called');
- try {
- this.callee.on(method, funcCallBack);
- } catch (error) {
- console.log('Callee.on catch error, error.code: ' + JSON.stringify(error.code) +
- ' error.message: ' + JSON.stringify(error.message));
- }
- }
- }
- ```
-
-## Callee.off
-
-off(method: string): void;
-
-Deregisters a caller notification callback, which is invoked when the target ability registers a function.
-
-**System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore
-
-**Parameters**
-
- | Name| Type| Mandatory| Description|
- | -------- | -------- | -------- | -------- |
- | method | string | Yes| Registered notification message string.|
-
-**Error codes**
-
-| ID| Error Message|
-| ------- | -------------------------------- |
-| 401 | Invalid input parameter. |
-| 16200005 | Method not registered. The method has not registered. |
-| 16000050 | Internal Error. |
-
-
-**Example**
-
- ```ts
- import UIAbility from '@ohos.app.ability.UIAbility';
-
- var method = 'call_Function';
-
- export default class EntryAbility extends UIAbility {
- onCreate(want, launchParam) {
- console.log('Callee onCreate is called');
- try {
- this.callee.off(method);
- } catch (error) {
- console.log('Callee.off catch error, error.code: ' + JSON.stringify(error.code) +
- ' error.message: ' + JSON.stringify(error.message));
- }
- }
- }
- ```
-
-## OnReleaseCallBack
-
-(msg: string): void;
-
-**System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore
-
-| Name| Type| Readable| Writable| Description|
-| -------- | -------- | -------- | -------- | -------- |
-| (msg: string) | function | Yes| No| Prototype of the listener function registered by the caller.|
-
-## CalleeCallBack
-
-(indata: rpc.MessageParcel): rpc.Sequenceable;
-
-**System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore
-
-| Name| Type| Readable| Writable| Description|
-| -------- | -------- | -------- | -------- | -------- |
-| (indata: rpc.MessageParcel) | rpc.Sequenceable | Yes| No| Prototype of the listener function registered by the callee.|
diff --git a/en/application-dev/reference/apis/js-apis-application-abilityDelegatorRegistry.md b/en/application-dev/reference/apis/js-apis-application-abilityDelegatorRegistry.md
index ae72afeca2e3214d00a785c0639793e8df47d715..d022dd0177356fbbcd1d81031f1b505d009136c6 100644
--- a/en/application-dev/reference/apis/js-apis-application-abilityDelegatorRegistry.md
+++ b/en/application-dev/reference/apis/js-apis-application-abilityDelegatorRegistry.md
@@ -1,10 +1,10 @@
# @ohos.application.abilityDelegatorRegistry (AbilityDelegatorRegistry)
-The **AbilityDelegatorRegistry** module provides APIs for storing the global registers of the registered **AbilityDelegator** and **AbilityDelegatorArgs** objects. You can use the APIs to obtain the **AbilityDelegator** and **AbilityDelegatorArgs** objects of an application.
+The **AbilityDelegatorRegistry** module provides APIs for storing the global registers of the registered **AbilityDelegator** and **AbilityDelegatorArgs** objects. You can use the APIs to obtain the **AbilityDelegator** and **AbilityDelegatorArgs** objects of an application. The APIs can be used only in the test framework.
> **NOTE**
>
-> The APIs of this module are supported since API version 8 and deprecated since API version 9. You are advised to use [@ohos.app.ability.abilityDelegatorRegistry](js-apis-app-ability-abilityDelegatorRegistry.md) instead. Newly added APIs will be marked with a superscript to indicate their earliest API version.
+> The APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version.
## Modules to Import
@@ -43,7 +43,7 @@ Obtains the **AbilityDelegator** object of the application.
**Example**
```ts
-var abilityDelegator;
+let abilityDelegator;
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator();
```
@@ -65,8 +65,8 @@ Obtains the **AbilityDelegatorArgs** object of the application.
**Example**
```ts
-var args = AbilityDelegatorRegistry.getArguments();
-console.info("getArguments bundleName:" + args.bundleName);
-console.info("getArguments testCaseNames:" + args.testCaseNames);
-console.info("getArguments testRunnerClassName:" + args.testRunnerClassName);
+let args = AbilityDelegatorRegistry.getArguments();
+console.info('getArguments bundleName:' + args.bundleName);
+console.info('getArguments testCaseNames:' + args.testCaseNames);
+console.info('getArguments testRunnerClassName:' + args.testRunnerClassName);
```
diff --git a/en/application-dev/reference/apis/js-apis-application-abilityLifecycleCallback.md b/en/application-dev/reference/apis/js-apis-application-abilityLifecycleCallback.md
deleted file mode 100644
index 040448220bb9da59779f0d449c43a59d8ab920bd..0000000000000000000000000000000000000000
--- a/en/application-dev/reference/apis/js-apis-application-abilityLifecycleCallback.md
+++ /dev/null
@@ -1,213 +0,0 @@
-# @ohos.application.AbilityLifecycleCallback (AbilityLifecycleCallback)
-
-The **AbilityLifecycleCallback** module provides callbacks, such as **onAbilityCreate**, **onWindowStageCreate**, and **onWindowStageDestroy**, to receive lifecycle state changes in the application context. These callbacks can be used as an input parameter of [registerAbilityLifecycleCallback](js-apis-inner-application-applicationContext.md#applicationcontextregisterabilitylifecyclecallback).
-
-> **NOTE**
->
-> The APIs of this module are supported since API version 9 and are deprecated in versions later than API version 9. You are advised to use [@ohos.app.ability.AbilityLifecycleCallback](js-apis-app-ability-abilityLifecycleCallback.md) instead. Newly added APIs will be marked with a superscript to indicate their earliest API version.
-> The APIs of this module can be used only in the stage model.
-
-
-## Modules to Import
-
-```ts
-import AbilityLifecycleCallback from "@ohos.application.AbilityLifecycleCallback";
-```
-
-
-## AbilityLifecycleCallback.onAbilityCreate
-
-onAbilityCreate(ability: Ability): void;
-
-Called when an ability is created.
-
-**System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore
-
-**Parameters**
-
-| Name| Type| Mandatory| Description|
-| -------- | -------- | -------- | -------- |
-| ability | [Ability](js-apis-application-ability.md#Ability) | Yes| **Ability** object.|
-
-
-## AbilityLifecycleCallback.onWindowStageCreate
-
-onWindowStageCreate(ability: Ability, windowStage: window.WindowStage): void;
-
-Called when the window stage of an ability is created.
-
-**System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore
-
-**Parameters**
-
-| Name| Type| Mandatory| Description|
-| -------- | -------- | -------- | -------- |
-| ability | [Ability](js-apis-application-ability.md#Ability) | Yes| **Ability** object.|
-| windowStage | [window.WindowStage](js-apis-window.md#windowstage9) | Yes| **WindowStage** object.|
-
-
-## AbilityLifecycleCallback.onWindowStageActive
-
-onWindowStageActive(ability: Ability, windowStage: window.WindowStage): void;
-
-Called when the window stage of an ability gains focus.
-
-**System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore
-
-**Parameters**
-
-| Name| Type| Mandatory| Description|
-| -------- | -------- | -------- | -------- |
-| ability | [Ability](js-apis-application-ability.md#Ability) | Yes| **Ability** object.|
-| windowStage | [window.WindowStage](js-apis-window.md#windowstage9) | Yes| **WindowStage** object.|
-
-
-## AbilityLifecycleCallback.onWindowStageInactive
-
-onWindowStageInactive(ability: Ability, windowStage: window.WindowStage): void;
-
-Called when the window stage of an ability loses focus.
-
-**System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore
-
-**Parameters**
-
-| Name| Type| Mandatory| Description|
-| -------- | -------- | -------- | -------- |
-| ability | [Ability](js-apis-application-ability.md#Ability) | Yes| **Ability** object.|
-| windowStage | [window.WindowStage](js-apis-window.md#windowstage9) | Yes| **WindowStage** object.|
-
-
-## AbilityLifecycleCallback.onWindowStageDestroy
-
-onWindowStageDestroy(ability: Ability, windowStage: window.WindowStage): void;
-
-Called when the window stage of an ability is destroyed.
-
-**System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore
-
-**Parameters**
-
-| Name| Type| Mandatory| Description|
-| -------- | -------- | -------- | -------- |
-| ability | [Ability](js-apis-application-ability.md#Ability) | Yes| **Ability** object.|
-| windowStage | [window.WindowStage](js-apis-window.md#windowstage9) | Yes| **WindowStage** object.|
-
-
-## AbilityLifecycleCallback.onAbilityDestroy
-
-onAbilityDestroy(ability: Ability): void;
-
-Called when an ability is destroyed.
-
-**System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore
-
-**Parameters**
-
-| Name| Type| Mandatory| Description|
-| -------- | -------- | -------- | -------- |
-| ability | [Ability](js-apis-application-ability.md#Ability) | Yes| **Ability** object.|
-
-
-## AbilityLifecycleCallback.onAbilityForeground
-
-onAbilityForeground(ability: Ability): void;
-
-Called when an ability is switched from the background to the foreground.
-
-**System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore
-
-**Parameters**
-
-| Name| Type| Mandatory| Description|
-| -------- | -------- | -------- | -------- |
-| ability | [Ability](js-apis-application-ability.md#Ability) | Yes| **Ability** object.|
-
-
-## AbilityLifecycleCallback.onAbilityBackground
-
-onAbilityBackground(ability: Ability): void;
-
-Called when an ability is switched from the foreground to the background.
-
-**System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore
-
-**Parameters**
-
-| Name| Type| Mandatory| Description|
-| -------- | -------- | -------- | -------- |
-| ability | [Ability](js-apis-application-ability.md#Ability) | Yes| **Ability** object.|
-
-
-## AbilityLifecycleCallback.onAbilityContinue
-
-onAbilityContinue(ability: Ability): void;
-
-Called when an ability is continued on another device.
-
-**System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore
-
-**Parameters**
-
-| Name| Type| Mandatory| Description|
-| -------- | -------- | -------- | -------- |
-| ability | [Ability](js-apis-application-ability.md#Ability) | Yes| **Ability** object.|
-
-**Example**
-
-```ts
-import AbilityStage from "@ohos.application.AbilityStage";
-
-var lifecycleId;
-
-export default class MyAbilityStage extends AbilityStage {
- onCreate() {
- console.log("MyAbilityStage onCreate")
- let AbilityLifecycleCallback = {
- onAbilityCreate(ability) {
- console.log("onAbilityCreate ability:" + JSON.stringify(ability));
- },
- onWindowStageCreate(ability, windowStage) {
- console.log("onWindowStageCreate ability:" + JSON.stringify(ability));
- console.log("onWindowStageCreate windowStage:" + JSON.stringify(windowStage));
- },
- onWindowStageActive(ability, windowStage) {
- console.log("onWindowStageActive ability:" + JSON.stringify(ability));
- console.log("onWindowStageActive windowStage:" + JSON.stringify(windowStage));
- },
- onWindowStageInactive(ability, windowStage) {
- console.log("onWindowStageInactive ability:" + JSON.stringify(ability));
- console.log("onWindowStageInactive windowStage:" + JSON.stringify(windowStage));
- },
- onWindowStageDestroy(ability, windowStage) {
- console.log("onWindowStageDestroy ability:" + JSON.stringify(ability));
- console.log("onWindowStageDestroy windowStage:" + JSON.stringify(windowStage));
- },
- onAbilityDestroy(ability) {
- console.log("onAbilityDestroy ability:" + JSON.stringify(ability));
- },
- onAbilityForeground(ability) {
- console.log("onAbilityForeground ability:" + JSON.stringify(ability));
- },
- onAbilityBackground(ability) {
- console.log("onAbilityBackground ability:" + JSON.stringify(ability));
- },
- onAbilityContinue(ability) {
- console.log("onAbilityContinue ability:" + JSON.stringify(ability));
- }
- }
- // 1. Obtain applicationContext through the context attribute.
- let applicationContext = this.context.getApplicationContext();
- // 2. Use applicationContext to register a listener for the ability lifecycle in the application.
- lifecycleId = applicationContext.registerAbilityLifecycleCallback(AbilityLifecycleCallback);
- console.log("registerAbilityLifecycleCallback number: " + JSON.stringify(lifecycleId));
- }
-
- onDestroy() {
- let applicationContext = this.context.getApplicationContext();
- applicationContext.unregisterAbilityLifecycleCallback(lifecycleId, (error, data) => {
- console.log("unregisterAbilityLifecycleCallback success, err: " + JSON.stringify(error));
- });
- }
-}
-```
diff --git a/en/application-dev/reference/apis/js-apis-application-abilityManager.md b/en/application-dev/reference/apis/js-apis-application-abilityManager.md
index e509a1b5d13a2d0d20b8d6dee4efee9487c5ee92..677884b754c5896b1a6af853d8a4df54355bbb85 100644
--- a/en/application-dev/reference/apis/js-apis-application-abilityManager.md
+++ b/en/application-dev/reference/apis/js-apis-application-abilityManager.md
@@ -4,13 +4,13 @@ The **AbilityManager** module provides APIs for obtaining, adding, and modifying
> **NOTE**
>
-> The APIs of this module are supported since API version 8 and deprecated since API version 9. You are advised to use [@ohos.app.ability.abilityManager](js-apis-app-ability-abilityManager.md) instead. Newly added APIs will be marked with a superscript to indicate their earliest API version.
+> The APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version.
> The APIs of this module are system APIs and cannot be called by third-party applications.
## Modules to Import
```ts
-import abilityManager from '@ohos.application.abilityManager'
+import AbilityManager from '@ohos.application.abilityManager';
```
## AbilityState
@@ -38,7 +38,7 @@ Updates the configuration. This API uses an asynchronous callback to return the
**Permission required**: ohos.permission.UPDATE_CONFIGURATION
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
-
+
**Parameters**
| Name | Type | Mandatory | Description |
@@ -49,11 +49,13 @@ Updates the configuration. This API uses an asynchronous callback to return the
**Example**
```ts
-var config = {
+import abilitymanager from '@ohos.application.abilityManager';
+
+let config = {
language: 'chinese'
-}
+};
-abilityManager.updateConfiguration(config, () => {
+abilitymanager.updateConfiguration(config, () => {
console.log('------------ updateConfiguration -----------');
})
```
@@ -83,11 +85,13 @@ Updates the configuration. This API uses a promise to return the result.
**Example**
```ts
-var config = {
+import abilitymanager from '@ohos.application.abilityManager';
+
+let config = {
language: 'chinese'
-}
+};
-abilityManager.updateConfiguration(config).then(() => {
+abilitymanager.updateConfiguration(config).then(() => {
console.log('updateConfiguration success');
}).catch((err) => {
console.log('updateConfiguration fail');
@@ -113,7 +117,9 @@ Obtains the ability running information. This API uses an asynchronous callback
**Example**
```ts
-abilityManager.getAbilityRunningInfos((err,data) => {
+import abilitymanager from '@ohos.application.abilityManager';
+
+abilitymanager.getAbilityRunningInfos((err,data) => {
console.log("getAbilityRunningInfos err: " + err + " data: " + JSON.stringify(data));
});
```
@@ -137,116 +143,11 @@ Obtains the ability running information. This API uses a promise to return the r
**Example**
```ts
-abilityManager.getAbilityRunningInfos().then((data) => {
- console.log("getAbilityRunningInfos data: " + JSON.stringify(data))
-}).catch((err) => {
- console.log("getAbilityRunningInfos err: " + err)
-});
-```
-
-## getExtensionRunningInfos9+
-
-getExtensionRunningInfos(upperLimit: number, callback: AsyncCallback\>): void
-
-Obtains the extension running information. This API uses an asynchronous callback to return the result.
-
-**Required permissions**: ohos.permission.GET_RUNNING_INFO
-
-**System capability**: SystemCapability.Ability.AbilityRuntime.Core
-
-**Parameters**
-
-| Name | Type | Mandatory | Description |
-| --------- | ---------------------------------------- | ---- | -------------- |
-| upperLimit | number | Yes| Maximum number of messages that can be obtained.|
-| callback | AsyncCallback\> | Yes | Callback used to return the result. |
-
-**Example**
-
-```ts
-var upperLimit = 0;
-
-abilityManager.getExtensionRunningInfos(upperLimit, (err,data) => {
- console.log("getExtensionRunningInfos err: " + err + " data: " + JSON.stringify(data));
-});
-```
-
-## getExtensionRunningInfos9+
-
-getExtensionRunningInfos(upperLimit: number): Promise\>
-
-Obtains the extension running information. This API uses a promise to return the result.
+import abilitymanager from '@ohos.application.abilityManager';
-**Required permissions**: ohos.permission.GET_RUNNING_INFO
-
-**System capability**: SystemCapability.Ability.AbilityRuntime.Core
-
-**Parameters**
-
-| Name | Type | Mandatory | Description |
-| --------- | ---------------------------------------- | ---- | -------------- |
-| upperLimit | number | Yes| Maximum number of messages that can be obtained.|
-
-**Return value**
-
-| Type | Description |
-| ---------------------------------------- | ------- |
-| Promise\> | Promise used to return the result.|
-
-**Example**
-
-```ts
-var upperLimit = 0;
-
-abilityManager.getExtensionRunningInfos(upperLimit).then((data) => {
- console.log("getAbilityRunningInfos data: " + JSON.stringify(data));
+abilitymanager.getAbilityRunningInfos().then((data) => {
+ console.log("getAbilityRunningInfos data: " + JSON.stringify(data));
}).catch((err) => {
console.log("getAbilityRunningInfos err: " + err);
-})
-```
-
-## getTopAbility9+
-
-getTopAbility(callback: AsyncCallback\): void;
-
-Obtains the top ability, which is the ability that has the window focus. This API uses an asynchronous callback to return the result.
-
-**System capability**: SystemCapability.Ability.AbilityRuntime.Core
-
-**Parameters**
-
-| Name | Type | Mandatory | Description |
-| --------- | ---------------------------------------- | ---- | -------------- |
-| callback | AsyncCallback\<[ElementName](js-apis-bundleManager-elementName.md)> | Yes | Callback used to return the result. |
-
-**Example**
-
-```ts
-abilityManager.getTopAbility((err,data) => {
- console.log("getTopAbility err: " + err + " data: " + JSON.stringify(data));
});
```
-
-## getTopAbility9+
-
-getTopAbility(): Promise\;
-
-Obtains the top ability, which is the ability that has the window focus. This API uses a promise to return the result.
-
-**System capability**: SystemCapability.Ability.AbilityRuntime.Core
-
-**Return value**
-
-| Type | Description |
-| ---------------------------------------- | ------- |
-| Promise\<[ElementName](js-apis-bundleManager-elementName.md)>| Promise used to return the result.|
-
-**Example**
-
-```ts
-abilityManager.getTopAbility().then((data) => {
- console.log("getTopAbility data: " + JSON.stringify(data));
-}).catch((err) => {
- console.log("getTopAbility err: " + err);
-})
-```
diff --git a/en/application-dev/reference/apis/js-apis-application-abilityMonitor.md b/en/application-dev/reference/apis/js-apis-application-abilityMonitor.md
index 33feda3afdd757e91ed7b7f682dca1ef597a7847..e857972a4d075fa6161a082fd46e8f308aff9464 100644
--- a/en/application-dev/reference/apis/js-apis-application-abilityMonitor.md
+++ b/en/application-dev/reference/apis/js-apis-application-abilityMonitor.md
@@ -3,25 +3,25 @@
The **AbilityMonitor** module provides monitors for abilities that meet specified conditions. The latest matched abilities are stored in an **AbilityMonitor** object.
> **NOTE**
->
-> The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version.
+>
+> The APIs of this module are supported and deprecated since API version 9. You are advised to use [abilityMonitor (AbilityMonitor)](js-apis-inner-application-abilityMonitor.md) instead.
## Usage
-The ability monitor is set by calling **addAbilityMonitor** in **abilityDelegator**.
+The ability monitor can be set by calling **addAbilityMonitor** in **abilityDelegator**.
```js
-import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'
-var abilityDelegator;
+import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry';
+let abilityDelegator;
function onAbilityCreateCallback(data) {
console.info("onAbilityCreateCallback");
}
-var monitor = {
+let monitor = {
abilityName: "abilityname",
onAbilityCreate: onAbilityCreateCallback
-}
+};
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator();
abilityDelegator.addAbilityMonitor(monitor, (err : any) => {
@@ -37,11 +37,13 @@ Describes an ability monitor.
| Name | Type | Readable| Writable| Description |
| ------------------------------------------------------------ | -------- | ---- | ---- | ------------------------------------------------------------ |
-| abilityName | string | Yes | Yes | Name of the ability bound to the ability monitor. |
-| onAbilityCreate?:(data: [Ability](js-apis-application-ability.md#Ability)) | function | Yes | Yes | Called when the ability is created.
If this attribute is not set, the corresponding lifecycle callback cannot be received. |
-| onAbilityForeground?:(data: [Ability](js-apis-application-ability.md#Ability)) | function | Yes | Yes | Called when the ability starts to run in the foreground.
If this attribute is not set, the corresponding lifecycle callback cannot be received. |
-| onAbilityBackground?:(data: [Ability](js-apis-application-ability.md#Ability)) | function | Yes | Yes | Called when the ability starts to run in the background.
If this attribute is not set, the corresponding lifecycle callback cannot be received. |
-| onAbilityDestroy?:(data: [Ability](js-apis-application-ability.md#Ability)) | function | Yes | Yes | Called when the ability is destroyed.
If this attribute is not set, the corresponding lifecycle callback cannot be received. |
-| onWindowStageCreate?:(data: [Ability](js-apis-application-ability.md#Ability)) | function | Yes | Yes | Called when the window stage is created.
If this attribute is not set, the corresponding lifecycle callback cannot be received. |
-| onWindowStageRestore?:(data: [Ability](js-apis-application-ability.md#Ability)) | function | Yes | Yes | Called when the window stage is restored.
If this attribute is not set, the corresponding lifecycle callback cannot be received. |
-| onWindowStageDestroy?:(data: [Ability](js-apis-application-ability.md#Ability)) | function | Yes | Yes | Called when the window stage is destroyed.
If this attribute is not set, the corresponding lifecycle callback cannot be received. |
+| abilityName | string | Yes | Yes | Name of the ability bound to the ability monitor.|
+| moduleName? | string | Yes | Yes | Name of the module bound to the ability monitor.|
+| onAbilityCreate?:(data: [Ability](js-apis-application-ability.md#Ability)) | function | Yes | Yes | Called when the ability is created.
If this attribute is not set, the corresponding lifecycle callback cannot be received.|
+| onAbilityForeground?:(data: [Ability](js-apis-application-ability.md#Ability)) | function | Yes | Yes | Called when the ability starts to run in the foreground.
If this attribute is not set, the corresponding lifecycle callback cannot be received.|
+| onAbilityBackground?:(data: [Ability](js-apis-application-ability.md#Ability)) | function | Yes | Yes | Called when the ability starts to run in the background.
If this attribute is not set, the corresponding lifecycle callback cannot be received.|
+| onAbilityDestroy?:(data: [Ability](js-apis-application-ability.md#Ability)) | function | Yes | Yes | Called when the ability is destroyed.
If this attribute is not set, the corresponding lifecycle callback cannot be received.
|
+| onWindowStageCreate?:(data: [Ability](js-apis-application-ability.md#Ability)) | function | Yes | Yes | Called when the window stage is created.
If this attribute is not set, the corresponding lifecycle callback cannot be received.
|
+| onWindowStageRestore?:(data: [Ability](js-apis-application-ability.md#Ability)) | function | Yes | Yes | Called when the window stage is restored.
If this attribute is not set, the corresponding lifecycle callback cannot be received.
|
+| onWindowStageDestroy?:(data: [Ability](js-apis-application-ability.md#Ability)) | function | Yes | Yes | Called when the window stage is destroyed.
If this attribute is not set, the corresponding lifecycle callback cannot be received.
|
+
diff --git a/en/application-dev/reference/apis/js-apis-application-accessibilityExtensionAbility.md b/en/application-dev/reference/apis/js-apis-application-accessibilityExtensionAbility.md
index a3bf30002a2377ca6deb995a5bb3c120b59f7991..e9327b99666d40cb367e54ec351048af3d384cd3 100644
--- a/en/application-dev/reference/apis/js-apis-application-accessibilityExtensionAbility.md
+++ b/en/application-dev/reference/apis/js-apis-application-accessibilityExtensionAbility.md
@@ -9,7 +9,7 @@ The **AccessibilityExtensionAbility** module provides accessibility extension ca
## Modules to Import
```ts
-import AccessibilityExtensionAbility from '@ohos.application.AccessibilityExtensionAbility'
+import AccessibilityExtensionAbility from '@ohos.application.AccessibilityExtensionAbility';
```
## Attributes
@@ -137,7 +137,7 @@ Called when an event that matches the specified bundle and event type occurs. In
class MyAccessibilityExtensionAbility extends AccessibilityExtensionAbility {
onAccessibilityEvent(event) {
console.log('AxExtensionAbility onAccessibilityEvent');
- if (event.eventType == 'click') {
+ if (event.eventType === 'click') {
console.log('AxExtensionAbility onAccessibilityEvent: click');
}
}
@@ -164,7 +164,7 @@ Called when a physical key is pressed. In this API, you can determine whether to
class MyAccessibilityExtensionAbility extends AccessibilityExtensionAbility {
onKeyEvent(keyEvent) {
console.log('AxExtensionAbility onKeyEvent');
- if (keyEvent.keyCode == 22) {
+ if (keyEvent.keyCode === 22) {
console.log('AxExtensionAbility onKeyEvent: intercept 22');
return true;
}
diff --git a/en/application-dev/reference/apis/js-apis-application-appManager.md b/en/application-dev/reference/apis/js-apis-application-appManager.md
index 8e8547985ddc883c7643eab6f3f3e25412eebf4a..5c42a550ea14ed421d195772ee2f143265d7ef8d 100644
--- a/en/application-dev/reference/apis/js-apis-application-appManager.md
+++ b/en/application-dev/reference/apis/js-apis-application-appManager.md
@@ -22,9 +22,9 @@ Checks whether this application is undergoing a stability test. This API uses an
**Parameters**
-| Name| Type| Mandatory| Description|
-| -------- | -------- | -------- | -------- |
-| callback | AsyncCallback<boolean> | Yes| Callback used to return the result. If the application is undergoing a stability test, **true** will be returned; otherwise, **false** will be returned.|
+ | Name| Type| Mandatory| Description|
+ | -------- | -------- | -------- | -------- |
+ | callback | AsyncCallback<boolean> | Yes| Callback used to return the result. If the application is undergoing a stability test, **true** will be returned; otherwise, **false** will be returned.|
**Example**
@@ -46,9 +46,9 @@ Checks whether this application is undergoing a stability test. This API uses a
**Return value**
-| Type| Description|
-| -------- | -------- |
-| Promise<boolean> | Promise used to return the result. If the application is undergoing a stability test, **true** will be returned; otherwise, **false** will be returned.|
+ | Type| Description|
+ | -------- | -------- |
+ | Promise<boolean> | Promise used to return the result. If the application is undergoing a stability test, **true** will be returned; otherwise, **false** will be returned.|
**Example**
@@ -72,9 +72,9 @@ Checks whether this application is running on a RAM constrained device. This API
**Return value**
-| Type| Description|
-| -------- | -------- |
-| Promise<boolean> | Promise used to return whether the application is running on a RAM constrained device. If the application is running on a RAM constrained device, **true** will be returned; otherwise, **false** will be returned.|
+ | Type| Description|
+ | -------- | -------- |
+ | Promise<boolean> | Promise used to return whether the application is running on a RAM constrained device. If the application is running on a RAM constrained device, **true** will be returned; otherwise, **false** will be returned.|
**Example**
@@ -96,9 +96,9 @@ Checks whether this application is running on a RAM constrained device. This API
**Parameters**
-| Name| Type| Mandatory| Description|
-| -------- | -------- | -------- | -------- |
-| callback | AsyncCallback<boolean> | Yes| Callback used to return whether the application is running on a RAM constrained device. If the application is running on a RAM constrained device, **true** will be returned; otherwise, **false** will be returned.|
+ | Name| Type| Mandatory| Description|
+ | -------- | -------- | -------- | -------- |
+ | callback | AsyncCallback<boolean> | Yes| Callback used to return whether the application is running on a RAM constrained device. If the application is running on a RAM constrained device, **true** will be returned; otherwise, **false** will be returned.|
**Example**
@@ -119,9 +119,9 @@ Obtains the memory size of this application. This API uses a promise to return t
**Return value**
-| Type| Description|
-| -------- | -------- |
-| Promise<number> | Promise used to return the memory size, in MB.|
+ | Type| Description|
+ | -------- | -------- |
+ | Promise<number> | Promise used to return the memory size, in MB.|
**Example**
@@ -143,9 +143,9 @@ Obtains the memory size of this application. This API uses an asynchronous callb
**Parameters**
-| Name| Type| Mandatory| Description|
-| -------- | -------- | -------- | -------- |
-| callback | AsyncCallback<number> | Yes| Callback used to return the memory size, in MB.|
+ | Name| Type| Mandatory| Description|
+ | -------- | -------- | -------- | -------- |
+ | callback | AsyncCallback<number> | Yes| Callback used to return the memory size, in MB.|
**Example**
@@ -199,7 +199,7 @@ Obtains information about the running processes. This API uses an asynchronous c
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
-| callback | AsyncCallback\> | Yes| Obtains information about the running processes. This API uses a promise to return the result.|
+| callback | AsyncCallback\> | Yes| Callback used to return the running processes. |
**Example**
diff --git a/en/application-dev/reference/apis/js-apis-application-configuration.md b/en/application-dev/reference/apis/js-apis-application-configuration.md
index 81870036a845c61f852f671616f63c12f92851b8..0d7b8756ca0bc611d2c5c92bfb12c5764b8e9569 100644
--- a/en/application-dev/reference/apis/js-apis-application-configuration.md
+++ b/en/application-dev/reference/apis/js-apis-application-configuration.md
@@ -1,38 +1,27 @@
# @ohos.application.Configuration (Configuration)
-The **Configuration** module defines environment change information.
+The **Configuration** module defines environment change information. **Configuration** is an interface definition and is used only for field declaration.
> **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.
> This module is deprecated since API version 9. You are advised to use [@ohos.app.ability.Configuration](js-apis-app-ability-configuration.md) instead.
-## Modules to Import
-
-```ts
-import Configuration from '@ohos.application.Configuration'
-```
-
**System capability**: SystemCapability.Ability.AbilityBase
| Name| Type| Readable| Writable| Description|
| -------- | -------- | -------- | -------- | -------- |
-| language8+ | string | Yes| Yes| Language of the application, for example, **zh**.|
+| language8+ | string | Yes| Yes| Language of the application.|
| colorMode8+ | [ColorMode](js-apis-application-configurationConstant.md#configurationconstantcolormode) | Yes| Yes| Color mode, which can be **COLOR_MODE_LIGHT** or **COLOR_MODE_DARK**. The default value is **COLOR_MODE_LIGHT**.|
-| direction9+ | [Direction](js-apis-application-configurationConstant.md#configurationconstantdirection9) | Yes| No| Screen orientation, which can be **DIRECTION_HORIZONTAL** or **DIRECTION_VERTICAL**.|
-| screenDensity9+ | [ScreenDensity](js-apis-application-configurationConstant.md#configurationconstantscreendensity9) | Yes| No| Screen resolution, which can be **SCREEN_DENSITY_SDPI** (120), **SCREEN_DENSITY_MDPI** (160), **SCREEN_DENSITY_LDPI** (240), **SCREEN_DENSITY_XLDPI** (320), **SCREEN_DENSITY_XXLDPI** (480), or **SCREEN_DENSITY_XXXLDPI** (640).|
-| displayId9+ | number | Yes| No| ID of the display where the application is located.|
-| hasPointerDevice9+ | boolean | Yes| No| Whether a pointer device, such as a keyboard, mouse, or touchpad, is connected.|
For details about the fields, see the **ohos.application.Configuration.d.ts** file.
**Example**
```ts
-import hilog from '@ohos.hilog';
-import UIAbility from '@ohos.app.ability.UIAbility';
-import Window from '@ohos.window';
+import Ability from '@ohos.application.Ability'
+import Window from '@ohos.window'
-export default class EntryAbility extends UIAbility {
+export default class MainAbility extends Ability {
onCreate(want, launchParam) {
}
@@ -42,13 +31,9 @@ export default class EntryAbility extends UIAbility {
onWindowStageCreate(windowStage: Window.WindowStage) {
let envCallback = {
onConfigurationUpdated(config) {
- console.info(`envCallback onConfigurationUpdated success: ${JSON.stringify(config)}`)
+ console.info(`envCallback onConfigurationUpdated success: ${JSON.stringify(config)}`);
let language = config.language;
let colorMode = config.colorMode;
- let direction = config.direction;
- let screenDensity = config.screenDensity;
- let displayId = config.displayId;
- let hasPointerDevice = config.hasPointerDevice;
}
};
@@ -57,12 +42,10 @@ export default class EntryAbility extends UIAbility {
windowStage.loadContent('pages/index', (err, data) => {
if (err.code) {
- hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.ERROR);
- hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? '');
+ console.error('failed to load the content, error: + ${JSON.stringify(err)}');
return;
}
- hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO);
- hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? '');
+ console.info('Succeeded in loading the content, data: + ${JSON.stringify(data)}');
});
}
}
diff --git a/en/application-dev/reference/apis/js-apis-application-configurationConstant.md b/en/application-dev/reference/apis/js-apis-application-configurationConstant.md
index dabe32b2f9d166dbce68b94c204b82f78b0090de..b1017a036bdb9f02a656c1890310cd3e029337f5 100644
--- a/en/application-dev/reference/apis/js-apis-application-configurationConstant.md
+++ b/en/application-dev/reference/apis/js-apis-application-configurationConstant.md
@@ -23,33 +23,3 @@ You can obtain the value of this constant by calling the **ConfigurationConstant
| COLOR_MODE_NOT_SET | -1 | Unspecified color mode.|
| COLOR_MODE_DARK | 0 | Dark mode.|
| COLOR_MODE_LIGHT | 1 | Light mode.|
-
-
-## ConfigurationConstant.Direction9+
-
-You can obtain the value of this constant by calling the **ConfigurationConstant.Direction** API.
-
-**System capability**: SystemCapability.Ability.AbilityBase
-
-| Name| Value| Description|
-| -------- | -------- | -------- |
-| DIRECTION_NOT_SET | -1 | Unspecified direction.|
-| DIRECTION_VERTICAL | 0 | Vertical direction.|
-| DIRECTION_HORIZONTAL | 1 | Horizontal direction.|
-
-
-## ConfigurationConstant.ScreenDensity9+
-
-You can obtain the value of this constant by calling the **ConfigurationConstant.ScreenDensity** API.
-
-**System capability**: SystemCapability.Ability.AbilityBase
-
-| Name| Value| Description|
-| -------- | -------- | -------- |
-| SCREEN_DENSITY_NOT_SET | 0 | Unspecified screen resolution.|
-| SCREEN_DENSITY_SDPI | 120 | The screen resolution is sdpi.|
-| SCREEN_DENSITY_MDPI | 160 | The screen resolution is mdpi.|
-| SCREEN_DENSITY_LDPI | 240 | The screen resolution is ldpi.|
-| SCREEN_DENSITY_XLDPI | 320 | The screen resolution is xldpi.|
-| SCREEN_DENSITY_XXLDPI | 480 | The screen resolution is xxldpi.|
-| SCREEN_DENSITY_XXXLDPI | 640 | The screen resolution is xxxldpi.|
diff --git a/en/application-dev/reference/apis/js-apis-application-dataShareExtensionAbility.md b/en/application-dev/reference/apis/js-apis-application-dataShareExtensionAbility.md
index 2b868190b0b901638830d8051a2d973188c43d41..822b524809931cae4853d069606c77b1a1e5af26 100644
--- a/en/application-dev/reference/apis/js-apis-application-dataShareExtensionAbility.md
+++ b/en/application-dev/reference/apis/js-apis-application-dataShareExtensionAbility.md
@@ -14,7 +14,7 @@ The **DataShareExtensionAbility** module provides data share services based on t
## Modules to Import
```ts
-import DataShareExtensionAbility from '@ohos.application.DataShareExtensionAbility'
+import DataShareExtensionAbility from '@ohos.application.DataShareExtensionAbility';
```
## URI Naming Rule
@@ -43,7 +43,7 @@ Example:
| Name| Type| Readable| Writable| Description|
| -------- | -------- | -------- | -------- | -------- |
-| context | [ExtensionContext](js-apis-inner-application-extensionContext.md) | Yes| No|Context of the DataShare Extension ability.|
+| context | [ExtensionContext](js-apis-inner-application-extensionContext.md) | Yes| No|Context of the DataShare Extension ability.|
## onCreate
@@ -65,11 +65,11 @@ Called by the server to initialize service logic when the DataShare client conne
```ts
import rdb from '@ohos.data.relationalStore';
-let DB_NAME = "DB00.db";
-let TBL_NAME = "TBL00";
-let DDL_TBL_CREATE = "CREATE TABLE IF NOT EXISTS "
+let DB_NAME = 'DB00.db';
+let TBL_NAME = 'TBL00';
+let DDL_TBL_CREATE = 'CREATE TABLE IF NOT EXISTS '
+ TBL_NAME
- + " (id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT, age INTEGER, phoneNumber DOUBLE, isStudent BOOLEAN, Binary BINARY)";
+ + ' (id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT, age INTEGER, phoneNumber DOUBLE, isStudent BOOLEAN, Binary BINARY)';
let rdbStore;
export default class DataShareExtAbility extends DataShareExtensionAbility {
@@ -112,22 +112,22 @@ Inserts data into the database. This API can be overridden as required.
```ts
import rdb from '@ohos.data.relationalStore';
-let DB_NAME = "DB00.db";
-let TBL_NAME = "TBL00";
-let DDL_TBL_CREATE = "CREATE TABLE IF NOT EXISTS "
+let DB_NAME = 'DB00.db';
+let TBL_NAME = 'TBL00';
+let DDL_TBL_CREATE = 'CREATE TABLE IF NOT EXISTS '
+ TBL_NAME
- + " (id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT, age INTEGER, phoneNumber DOUBLE, isStudent BOOLEAN, Binary BINARY)";
+ + ' (id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT, age INTEGER, phoneNumber DOUBLE, isStudent BOOLEAN, Binary BINARY)';
let rdbStore;
export default class DataShareExtAbility extends DataShareExtensionAbility {
insert(uri, valueBucket, callback) {
- if (valueBucket == null) {
+ if (valueBucket === null) {
console.info('invalid valueBuckets');
return;
}
rdbStore.insert(TBL_NAME, valueBucket, function (err, ret) {
console.info('callback ret:' + ret);
- if (callback != undefined) {
+ if (callback !== undefined) {
callback(err, ret);
}
});
@@ -157,20 +157,20 @@ Updates data in the database. This API can be overridden as required.
```ts
import rdb from '@ohos.data.relationalStore';
-let DB_NAME = "DB00.db";
-let TBL_NAME = "TBL00";
-let DDL_TBL_CREATE = "CREATE TABLE IF NOT EXISTS "
+let DB_NAME = 'DB00.db';
+let TBL_NAME = 'TBL00';
+let DDL_TBL_CREATE = 'CREATE TABLE IF NOT EXISTS '
+ TBL_NAME
- + " (id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT, age INTEGER, phoneNumber DOUBLE, isStudent BOOLEAN, Binary BINARY)";
+ + ' (id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT, age INTEGER, phoneNumber DOUBLE, isStudent BOOLEAN, Binary BINARY)';
let rdbStore;
export default class DataShareExtAbility extends DataShareExtensionAbility {
update(uri, predicates, valueBucket, callback) {
- if (predicates == null || predicates == undefined) {
+ if (predicates === null || predicates === undefined) {
return;
}
rdbStore.update(TBL_NAME, valueBucket, predicates, function (err, ret) {
- if (callback != undefined) {
+ if (callback !== undefined) {
callback(err, ret);
}
});
@@ -199,20 +199,20 @@ Deletes data from the database. This API can be overridden as required.
```ts
import rdb from '@ohos.data.relationalStore';
-let DB_NAME = "DB00.db";
-let TBL_NAME = "TBL00";
-let DDL_TBL_CREATE = "CREATE TABLE IF NOT EXISTS "
+let DB_NAME = 'DB00.db';
+let TBL_NAME = 'TBL00';
+let DDL_TBL_CREATE = 'CREATE TABLE IF NOT EXISTS '
+ TBL_NAME
- + " (id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT, age INTEGER, phoneNumber DOUBLE, isStudent BOOLEAN, Binary BINARY)";
+ + ' (id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT, age INTEGER, phoneNumber DOUBLE, isStudent BOOLEAN, Binary BINARY)';
let rdbStore;
export default class DataShareExtAbility extends DataShareExtensionAbility {
delete(uri, predicates, callback) {
- if (predicates == null || predicates == undefined) {
+ if (predicates === null || predicates === undefined) {
return;
}
rdbStore.delete(TBL_NAME, predicates, function (err, ret) {
- if (callback != undefined) {
+ if (callback !== undefined) {
callback(err, ret);
}
});
@@ -235,30 +235,30 @@ Queries data from the database. This API can be overridden as required.
| uri | string | Yes | URI of the data to query.|
| predicates | [dataSharePredicates.DataSharePredicates](js-apis-data-dataSharePredicates.md#datasharepredicates) | Yes | Filter criteria for querying data.|
| columns | Array<string> | Yes| Columns to query. If this parameter is empty, all columns will be queried.|
-| callback | AsyncCallback<Object> | Yes| Callback invoked to return the result set.|
+| callback | AsyncCallback<Object> | Yes| Callback invoked to return the result set obtained.|
**Example**
```ts
import rdb from '@ohos.data.relationalStore';
-let DB_NAME = "DB00.db";
-let TBL_NAME = "TBL00";
-let DDL_TBL_CREATE = "CREATE TABLE IF NOT EXISTS "
+let DB_NAME = 'DB00.db';
+let TBL_NAME = 'TBL00';
+let DDL_TBL_CREATE = 'CREATE TABLE IF NOT EXISTS '
+ TBL_NAME
- + " (id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT, age INTEGER, phoneNumber DOUBLE, isStudent BOOLEAN, Binary BINARY)";
+ + ' (id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT, age INTEGER, phoneNumber DOUBLE, isStudent BOOLEAN, Binary BINARY)';
let rdbStore;
export default class DataShareExtAbility extends DataShareExtensionAbility {
query(uri, predicates, columns, callback) {
- if (predicates == null || predicates == undefined) {
+ if (predicates === null || predicates === undefined) {
return;
}
rdbStore.query(TBL_NAME, predicates, columns, function (err, resultSet) {
- if (resultSet != undefined) {
+ if (resultSet !== undefined) {
console.info('resultSet.rowCount: ' + resultSet.rowCount);
}
- if (callback != undefined) {
+ if (callback !== undefined) {
callback(err, resultSet);
}
});
@@ -287,23 +287,23 @@ Batch inserts data into the database. This API is called by the server and can b
```ts
import rdb from '@ohos.data.relationalStore';
-let DB_NAME = "DB00.db";
-let TBL_NAME = "TBL00";
-let DDL_TBL_CREATE = "CREATE TABLE IF NOT EXISTS "
+let DB_NAME = 'DB00.db';
+let TBL_NAME = 'TBL00';
+let DDL_TBL_CREATE = 'CREATE TABLE IF NOT EXISTS '
+ TBL_NAME
- + " (id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT, age INTEGER, phoneNumber DOUBLE, isStudent BOOLEAN, Binary BINARY)";
+ + ' (id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT, age INTEGER, phoneNumber DOUBLE, isStudent BOOLEAN, Binary BINARY)';
let rdbStore;
export default class DataShareExtAbility extends DataShareExtensionAbility {
batchInsert(uri, valueBuckets, callback) {
- if (valueBuckets == null || valueBuckets.length == undefined) {
+ if (valueBuckets === null || valueBuckets.length === undefined) {
console.info('invalid valueBuckets');
return;
}
- let resultNum = valueBuckets.length
+ let resultNum = valueBuckets.length;
valueBuckets.forEach(vb => {
rdbStore.insert(TBL_NAME, vb, function (err, ret) {
- if (callback != undefined) {
+ if (callback !== undefined) {
callback(err, resultNum);
}
});
@@ -332,8 +332,8 @@ Normalizes a URI. This API can be overridden as required.
```ts
export default class DataShareExtAbility extends DataShareExtensionAbility {
normalizeUri(uri, callback) {
- let err = {"code":0};
- let ret = "normalize+" + uri;
+ let err = {'code':0};
+ let ret = 'normalize+' + uri;
callback(err, ret);
}
};
@@ -359,8 +359,8 @@ Denormalizes a URI. This API can be overridden as required.
```ts
export default class DataShareExtAbility extends DataShareExtensionAbility {
denormalizeUri(uri, callback) {
- let err = {"code":0};
- let ret = "denormalize+" + uri;
+ let err = {'code':0};
+ let ret = 'denormalize+' + uri;
callback(err, ret);
}
};
diff --git a/en/application-dev/reference/apis/js-apis-application-environmentCallback.md b/en/application-dev/reference/apis/js-apis-application-environmentCallback.md
index d4c25269235da3b95e4f230c084d92c1df047269..b6fdcadbee8d1518fb830f46db13270c82a77d11 100644
--- a/en/application-dev/reference/apis/js-apis-application-environmentCallback.md
+++ b/en/application-dev/reference/apis/js-apis-application-environmentCallback.md
@@ -1,17 +1,17 @@
# @ohos.application.EnvironmentCallback (EnvironmentCallback)
-The **EnvironmentCallback** module provides APIs, such as **onConfigurationUpdated** and **onMemoryLevel**, for the application context to listen for system environment changes.
+The **EnvironmentCallback** module provides APIs, such as **onConfigurationUpdated**, for the application context to listen for system environment changes.
> **NOTE**
>
-> The APIs of this module are supported since API version 9 and are deprecated in versions later than API version 9. You are advised to use [@ohos.app.ability.EnvironmentCallback](js-apis-app-ability-environmentCallback.md) instead. Newly added APIs will be marked with a superscript to indicate their earliest API version.
+> The APIs of this module are supported and deprecated in API version 9. You are advised to use [@ohos.app.ability.EnvironmentCallback](js-apis-app-ability-environmentCallback.md) instead. Newly added APIs will be marked with a superscript to indicate their earliest API version.
> The APIs of this module can be used only in the stage model.
## Modules to Import
```ts
-import EnvironmentCallback from "@ohos.application.EnvironmentCallback";
+import EnvironmentCallback from '@ohos.application.EnvironmentCallback';
```
@@ -30,48 +30,32 @@ Called when the system environment changes.
| config | [Configuration](js-apis-application-configuration.md) | Yes| **Configuration** object after the change.|
## EnvironmentCallback.onMemoryLevel
-
-onMemoryLevel(level: number): void;
-
-Called when the system memory level changes.
-
-**System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore
-
-**Parameters**
-
- | Name| Type| Mandatory| Description|
- | -------- | -------- | -------- | -------- |
- | level | [MemoryLevel](js-apis-application-abilityConstant.md#abilityconstantmemorylevel) | Yes| New memory level.|
-
-**Example**
+
```ts
-import UIAbility from '@ohos.app.ability.UIAbility';
+import Ability from '@ohos.application.Ability';
-var callbackId;
+let callbackId;
-export default class EntryAbility extends UIAbility {
+export default class MyAbility extends Ability {
onCreate() {
- console.log("MyAbility onCreate")
+ console.log('MyAbility onCreate');
globalThis.applicationContext = this.context.getApplicationContext();
let EnvironmentCallback = {
onConfigurationUpdated(config){
- console.log("onConfigurationUpdated config:" + JSON.stringify(config));
+ console.log('onConfigurationUpdated config:' + JSON.stringify(config));
},
- onMemoryLevel(level){
- console.log("onMemoryLevel level:" + level);
- }
- }
+ };
// 1. Obtain an applicationContext object.
let applicationContext = globalThis.applicationContext;
// 2. Register a listener for the environment changes through the applicationContext object.
callbackId = applicationContext.registerEnvironmentCallback(EnvironmentCallback);
- console.log("registerEnvironmentCallback number: " + JSON.stringify(callbackId));
+ console.log('registerEnvironmentCallback number: ' + JSON.stringify(callbackId));
}
onDestroy() {
let applicationContext = globalThis.applicationContext;
applicationContext.unregisterEnvironmentCallback(callbackId, (error, data) => {
- console.log("unregisterEnvironmentCallback success, err: " + JSON.stringify(error));
+ console.log('unregisterEnvironmentCallback success, err: ' + JSON.stringify(error));
});
}
}
diff --git a/en/application-dev/reference/apis/js-apis-application-errorManager.md b/en/application-dev/reference/apis/js-apis-application-errorManager.md
deleted file mode 100644
index c1eaa2d35e90966795e4b98f4b75cffc0570e855..0000000000000000000000000000000000000000
--- a/en/application-dev/reference/apis/js-apis-application-errorManager.md
+++ /dev/null
@@ -1,100 +0,0 @@
-# @ohos.application.errorManager (ErrorManager)
-
-The **ErrorManager** module provides APIs for registering and deregistering error observers.
-
-> **NOTE**
->
-> The APIs of this module are supported since API version 9 and are deprecated in versions later than API version 9. You are advised to use [@ohos.app.ability.errorManager](js-apis-app-ability-errorManager.md) instead. Newly added APIs will be marked with a superscript to indicate their earliest API version.
-
-## Modules to Import
-```ts
-import errorManager from '@ohos.application.errorManager'
-```
-
-## ErrorManager.registerErrorObserver
-
-registerErrorObserver(observer: ErrorObserver): number;
-
-Registers an error observer.
-
-**System capability**: SystemCapability.Ability.AbilityRuntime.Core
-
-**Parameters**
-
-| Name| Type| Mandatory| Description|
-| -------- | -------- | -------- | -------- |
-| observer | [ErrorObserver](js-apis-inner-application-errorObserver.md) | Yes| Numeric code of the observer.|
-
-**Example**
-
-```ts
-var observer = {
- onUnhandledException(errorMsg) {
- console.log('onUnhandledException, errorMsg: ', errorMsg)
- }
-}
-errorManager.registerErrorObserver(observer)
-```
-
-## ErrorManager.unregisterErrorObserver
-
-unregisterErrorObserver(observerId: number, callback: AsyncCallback\): void;
-
-Deregisters an error observer. This API uses an asynchronous callback to return the result.
-
-**System capability**: SystemCapability.Ability.AbilityRuntime.Core
-
-**Parameters**
-
-| Name| Type| Mandatory| Description|
-| -------- | -------- | -------- | -------- |
-| observerId | number | Yes| Numeric code of the observer.|
-| callback | AsyncCallback\ | Yes| Callback used to return the result.|
-
-**Example**
-
-```ts
-var observerId = 100;
-
-function unregisterErrorObserverCallback(err) {
- if (err) {
- console.log('------------ unregisterErrorObserverCallback ------------', err);
- }
-}
-errorManager.unregisterErrorObserver(observerId, unregisterErrorObserverCallback);
-
-```
-
-## ErrorManager.unregisterErrorObserver
-
-unregisterErrorObserver(observerId: number): Promise\;
-
-Deregisters an error observer. This API uses a promise to return the result.
-
-**System capability**: SystemCapability.Ability.AbilityRuntime.Core
-
-**Parameters**
-
-| Name| Type| Mandatory| Description|
-| -------- | -------- | -------- | -------- |
-| observerId | number | Yes| Numeric code of the observer.|
-
-**Return value**
-
-| Type| Description|
-| -------- | -------- |
-| Promise\ | Promise used to return the result.|
-
-**Example**
-
-```ts
-var observerId = 100;
-errorManager.unregisterErrorObserver(observerId)
-.then((data) => {
- console.log('----------- unregisterErrorObserver success ----------', data);
-})
-.catch((err) => {
- console.log('----------- unregisterErrorObserver fail ----------', err);
-})
-
-```
diff --git a/en/application-dev/reference/apis/js-apis-application-formBindingData.md b/en/application-dev/reference/apis/js-apis-application-formBindingData.md
index 5fbc52c95dc9e573947fb9820f00100a76a06f22..57e978adfb5fe88a505d99aa9175905cf3c1d1c4 100644
--- a/en/application-dev/reference/apis/js-apis-application-formBindingData.md
+++ b/en/application-dev/reference/apis/js-apis-application-formBindingData.md
@@ -35,7 +35,7 @@ Creates a **FormBindingData** object.
| Name| Type | Mandatory| Description |
| ------ | -------------- | ---- | ------------------------------------------------------------ |
-| obj | Object\|string | No | Data to be displayed on the JS widget. The value can be an object containing multiple key-value pairs or a string in JSON format. The image data is identified by "formImages", and the content is multiple key-value pairs, each of which consists of an image identifier and image file descriptor. The final format is {"formImages": {"key1": fd1, "key2": fd2}}.|
+| obj | Object\|string | No | Data to be displayed on the JS widget. The value can be an object containing multiple key-value pairs or a string in JSON format. The image data is identified by **'formImages'**, and the content is multiple key-value pairs, each of which consists of an image identifier and image file descriptor. The final format is {'formImages': {'key1': fd1, 'key2': fd2}}.|
**Return value**
@@ -48,17 +48,16 @@ Creates a **FormBindingData** object.
**Example**
```ts
-import formBindingData from @ohos.application.formBindingData;
-import fs from '@ohos.file.fs';
-
-try {
- let fd = fs.openSync('/path/to/form.png')
+import featureAbility from '@ohos.ability.featureAbility';
+import fileio from '@ohos.fileio';
+let context=featureAbility.getContext();
+context.getOrCreateLocalDir((err,data)=>{
+ let path=data+'/xxx.jpg';
+ let fd = fileio.openSync(path);
let obj = {
- "temperature": "21°",
- "formImages": { "image": fd }
+ 'temperature': '21°',
+ 'formImages': {'image': fd}
};
- formBindingData.createFormBindingData(obj);
-} catch (error.code) {
- console.log('catch error, error:' + JSON.stringify(error));
-}
+ let formBindingDataObj = formBindingData.createFormBindingData(obj);
+});
```
diff --git a/en/application-dev/reference/apis/js-apis-application-formHost.md b/en/application-dev/reference/apis/js-apis-application-formHost.md
index 11da810effa714b8aaf37e35d3c0566556281ebf..67891daa343ff73efce912c073b9fe946947c739 100644
--- a/en/application-dev/reference/apis/js-apis-application-formHost.md
+++ b/en/application-dev/reference/apis/js-apis-application-formHost.md
@@ -1,6 +1,6 @@
-# @ohos.application.formHost (formHost)
+# @ohos.application.formHost (FormHost)
-The **formHost** module provides APIs related to the widget host, which is an application that displays the widget content and controls the position where the widget is displayed. You can use the APIs to delete, release, and update widgets installed by the same user, and obtain widget information and status.
+The **FormHost** module provides APIs related to the widget host, which is an application that displays the widget content and controls the position where the widget is displayed. You can use the APIs to delete, release, and update widgets installed by the same user, and obtain widget information and status.
> **NOTE**
>
@@ -34,12 +34,10 @@ Deletes a widget. After this API is called, the application can no longer use th
**Example**
```ts
-import formHost from '@ohos.application.formHost';
-
-let formId = "12400633174999288";
+let formId = '12400633174999288';
formHost.deleteForm(formId, (error, data) => {
if (error.code) {
- console.error('formHost deleteForm, error:' + JSON.stringify(error));
+ console.log('formHost deleteForm, error:' + JSON.stringify(error));
}
});
```
@@ -66,16 +64,14 @@ Deletes a widget. After this API is called, the application can no longer use th
| -------- | -------- |
| Promise<void> | Promise that returns no value.|
-**Parameters**
+**Example**
```ts
-import formHost from '@ohos.application.formHost';
-
-let formId = "12400633174999288";
+let formId = '12400633174999288';
formHost.deleteForm(formId).then(() => {
console.log('formHost deleteForm success');
}).catch((error) => {
- console.error('formHost deleteForm, error:' + JSON.stringify(error));
+ console.log('formHost deleteForm, error:' + JSON.stringify(error));
});
```
@@ -99,14 +95,10 @@ Releases a widget. After this API is called, the application can no longer use t
**Example**
```ts
-import formHost from '@ohos.application.formHost';
-
-let formId = "12400633174999288";
+let formId = '12400633174999288';
formHost.releaseForm(formId, (error, data) => {
if (error.code) {
- console.error('formHost releaseForm, error:' + JSON.stringify(error));
- } else {
- console.log('formHost releaseForm success');
+ console.log('formHost releaseForm, error:' + JSON.stringify(error));
}
});
```
@@ -132,14 +124,10 @@ Releases a widget. After this API is called, the application can no longer use t
**Example**
```ts
-import formHost from '@ohos.application.formHost';
-
-let formId = "12400633174999288";
+let formId = '12400633174999288';
formHost.releaseForm(formId, true, (error, data) => {
if (error.code) {
- console.error('formHost releaseForm, error:' + JSON.stringify(error));
- } else {
- console.log('formHost releaseForm success');
+ console.log('formHost releaseForm, error:' + JSON.stringify(error));
}
});
```
@@ -170,13 +158,11 @@ Releases a widget. After this API is called, the application can no longer use t
**Example**
```ts
-import formHost from '@ohos.application.formHost';
-
-let formId = "12400633174999288";
+let formId = '12400633174999288';
formHost.releaseForm(formId, true).then(() => {
console.log('formHost releaseForm success');
}).catch((error) => {
- console.error('formHost releaseForm, error:' + JSON.stringify(error));
+ console.log('formHost releaseForm, error:' + JSON.stringify(error));
});
```
@@ -200,12 +186,10 @@ Requests a widget update. This API uses an asynchronous callback to return the r
**Example**
```ts
-import formHost from '@ohos.application.formHost';
-
-let formId = "12400633174999288";
+let formId = '12400633174999288';
formHost.requestForm(formId, (error, data) => {
if (error.code) {
- console.error('formHost requestForm, error:' + JSON.stringify(error));
+ console.log('formHost requestForm, error:' + JSON.stringify(error));
}
});
```
@@ -235,13 +219,11 @@ Requests a widget update. This API uses a promise to return the result.
**Example**
```ts
-import formHost from '@ohos.application.formHost';
-
-let formId = "12400633174999288";
+let formId = '12400633174999288';
formHost.requestForm(formId).then(() => {
console.log('formHost requestForm success');
}).catch((error) => {
- console.error('formHost requestForm, error:' + JSON.stringify(error));
+ console.log('formHost requestForm, error:' + JSON.stringify(error));
});
```
@@ -265,12 +247,10 @@ Converts a temporary widget to a normal one. This API uses an asynchronous callb
**Example**
```ts
-import formHost from '@ohos.application.formHost';
-
-let formId = "12400633174999288";
+let formId = '12400633174999288';
formHost.castTempForm(formId, (error, data) => {
if (error.code) {
- console.error('formHost castTempForm, error:' + JSON.stringify(error));
+ console.log('formHost castTempForm, error:' + JSON.stringify(error));
}
});
```
@@ -300,13 +280,11 @@ Converts a temporary widget to a normal one. This API uses a promise to return t
**Example**
```ts
-import formHost from '@ohos.application.formHost';
-
-let formId = "12400633174999288";
+let formId = '12400633174999288';
formHost.castTempForm(formId).then(() => {
console.log('formHost castTempForm success');
}).catch((error) => {
- console.error('formHost castTempForm, error:' + JSON.stringify(error));
+ console.log('formHost castTempForm, error:' + JSON.stringify(error));
});
```
@@ -330,12 +308,10 @@ Instructs the widget framework to make a widget visible. After this API is calle
**Example**
```ts
-import formHost from '@ohos.application.formHost';
-
-let formId = ["12400633174999288"];
+let formId = ['12400633174999288'];
formHost.notifyVisibleForms(formId, (error, data) => {
if (error.code) {
- console.error('formHost notifyVisibleForms, error:' + JSON.stringify(error));
+ console.log('formHost notifyVisibleForms, error:' + JSON.stringify(error));
}
});
```
@@ -365,13 +341,11 @@ Instructs the widget framework to make a widget visible. After this API is calle
**Example**
```ts
-import formHost from '@ohos.application.formHost';
-
-let formId = ["12400633174999288"];
+let formId = ['12400633174999288'];
formHost.notifyVisibleForms(formId).then(() => {
console.log('formHost notifyVisibleForms success');
}).catch((error) => {
- console.error('formHost notifyVisibleForms, error:' + JSON.stringify(error));
+ console.log('formHost notifyVisibleForms, error:' + JSON.stringify(error));
});
```
@@ -395,12 +369,10 @@ Instructs the widget framework to make a widget invisible. After this API is cal
**Example**
```ts
-import formHost from '@ohos.application.formHost';
-
-let formId = ["12400633174999288"];
+let formId = ['12400633174999288'];
formHost.notifyInvisibleForms(formId, (error, data) => {
if (error.code) {
- console.error('formHost notifyInvisibleForms, error:' + JSON.stringify(error));
+ console.log('formHost notifyInvisibleForms, error:' + JSON.stringify(error));
}
});
```
@@ -430,13 +402,11 @@ Instructs the widget framework to make a widget invisible. After this API is cal
**Example**
```ts
-import formHost from '@ohos.application.formHost';
-
-let formId = ["12400633174999288"];
+let formId = ['12400633174999288'];
formHost.notifyInvisibleForms(formId).then(() => {
console.log('formHost notifyInvisibleForms success');
}).catch((error) => {
- console.error('formHost notifyInvisibleForms, error:' + JSON.stringify(error));
+ console.log('formHost notifyInvisibleForms, error:' + JSON.stringify(error));
});
```
@@ -460,12 +430,10 @@ Instructs the widget framework to make a widget updatable. After this API is cal
**Example**
```ts
-import formHost from '@ohos.application.formHost';
-
-let formId = ["12400633174999288"];
+let formId = ['12400633174999288'];
formHost.enableFormsUpdate(formId, (error, data) => {
if (error.code) {
- console.error('formHost enableFormsUpdate, error:' + JSON.stringify(error));
+ console.log('formHost enableFormsUpdate, error:' + JSON.stringify(error));
}
});
```
@@ -495,13 +463,11 @@ Instructs the widget framework to make a widget updatable. After this API is cal
**Example**
```ts
-import formHost from '@ohos.application.formHost';
-
-let formId = ["12400633174999288"];
+let formId = ['12400633174999288'];
formHost.enableFormsUpdate(formId).then(() => {
console.log('formHost enableFormsUpdate success');
}).catch((error) => {
- console.error('formHost enableFormsUpdate, error:' + JSON.stringify(error));
+ console.log('formHost enableFormsUpdate, error:' + JSON.stringify(error));
});
```
@@ -525,12 +491,10 @@ Instructs the widget framework to make a widget not updatable. After this API is
**Example**
```ts
-import formHost from '@ohos.application.formHost';
-
-let formId = ["12400633174999288"];
+let formId = ['12400633174999288'];
formHost.disableFormsUpdate(formId, (error, data) => {
if (error.code) {
- console.error('formHost disableFormsUpdate, error:' + JSON.stringify(error));
+ console.log('formHost disableFormsUpdate, error:' + JSON.stringify(error));
}
});
```
@@ -560,13 +524,11 @@ Instructs the widget framework to make a widget not updatable. After this API is
**Example**
```ts
-import formHost from '@ohos.application.formHost';
-
-let formId = ["12400633174999288"];
+let formId = ['12400633174999288'];
formHost.disableFormsUpdate(formId).then(() => {
console.log('formHost disableFormsUpdate success');
}).catch((error) => {
- console.error('formHost disableFormsUpdate, error:' + JSON.stringify(error));
+ console.log('formHost disableFormsUpdate, error:' + JSON.stringify(error));
});
```
@@ -587,12 +549,10 @@ Checks whether the system is ready. This API uses an asynchronous callback to re
**Example**
```ts
-import formHost from '@ohos.application.formHost';
-
-let formId = "12400633174999288";
+let formId = '12400633174999288';
formHost.isSystemReady((error, data) => {
if (error.code) {
- console.error('formHost isSystemReady, error:' + JSON.stringify(error));
+ console.log('formHost isSystemReady, error:' + JSON.stringify(error));
}
});
```
@@ -614,13 +574,11 @@ Checks whether the system is ready. This API uses a promise to return the result
**Example**
```ts
-import formHost from '@ohos.application.formHost';
-
-let formId = "12400633174999288";
+let formId = '12400633174999288';
formHost.isSystemReady().then(() => {
console.log('formHost isSystemReady success');
}).catch((error) => {
- console.error('formHost isSystemReady, error:' + JSON.stringify(error));
+ console.log('formHost isSystemReady, error:' + JSON.stringify(error));
});
```
@@ -638,16 +596,14 @@ Obtains the widget information provided by all applications on the device. This
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ------- |
-| callback | AsyncCallback<Array<[formInfo.FormInfo](js-apis-application-formInfo.md)>> | Yes| Callback used to return the result. If the widget information is obtained, **error** is undefined and **data** is the information obtained; otherwise, **error** is an error object.|
+| callback | AsyncCallback<Array<[FormInfo](js-apis-application-formInfo.md)>> | Yes| Callback used to return the result. If the widget information is obtained, **error** is undefined and **data** is the information obtained; otherwise, **error** is an error object.|
**Example**
```ts
-import formHost from '@ohos.application.formHost';
-
formHost.getAllFormsInfo((error, data) => {
if (error.code) {
- console.error('formHost getAllFormsInfo, error:' + JSON.stringify(error));
+ console.log('formHost getAllFormsInfo, error:' + JSON.stringify(error));
} else {
console.log('formHost getAllFormsInfo, data:' + JSON.stringify(data));
}
@@ -668,17 +624,15 @@ Obtains the widget information provided by all applications on the device. This
| Type | Description |
| :------------ | :---------------------------------- |
-| Promise<Array<[formInfo.FormInfo](js-apis-application-formInfo.md)>> | Promise used to return the information obtained.|
+| Promise<Array<[FormInfo](js-apis-application-formInfo.md)>> | Promise used to return the information obtained.|
**Example**
```ts
- import formHost from '@ohos.application.formHost';
-
formHost.getAllFormsInfo().then((data) => {
- console.log('formHost getAllFormsInfo data:' + JSON.stringify(data));
+ console.log('formHost getAllFormsInfo data:' + JSON.stringify(data));
}).catch((error) => {
- console.error('formHost getAllFormsInfo, error:' + JSON.stringify(error));
+ console.log('formHost getAllFormsInfo, error:' + JSON.stringify(error));
});
```
@@ -697,16 +651,14 @@ Obtains the widget information provided by a given application on the device. Th
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ------- |
| bundleName | string | Yes| Bundle name of the application.|
-| callback | AsyncCallback<Array<[formInfo.FormInfo](js-apis-application-formInfo.md)>> | Yes| Callback used to return the result. If the widget information is obtained, **error** is undefined and **data** is the information obtained; otherwise, **error** is an error object.|
+| callback | AsyncCallback<Array<[FormInfo](js-apis-application-formInfo.md)>> | Yes| Callback used to return the result. If the widget information is obtained, **error** is undefined and **data** is the information obtained; otherwise, **error** is an error object.|
**Example**
```ts
-import formHost from '@ohos.application.formHost';
-
-formHost.getFormsInfo("com.example.ohos.formjsdemo", (error, data) => {
+formHost.getFormsInfo('com.example.ohos.formjsdemo', (error, data) => {
if (error.code) {
- console.error('formHost getFormsInfo, error:' + JSON.stringify(error));
+ console.log('formHost getFormsInfo, error:' + JSON.stringify(error));
} else {
console.log('formHost getFormsInfo, data:' + JSON.stringify(data));
}
@@ -729,18 +681,16 @@ Obtains the widget information provided by a given application on the device. Th
| ------ | ------ | ---- | ------- |
| bundleName | string | Yes| Bundle name of the application.|
| moduleName | string | Yes| Module name.|
-| callback | AsyncCallback<Array<[formInfo.FormInfo](js-apis-application-formInfo.md)>> | Yes| Callback used to return the result. If the widget information is obtained, **error** is undefined and **data** is the information obtained; otherwise, **error** is an error object.|
+| callback | AsyncCallback<Array<[FormInfo](js-apis-application-formInfo.md)>> | Yes| Callback used to return the result. If the widget information is obtained, **error** is undefined and **data** is the information obtained; otherwise, **error** is an error object.|
**Example**
```ts
-import formHost from '@ohos.application.formHost';
-
-formHost.getFormsInfo("com.example.ohos.formjsdemo", "entry", (error, data) => {
+formHost.getFormsInfo('com.example.ohos.formjsdemo', 'entry', (error, data) => {
if (error.code) {
- console.error('formHost getFormsInfo, error:' + JSON.stringify(error));
+ console.log('formHost getFormsInfo, error:' + JSON.stringify(error));
} else {
- console.log('formHost getFormsInfo, data:' + JSON.stringify(data));
+ console.log('formHost getFormsInfo, data:' + JSON.stringify(data));
}
});
```
@@ -766,17 +716,15 @@ Obtains the widget information provided by a given application on the device. Th
| Type | Description |
| :------------ | :---------------------------------- |
-| Promise<Array<[formInfo.FormInfo](js-apis-application-formInfo.md)>> | Promise used to return the information obtained.|
+| Promise<Array<[FormInfo](js-apis-application-formInfo.md)>> | Promise used to return the information obtained.|
**Example**
```ts
- import formHost from '@ohos.application.formHost';
-
- formHost.getFormsInfo("com.example.ohos.formjsdemo", "entry").then((data) => {
+ formHost.getFormsInfo('com.example.ohos.formjsdemo', 'entry').then((data) => {
console.log('formHost getFormsInfo, data:' + JSON.stringify(data));
}).catch((error) => {
- console.error('formHost getFormsInfo, error:' + JSON.stringify(error));
+ console.log('formHost getFormsInfo, error:' + JSON.stringify(error));
});
```
@@ -800,12 +748,10 @@ Deletes invalid widgets from the list. This API uses an asynchronous callback to
**Example**
```ts
-import formHost from '@ohos.application.formHost';
-
-let formIds = new Array("12400633174999288", "12400633174999289");
+let formIds = new Array('12400633174999288', '12400633174999289');
formHost.deleteInvalidForms(formIds, (error, data) => {
if (error.code) {
- console.error('formHost deleteInvalidForms, error:' + JSON.stringify(error));
+ console.log('formHost deleteInvalidForms, error:' + JSON.stringify(error));
} else {
console.log('formHost deleteInvalidForms, data:' + JSON.stringify(data));
}
@@ -837,13 +783,11 @@ Deletes invalid widgets from the list. This API uses a promise to return the res
**Example**
```ts
-import formHost from '@ohos.application.formHost';
-
-let formIds = new Array("12400633174999288", "12400633174999289");
+let formIds = new Array('12400633174999288', '12400633174999289');
formHost.deleteInvalidForms(formIds).then((data) => {
console.log('formHost deleteInvalidForms, data:' + JSON.stringify(data));
}).catch((error) => {
- console.error('formHost deleteInvalidForms, error:' + JSON.stringify(error));
+ console.log('formHost deleteInvalidForms, error:' + JSON.stringify(error));
});
```
@@ -862,26 +806,24 @@ Obtains the widget state. This API uses an asynchronous callback to return the r
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ------- |
| want | [Want](js-apis-application-want.md) | Yes | **Want** information carried to query the widget state. The information must contain the bundle name, ability name, module name, widget name, and widget dimensions.|
-| callback | AsyncCallback<[formInfo.FormStateInfo](js-apis-application-formInfo.md#formstateinfo)> | Yes| Callback used to return the result. If the widget state is obtained, **error** is undefined and **data** is the widget state obtained; otherwise, **error** is an error object.|
+| callback | AsyncCallback<[FormStateInfo](js-apis-application-formInfo.md#formstateinfo)> | Yes| Callback used to return the result. If the widget state is obtained, **error** is undefined and **data** is the widget state obtained; otherwise, **error** is an error object.|
**Example**
```ts
-import formHost from '@ohos.application.formHost';
-
let want = {
- "deviceId": "",
- "bundleName": "ohos.samples.FormApplication",
- "abilityName": "FormAbility",
- "parameters": {
- "ohos.extra.param.key.module_name": "entry",
- "ohos.extra.param.key.form_name": "widget",
- "ohos.extra.param.key.form_dimension": 2
+ 'deviceId': '',
+ 'bundleName': 'ohos.samples.FormApplication',
+ 'abilityName': 'FormAbility',
+ 'parameters': {
+ 'ohos.extra.param.key.module_name': 'entry',
+ 'ohos.extra.param.key.form_name': 'widget',
+ 'ohos.extra.param.key.form_dimension': 2
}
};
formHost.acquireFormState(want, (error, data) => {
if (error.code) {
- console.error('formHost acquireFormState, error:' + JSON.stringify(error));
+ console.log('formHost acquireFormState, error:' + JSON.stringify(error));
} else {
console.log('formHost acquireFormState, data:' + JSON.stringify(data));
}
@@ -913,28 +855,26 @@ Obtains the widget state. This API uses a promise to return the result.
**Example**
```ts
-import formHost from '@ohos.application.formHost';
-
let want = {
- "deviceId": "",
- "bundleName": "ohos.samples.FormApplication",
- "abilityName": "FormAbility",
- "parameters": {
- "ohos.extra.param.key.module_name": "entry",
- "ohos.extra.param.key.form_name": "widget",
- "ohos.extra.param.key.form_dimension": 2
+ 'deviceId': '',
+ 'bundleName': 'ohos.samples.FormApplication',
+ 'abilityName': 'FormAbility',
+ 'parameters': {
+ 'ohos.extra.param.key.module_name': 'entry',
+ 'ohos.extra.param.key.form_name': 'widget',
+ 'ohos.extra.param.key.form_dimension': 2
}
};
formHost.acquireFormState(want).then((data) => {
console.log('formHost acquireFormState, data:' + JSON.stringify(data));
}).catch((error) => {
- console.error('formHost acquireFormState, error:' + JSON.stringify(error));
+ console.log('formHost acquireFormState, error:' + JSON.stringify(error));
});
```
-## on("formUninstall")
+## on('formUninstall')
-on(type: "formUninstall", callback: Callback<string>): void
+on(type: 'formUninstall', callback: Callback<string>): void
Subscribes to widget uninstall events. This API uses an asynchronous callback to return the result.
@@ -944,23 +884,21 @@ Subscribes to widget uninstall events. This API uses an asynchronous callback to
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ------- |
-| type | string | Yes | Event type. The value **formUninstall** indicates a widget uninstallation event.|
+| type | string | Yes | Event type. The value **'formUninstall'** indicates a widget uninstallation event.|
| callback | Callback<string> | Yes| Callback used to return the widget ID.|
**Example**
```ts
-import formHost from '@ohos.application.formHost';
-
let callback = function(formId) {
console.log('formHost on formUninstall, formId:' + formId);
}
-formHost.on("formUninstall", callback);
+formHost.on('formUninstall', callback);
```
-## off("formUninstall")
+## off('formUninstall')
-off(type: "formUninstall", callback?: Callback<string>): void
+off(type: 'formUninstall', callback?: Callback<string>): void
Unsubscribes from widget uninstall events. This API uses an asynchronous callback to return the result.
@@ -970,18 +908,16 @@ Unsubscribes from widget uninstall events. This API uses an asynchronous callbac
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ------- |
-| type | string | Yes | Event type. The value **formUninstall** indicates a widget uninstallation event.|
-| callback | Callback<string> | No| Callback used to return the widget ID. If it is left unspecified, it indicates the callback for all the events that have been subscribed.
The value must be the same as that in **on("formUninstall")**.|
+| type | string | Yes | Event type. The value **'formUninstall'** indicates a widget uninstallation event.|
+| callback | Callback<string> | No| Callback used to return the widget ID. If it is left unspecified, it indicates the callback for all the events that have been subscribed.
The value must be the same as that in **on('formUninstall')**.|
**Example**
```ts
-import formHost from '@ohos.application.formHost';
-
let callback = function(formId) {
console.log('formHost on formUninstall, formId:' + formId);
}
-formHost.off("formUninstall", callback);
+formHost.off('formUninstall', callback);
```
## notifyFormsVisible
@@ -1005,12 +941,10 @@ Instructs the widgets to make themselves visible. This API uses an asynchronous
**Example**
```ts
-import formHost from '@ohos.application.formHost';
-
-let formIds = new Array("12400633174999288", "12400633174999289");
+let formIds = new Array('12400633174999288', '12400633174999289');
formHost.notifyFormsVisible(formIds, true, (error, data) => {
if (error.code) {
- console.error('formHost notifyFormsVisible, error:' + JSON.stringify(error));
+ console.log('formHost notifyFormsVisible, error:' + JSON.stringify(error));
}
});
```
@@ -1041,13 +975,11 @@ Instructs the widgets to make themselves visible. This API uses a promise to ret
**Example**
```ts
-import formHost from '@ohos.application.formHost';
-
-let formIds = new Array("12400633174999288", "12400633174999289");
+let formIds = new Array('12400633174999288', '12400633174999289');
formHost.notifyFormsVisible(formIds, true).then(() => {
console.log('formHost notifyFormsVisible success');
}).catch((error) => {
- console.error('formHost notifyFormsVisible, error:' + JSON.stringify(error));
+ console.log('formHost notifyFormsVisible, error:' + JSON.stringify(error));
});
```
@@ -1072,12 +1004,10 @@ Instructs the widgets to enable or disable updates. This API uses an asynchronou
**Example**
```ts
-import formHost from '@ohos.application.formHost';
-
-let formIds = new Array("12400633174999288", "12400633174999289");
+let formIds = new Array('12400633174999288', '12400633174999289');
formHost.notifyFormsEnableUpdate(formIds, true, (error, data) => {
if (error.code) {
- console.error('formHost notifyFormsEnableUpdate, error:' + JSON.stringify(error));
+ console.log('formHost notifyFormsEnableUpdate, error:' + JSON.stringify(error));
}
});
```
@@ -1108,13 +1038,11 @@ Instructs the widgets to enable or disable updates. This API uses a promise to r
**Example**
```ts
-import formHost from '@ohos.application.formHost';
-
-let formIds = new Array("12400633174999288", "12400633174999289");
+let formIds = new Array('12400633174999288', '12400633174999289');
formHost.notifyFormsEnableUpdate(formIds, true).then(() => {
console.log('formHost notifyFormsEnableUpdate success');
}).catch((error) => {
- console.error('formHost notifyFormsEnableUpdate, error:' + JSON.stringify(error));
+ console.log('formHost notifyFormsEnableUpdate, error:' + JSON.stringify(error));
});
```
## shareForm9+
@@ -1123,7 +1051,7 @@ shareForm(formId: string, deviceId: string, callback: AsyncCallback<void>)
Shares a specified widget with a remote device. This API uses an asynchronous callback to return the result.
-**Required permissions**: ohos.permission.REQUIRE_FORM and ohos.permission.DISTRIBUTED_DATASYNC
+**Required permissions**: ohos.permission.REQUIRE_FORM
**System capability**: SystemCapability.Ability.Form
@@ -1138,13 +1066,11 @@ Shares a specified widget with a remote device. This API uses an asynchronous ca
**Example**
```ts
-import formHost from '@ohos.application.formHost';
-
-let formId = "12400633174999288";
-let deviceId = "EFC11C0C53628D8CC2F8CB5052477E130D075917034613B9884C55CD22B3DEF2";
+let formId = '12400633174999288';
+let deviceId = 'EFC11C0C53628D8CC2F8CB5052477E130D075917034613B9884C55CD22B3DEF2';
formHost.shareForm(formId, deviceId, (error, data) => {
if (error.code) {
- console.error('formHost shareForm, error:' + JSON.stringify(error));
+ console.log('formHost shareForm, error:' + JSON.stringify(error));
}
});
```
@@ -1172,23 +1098,21 @@ Shares a specified widget with a remote device. This API uses a promise to retur
| -------- | -------- |
| Promise<void> | Promise that returns no value.|
-**Parameters**
+**Example**
```ts
-import formHost from '@ohos.application.formHost';
-
-let formId = "12400633174999288";
-let deviceId = "EFC11C0C53628D8CC2F8CB5052477E130D075917034613B9884C55CD22B3DEF2";
+let formId = '12400633174999288';
+let deviceId = 'EFC11C0C53628D8CC2F8CB5052477E130D075917034613B9884C55CD22B3DEF2';
formHost.shareForm(formId, deviceId).then(() => {
console.log('formHost shareForm success');
}).catch((error) => {
- console.error('formHost shareForm, error:' + JSON.stringify(error));
+ console.log('formHost shareForm, error:' + JSON.stringify(error));
});
```
## notifyFormsPrivacyProtected9+
-notifyFormsPrivacyProtected(formIds: Array<string>, isProtected: boolean, callback: AsyncCallback<void>): void
+notifyFormsPrivacyProtected(formIds: Array\, isProtected: boolean, callback: AsyncCallback\): void
Notifies that the privacy protection status of the specified widgets changes. This API uses an asynchronous callback to return the result.
@@ -1204,51 +1128,10 @@ Notifies that the privacy protection status of the specified widgets changes. Th
| deviceId | string | Yes | Remote device ID.|
```ts
-import formHost from '@ohos.application.formHost';
-
-let formIds = new Array("12400633174999288", "12400633174999289");
+let formIds = new Array('12400633174999288', '12400633174999289');
formHost.notifyFormsPrivacyProtected(formIds, true).then(() => {
console.log('formHost shareForm success');
}).catch((error) => {
- console.error('formHost shareForm, error:' + JSON.stringify(error));
+ console.log('formHost shareForm, error:' + JSON.stringify(error));
});
```
-
-## notifyFormsPrivacyProtected
-
-function notifyFormsPrivacyProtected(formIds: Array<string>, isProtected: boolean): Promise<void>;
-
-Notifies that the privacy protection status of the specified widgets changes. This API uses a promise to return the result.
-
-**Required permissions**: ohos.permission.REQUIRE_FORM
-
-**System capability**: SystemCapability.Ability.Form
-
-**Parameters**
-
-| Name | Type | Mandatory| Description |
-| ----------- | --------------- | ---- | -------------------------------- |
-| formIds | Array<string> | Yes | ID of the widgets.|
-| isProtected | boolean | Yes | Whether privacy protection is enabled. |
-
-**Return value**
-
-| Type | Description |
-| ------------------- | ------------------------- |
-| Promise<void> | Promise that returns no value.|
-
-
-```ts
-import formHost from '@ohos.application.formHost';
-
-let formIds = new Array("12400633174999288", "12400633174999289");
-try {
- formHost.notifyFormsPrivacyProtected(formIds, true).then(() => {
- console.log('formHost notifyFormsPrivacyProtected success');
- }).catch((error) => {
- console.log('formHost notifyFormsPrivacyProtected, error:' + JSON.stringify(error));
- });
-} catch(error) {
- console.log('formHost notifyFormsPrivacyProtected, error:' + JSON.stringify(error));
-}
-```
diff --git a/en/application-dev/reference/apis/js-apis-application-formProvider.md b/en/application-dev/reference/apis/js-apis-application-formProvider.md
index 4d604ff7295eb9903d450bc96f9c00fde253ee11..d23e6e15e21e68017f0c305427ad095446ca54cf 100644
--- a/en/application-dev/reference/apis/js-apis-application-formProvider.md
+++ b/en/application-dev/reference/apis/js-apis-application-formProvider.md
@@ -1,10 +1,10 @@
-# @ohos.application.formProvider (formProvider)
+# @ohos.application.formProvider (FormProvider)
The **FormProvider** module provides APIs related to the widget provider. You can use the APIs to update a widget, set the next refresh time for a widget, obtain widget information, and request a widget release.
> **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.
-> This module is deprecated since API version 9. You are advised to use [formProvider](js-apis-app-form-formProvider.md) instead.
+> This module is deprecated since API version 9. You are advised to use [FormProvider](js-apis-app-form-formProvider.md) instead.
## Modules to Import
@@ -31,13 +31,11 @@ Sets the next refresh time for a widget. This API uses an asynchronous callback
**Example**
```ts
- import formProvider from '@ohos.app.form.formProvider';
-
- let formId = "12400633174999288";
+ let formId = '12400633174999288';
formProvider.setFormNextRefreshTime(formId, 5, (error, data) => {
- if (error.code) {
- console.log('formProvider setFormNextRefreshTime, error:' + JSON.stringify(error));
- }
+ if (error.code) {
+ console.log('formProvider setFormNextRefreshTime, error:' + JSON.stringify(error));
+ }
});
```
@@ -65,13 +63,11 @@ Sets the next refresh time for a widget. This API uses a promise to return the r
**Example**
```ts
- import formProvider from '@ohos.app.form.formProvider';
-
- let formId = "12400633174999288";
+ let formId = '12400633174999288';
formProvider.setFormNextRefreshTime(formId, 5).then(() => {
- console.log('formProvider setFormNextRefreshTime success');
+ console.log('formProvider setFormNextRefreshTime success');
}).catch((error) => {
- console.log('formProvider setFormNextRefreshTime, error:' + JSON.stringify(error));
+ console.log('formProvider setFormNextRefreshTime, error:' + JSON.stringify(error));
});
```
@@ -88,21 +84,19 @@ Updates a widget. This API uses an asynchronous callback to return the result.
| Name| Type | Mandatory| Description |
| ------ | ---------------------------------------------------------------------- | ---- | ---------------- |
| formId | string | Yes | ID of the widget to update.|
- | formBindingData | [formBindingData.FormBindingData](js-apis-application-formBindingData.md#formbindingdata) | Yes | Data to be used for the update. |
+ | formBindingData.FormBindingData | [FormBindingData](js-apis-application-formBindingData.md#formbindingdata) | Yes | Data to be used for the update. |
| callback | AsyncCallback<void> | Yes| Callback used to return the result.|
**Example**
```ts
import formBindingData from '@ohos.application.formBindingData';
- import formProvider from '@ohos.app.form.formProvider';
-
- let formId = "12400633174999288";
- let obj = formBindingData.createFormBindingData({temperature:"22c", time:"22:00"});
+ let formId = '12400633174999288';
+ let obj = formBindingData.createFormBindingData({temperature:'22c', time:'22:00'});
formProvider.updateForm(formId, obj, (error, data) => {
- if (error.code) {
- console.log('formProvider updateForm, error:' + JSON.stringify(error));
- }
+ if (error.code) {
+ console.log('formProvider updateForm, error:' + JSON.stringify(error));
+ }
});
```
@@ -119,7 +113,7 @@ Updates a widget. This API uses a promise to return the result.
| Name| Type | Mandatory| Description |
| ------ | ---------------------------------------------------------------------- | ---- | ---------------- |
| formId | string | Yes | ID of the widget to update.|
- | formBindingData | [formBindingData.FormBindingData](js-apis-application-formBindingData.md#formbindingdata) | Yes | Data to be used for the update. |
+ | formBindingData.FormBindingData | [FormBindingData](js-apis-application-formBindingData.md#formbindingdat) | Yes | Data to be used for the update. |
**Return value**
@@ -131,14 +125,12 @@ Updates a widget. This API uses a promise to return the result.
```ts
import formBindingData from '@ohos.application.formBindingData';
- import formProvider from '@ohos.app.form.formProvider';
-
- let formId = "12400633174999288";
- let obj = formBindingData.createFormBindingData({temperature:"22c", time:"22:00"});
+ let formId = '12400633174999288';
+ let obj = formBindingData.createFormBindingData({temperature:'22c', time:'22:00'});
formProvider.updateForm(formId, obj).then(() => {
- console.log('formProvider updateForm success');
+ console.log('formProvider updateForm success');
}).catch((error) => {
- console.log('formProvider updateForm, error:' + JSON.stringify(error));
+ console.log('formProvider updateForm, error:' + JSON.stringify(error));
});
```
@@ -154,19 +146,17 @@ Obtains the application's widget information on the device. This API uses an asy
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ------- |
-| callback | AsyncCallback<Array<[formInfo.FormInfo](./js-apis-application-formInfo.md#forminfo-1)>> | Yes| Callback used to return the information obtained.|
+| callback | AsyncCallback<Array<[FormInfo](./js-apis-application-formInfo.md#forminfo-1)>> | Yes| Callback used to return the information obtained.|
**Example**
```ts
-import formProvider from '@ohos.app.form.formProvider';
-
formProvider.getFormsInfo((error, data) => {
- if (error.code) {
- console.log('formProvider getFormsInfo, error:' + JSON.stringify(error));
- } else {
- console.log('formProvider getFormsInfo, data:' + JSON.stringify(data));
- }
+ if (error.code) {
+ console.log('formProvider getFormsInfo, error:' + JSON.stringify(error));
+ } else {
+ console.log('formProvider getFormsInfo, data:' + JSON.stringify(data));
+ }
});
```
## getFormsInfo9+
@@ -182,24 +172,22 @@ Obtains the application's widget information that meets a filter criterion on th
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ------- |
| filter | [formInfo.FormInfoFilter](./js-apis-application-formInfo.md#forminfofilter) | Yes| Filter criterion.|
-| callback | AsyncCallback<Array<[formInfo.FormInfo](./js-apis-application-formInfo.md#forminfo-1)>> | Yes| Callback used to return the information obtained.|
+| callback | AsyncCallback<Array<[FormInfo](./js-apis-application-formInfo.md#forminfo-1)>> | Yes| Callback used to return the information obtained.|
**Example**
```ts
import formInfo from '@ohos.application.formInfo';
-import formProvider from '@ohos.app.form.formProvider';
-
const filter : formInfo.FormInfoFilter = {
- // get info of forms belong to module entry.
- moduleName : "entry"
+ // get info of forms belong to module entry.
+ moduleName : 'entry'
};
formProvider.getFormsInfo(filter, (error, data) => {
- if (error.code) {
- console.log('formProvider getFormsInfo, error:' + JSON.stringify(error));
- } else {
- console.log('formProvider getFormsInfo, data:' + JSON.stringify(data));
- }
+ if (error.code) {
+ console.log('formProvider getFormsInfo, error:' + JSON.stringify(error));
+ } else {
+ console.log('formProvider getFormsInfo, data:' + JSON.stringify(data));
+ }
});
```
@@ -221,22 +209,20 @@ Obtains the application's widget information on the device. This API uses a prom
| Type | Description |
| :------------ | :---------------------------------- |
-| Promise<Array<[formInfo.FormInfo](./js-apis-application-formInfo.md#forminfo-1)>> | Promise used to return the information obtained.|
+| Promise<Array<[FormInfo](./js-apis-application-formInfo.md#forminfo-1)>> | Promise used to return the information obtained.|
**Example**
```ts
import formInfo from '@ohos.application.formInfo';
-import formProvider from '@ohos.app.form.formProvider';
-
const filter : formInfo.FormInfoFilter = {
- // get info of forms belong to module entry.
- moduleName : "entry"
+ // get info of forms belong to module entry.
+ moduleName : 'entry'
};
formProvider.getFormsInfo(filter).then((data) => {
- console.log('formProvider getFormsInfo, data:' + JSON.stringify(data));
+ console.log('formProvider getFormsInfo, data:' + JSON.stringify(data));
}).catch((error) => {
- console.log('formProvider getFormsInfo, error:' + JSON.stringify(error));
+ console.log('formProvider getFormsInfo, error:' + JSON.stringify(error));
});
```
@@ -255,29 +241,28 @@ Requests to publish a widget carrying data to the widget host. This API uses an
| Name| Type | Mandatory| Description |
| ------ | ---------------------------------------------------------------------- | ---- | ---------------- |
| want | [Want](js-apis-application-want.md) | Yes | Request used for publishing. The following fields must be included:
Information about the target widget.
**abilityName**: ability of the target widget.
**parameters**:
"ohos.extra.param.key.form_dimension"
"ohos.extra.param.key.form_name"
"ohos.extra.param.key.module_name" |
-| formBindingData | [formBindingData.FormBindingData](js-apis-application-formBindingData.md#formbindingdata) | Yes | Data used for creating the widget.|
+| formBindingData.FormBindingData | [FormBindingData](js-apis-application-formBindingData.md#formbindingdata) | Yes | Data used for creating the widget.|
| callback | AsyncCallback<string> | Yes| Callback used to return the widget ID.|
**Example**
```ts
import formBindingData from '@ohos.application.formBindingData';
- import formProvider from '@ohos.app.form.formProvider';
let want = {
- abilityName: "FormAbility",
- parameters: {
- "ohos.extra.param.key.form_dimension": 2,
- "ohos.extra.param.key.form_name": "widget",
- "ohos.extra.param.key.module_name": "entry"
- }
+ abilityName: 'FormAbility',
+ parameters: {
+ 'ohos.extra.param.key.form_dimension': 2,
+ 'ohos.extra.param.key.form_name': 'widget',
+ 'ohos.extra.param.key.module_name': 'entry'
+ }
};
- let obj = formBindingData.createFormBindingData({temperature:"22c", time:"22:00"});
+ let obj = formBindingData.createFormBindingData({temperature:'22c', time:'22:00'});
formProvider.requestPublishForm(want, obj, (error, data) => {
- if (error.code) {
- console.log('formProvider requestPublishForm, error: ' + JSON.stringify(error));
- } else {
- console.log('formProvider requestPublishForm, form ID is: ' + JSON.stringify(data));
- }
+ if (error.code) {
+ console.log('formProvider requestPublishForm, error: ' + JSON.stringify(error));
+ } else {
+ console.log('formProvider requestPublishForm, form ID is: ' + JSON.stringify(data));
+ }
});
```
@@ -301,22 +286,20 @@ Requests to publish a widget to the widget host. This API uses an asynchronous c
**Example**
```ts
- import formProvider from '@ohos.app.form.formProvider';
-
let want = {
- abilityName: "FormAbility",
- parameters: {
- "ohos.extra.param.key.form_dimension": 2,
- "ohos.extra.param.key.form_name": "widget",
- "ohos.extra.param.key.module_name": "entry"
- }
+ abilityName: 'FormAbility',
+ parameters: {
+ 'ohos.extra.param.key.form_dimension': 2,
+ 'ohos.extra.param.key.form_name': 'widget',
+ 'ohos.extra.param.key.module_name': 'entry'
+ }
};
formProvider.requestPublishForm(want, (error, data) => {
- if (error.code) {
- console.log('formProvider requestPublishForm, error: ' + JSON.stringify(error));
- } else {
- console.log('formProvider requestPublishForm, form ID is: ' + JSON.stringify(data));
- }
+ if (error.code) {
+ console.log('formProvider requestPublishForm, error: ' + JSON.stringify(error));
+ } else {
+ console.log('formProvider requestPublishForm, form ID is: ' + JSON.stringify(data));
+ }
});
```
@@ -335,7 +318,7 @@ Requests to publish a widget to the widget host. This API uses a promise to retu
| Name | Type | Mandatory| Description |
| --------------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
| want | [Want](js-apis-application-want.md) | Yes | Request used for publishing. The following fields must be included:
Information about the target widget.
**abilityName**: ability of the target widget.
**parameters**:
"ohos.extra.param.key.form_dimension"
"ohos.extra.param.key.form_name"
"ohos.extra.param.key.module_name" |
-| formBindingData | [formBindingData.FormBindingData](js-apis-application-formBindingData.md#formbindingdata) | Yes | Data used for creating the widget.|
+| formBindingData.FormBindingData | [FormBindingData](js-apis-application-formBindingData.md#formbindingdata) | Yes | Data used for creating the widget.|
**Return value**
@@ -346,20 +329,18 @@ Requests to publish a widget to the widget host. This API uses a promise to retu
**Example**
```ts
- import formProvider from '@ohos.app.form.formProvider';
-
let want = {
- abilityName: "FormAbility",
- parameters: {
- "ohos.extra.param.key.form_dimension": 2,
- "ohos.extra.param.key.form_name": "widget",
- "ohos.extra.param.key.module_name": "entry"
- }
+ abilityName: 'FormAbility',
+ parameters: {
+ 'ohos.extra.param.key.form_dimension': 2,
+ 'ohos.extra.param.key.form_name': 'widget',
+ 'ohos.extra.param.key.module_name': 'entry'
+ }
};
formProvider.requestPublishForm(want).then((data) => {
- console.log('formProvider requestPublishForm success, form ID is :' + JSON.stringify(data));
+ console.log('formProvider requestPublishForm success, form ID is :' + JSON.stringify(data));
}).catch((error) => {
- console.log('formProvider requestPublishForm, error: ' + JSON.stringify(error));
+ console.log('formProvider requestPublishForm, error: ' + JSON.stringify(error));
});
```
@@ -388,12 +369,12 @@ formProvider.isRequestPublishFormSupported((error, isSupported) => {
} else {
if (isSupported) {
let want = {
- abilityName: "FormAbility",
- parameters: {
- "ohos.extra.param.key.form_dimension": 2,
- "ohos.extra.param.key.form_name": "widget",
- "ohos.extra.param.key.module_name": "entry"
- }
+ abilityName: 'FormAbility',
+ parameters: {
+ 'ohos.extra.param.key.form_dimension': 2,
+ 'ohos.extra.param.key.form_name': 'widget',
+ 'ohos.extra.param.key.module_name': 'entry'
+ }
};
formProvider.requestPublishForm(want, (error, data) => {
if (error.code) {
@@ -429,12 +410,12 @@ Checks whether a widget can be published to the widget host. This API uses a pro
formProvider.isRequestPublishFormSupported().then((isSupported) => {
if (isSupported) {
let want = {
- abilityName: "FormAbility",
- parameters: {
- "ohos.extra.param.key.form_dimension": 2,
- "ohos.extra.param.key.form_name": "widget",
- "ohos.extra.param.key.module_name": "entry"
- }
+ abilityName: 'FormAbility',
+ parameters: {
+ 'ohos.extra.param.key.form_dimension': 2,
+ 'ohos.extra.param.key.form_name': 'widget',
+ 'ohos.extra.param.key.module_name': 'entry'
+ }
};
formProvider.requestPublishForm(want).then((data) => {
console.log('formProvider requestPublishForm success, form ID is :' + JSON.stringify(data));
@@ -445,4 +426,4 @@ formProvider.isRequestPublishFormSupported().then((isSupported) => {
}).catch((error) => {
console.log('formProvider isRequestPublishFormSupported, error:' + JSON.stringify(error));
});
-```
+```
\ No newline at end of file
diff --git a/en/application-dev/reference/apis/js-apis-application-missionManager.md b/en/application-dev/reference/apis/js-apis-application-missionManager.md
index 17de66e19334dce9663017c3df9c18b575e14bd7..21501d5710ad7435acafbe8d66892d04b2f45da9 100644
--- a/en/application-dev/reference/apis/js-apis-application-missionManager.md
+++ b/en/application-dev/reference/apis/js-apis-application-missionManager.md
@@ -4,12 +4,12 @@ The **missionManager** module provides APIs to lock, unlock, and clear missions,
> **NOTE**
>
-> The APIs of this module are supported since API version 8 and deprecated since API version 9. You are advised to use [@ohos.app.ability.missionManager](js-apis-app-ability-missionManager.md) instead. Newly added APIs will be marked with a superscript to indicate their earliest API version.
+> The APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version.
## Modules to Import
```ts
-import missionManager from '@ohos.application.missionManager'
+import missionManager from '@ohos.application.missionManager';
```
## Required Permissions
@@ -43,17 +43,17 @@ Registers a listener to observe the mission status.
**Example**
```ts
-var listener = {
- onMissionCreated: function (mission) {console.log("--------onMissionCreated-------")},
- onMissionDestroyed: function (mission) {console.log("--------onMissionDestroyed-------")},
- onMissionSnapshotChanged: function (mission) {console.log("--------onMissionSnapshotChanged-------")},
- onMissionMovedToFront: function (mission) {console.log("--------onMissionMovedToFront-------")},
- onMissionIconUpdated: function (mission, icon) {console.log("--------onMissionIconUpdated-------")},
- onMissionClosed: function (mission) {console.log("--------onMissionClosed-------")},
- onMissionLabelUpdated: function (mission) {console.log("--------onMissionLabelUpdated-------")}
+let listener = {
+ onMissionCreated: function (mission) {console.log('--------onMissionCreated-------');},
+ onMissionDestroyed: function (mission) {console.log('--------onMissionDestroyed-------');},
+ onMissionSnapshotChanged: function (mission) {console.log('--------onMissionSnapshotChanged-------');},
+ onMissionMovedToFront: function (mission) {console.log('--------onMissionMovedToFront-------');},
+ onMissionIconUpdated: function (mission, icon) {console.log('--------onMissionIconUpdated-------');},
+ onMissionClosed: function (mission) {console.log('--------onMissionClosed-------');},
+ onMissionLabelUpdated: function (mission) {console.log('--------onMissionLabelUpdated-------');}
};
-console.log("registerMissionListener")
-var listenerid = missionManager.registerMissionListener(listener);
+console.log('registerMissionListener');
+let listenerid = missionManager.registerMissionListener(listener);
```
@@ -79,21 +79,21 @@ Deregisters a mission status listener. This API uses an asynchronous callback to
**Example**
```ts
- var listener = {
- onMissionCreated: function (mission) {console.log("--------onMissionCreated-------")},
- onMissionDestroyed: function (mission) {console.log("--------onMissionDestroyed-------")},
- onMissionSnapshotChanged: function (mission) {console.log("--------onMissionSnapshotChanged-------")},
- onMissionMovedToFront: function (mission) {console.log("--------onMissionMovedToFront-------")},
- onMissionIconUpdated: function (mission, icon) {console.log("--------onMissionIconUpdated-------")},
- onMissionClosed: function (mission) {console.log("--------onMissionClosed-------")},
- onMissionLabelUpdated: function (mission) {console.log("--------onMissionLabelUpdated-------")}
+ let listener = {
+ onMissionCreated: function (mission) {console.log('--------onMissionCreated-------');},
+ onMissionDestroyed: function (mission) {console.log('--------onMissionDestroyed-------');},
+ onMissionSnapshotChanged: function (mission) {console.log('--------onMissionSnapshotChanged-------');},
+ onMissionMovedToFront: function (mission) {console.log('--------onMissionMovedToFront-------');},
+ onMissionIconUpdated: function (mission, icon) {console.log('--------onMissionIconUpdated-------');},
+ onMissionClosed: function (mission) {console.log('--------onMissionClosed-------');},
+ onMissionLabelUpdated: function (mission) {console.log('--------onMissionLabelUpdated-------');}
};
- console.log("registerMissionListener")
- var listenerid = missionManager.registerMissionListener(listener);
+ console.log('registerMissionListener');
+ let listenerid = missionManager.registerMissionListener(listener);
missionManager.unregisterMissionListener(listenerid, (error) => {
- console.log("unregisterMissionListener");
- })
+ console.log('unregisterMissionListener');
+ });
```
@@ -124,17 +124,17 @@ Deregisters a mission status listener. This API uses a promise to return the res
**Example**
```ts
- var listener = {
- onMissionCreated: function (mission) {console.log("--------onMissionCreated-------")},
- onMissionDestroyed: function (mission) {console.log("--------onMissionDestroyed-------")},
- onMissionSnapshotChanged: function (mission) {console.log("--------onMissionSnapshotChanged-------")},
- onMissionMovedToFront: function (mission) {console.log("--------onMissionMovedToFront-------")},
- onMissionIconUpdated: function (mission, icon) {console.log("--------onMissionIconUpdated-------")},
- onMissionClosed: function (mission) {console.log("--------onMissionClosed-------")},
- onMissionLabelUpdated: function (mission) {console.log("--------onMissionLabelUpdated-------")}
+ let listener = {
+ onMissionCreated: function (mission) {console.log('--------onMissionCreated-------');},
+ onMissionDestroyed: function (mission) {console.log('--------onMissionDestroyed-------');},
+ onMissionSnapshotChanged: function (mission) {console.log('--------onMissionSnapshotChanged-------');},
+ onMissionMovedToFront: function (mission) {console.log('--------onMissionMovedToFront-------');},
+ onMissionIconUpdated: function (mission, icon) {console.log('--------onMissionIconUpdated-------');},
+ onMissionClosed: function (mission) {console.log('--------onMissionClosed-------');},
+ onMissionLabelUpdated: function (mission) {console.log('--------onMissionLabelUpdated-------');}
};
- console.log("registerMissionListener")
- var listenerid = missionManager.registerMissionListener(listener);
+ console.log('registerMissionListener');
+ let listenerid = missionManager.registerMissionListener(listener);
missionManager.unregisterMissionListener(listenerid).catch(function (err) {
console.log(err);
@@ -167,20 +167,15 @@ Obtains the information about a given mission. This API uses an asynchronous cal
```ts
import missionManager from '@ohos.application.missionManager'
- var allMissions=missionManager.getMissionInfos("",10).catch(function(err){console.log(err);});
- missionManager.getMissionInfo("", allMissions[0].missionId, (error, mission) => {
- if (error.code) {
- console.log("getMissionInfo failed, error.code:" + JSON.stringify(error.code) +
- "error.message:" + JSON.stringify(error.message));
- return;
- }
-
- console.log("mission.missionId = " + mission.missionId);
- console.log("mission.runningState = " + mission.runningState);
- console.log("mission.lockedState = " + mission.lockedState);
- console.log("mission.timestamp = " + mission.timestamp);
- console.log("mission.label = " + mission.label);
- console.log("mission.iconPath = " + mission.iconPath);
+ let allMissions=missionManager.getMissionInfos('',10).catch(function(err){console.log(err);});
+ missionManager.getMissionInfo('', allMissions[0].missionId, (error, mission) => {
+ console.log('getMissionInfo is called, error.code = ' + error.code)
+ console.log('mission.missionId = ' + mission.missionId);
+ console.log('mission.runningState = ' + mission.runningState);
+ console.log('mission.lockedState = ' + mission.lockedState);
+ console.log('mission.timestamp = ' + mission.timestamp);
+ console.log('mission.label = ' + mission.label);
+ console.log('mission.iconPath = ' + mission.iconPath);
});
```
@@ -213,9 +208,9 @@ Obtains the information about a given mission. This API uses a promise to return
**Example**
```ts
- import missionManager from '@ohos.application.missionManager'
+ import missionManager from '@ohos.application.missionManager';
- var mission = missionManager.getMissionInfo("", 10).catch(function (err){
+ let mission = missionManager.getMissionInfo('', 10).catch(function (err){
console.log(err);
});
```
@@ -244,17 +239,13 @@ Obtains information about all missions. This API uses an asynchronous callback t
**Example**
```ts
- import missionManager from '@ohos.application.missionManager'
+ import missionManager from '@ohos.application.missionManager';
- missionManager.getMissionInfos("", 10, (error, missions) => {
- if (error.code) {
- console.log("getMissionInfos failed, error.code:" + JSON.stringify(error.code) +
- "error.message:" + JSON.stringify(error.message));
- return;
- }
- console.log("size = " + missions.length);
- console.log("missions = " + JSON.stringify(missions));
- })
+ missionManager.getMissionInfos('', 10, (error, missions) => {
+ console.log('getMissionInfos is called, error.code = ' + error.code);
+ console.log('size = ' + missions.length);
+ console.log('missions = ' + JSON.stringify(missions));
+ });
```
@@ -286,9 +277,9 @@ Obtains information about all missions. This API uses a promise to return the re
**Example**
```ts
- import missionManager from '@ohos.application.missionManager'
+ import missionManager from '@ohos.application.missionManager';
- var allMissions = missionManager.getMissionInfos("", 10).catch(function (err){
+ let allMissions = missionManager.getMissionInfos('', 10).catch(function (err){
console.log(err);
});
```
@@ -317,27 +308,19 @@ Obtains the snapshot of a given mission. This API uses an asynchronous callback
**Example**
```ts
- import missionManager from '@ohos.application.missionManager'
+ import missionManager from '@ohos.application.missionManager';
+
+ missionManager.getMissionInfos('', 10, (error, missions) => {
+ console.log('getMissionInfos is called, error.code = ' + error.code);
+ console.log('size = ' + missions.length);
+ console.log('missions = ' + JSON.stringify(missions));
+ let id = missions[0].missionId;
- missionManager.getMissionInfos("", 10, (error, missions) => {
- if (error.code) {
- console.log("getMissionInfos failed, error.code:" + JSON.stringify(error.code) +
- "error.message:" + JSON.stringify(error.message));
- return;
- }
- console.log("size = " + missions.length);
- console.log("missions = " + JSON.stringify(missions));
- var id = missions[0].missionId;
-
- missionManager.getMissionSnapShot("", id, (error, snapshot) => {
- if (error.code) {
- console.log("getMissionSnapShot failed, error.code:" + JSON.stringify(error.code) +
- "error.message:" + JSON.stringify(error.message));
- return;
- }
- console.log("bundleName = " + snapshot.ability.bundleName);
- })
- })
+ missionManager.getMissionSnapShot('', id, (error, snapshot) => {
+ console.log('getMissionSnapShot is called, error.code = ' + error.code);
+ console.log('bundleName = ' + snapshot.ability.bundleName);
+ });
+ });
```
@@ -369,17 +352,17 @@ Obtains the snapshot of a given mission. This API uses a promise to return the r
**Example**
```ts
- import missionManager from '@ohos.application.missionManager'
+ import missionManager from '@ohos.application.missionManager';
- var allMissions;
- missionManager.getMissionInfos("",10).then(function(res){
+ let allMissions;
+ missionManager.getMissionInfos('',10).then(function(res){
allMissions=res;
}).catch(function(err){console.log(err);});
- console.log("size = " + allMissions.length);
- console.log("missions = " + JSON.stringify(allMissions));
- var id = allMissions[0].missionId;
+ console.log('size = ' + allMissions.length);
+ console.log('missions = ' + JSON.stringify(allMissions));
+ let id = allMissions[0].missionId;
- var snapshot = missionManager.getMissionSnapShot("", id).catch(function (err){
+ let snapshot = missionManager.getMissionSnapShot('', id).catch(function (err){
console.log(err);
});
```
@@ -407,27 +390,19 @@ Obtains the low-resolution snapshot of a given mission. This API uses an asynchr
**Example**
```ts
- import missionManager from '@ohos.application.missionManager'
+ import missionManager from '@ohos.application.missionManager';
+
+ missionManager.getMissionInfos('', 10, (error, missions) => {
+ console.log('getMissionInfos is called, error.code = ' + error.code);
+ console.log('size = ' + missions.length);
+ console.log('missions = ' + JSON.stringify(missions));
+ let id = missions[0].missionId;
- missionManager.getMissionInfos("", 10, (error, missions) => {
- if (error.code) {
- console.log("getMissionInfos failed, error.code:" + JSON.stringify(error.code) +
- "error.message:" + JSON.stringify(error.message));
- return;
- }
- console.log("size = " + missions.length);
- console.log("missions = " + JSON.stringify(missions));
- var id = missions[0].missionId;
-
- missionManager.getLowResolutionMissionSnapShot("", id, (error, snapshot) => {
- if (error.code) {
- console.log("getLowResolutionMissionSnapShot failed, error.code:" + JSON.stringify(error.code) +
- "error.message:" + JSON.stringify(error.message));
- return;
- }
- console.log("bundleName = " + snapshot.ability.bundleName);
- })
- })
+ missionManager.getLowResolutionMissionSnapShot('', id, (error, snapshot) => {
+ console.log('getLowResolutionMissionSnapShot is called, error.code = ' + error.code);
+ console.log('bundleName = ' + snapshot.ability.bundleName);
+ });
+ });
```
@@ -459,17 +434,17 @@ Obtains the low-resolution snapshot of a given mission. This API uses a promise
**Example**
```ts
- import missionManager from '@ohos.application.missionManager'
+ import missionManager from '@ohos.application.missionManager';
- var allMissions;
- missionManager.getMissionInfos("",10).then(function(res){
+ let allMissions;
+ missionManager.getMissionInfos('',10).then(function(res){
allMissions=res;
}).catch(function(err){console.log(err);});
- console.log("size = " + allMissions.length);
- console.log("missions = " + JSON.stringify(allMissions));
- var id = allMissions[0].missionId;
+ console.log('size = ' + allMissions.length);
+ console.log('missions = ' + JSON.stringify(allMissions));
+ let id = allMissions[0].missionId;
- var snapshot = missionManager.getLowResolutionMissionSnapShot("", id).catch(function (err){
+ let snapshot = missionManager.getLowResolutionMissionSnapShot('', id).catch(function (err){
console.log(err);
});
```
@@ -497,20 +472,16 @@ Locks a given mission. This API uses an asynchronous callback to return the resu
**Example**
```ts
- import missionManager from '@ohos.application.missionManager'
+ import missionManager from '@ohos.application.missionManager';
- missionManager.getMissionInfos("", 10, (error, missions) => {
- if (error.code) {
- console.log("getMissionInfos failed, error.code:" + JSON.stringify(error.code) +
- "error.message:" + JSON.stringify(error.message));
- return;
- }
- console.log("size = " + missions.length);
- console.log("missions = " + JSON.stringify(missions));
- var id = missions[0].missionId;
+ missionManager.getMissionInfos('', 10, (error, missions) => {
+ console.log('getMissionInfos is called, error.code = ' + error.code);
+ console.log('size = ' + missions.length);
+ console.log('missions = ' + JSON.stringify(missions));
+ let id = missions[0].missionId;
missionManager.lockMission(id).then(() => {
- console.log("lockMission is called ");
+ console.log('lockMission is called ');
});
});
```
@@ -543,14 +514,14 @@ Locks a given mission. This API uses a promise to return the result.
**Example**
```ts
- import missionManager from '@ohos.application.missionManager'
- var allMissions;
- missionManager.getMissionInfos("",10).then(function(res){
+ import missionManager from '@ohos.application.missionManager';
+ let allMissions;
+ missionManager.getMissionInfos('',10).then(function(res){
allMissions=res;
}).catch(function(err){console.log(err);});
- console.log("size = " + allMissions.length);
- console.log("missions = " + JSON.stringify(allMissions));
- var id = allMissions[0].missionId;
+ console.log('size = ' + allMissions.length);
+ console.log('missions = ' + JSON.stringify(allMissions));
+ let id = allMissions[0].missionId;
missionManager.lockMission(id).catch(function (err){
console.log(err);
@@ -580,20 +551,16 @@ Unlocks a given mission. This API uses an asynchronous callback to return the re
**Example**
```ts
- import missionManager from '@ohos.application.missionManager'
+ import missionManager from '@ohos.application.missionManager';
- missionManager.getMissionInfos("", 10, (error, missions) => {
- if (error.code) {
- console.log("getMissionInfos failed, error.code:" + JSON.stringify(error.code) +
- "error.message:" + JSON.stringify(error.message));
- return;
- }
- console.log("size = " + missions.length);
- console.log("missions = " + JSON.stringify(missions));
- var id = missions[0].missionId;
+ missionManager.getMissionInfos('', 10, (error, missions) => {
+ console.log('getMissionInfos is called, error.code = ' + error.code);
+ console.log('size = ' + missions.length);
+ console.log('missions = ' + JSON.stringify(missions));
+ let id = missions[0].missionId;
missionManager.unlockMission(id).then(() => {
- console.log("unlockMission is called ");
+ console.log('unlockMission is called ');
});
});
```
@@ -626,15 +593,15 @@ Unlocks a given mission. This API uses a promise to return the result.
**Example**
```ts
- import missionManager from '@ohos.application.missionManager'
+ import missionManager from '@ohos.application.missionManager';
- var allMissions;
- missionManager.getMissionInfos("",10).then(function(res){
+ let allMissions;
+ missionManager.getMissionInfos('',10).then(function(res){
allMissions=res;
}).catch(function(err){console.log(err);});
- console.log("size = " + allMissions.length);
- console.log("missions = " + JSON.stringify(allMissions));
- var id = allMissions[0].missionId;
+ console.log('size = ' + allMissions.length);
+ console.log('missions = ' + JSON.stringify(allMissions));
+ let id = allMissions[0].missionId;
missionManager.lockMission(id).catch(function (err){
console.log(err);
@@ -667,20 +634,16 @@ Clears a given mission, regardless of whether it is locked. This API uses an asy
**Example**
```ts
- import missionManager from '@ohos.application.missionManager'
+ import missionManager from '@ohos.application.missionManager';
- missionManager.getMissionInfos("", 10, (error, missions) => {
- if (error.code) {
- console.log("getMissionInfos failed, error.code:" + JSON.stringify(error.code) +
- "error.message:" + JSON.stringify(error.message));
- return;
- }
- console.log("size = " + missions.length);
- console.log("missions = " + JSON.stringify(missions));
- var id = missions[0].missionId;
+ missionManager.getMissionInfos('', 10, (error, missions) => {
+ console.log('getMissionInfos is called, error.code = ' + error.code);
+ console.log('size = ' + missions.length);
+ console.log('missions = ' + JSON.stringify(missions));
+ let id = missions[0].missionId;
missionManager.clearMission(id).then(() => {
- console.log("clearMission is called ");
+ console.log('clearMission is called ');
});
});
```
@@ -713,15 +676,15 @@ Clears a given mission, regardless of whether it is locked. This API uses a prom
**Example**
```ts
- import missionManager from '@ohos.application.missionManager'
+ import missionManager from '@ohos.application.missionManager';
- var allMissions;
- missionManager.getMissionInfos("",10).then(function(res){
+ let allMissions;
+ missionManager.getMissionInfos('',10).then(function(res){
allMissions=res;
}).catch(function(err){console.log(err);});
- console.log("size = " + allMissions.length);
- console.log("missions = " + JSON.stringify(allMissions));
- var id = allMissions[0].missionId;
+ console.log('size = ' + allMissions.length);
+ console.log('missions = ' + JSON.stringify(allMissions));
+ let id = allMissions[0].missionId;
missionManager.clearMission(id).catch(function (err){
console.log(err);
@@ -744,10 +707,10 @@ Clears all unlocked missions. This API uses an asynchronous callback to return t
**Example**
```ts
- import missionManager from '@ohos.application.missionManager'
+ import missionManager from '@ohos.application.missionManager';
missionManager.clearAllMissions().then(() => {
- console.log("clearAllMissions is called ");
+ console.log('clearAllMissions is called ');
});
```
@@ -773,7 +736,7 @@ Clears all unlocked missions. This API uses a promise to return the result.
**Example**
```ts
- import missionManager from '@ohos.application.missionManager'
+ import missionManager from '@ohos.application.missionManager';
missionManager.clearAllMissions().catch(function (err){
console.log(err);
});
@@ -802,20 +765,16 @@ Switches a given mission to the foreground. This API uses an asynchronous callba
**Example**
```ts
- import missionManager from '@ohos.application.missionManager'
+ import missionManager from '@ohos.application.missionManager';
- missionManager.getMissionInfos("", 10, (error, missions) => {
- if (error.code) {
- console.log("getMissionInfos failed, error.code:" + JSON.stringify(error.code) +
- "error.message:" + JSON.stringify(error.message));
- return;
- }
- console.log("size = " + missions.length);
- console.log("missions = " + JSON.stringify(missions));
- var id = missions[0].missionId;
+ missionManager.getMissionInfos('', 10, (error, missions) => {
+ console.log('getMissionInfos is called, error.code = ' + error.code);
+ console.log('size = ' + missions.length);
+ console.log('missions = ' + JSON.stringify(missions));
+ let id = missions[0].missionId;
missionManager.moveMissionToFront(id).then(() => {
- console.log("moveMissionToFront is called ");
+ console.log('moveMissionToFront is called ');
});
});
```
@@ -838,26 +797,22 @@ Switches a given mission to the foreground, with the startup parameters for the
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| missionId | number | Yes| Mission ID.|
- | options | [StartOptions](js-apis-application-startOptions.md) | Yes| Startup parameters, which are used to specify the window mode and device ID for switching the mission to the foreground.|
+ | options | [StartOptions](js-apis-app-ability-startOptions.md) | Yes| Startup parameters, which are used to specify the window mode and device ID for switching the mission to the foreground.|
| callback | AsyncCallback<void> | Yes| Callback used to return the result.|
**Example**
```ts
- import missionManager from '@ohos.application.missionManager'
+ import missionManager from '@ohos.application.missionManager';
- missionManager.getMissionInfos("", 10, (error, missions) => {
- if (error.code) {
- console.log("getMissionInfos failed, error.code:" + JSON.stringify(error.code) +
- "error.message:" + JSON.stringify(error.message));
- return;
- }
- console.log("size = " + missions.length);
- console.log("missions = " + JSON.stringify(missions));
- var id = missions[0].missionId;
+ missionManager.getMissionInfos('', 10, (error, missions) => {
+ console.log('getMissionInfos is called, error.code = ' + error.code);
+ console.log('size = ' + missions.length);
+ console.log('missions = ' + JSON.stringify(missions));
+ let id = missions[0].missionId;
missionManager.moveMissionToFront(id,{windowMode : 101}).then(() => {
- console.log("moveMissionToFront is called ");
+ console.log('moveMissionToFront is called ');
});
});
```
@@ -880,7 +835,7 @@ Switches a given mission to the foreground, with the startup parameters for the
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| missionId | number | Yes| Mission ID.|
- | options | [StartOptions](js-apis-application-startOptions.md) | No| Startup parameters, which are used to specify the window mode and device ID for switching the mission to the foreground.|
+ | options | [StartOptions](js-apis-app-ability-startOptions.md) | No| Startup parameters, which are used to specify the window mode and device ID for switching the mission to the foreground.|
**Return value**
@@ -891,15 +846,15 @@ Switches a given mission to the foreground, with the startup parameters for the
**Example**
```ts
- import missionManager from '@ohos.application.missionManager'
+ import missionManager from '@ohos.application.missionManager';
- var allMissions;
- missionManager.getMissionInfos("",10).then(function(res){
+ let allMissions;
+ missionManager.getMissionInfos('',10).then(function(res){
allMissions=res;
}).catch(function(err){console.log(err);});
- console.log("size = " + allMissions.length);
- console.log("missions = " + JSON.stringify(allMissions));
- var id = allMissions[0].missionId;
+ console.log('size = ' + allMissions.length);
+ console.log('missions = ' + JSON.stringify(allMissions));
+ let id = allMissions[0].missionId;
missionManager.moveMissionToFront(id).catch(function (err){
console.log(err);
diff --git a/en/application-dev/reference/apis/js-apis-application-staticSubscriberExtensionAbility.md b/en/application-dev/reference/apis/js-apis-application-staticSubscriberExtensionAbility.md
index 5fc9b0999940310b10bf7b4e7227d5651153eb50..d83e3e55f645b38303b2d4252e60ce2181f54099 100644
--- a/en/application-dev/reference/apis/js-apis-application-staticSubscriberExtensionAbility.md
+++ b/en/application-dev/reference/apis/js-apis-application-staticSubscriberExtensionAbility.md
@@ -10,7 +10,7 @@ The **StaticSubscriberExtensionAbility** module provides Extension abilities for
## Modules to Import
```ts
-import StaticSubscriberExtensionAbility from '@ohos.application.StaticSubscriberExtensionAbility'
+import StaticSubscriberExtensionAbility from '@ohos.application.StaticSubscriberExtensionAbility';
```
## StaticSubscriberExtensionAbility.onReceiveEvent
@@ -27,17 +27,14 @@ Callback of the common event of a static subscriber.
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
-| event | [CommonEventData](js-apis-commonEventManager.md#commoneventdata) | Yes| Common event of a static subscriber.|
+| event | [CommonEventData](js-apis-commonEvent.md#commoneventdata) | Yes| Common event of a static subscriber.|
**Example**
```ts
- var StaticSubscriberExtensionAbility = requireNapi("application.StaticSubscriberExtensionAbility")
- {
- onReceiveEvent(event){
- console.log('onReceiveEvent,event:' + event.code);
- }
- }
- export default MyStaticSubscriberExtensionAbility
-
+ class MyStaticSubscriberExtensionAbility extends StaticSubscriberExtensionAbility {
+ onReceiveEvent(event) {
+ console.log('onReceiveEvent, event: ' + JSON.stringify(event));
+ }
+ }
```
diff --git a/en/application-dev/reference/apis/js-apis-application-testRunner.md b/en/application-dev/reference/apis/js-apis-application-testRunner.md
index d2146524c0c5249374e21c95762438d35dc48c35..34d272091725be3a4086b6df466f02f4aff38e7c 100644
--- a/en/application-dev/reference/apis/js-apis-application-testRunner.md
+++ b/en/application-dev/reference/apis/js-apis-application-testRunner.md
@@ -11,7 +11,7 @@ To implement your own unit test framework, extend this class and override its AP
## Modules to Import
```ts
-import TestRunner from '@ohos.application.testRunner'
+import TestRunner from '@ohos.application.testRunner';
```
## TestRunner.onPrepare
@@ -27,7 +27,7 @@ Prepares the unit test environment to run test cases.
```ts
export default class UserTestRunner implements TestRunner {
onPrepare() {
- console.log("Trigger onPrepare")
+ console.log('Trigger onPrepare');
}
onRun() {}
};
@@ -49,7 +49,7 @@ Runs test cases.
export default class UserTestRunner implements TestRunner {
onPrepare() {}
onRun() {
- console.log("Trigger onRun")
+ console.log('Trigger onRun');
}
};
```
diff --git a/en/application-dev/reference/apis/js-apis-application-want.md b/en/application-dev/reference/apis/js-apis-application-want.md
index 44cc01a00c5057488b45a5a6a38cc02adbf1cbc2..bb546edc8038717b5f2f29208f5e864cbac7f338 100644
--- a/en/application-dev/reference/apis/js-apis-application-want.md
+++ b/en/application-dev/reference/apis/js-apis-application-want.md
@@ -4,7 +4,7 @@ Want is a carrier for information transfer between objects (application componen
> **NOTE**
>
-> The APIs of this module are supported since API version 8 and deprecated since API version 9. You are advised to use [Want](js-apis-app-ability-want.md) instead. Newly added APIs will be marked with a superscript to indicate their earliest API version.
+> The APIs of this module are supported since API version 8 and deprecated since API version 9. You are advised to use [@ohos.app.ability.Want](js-apis-app-ability-want.md) instead. Newly added APIs will be marked with a superscript to indicate their earliest API version.
## Modules to Import
@@ -18,119 +18,117 @@ import Want from '@ohos.application.Want';
| Name | Type | Mandatory| Description |
| ----------- | -------------------- | ---- | ------------------------------------------------------------ |
-| deviceId | string | No | ID of the device running the ability. If this field is unspecified, the local device is used. |
-| bundleName | string | No | Bundle name.|
+| deviceId | string | No | ID of the device running the ability. |
+| bundleName | string | No | Bundle name. If both **bundleName** and **abilityName** are specified in a bWantb, the **Want** can directly match the specified ability.|
| abilityName | string | No | Name of the ability. If both **bundleName** and **abilityName** are specified in a **Want** object, the **Want** object can match a specific ability. The value of **abilityName** must be unique in an application.|
| uri | string | No | URI information to match. If **uri** is specified in a **Want** object, the **Want** object will match the specified URI information, including **scheme**, **schemeSpecificPart**, **authority**, and **path**.|
-| type | string | No | MIME type, that is, the type of the file to open, for example, **text/xml** and **image/***. For details about the MIME type definition, see https://www.iana.org/assignments/media-types/media-types.xhtml?utm_source=ld246.com. |
+| type | string | No | MIME type, that is, the type of the file to open, for example, **'text/xml'** and **'image/*'**. For details about the MIME type definition, see https://www.iana.org/assignments/media-types/media-types.xhtml?utm_source=ld246.com. |
| flags | number | No | How the **Want** object will be handled. By default, numbers are passed in. For details, see [flags](js-apis-ability-wantConstant.md#wantConstant.Flags).|
-| action | string | No | Action to take, such as viewing and sharing application details. In implicit **Want**, you can define this attribute and use it together with **uri** or **parameters** to specify the operation to be performed on the data. For details, see [action](js-apis-app-ability-wantConstant.md#wantConstant.Action). For details about the definition and matching rules of implicit Want, see [Matching Rules of Explicit Want and Implicit Want](application-models/explicit-implicit-want-mappings.md). |
-| parameters | {[key: string]: any} | No | Want parameters in the form of custom key-value (KV) pairs. By default, the following keys are carried:
**ohos.aafwk.callerPid**: PID of the caller.
**ohos.aafwk.param.callerToken**: token of the caller.
**ohos.aafwk.param.callerUid**: UID in [bundleInfo](js-apis-bundle-BundleInfo.md#bundleinfo-1), that is, the application UID in the bundle information. |
-| entities | Array\ | No | Additional category information (such as browser and video player) of the ability. It is a supplement to the **action** field for implicit Want. and is used to filter ability types. For details, see [entity](js-apis-app-ability-wantConstant.md#wantConstant.Entity). |
+| action | string | No | Action to take, such as viewing and sharing application details. In implicit **Want**, you can define this attribute and use it together with **uri** or **parameters** to specify the operation to be performed on the data. |
+| parameters | {[key: string]: any} | No | Want parameters in the form of custom key-value (KV) pairs. By default, the following keys are carried:
- **ohos.aafwk.callerPid**: PID of the caller.
- **ohos.aafwk.param.callerToken**: token of the caller.
- **ohos.aafwk.param.callerUid**: UID in [bundleInfo](js-apis-bundle-BundleInfo.md#bundleinfo-1), that is, the application UID in the bundle information.
- **component.startup.newRules**: whether to enable the new control rule.
- **moduleName**: module name of the caller. No matter what this field is set to, the correct module name will be sent to the peer.
- **ohos.dlp.params.sandbox**: available only for DLP files. |
+| entities | Array\ | No | Additional category information (such as browser and video player) of the ability. It is a supplement to the **action** field for implicit Want. and is used to filter ability types. |
| moduleName9+ | string | No | Module to which the ability belongs.|
**Example**
-- Basic usage (called in a UIAbility object, where context in the example is the context object of the UIAbility).
+- Basic usage
```ts
let want = {
- "deviceId": "", // An empty deviceId indicates the local device.
- "bundleName": "com.example.myapplication",
- "abilityName": "EntryAbility",
- "moduleName": "entry" // moduleName is optional.
+ 'deviceId': '', // An empty deviceId indicates the local device.
+ 'bundleName': 'com.extreme.test',
+ 'abilityName': 'MainAbility',
+ 'moduleName': 'entry' // moduleName is optional.
};
this.context.startAbility(want, (error) => {
// Start an ability explicitly. The bundleName, abilityName, and moduleName parameters work together to uniquely identify an ability.
- console.log("error.code = " + error.code)
- })
+ console.log('error.code = ' + error.code)
+ });
```
-- Data is transferred through user-defined fields. The following data types are supported (called in a UIAbility object, where context in the example is the context object of the UIAbility):
+- Data is transferred through user-defined fields. The following data types are supported:
* String
```ts
let want = {
- bundleName: "com.example.myapplication",
- abilityName: "EntryAbility",
+ bundleName: 'com.example.demo',
+ abilityName: 'com.example.demo.MainAbility',
parameters: {
- keyForString: "str",
+ keyForString: 'str',
},
- }
+ };
```
* Number
```ts
let want = {
- bundleName: "com.example.myapplication",
- abilityName: "EntryAbility",
+ bundleName: 'com.example.demo',
+ abilityName: 'com.example.demo.MainAbility',
parameters: {
keyForInt: 100,
keyForDouble: 99.99,
},
- }
+ };
```
* Boolean
```ts
let want = {
- bundleName: "com.example.myapplication",
- abilityName: "EntryAbility",
+ bundleName: 'com.example.demo',
+ abilityName: 'com.example.demo.MainAbility',
parameters: {
keyForBool: true,
},
- }
+ };
```
* Object
```ts
let want = {
- bundleName: "com.example.myapplication",
- abilityName: "EntryAbility",
+ bundleName: 'com.example.demo',
+ abilityName: 'com.example.demo.MainAbility',
parameters: {
keyForObject: {
- keyForObjectString: "str",
+ keyForObjectString: 'str',
keyForObjectInt: -200,
keyForObjectDouble: 35.5,
keyForObjectBool: false,
},
},
- }
+ };
```
* Array
```ts
let want = {
- bundleName: "com.example.myapplication",
- abilityName: "EntryAbility",
+ bundleName: 'com.example.demo',
+ abilityName: 'com.example.demo.MainAbility',
parameters: {
- keyForArrayString: ["str1", "str2", "str3"],
+ keyForArrayString: ['str1', 'str2', 'str3'],
keyForArrayInt: [100, 200, 300, 400],
keyForArrayDouble: [0.1, 0.2],
- keyForArrayObject: [{obj1: "aaa"}, {obj2: 100}],
+ keyForArrayObject: [{obj1: 'aaa'}, {obj2: 100}],
},
- }
+ };
```
* File descriptor (FD)
```ts
import fileio from '@ohos.fileio';
let fd;
try {
- fd = fileio.openSync("/data/storage/el2/base/haps/pic.png");
+ fd = fileio.openSync('/data/storage/el2/base/haps/pic.png');
} catch(e) {
- console.log("openSync fail:" + JSON.stringify(e));
+ console.log('openSync fail:' + JSON.stringify(e));
}
let want = {
- "deviceId": "", // An empty deviceId indicates the local device.
- "bundleName": "com.example.myapplication",
- "abilityName": "EntryAbility",
- "moduleName": "entry", // moduleName is optional.
- "parameters": {
- "keyFd":{"type":"FD", "value":fd}
+ 'deviceId': '', // An empty deviceId indicates the local device.
+ 'bundleName': 'com.extreme.test',
+ 'abilityName': 'MainAbility',
+ 'moduleName': 'entry', // moduleName is optional.
+ 'parameters': {
+ 'keyFd':{'type':'FD', 'value':fd}
}
};
this.context.startAbility(want, (error) => {
// Start an ability explicitly. The bundleName, abilityName, and moduleName parameters work together to uniquely identify an ability.
- console.log("error.code = " + error.code)
- })
+ console.log('error.code = ' + error.code)
+ });
```
-- For more details and examples, see [Want](../../application-models/want-overview.md).
-
diff --git a/en/application-dev/reference/apis/js-apis-application-windowExtensionAbility.md b/en/application-dev/reference/apis/js-apis-application-windowExtensionAbility.md
index bd6d74bbcbbdb4b0d29ccad209b012a11f44c9af..535de4e3f89582b94b486e65aac69e301524d285 100644
--- a/en/application-dev/reference/apis/js-apis-application-windowExtensionAbility.md
+++ b/en/application-dev/reference/apis/js-apis-application-windowExtensionAbility.md
@@ -5,7 +5,7 @@
> **NOTE**
>
> The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version.
->
+>
> The APIs provided by this module are system APIs.
>
> The APIs of this module can be used only in the stage model.
@@ -22,7 +22,7 @@ import WindowExtensionAbility from '@ohos.application.WindowExtensionAbility';
| Name | Type| Readable| Writable| Description |
| --------- | -------- | ---- | ---- | ------------------------- |
-| context | [ExtensionContext](js-apis-inner-application-extensionContext.md) | Yes | No | Context of an Extension ability. |
+| context | [WindowExtensionContext](js-apis-inner-application-windowExtensionContext.md) | Yes | No | Context of an Extension ability. |
## WindowExtensionAbility.onConnect
@@ -101,9 +101,9 @@ export default class MyWindowExtensionAbility extends WindowExtensionAbility {
window.loadContent('WindowExtAbility/pages/index1').then(() => {
window.getProperties().then((pro) => {
console.log('WindowExtension ' + JSON.stringify(pro));
- })
+ });
window.show();
- })
+ });
}
}
diff --git a/en/application-dev/reference/apis/js-apis-arraylist.md b/en/application-dev/reference/apis/js-apis-arraylist.md
index ebf538d3b5508c1ee26aa77d4db01aa995239c3b..283786a82fd1ce50d7632b9354b99f32ff4419fb 100644
--- a/en/application-dev/reference/apis/js-apis-arraylist.md
+++ b/en/application-dev/reference/apis/js-apis-arraylist.md
@@ -404,11 +404,9 @@ arrayList.add(2);
arrayList.add(4);
arrayList.add(5);
arrayList.add(4);
-arrayList.replaceAllElements((value: number, index: number)=> {
- return value = 2 * value;
-});
-arrayList.replaceAllElements((value: number, index: number) => {
- return value = value - 2;
+arrayList.replaceAllElements((value) => {
+ // Add the user operation logic based on the actual scenario.
+ return value;
});
```
@@ -453,7 +451,7 @@ arrayList.add(4);
arrayList.add(5);
arrayList.add(4);
arrayList.forEach((value, index) => {
- console.log(`value:${value}`, index);
+ console.log("value:" + value, "index:" + index);
});
```
@@ -796,14 +794,14 @@ arrayList.add(4);
// Method 1:
for (let item of arrayList) {
- console.log(`value:${item}`);
+ console.log(`value:${item}`);
}
// Method 2:
let iter = arrayList[Symbol.iterator]();
let temp = iter.next().value;
while(temp != undefined) {
- console.log(`value:${temp}`);
- temp = iter.next().value;
+ console.log(`value:${temp}`);
+ temp = iter.next().value;
}
```
diff --git a/en/application-dev/reference/apis/js-apis-audio.md b/en/application-dev/reference/apis/js-apis-audio.md
index a992de969d6b6e673b89eff8f14f28f5328ce017..0f4e0f79339043054cd47b5e76e58752012fd48f 100644
--- a/en/application-dev/reference/apis/js-apis-audio.md
+++ b/en/application-dev/reference/apis/js-apis-audio.md
@@ -75,7 +75,7 @@ Creates an **AudioRenderer** instance. This API uses an asynchronous callback to
```js
import featureAbility from '@ohos.ability.featureAbility';
-import fileio from '@ohos.fileio';
+import fs from '@ohos.file.fs';
import audio from '@ohos.multimedia.audio';
let audioStreamInfo = {
@@ -130,7 +130,7 @@ Creates an **AudioRenderer** instance. This API uses a promise to return the res
```js
import featureAbility from '@ohos.ability.featureAbility';
-import fileio from '@ohos.fileio';
+import fs from '@ohos.file.fs';
import audio from '@ohos.multimedia.audio';
let audioStreamInfo = {
@@ -457,7 +457,7 @@ Enumerates the audio sample formats.
| SAMPLE_FORMAT_S16LE | 1 | Signed 16-bit integer, little endian.|
| SAMPLE_FORMAT_S24LE | 2 | Signed 24-bit integer, little endian.
Due to system restrictions, only some devices support this sampling format.|
| SAMPLE_FORMAT_S32LE | 3 | Signed 32-bit integer, little endian.
Due to system restrictions, only some devices support this sampling format.|
-| SAMPLE_FORMAT_F32LE9+ | 4 | Signed 32-bit integer, little endian.
Due to system restrictions, only some devices support this sampling format.|
+| SAMPLE_FORMAT_F32LE9+ | 4 | Signed 32-bit floating point number, little endian.
Due to system restrictions, only some devices support this sampling format.|
## AudioErrors9+
@@ -529,7 +529,7 @@ Enumerates the audio content types.
| CONTENT_TYPE_SPEECH | 1 | Speech. |
| CONTENT_TYPE_MUSIC | 2 | Music. |
| CONTENT_TYPE_MOVIE | 3 | Movie. |
-| CONTENT_TYPE_SONIFICATION | 4 | Sonification content.|
+| CONTENT_TYPE_SONIFICATION | 4 | Notification tone. |
| CONTENT_TYPE_RINGTONE8+ | 5 | Ringtone. |
## StreamUsage
@@ -1757,7 +1757,7 @@ Sets a device to the active state. This API uses an asynchronous callback to ret
| Name | Type | Mandatory| Description |
| ---------- | ------------------------------------- | ---- | ------------------------ |
-| deviceType | [ActiveDeviceType](#activedevicetypedeprecated) | Yes | Audio device type. |
+| deviceType | [ActiveDeviceType](#activedevicetypedeprecated) | Yes | Active audio device type. |
| active | boolean | Yes | Active state to set. The value **true** means to set the device to the active state, and **false** means the opposite. |
| callback | AsyncCallback<void> | Yes | Callback used to return the result.|
@@ -1789,7 +1789,7 @@ Sets a device to the active state. This API uses a promise to return the result.
| Name | Type | Mandatory| Description |
| ---------- | ------------------------------------- | ---- | ------------------ |
-| deviceType | [ActiveDeviceType](#activedevicetypedeprecated) | Yes | Audio device type.|
+| deviceType | [ActiveDeviceType](#activedevicetypedeprecated) | Yes | Active audio device type. |
| active | boolean | Yes | Active state to set. The value **true** means to set the device to the active state, and **false** means the opposite. |
**Return value**
@@ -1823,7 +1823,7 @@ Checks whether a device is active. This API uses an asynchronous callback to ret
| Name | Type | Mandatory| Description |
| ---------- | ------------------------------------- | ---- | ------------------------ |
-| deviceType | [ActiveDeviceType](#activedevicetypedeprecated) | Yes | Audio device type. |
+| deviceType | [ActiveDeviceType](#activedevicetypedeprecated) | Yes | Active audio device type. |
| callback | AsyncCallback<boolean> | Yes | Callback used to return the active state of the device.|
**Example**
@@ -1854,7 +1854,7 @@ Checks whether a device is active. This API uses a promise to return the result.
| Name | Type | Mandatory| Description |
| ---------- | ------------------------------------- | ---- | ------------------ |
-| deviceType | [ActiveDeviceType](#activedevicetypedeprecated) | Yes | Audio device type.|
+| deviceType | [ActiveDeviceType](#activedevicetypedeprecated) | Yes | Active audio device type. |
**Return value**
@@ -3950,6 +3950,7 @@ Describes the audio renderer change event.
**Example**
```js
+
import audio from '@ohos.multimedia.audio';
const audioManager = audio.getAudioManager();
@@ -4054,7 +4055,7 @@ Describes an audio device.
| ----------------------------- | ------------------------- | -------- | -------- | ------------------------------------------------------------ |
| deviceRole | [DeviceRole](#devicerole) | Yes | No | Device role. |
| deviceType | [DeviceType](#devicetype) | Yes | No | Device type. |
-| id9+ | number | Yes | No | Device ID. |
+| id9+ | number | Yes | No | Device ID, which is unique. |
| name9+ | string | Yes | No | Device name. |
| address9+ | string | Yes | No | Device address. |
| sampleRates9+ | Array<number> | Yes | No | Supported sampling rates. |
@@ -4234,7 +4235,6 @@ audioRenderer.getStreamInfo().then((streamInfo) => {
}).catch((err) => {
console.error(`ERROR: ${err}`);
});
-
```
### getAudioStreamId9+
@@ -4257,7 +4257,6 @@ Obtains the stream ID of this **AudioRenderer** instance. This API uses an async
audioRenderer.getAudioStreamId((err, streamid) => {
console.info(`Renderer GetStreamId: ${streamid}`);
});
-
```
### getAudioStreamId9+
@@ -4282,7 +4281,6 @@ audioRenderer.getAudioStreamId().then((streamid) => {
}).catch((err) => {
console.error(`ERROR: ${err}`);
});
-
```
### start8+
@@ -4309,7 +4307,6 @@ audioRenderer.start((err) => {
console.info('Renderer start success.');
}
});
-
```
### start8+
@@ -4334,7 +4331,6 @@ audioRenderer.start().then(() => {
}).catch((err) => {
console.error(`ERROR: ${err}`);
});
-
```
### pause8+
@@ -4361,7 +4357,6 @@ audioRenderer.pause((err) => {
console.info('Renderer paused.');
}
});
-
```
### pause8+
@@ -4386,7 +4381,6 @@ audioRenderer.pause().then(() => {
}).catch((err) => {
console.error(`ERROR: ${err}`);
});
-
```
### drain8+
@@ -4413,7 +4407,6 @@ audioRenderer.drain((err) => {
console.info('Renderer drained.');
}
});
-
```
### drain8+
@@ -4438,7 +4431,6 @@ audioRenderer.drain().then(() => {
}).catch((err) => {
console.error(`ERROR: ${err}`);
});
-
```
### stop8+
@@ -4465,7 +4457,6 @@ audioRenderer.stop((err) => {
console.info('Renderer stopped.');
}
});
-
```
### stop8+
@@ -4490,7 +4481,6 @@ audioRenderer.stop().then(() => {
}).catch((err) => {
console.error(`ERROR: ${err}`);
});
-
```
### release8+
@@ -4517,7 +4507,6 @@ audioRenderer.release((err) => {
console.info('Renderer released.');
}
});
-
```
### release8+
@@ -4542,7 +4531,6 @@ audioRenderer.release().then(() => {
}).catch((err) => {
console.error(`ERROR: ${err}`);
});
-
```
### write8+
@@ -4577,17 +4565,26 @@ async function getCacheDir(){
path = await context.getCacheDir();
}
let filePath = path + '/StarWars10s-2C-48000-4SW.wav';
-let ss = fileio.createStreamSync(filePath, 'r');
+let file = fs.openSync(filePath, fs.OpenMode.READ_ONLY);
+let stat = await fs.stat(path);
let buf = new ArrayBuffer(bufferSize);
-ss.readSync(buf);
-audioRenderer.write(buf, (err, writtenbytes) => {
- if (writtenbytes < 0) {
- console.error('write failed.');
- } else {
- console.info(`Actual written bytes: ${writtenbytes}`);
- }
-});
-
+let len = stat.size % this.bufferSize == 0 ? Math.floor(stat.size / this.bufferSize) : Math.floor(stat.size / this.bufferSize + 1);
+for (let i = 0;i < len; i++) {
+ let options = {
+ offset: i * this.bufferSize,
+ length: this.bufferSize
+ }
+ let readsize = await fs.read(file.fd, buf, options)
+ let writeSize = await new Promise((resolve,reject)=>{
+ this.audioRenderer.write(buf,(err,writeSize)=>{
+ if(err){
+ reject(err)
+ }else{
+ resolve(writeSize)
+ }
+ })
+ })
+}
```
### write8+
@@ -4621,19 +4618,22 @@ async function getCacheDir(){
path = await context.getCacheDir();
}
let filePath = path + '/StarWars10s-2C-48000-4SW.wav';
-let ss = fileio.createStreamSync(filePath, 'r');
+let file = fs.openSync(filePath, fs.OpenMode.READ_ONLY);
+let stat = await fs.stat(path);
let buf = new ArrayBuffer(bufferSize);
-ss.readSync(buf);
-audioRenderer.write(buf).then((writtenbytes) => {
- if (writtenbytes < 0) {
- console.error('write failed.');
- } else {
- console.info(`Actual written bytes: ${writtenbytes}`);
- }
-}).catch((err) => {
- console.error(`ERROR: ${err}`);
-});
-
+let len = stat.size % this.bufferSize == 0 ? Math.floor(stat.size / this.bufferSize) : Math.floor(stat.size / this.bufferSize + 1);
+for (let i = 0;i < len; i++) {
+ let options = {
+ offset: i * this.bufferSize,
+ length: this.bufferSize
+ }
+ let readsize = await fs.read(file.fd, buf, options)
+ try{
+ let writeSize = await this.audioRenderer.write(buf);
+ } catch(err) {
+ console.error(`audioRenderer.write err: ${err}`);
+ }
+}
```
### getAudioTime8+
@@ -4656,7 +4656,6 @@ Obtains the number of nanoseconds elapsed from the Unix epoch (January 1, 1970).
audioRenderer.getAudioTime((err, timestamp) => {
console.info(`Current timestamp: ${timestamp}`);
});
-
```
### getAudioTime8+
@@ -4681,7 +4680,6 @@ audioRenderer.getAudioTime().then((timestamp) => {
}).catch((err) => {
console.error(`ERROR: ${err}`);
});
-
```
### getBufferSize8+
@@ -4706,7 +4704,6 @@ let bufferSize = audioRenderer.getBufferSize(async(err, bufferSize) => {
console.error('getBufferSize error');
}
});
-
```
### getBufferSize8+
@@ -4733,7 +4730,6 @@ audioRenderer.getBufferSize().then((data) => {
}).catch((err) => {
console.error(`AudioFrameworkRenderLog: getBufferSize: ERROR: ${err}`);
});
-
```
### setRenderRate8+
@@ -4761,7 +4757,6 @@ audioRenderer.setRenderRate(audio.AudioRendererRate.RENDER_RATE_NORMAL, (err) =>
console.info('Callback invoked to indicate a successful render rate setting.');
}
});
-
```
### setRenderRate8+
@@ -4792,7 +4787,6 @@ audioRenderer.setRenderRate(audio.AudioRendererRate.RENDER_RATE_NORMAL).then(()
}).catch((err) => {
console.error(`ERROR: ${err}`);
});
-
```
### getRenderRate8+
@@ -4815,7 +4809,6 @@ Obtains the current render rate. This API uses an asynchronous callback to retur
audioRenderer.getRenderRate((err, renderrate) => {
console.info(`getRenderRate: ${renderrate}`);
});
-
```
### getRenderRate8+
@@ -4840,9 +4833,7 @@ audioRenderer.getRenderRate().then((renderRate) => {
}).catch((err) => {
console.error(`ERROR: ${err}`);
});
-
```
-
### setInterruptMode9+
setInterruptMode(mode: InterruptMode): Promise<void>
@@ -4872,9 +4863,7 @@ audioRenderer.setInterruptMode(mode).then(data=>{
}).catch((err) => {
console.error(`setInterruptMode Fail: ${err}`);
});
-
```
-
### setInterruptMode9+
setInterruptMode(mode: InterruptMode, callback: AsyncCallback\): void
@@ -4900,7 +4889,6 @@ audioRenderer.setInterruptMode(mode, (err, data)=>{
}
console.info('setInterruptMode Success!');
});
-
```
### setVolume9+
@@ -4931,9 +4919,7 @@ audioRenderer.setVolume(0.5).then(data=>{
}).catch((err) => {
console.error(`setVolume Fail: ${err}`);
});
-
```
-
### setVolume9+
setVolume(volume: number, callback: AsyncCallback\): void
@@ -4958,7 +4944,6 @@ audioRenderer.setVolume(0.5, (err, data)=>{
}
console.info('setVolume Success!');
});
-
```
### on('audioInterrupt')9+
@@ -5038,7 +5023,6 @@ async function onAudioInterrupt(){
}
});
}
-
```
### on('markReach')8+
@@ -5065,7 +5049,6 @@ audioRenderer.on('markReach', 1000, (position) => {
console.info('ON Triggered successfully');
}
});
-
```
@@ -5087,7 +5070,6 @@ Unsubscribes from mark reached events.
```js
audioRenderer.off('markReach');
-
```
### on('periodReach') 8+
@@ -5114,7 +5096,6 @@ audioRenderer.on('periodReach', 1000, (position) => {
console.info('ON Triggered successfully');
}
});
-
```
### off('periodReach') 8+
@@ -5135,10 +5116,9 @@ Unsubscribes from period reached events.
```js
audioRenderer.off('periodReach')
-
```
-### on('stateChange')8+
+### on('stateChange') 8+
on(type: 'stateChange', callback: Callback): void
@@ -5164,7 +5144,6 @@ audioRenderer.on('stateChange', (state) => {
console.info('audio renderer state is: STATE_RUNNING');
}
});
-
```
## AudioCapturer8+
@@ -5183,7 +5162,6 @@ Provides APIs for audio capture. Before calling any API in **AudioCapturer**, yo
```js
let state = audioCapturer.state;
-
```
### getCapturerInfo8+
@@ -5212,7 +5190,6 @@ audioCapturer.getCapturerInfo((err, capturerInfo) => {
console.info(`Capturer flags: ${capturerInfo.capturerFlags}`);
}
});
-
```
@@ -5245,7 +5222,6 @@ audioCapturer.getCapturerInfo().then((audioParamsGet) => {
}).catch((err) => {
console.error(`AudioFrameworkRecLog: CapturerInfo :ERROR: ${err}`);
});
-
```
### getStreamInfo8+
@@ -5276,7 +5252,6 @@ audioCapturer.getStreamInfo((err, streamInfo) => {
console.info(`Capturer encoding type: ${streamInfo.encodingType}`);
}
});
-
```
### getStreamInfo8+
@@ -5305,7 +5280,6 @@ audioCapturer.getStreamInfo().then((audioParamsGet) => {
}).catch((err) => {
console.error(`getStreamInfo :ERROR: ${err}`);
});
-
```
### getAudioStreamId9+
@@ -5328,7 +5302,6 @@ Obtains the stream ID of this **AudioCapturer** instance. This API uses an async
audioCapturer.getAudioStreamId((err, streamid) => {
console.info(`audioCapturer GetStreamId: ${streamid}`);
});
-
```
### getAudioStreamId9+
@@ -5353,7 +5326,6 @@ audioCapturer.getAudioStreamId().then((streamid) => {
}).catch((err) => {
console.error(`ERROR: ${err}`);
});
-
```
### start8+
@@ -5380,7 +5352,6 @@ audioCapturer.start((err) => {
console.info('Capturer start success.');
}
});
-
```
@@ -5412,7 +5383,6 @@ audioCapturer.start().then(() => {
}).catch((err) => {
console.info(`AudioFrameworkRecLog: Capturer start :ERROR : ${err}`);
});
-
```
### stop8+
@@ -5439,7 +5409,6 @@ audioCapturer.stop((err) => {
console.info('Capturer stopped.');
}
});
-
```
@@ -5469,7 +5438,6 @@ audioCapturer.stop().then(() => {
}).catch((err) => {
console.info(`AudioFrameworkRecLog: Capturer stop: ERROR: ${err}`);
});
-
```
### release8+
@@ -5496,7 +5464,6 @@ audioCapturer.release((err) => {
console.info('capturer released.');
}
});
-
```
@@ -5526,7 +5493,6 @@ audioCapturer.release().then(() => {
}).catch((err) => {
console.info(`AudioFrameworkRecLog: Capturer stop: ERROR: ${err}`);
});
-
```
### read8+
@@ -5560,7 +5526,6 @@ audioCapturer.read(bufferSize, true, async(err, buffer) => {
console.info('Success in reading the buffer data');
}
});
-
```
### read8+
@@ -5600,7 +5565,6 @@ audioCapturer.read(bufferSize, true).then((buffer) => {
}).catch((err) => {
console.info(`ERROR : ${err}`);
});
-
```
### getAudioTime8+
@@ -5623,7 +5587,6 @@ Obtains the number of nanoseconds elapsed from the Unix epoch (January 1, 1970).
audioCapturer.getAudioTime((err, timestamp) => {
console.info(`Current timestamp: ${timestamp}`);
});
-
```
### getAudioTime8+
@@ -5648,7 +5611,6 @@ audioCapturer.getAudioTime().then((audioTime) => {
}).catch((err) => {
console.info(`AudioFrameworkRecLog: AudioCapturer Created : ERROR : ${err}`);
});
-
```
### getBufferSize8+
@@ -5678,7 +5640,6 @@ audioCapturer.getBufferSize((err, bufferSize) => {
});
}
});
-
```
### getBufferSize8+
@@ -5705,7 +5666,6 @@ audioCapturer.getBufferSize().then((data) => {
}).catch((err) => {
console.info(`AudioFrameworkRecLog: getBufferSize :ERROR : ${err}`);
});
-
```
### on('markReach')8+
@@ -5732,7 +5692,6 @@ audioCapturer.on('markReach', 1000, (position) => {
console.info('ON Triggered successfully');
}
});
-
```
### off('markReach')8+
@@ -5753,7 +5712,6 @@ Unsubscribes from mark reached events.
```js
audioCapturer.off('markReach');
-
```
### on('periodReach')8+
@@ -5780,7 +5738,6 @@ audioCapturer.on('periodReach', 1000, (position) => {
console.info('ON Triggered successfully');
}
});
-
```
### off('periodReach')8+
@@ -5801,10 +5758,9 @@ Unsubscribes from period reached events.
```js
audioCapturer.off('periodReach')
-
```
-### on('stateChange')8+
+### on('stateChange') 8+
on(type: 'stateChange', callback: Callback): void
@@ -5830,7 +5786,6 @@ audioCapturer.on('stateChange', (state) => {
console.info('audio capturer state is: STATE_RUNNING');
}
});
-
```
## ToneType9+
@@ -5905,7 +5860,6 @@ tonePlayer.load(audio.ToneType.TONE_TYPE_DIAL_5, (err) => {
console.info('callback call load success');
}
});
-
```
### load9+
@@ -5938,7 +5892,6 @@ tonePlayer.load(audio.ToneType.TONE_TYPE_DIAL_1).then(() => {
}).catch(() => {
console.error('promise call load fail');
});
-
```
### start9+
@@ -5968,7 +5921,6 @@ tonePlayer.start((err) => {
console.info('callback call start success');
}
});
-
```
### start9+
@@ -5995,7 +5947,6 @@ tonePlayer.start().then(() => {
}).catch(() => {
console.error('promise call start fail');
});
-
```
### stop9+
@@ -6025,7 +5976,6 @@ tonePlayer.stop((err) => {
console.error('callback call stop success ');
}
});
-
```
### stop9+
@@ -6052,7 +6002,6 @@ tonePlayer.stop().then(() => {
}).catch(() => {
console.error('promise call stop fail');
});
-
```
### release9+
@@ -6082,7 +6031,6 @@ tonePlayer.release((err) => {
console.info('callback call release success ');
}
});
-
```
### release9+
@@ -6109,7 +6057,6 @@ tonePlayer.release().then(() => {
}).catch(() => {
console.error('promise call release fail');
});
-
```
## ActiveDeviceType(deprecated)
diff --git a/en/application-dev/reference/apis/js-apis-bundleManager-BundlePackInfo.md b/en/application-dev/reference/apis/js-apis-bundleManager-BundlePackInfo.md
new file mode 100644
index 0000000000000000000000000000000000000000..e6fd8bd2c8cd018a0ed0fe0d5cfdb226f542b438
--- /dev/null
+++ b/en/application-dev/reference/apis/js-apis-bundleManager-BundlePackInfo.md
@@ -0,0 +1,146 @@
+# BundlePackInfo
+
+The **BundlePackInfo** module provides information in the **pack.info** file. The information can be obtained using [freeInstall.getBundlePackInfo](js-apis-freeInstall.md).
+
+> **NOTE**
+>
+> The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version.
+
+## BundlePackInfo
+
+**System API**: This is a system API.
+
+**System capability**: SystemCapability.BundleManager.BundleFrameWork.FreeInstall
+
+
+| Name | Type | Readable| Writable| Description |
+| -------- | --------------------------------------- | ---- | ---- | ------------------------- |
+| packages | Array\<[PackageConfig](#packageconfig)> | Yes | No | Package configuration information in the **pack.info** file. |
+| summary | [PackageSummary](#packagesummary) | Yes | No | Package summary information in the **pack.info** file.|
+
+## PackageConfig
+
+**System API**: This is a system API.
+
+**System capability**: SystemCapability.BundleManager.BundleFrameWork.FreeInstall
+
+| Name | Type | Readable| Writable| Description |
+| ------------------- | -------------- | ---- | ---- | ------------------------------------------------------------ |
+| deviceTypes | Array\ | Yes | No | Device types supported by the bundle. |
+| name | string | Yes | No | Bundle name. |
+| moduleType | string | Yes | No | Module type of the bundle. |
+| deliveryWithInstall | boolean | Yes | No | Whether the HAP file will be installed when the user installs the bundle. The value **true** means that the HAP file will be automatically installed when the user installs the bundle, and **false** means the opposite.|
+
+## PackageSummary
+
+**System API**: This is a system API.
+
+**System capability**: SystemCapability.BundleManager.BundleFrameWork.FreeInstall
+
+| Name | Type | Readable| Writable| Description |
+| ------- | --------------------------------------------- | ---- | ---- | -------------------- |
+| app | [BundleConfigInfo](#bundleconfiginfo) | Yes | No | Bundle configuration information. |
+| modules | Array\<[ModuleConfigInfo](#moduleconfiginfo)> | Yes | No | Module configuration information of the bundle.|
+
+## BundleConfigInfo
+
+**System API**: This is a system API.
+
+**System capability**: SystemCapability.BundleManager.BundleFrameWork.FreeInstall
+
+| Name | Type | Readable| Writable| Description |
+| ---------- | ------------------- | ---- | ---- | -------------------------------------- |
+| bundleName | string | Yes | No | Bundle name. It uniquely identifies an application.|
+| version | [Version](#version) | Yes | No | Bundle version. |
+
+## ModuleConfigInfo
+
+**System API**: This is a system API.
+
+**System capability**: SystemCapability.BundleManager.BundleFrameWork.FreeInstall
+
+| Name | Type | Readable| Writable| Description |
+| ------------------ | ------------------------------------------------- | ---- | ---- | ---------------------------------- |
+| mainAbility | string | Yes| No| Name of the main ability.|
+| apiVersion | [ApiVersion](#apiversion) | Yes | No | API version of the module. |
+| deviceType | Array\ | Yes | No | Device types supported by the module. |
+| distro | [ModuleDistroInfo](#moduledistroinfo) | Yes | No | Distribution information of the module. |
+| abilities | Array\<[ModuleAbilityInfo](#moduleabilityinfo)> | Yes | No | Ability information of the module. |
+| extensionAbilities | Array\<[ExtensionAbilities](#extensionability)> | Yes | No | ExtensionAbility information of the module.|
+
+## ModuleDistroInfo
+
+**System API**: This is a system API.
+
+**System capability**: SystemCapability.BundleManager.BundleFrameWork.FreeInstall
+
+| Name | Type | Readable| Writable| Description |
+| ------------------- | ------- | ---- | ---- | ------------------------------------------------------------ |
+| deliveryWithInstall | boolean | Yes | No | Whether the HAP file will be installed when the user installs the bundle. The value **true** means that the HAP file will be automatically installed when the user installs the bundle, and **false** means the opposite.|
+| installationFree | boolean | Yes | No | Whether the HAP file supports the installation-free feature. The value **true** means that the HAP file supports the installation-free feature and meets installation-free constraints, and **false** means the opposite.|
+| moduleName | string | Yes | No | Module name. |
+| moduleType | string | Yes | No | Module type. |
+
+## ModuleAbilityInfo
+
+**System API**: This is a system API.
+
+**System capability**: SystemCapability.BundleManager.BundleFrameWork.FreeInstall
+
+| Name | Type | Readable| Writable| Description |
+| ------- | ------------------------------------------- | ---- | ---- | ------------------------------------------------------------ |
+| name | string | Yes | No | Name of the ability. The name must be unique in the bundle. |
+| label | string | Yes | No | Name of the ability displayed to users. The value is a resource index to names in multiple languages.|
+| exported | boolean | Yes | No | Whether the ability can be called by other bundles. The value **true** means that the ability can be called by other bundles, and **false** means the opposite.|
+| forms | Array\<[AbilityFormInfo](#abilityforminfo)> | Yes | No | Widget information. |
+
+## ExtensionAbility
+
+**System API**: This is a system API.
+
+**System capability**: SystemCapability.BundleManager.BundleFrameWork.FreeInstall
+
+| Name | Type | Readable| Writable| Description |
+| ----- | ------------------------------------------- | ---- | ---- | ------------------------------------------------------------ |
+| name | string | Yes| No| Name of the ExtensionAbility.|
+| forms | Array\<[AbilityFormInfo](#abilityforminfo)> | Yes | No | Widget information.|
+
+## AbilityFormInfo
+
+**System API**: This is a system API.
+
+**System capability**: SystemCapability.BundleManager.BundleFrameWork.FreeInstall
+
+| Name | Type | Readable| Writable| Description |
+| ------------------- | -------------- | ---- | ---- | ------------------------------------------------------------ |
+| name | string | Yes | No | Widget name. |
+| type | string | Yes | No | Widget type. |
+| updateEnabled | boolean | Yes | No | Whether the widget supports periodic update. The value **true** means that the widget supports periodic update, and **false** means the opposite.|
+| scheduledUpdateTime | string | Yes | No | Scheduled time to update the widget. The value is in 24-hour format and accurate to the minute. |
+| updateDuration | number | Yes | No | Interval to update the widget. The unit is 30 minutes. The value is a multiple of 30. A widget can be updated at a specified interval (**updateDuration**) or at the scheduled time (**scheduledUpdateTime**). If both are configured, **updateDuration** takes precedence.|
+| supportDimensions | Array\ | Yes | No | Dimensions of the widget. The value can be **1\*2**, **2\*2**, **2\*4**, **4\*4**, or a combination of these options. At least one option must be specified when defining the widget.|
+| defaultDimension | string | Yes | No | Default dimensions of the widget. The value must be available in the **supportDimensions** array of the widget.|
+
+## ApiVersion
+
+**System API**: This is a system API and cannot be called by third-party applications.
+
+**System capability**: SystemCapability.BundleManager.BundleFrameWork.FreeInstall
+
+| Name | Type | Readable| Writable| Description |
+| ----------- | ------ | ---- | ---- | -------------------- |
+| releaseType | string | Yes | No | Name of the API version. |
+| compatible | number | Yes | No | Minimum API version.|
+| target | number | Yes | No | Target API version. |
+
+## Version
+
+**System API**: This is a system API.
+
+**System capability**: SystemCapability.BundleManager.BundleFrameWork.FreeInstall
+
+| Name | Type | Readable| Writable| Description |
+| ------------------------ | ------ | ---- | ---- | ------------------------------------------------------------ |
+| minCompatibleVersionCode | number | Yes | No | Minimum compatible version of the bundle. It is used to check whether the bundle is compatible with a version on other devices in the cross-device scenario. The value is a 32-bit non-negative integer.|
+| name | string | Yes | No | Version number of the bundle visible to users. |
+| code | number | Yes | No | Version number of the bundle used only for bundle management. The value is a 32-bit non-negative integer. It is used only to determine whether a version is later than another version. A larger value indicates a later version.|
diff --git a/en/application-dev/reference/apis/js-apis-bundleManager-abilityInfo.md b/en/application-dev/reference/apis/js-apis-bundleManager-abilityInfo.md
index cacab28b20157441ee4f64bc69261c7f37f0809f..b15708816fdcaf8293209bcb008e2119979817f3 100644
--- a/en/application-dev/reference/apis/js-apis-bundleManager-abilityInfo.md
+++ b/en/application-dev/reference/apis/js-apis-bundleManager-abilityInfo.md
@@ -22,7 +22,7 @@ The **AbilityInfo** module defines the ability information. A system application
| icon | string | Yes | No | Index of the ability icon resource file. |
| iconId | number | Yes | No | ID of the ability icon. |
| process | string | Yes | No | Process in which the ability runs. If this parameter is not set, the bundle name is used.|
-| isVisible | boolean | Yes | No | Whether the ability can be called by other bundles. |
+| exported | boolean | Yes | No | Whether the ability can be called by other bundles. |
| type | [AbilityType](js-apis-bundleManager.md#abilitytype) | Yes | No | Ability type.
This attribute can be used only in the FA model.|
| orientation | [DisplayOrientation](js-apis-bundleManager.md#displayorientation) | Yes | No | Ability display orientation. |
| launchType | [LaunchType](js-apis-bundleManager.md#launchtype) | Yes | No | Ability launch mode. |
diff --git a/en/application-dev/reference/apis/js-apis-bundleManager-applicationInfo.md b/en/application-dev/reference/apis/js-apis-bundleManager-applicationInfo.md
index d87ee5597f2535ec83113f16775dbd33a7a623ba..8997e94099071ce9b4e806f06b008477352af187 100644
--- a/en/application-dev/reference/apis/js-apis-bundleManager-applicationInfo.md
+++ b/en/application-dev/reference/apis/js-apis-bundleManager-applicationInfo.md
@@ -9,27 +9,26 @@ The **ApplicationInfo** module defines the application information. A system app
## ApplicationInfo
**System capability**: SystemCapability.BundleManager.BundleFramework.Core
-
| Name | Type | Readable| Writable| Description |
| -------------------------- | ------------------------------------------------------------ | ---- | ---- | ------------------------------------------------------------ |
| name | string | Yes | No | Application name. |
-| description | string | Yes | No | Application description. |
+| description | string | Yes | No | Description of the application, for example, "description": $string: mainability_description". |
| descriptionId | number | Yes | No | ID of the application description. |
| enabled | boolean | Yes | No | Whether the application is enabled. The default value is **true**. |
-| label | string | Yes | No | Application label. |
+| label | string | Yes | No | Application name, for example, "label": "$string: mainability_description".|
| labelId | number | Yes | No | ID of the application label. |
-| icon | string | Yes | No | Application icon. |
+| icon | string | Yes | No | Application icon, for example, "icon": "$media:icon". |
| iconId | number | Yes | No | ID of the application icon. |
| process | string | Yes | No | Process in which the application runs. If this parameter is not set, the bundle name is used. |
-| permissions | Array\ | Yes | No | Permissions required for accessing the application. The permissions can be obtained by passing in **GET_APPLICATION_INFO_WITH_PERMISSION** to [bundleManager.getApplicationInfo](js-apis-bundleManager.md#bundlemanagergetapplicationinfo).|
+| permissions | Array\ | Yes | No | Permissions required for accessing the application. The permissions can be obtained by passing in **GET_APPLICATION_INFO_WITH_PERMISSION** to the **appFlags** parameter of [bundleManager.getApplicationInfo](js-apis-bundleManager.md#bundlemanagergetapplicationinfo).|
| codePath | string | Yes | No | Installation directory of the application. |
-| metadata | Map\> | Yes | No | Metadata of the application. The information can be obtained by passing in **GET_APPLICATION_INFO_WITH_METADATA** to [bundleManager.getApplicationInfo](js-apis-bundleManager.md#bundlemanagergetapplicationinfo).|
+| metadata | Map\> | Yes | No | Metadata of the application. The information can be obtained by passing in **GET_APPLICATION_INFO_WITH_METADATA** to the **appFlags** parameter of [bundleManager.getApplicationInfo](js-apis-bundleManager.md#bundlemanagergetapplicationinfo).|
| removable | boolean | Yes | No | Whether the application is removable. |
| accessTokenId | number | Yes | No | Access token ID of the application. |
| uid | number | Yes | No | UID of the application. |
-| iconResource | [Resource](js-apis-resource-manager.md#resource9) | Yes| No| Icon resource of the application. |
-| labelResource | [Resource](js-apis-resource-manager.md#resource9) | Yes| No| Label resource of the application. |
-| descriptionResource | [Resource](js-apis-resource-manager.md#resource9) | Yes| No| Description resource of the application. |
+| iconResource | [Resource](js-apis-resource-manager.md#resource9) | Yes| No| Resource information of the application icon. The resource information obtained contains the bundle name, module name, and ID of the resource. You can call **getMediaContent** in [@ohos.resourceManager.d.ts](https://gitee.com/openharmony/interface_sdk-js/blob/master/api/@ohos.resourceManager.d.ts) to obtain the resource details. |
+| labelResource | [Resource](js-apis-resource-manager.md#resource9) | Yes| No| Resource information of the application label. The resource information obtained contains the bundle name, module name, and ID of the resource. You can call **getMediaContent** in [@ohos.resourceManager.d.ts](https://gitee.com/openharmony/interface_sdk-js/blob/master/api/@ohos.resourceManager.d.ts) to obtain the resource details. |
+| descriptionResource | [Resource](js-apis-resource-manager.md#resource9) | Yes| No| Resource information of the application description. The resource information obtained contains the bundle name, module name, and ID of the resource. You can call **getMediaContent** in [@ohos.resourceManager.d.ts](https://gitee.com/openharmony/interface_sdk-js/blob/master/api/@ohos.resourceManager.d.ts) to obtain the resource details.|
| appDistributionType | string | Yes | No | Distribution type of the application signing certificate. The options are **app_gallery**, **enterprise**, **os_integration**, and **crowdtesting**. |
| appProvisionType | string | Yes | No | Type of the application signing certificate file. The options are **debug** and **release**. |
| systemApp | boolean | Yes | No | Whether the application is a system application. |
diff --git a/en/application-dev/reference/apis/js-apis-bundleManager.md b/en/application-dev/reference/apis/js-apis-bundleManager.md
index cac8e51923b2baf6f18f409f3538199b0bbef86d..1cef53613b8993c775bcaa6f7cef1c927bd43ee3 100644
--- a/en/application-dev/reference/apis/js-apis-bundleManager.md
+++ b/en/application-dev/reference/apis/js-apis-bundleManager.md
@@ -2215,7 +2215,7 @@ try {
### bundleManager.getProfileByAbility
-getProfileByAbility(moduleName: string, abilityName: string, metadataName: string, callback: AsyncCallback>): void;
+getProfileByAbility(moduleName: string, abilityName: string, metadataName: string, callback: AsyncCallback\\>): void;
Obtains the JSON strings of the configuration file based on the given module ame, ability name, and metadata name. This API uses an asynchronous callback to return the result.
@@ -2266,7 +2266,7 @@ try {
### bundleManager.getProfileByAbility
-getProfileByAbility(moduleName: string, abilityName: string, metadataName?: string): Promise>;
+getProfileByAbility(moduleName: string, abilityName: string, metadataName?: string): Promise\\>;
Obtains the JSON strings of the configuration file based on the given module ame, ability name, and metadata name. This API uses a promise to return the result.
@@ -2336,7 +2336,7 @@ try {
### bundleManager.getProfileByExtensionAbility
-getProfileByExtensionAbility(moduleName: string, extensionAbilityName: string, metadataName: string, callback: AsyncCallback>): void;
+getProfileByExtensionAbility(moduleName: string, extensionAbilityName: string, metadataName: string, callback: AsyncCallback\\>): void;
Obtains the JSON strings of the configuration file based on the given module ame, Extension ability name, and metadata name. This API uses an asynchronous callback to return the result.
@@ -2386,7 +2386,7 @@ try {
### bundleManager.getProfileByExtensionAbility
-getProfileByExtensionAbility(moduleName: string, extensionAbilityName: string, metadataName?: string): Promise>;
+getProfileByExtensionAbility(moduleName: string, extensionAbilityName: string, metadataName?: string): Promise\\>;
Obtains the JSON strings of the configuration file based on the given module ame, Extension ability name, and metadata name. This API uses a promise to return the result.
@@ -2658,7 +2658,6 @@ try {
### bundleManager.getApplicationInfoSync
getApplicationInfoSync(bundleName: string, applicationFlags: number, userId: number) : [ApplicationInfo](js-apis-bundleManager-applicationInfo.md);
-getApplicationInfoSync(bundleName: string, applicationFlags: number) : [ApplicationInfo](js-apis-bundleManager-applicationInfo.md);
Synchronously obtains the application information based on the given bundle name, application flags, and user ID.
@@ -2709,6 +2708,42 @@ try {
}
```
+### bundleManager.getApplicationInfoSync
+
+getApplicationInfoSync(bundleName: string, applicationFlags: number) : [ApplicationInfo](js-apis-bundleManager-applicationInfo.md);
+
+Synchronously obtains the application information based on the given bundle name and application flags.
+
+**System API**: This is a system API.
+
+**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO
+
+**System capability**: SystemCapability.BundleManager.BundleFramework.Core
+
+**Parameters**
+
+| Name | Type | Mandatory| Description |
+| ---------------- | -------------------------- | ---- | ----------------------------------------------------- |
+| bundleName | string | Yes | Bundle name. |
+| applicationFlags | [number](#applicationflag) | Yes | Type of the application information to obtain.|
+
+**Return value**
+
+| Type | Description |
+| ----------------------------------------------------------- | ------------------------- |
+| [ApplicationInfo](js-apis-bundleManager-applicationInfo.md) | Application information obtained.|
+
+**Error codes**
+
+For details about the error codes, see [Bundle Error Codes](../errorcodes/errorcode-bundle.md).
+
+| ID| Error Message |
+| -------- | -------------------------------------- |
+| 17700001 | The specified bundleName is not found. |
+| 17700026 | The specified bundle is disabled. |
+
+**Example**
+
```ts
import bundleManager from '@ohos.bundle.bundleManager';
import hilog from '@ohos.hilog';
@@ -2726,7 +2761,6 @@ try {
### bundleManager.getBundleInfoSync
getBundleInfoSync(bundleName: string, bundleFlags: [number](#bundleflag), userId: number): [BundleInfo](js-apis-bundleManager-bundleInfo.md);
-getBundleInfoSync(bundleName: string, bundleFlags: [number](#bundleflag)): [BundleInfo](js-apis-bundleManager-bundleInfo.md);
Synchronously obtains the bundle information based on the given bundle name, bundle flags, and user ID.
@@ -2742,7 +2776,7 @@ Synchronously obtains the bundle information based on the given bundle name, bun
| ----------- | ------ | ---- | -------------------------------------------------------- |
| bundleName | string | Yes | Bundle name. |
| bundleFlags | [number](#bundleflag) | Yes | Type of the bundle information to obtain.|
-| userId | number | No | User ID. |
+| userId | number | Yes | User ID. |
**Return value**
@@ -2777,6 +2811,42 @@ try {
}
```
+### bundleManager.getBundleInfoSync
+
+getBundleInfoSync(bundleName: string, bundleFlags: [number](#bundleflag)): [BundleInfo](js-apis-bundleManager-bundleInfo.md);
+
+Synchronously obtains the bundle information based on the given bundle name and bundle flags.
+
+**System API**: This is a system API.
+
+**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED or ohos.permission.GET_BUNDLE_INFO
+
+**System capability**: SystemCapability.BundleManager.BundleFramework.Core
+
+**Parameters**
+
+| Name | Type | Mandatory| Description |
+| ----------- | --------------------- | ---- | ------------------------------------------------------ |
+| bundleName | string | Yes | Bundle name. |
+| bundleFlags | [number](#bundleflag) | Yes | Type of the bundle information to obtain.|
+
+**Return value**
+
+| Type | Description |
+| ------------------------------------------------- | -------------------- |
+| [BundleInfo](js-apis-bundleManager-bundleInfo.md) | Bundle information obtained.|
+
+**Error codes**
+
+For details about the error codes, see [Bundle Error Codes](../errorcodes/errorcode-bundle.md).
+
+| ID| Error Message |
+| -------- | -------------------------------------- |
+| 17700001 | The specified bundleName is not found. |
+| 17700026 | The specified bundle is disabled. |
+
+**Example**
+
```ts
import bundleManager from '@ohos.bundle.bundleManager';
import hilog from '@ohos.hilog';
@@ -2789,3 +2859,37 @@ try {
hilog.error(0x0000, 'testTag', 'getBundleInfoSync failed: %{public}s', err.message);
}
```
+
+## ModuleType
+
+Enumerates the module types.
+
+ **System capability**: SystemCapability.BundleManager.BundleFramework.Core
+
+| Name | Value | Description |
+| ------- | ---- | -------------------- |
+| ENTRY | 1 | Main module of the application. |
+| FEATURE | 2 | Dynamic feature module of the application.|
+| SHARED | 3 | Dynamic shared library module of the application. |
+
+## BundleType
+
+Enumerates the bundle types.
+
+ **System capability**: SystemCapability.BundleManager.BundleFramework.Core
+
+| Name | Value | Description |
+| -------------- | ---- | --------------- |
+| APP | 0 | The bundle is a common application. |
+| ATOMIC_SERVICE | 1 | The bundle is an atomic service.|
+
+## AtomicServiceModuleType
+
+Enumerates the module types of an atomic service.
+
+ **System capability**: SystemCapability.BundleManager.BundleFramework.Core
+
+| Name | Value | Description |
+| ------ | ---- | --------------------------- |
+| NORMAL | 0 | Page package in the atomic service. |
+| MAIN | 1 | Landing page package in the atomic service.|
diff --git a/en/application-dev/reference/apis/js-apis-bundleMonitor.md b/en/application-dev/reference/apis/js-apis-bundleMonitor.md
index 11f54832d6556e24f35cd1baedee0d9abfe39079..b1601cfc665bc6b96364d9c9508b197137e52746 100644
--- a/en/application-dev/reference/apis/js-apis-bundleMonitor.md
+++ b/en/application-dev/reference/apis/js-apis-bundleMonitor.md
@@ -33,7 +33,7 @@ For details, see [Permission Levels](../../security/accesstoken-overview.md).
## bundleMonitor.on
-on(type: BundleChangedEvent, callback: callback\): void;
+on(type: BundleChangedEvent, callback: Callback\): void;
Subscribes to bundle installation, uninstall, and update events.
@@ -66,7 +66,7 @@ try {
## bundleMonitor.off
-off(type: BundleChangedEvent, callback?: callback\): void;
+off(type: BundleChangedEvent, callback?: Callback\): void;
Unsubscribes from bundle installation, uninstall, and update events.
diff --git a/en/application-dev/reference/apis/js-apis-call.md b/en/application-dev/reference/apis/js-apis-call.md
index 0ccd49a5dc2a8b8e3577b7614f8219573de7cf7d..6b6222abe96a415e28290892f8e6a215c1e98478 100644
--- a/en/application-dev/reference/apis/js-apis-call.md
+++ b/en/application-dev/reference/apis/js-apis-call.md
@@ -4,32 +4,32 @@ The **call** module provides call management functions, including making calls,
To subscribe to the call status, use [`observer.on('callStateChange')`](js-apis-observer.md#observeroncallstatechange).
->**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
```js
import call from '@ohos.telephony.call';
```
-## call.dial
+## call.dial(deprecated)
dial\(phoneNumber: string, callback: AsyncCallback\): void
Initiates a call. This API uses an asynchronous callback to return the result.
-**Required permission**: ohos.permission.PLACE\_CALL (a system permission)
+**Required Permissions**: ohos.permission.PLACE_CALL
**System capability**: SystemCapability.Telephony.CallManager
**Parameters**
-| Name | Type | Mandatory | Description |
-| ----------- | ---------------------------- | ---- | -------------------------------- |
-| phoneNumber | string | Yes | Phone number. |
-| callback | AsyncCallback<boolean> | Yes | Callback used to return the result.
- **true**: success
- **false**: failure |
+| Name | Type | Mandatory| Description |
+| ----------- | ---------------------------- | ---- | --------------------------------------- |
+| phoneNumber | string | Yes | Phone number. |
+| callback | AsyncCallback<boolean> | Yes | Callback used to return the result.
- **true**: success
- **false**: failure|
**Example**
@@ -40,23 +40,23 @@ call.dial("138xxxxxxxx", (err, data) => {
```
-## call.dial
+## call.dial(deprecated)
dial\(phoneNumber: string, options: DialOptions, callback: AsyncCallback\): void
-Initiates a call based on the specified options. This API uses an asynchronous callback to return the result.
+Initiates a call. You can set call options as needed. This API uses an asynchronous callback to return the result.
-**Required permission**: ohos.permission.PLACE\_CALL (a system permission)
+**Required Permissions**: ohos.permission.PLACE_CALL
**System capability**: SystemCapability.Telephony.CallManager
**Parameters**
-| Name | Type | Mandatory | Description |
+| Name | Type | Mandatory| Description |
| ----------- | ---------------------------- | ---- | --------------------------------------- |
-| phoneNumber | string | Yes | Phone number. |
-| options | [DialOptions](#dialoptions) | No | Call option, which indicates whether the call is a voice call or video call. |
-| callback | AsyncCallback<boolean> | Yes | Callback used to return the result.
- **true**: success
- **false**: failure |
+| phoneNumber | string | Yes | Phone number. |
+| options | [DialOptions](#dialoptions) | Yes | Call option, which indicates whether the call is a voice call or video call. |
+| callback | AsyncCallback<boolean> | Yes | Callback used to return the result.
- **true**: success
- **false**: failure|
**Example**
@@ -69,28 +69,28 @@ call.dial("138xxxxxxxx", {
```
-## call.dial
+## call.dial(deprecated)
dial\(phoneNumber: string, options?: DialOptions\): Promise
-Initiates a call based on the specified options. This API uses a promise to return the result.
+Initiates a call. You can set call options as needed. This API uses a promise to return the result.
-**Required permission**: ohos.permission.PLACE\_CALL (a system permission)
+**Required Permissions**: ohos.permission.PLACE_CALL
**System capability**: SystemCapability.Telephony.CallManager
**Parameters**
-| Name | Type | Mandatory | Description |
+| Name | Type | Mandatory| Description |
| ----------- | --------------------------- | ---- | -------------------------------------- |
-| phoneNumber | string | Yes | Phone number. |
-| options | [DialOptions](#dialoptions) | Yes | Call option, which indicates whether the call is a voice call or video call. |
+| phoneNumber | string | Yes | Phone number. |
+| options | [DialOptions](#dialoptions) | No | Call option, which indicates whether the call is a voice call or video call.|
**Return value**
-| Type | Description |
-| ---------------------- | ---------------------------------------------------------------- |
-| Promise<boolean> | Promise used to return the result.
- **true**: success
- **false**: failure |
+| Type | Description |
+| ---------------------- | ------------------------------------------------------------ |
+| Promise<boolean> | Promise used to return the result.
- **true**: success
- **false**: failure|
**Example**
@@ -105,6 +105,142 @@ promise.then(data => {
});
```
+
+## call.dialCall9+
+
+dialCall\(phoneNumber: string, callback: AsyncCallback\): void
+
+Initiates a call. This API uses an asynchronous callback to return the result.
+
+**System API**: This is a system API.
+
+**Required Permissions**: ohos.permission.PLACE_CALL
+
+**System capability**: SystemCapability.Telephony.CallManager
+
+**Parameters**
+
+| Name | Type | Mandatory| Description |
+| ----------- | ---------------------------- | ---- | --------------------------------------- |
+| phoneNumber | string | Yes | Phone number. |
+| callback | AsyncCallback<void> | Yes | Callback used to return the result. |
+
+**Error codes**
+For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
+
+| ID| Error Message |
+| -------- | -------------------------------------------- |
+| 201 | Permission denied. |
+| 401 | Parameter error. |
+| 8300001 | Invalid parameter value. |
+| 8300002 | Operation failed. Cannot connect to service. |
+| 8300003 | System internal error. |
+| 8300999 | Unknown error code. |
+
+**Example**
+
+```js
+call.dialCall("138xxxxxxxx", (err, data) => {
+ console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
+});
+```
+
+
+## call.dialCall9+
+
+dialCall\(phoneNumber: string, options: DialCallOptions, callback: AsyncCallback\): void
+
+Initiates a call. You can set call options as needed. This API uses an asynchronous callback to return the result.
+
+**System API**: This is a system API.
+
+**Required Permissions**: ohos.permission.PLACE_CALL
+
+**System capability**: SystemCapability.Telephony.CallManager
+
+**Parameters**
+
+| Name | Type | Mandatory| Description |
+| ----------- | ----------------------------------- | ---- | ------------------------------------ |
+| phoneNumber | string | Yes | Phone number. |
+| options | [DialCallOptions](#dialcalloptions9)| Yes | Call options, which carry other configuration information of the call. |
+| callback | AsyncCallback<void> | Yes | Callback used to return the result. |
+
+**Error codes**
+For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
+
+| ID| Error Message |
+| -------- | -------------------------------------------- |
+| 201 | Permission denied. |
+| 401 | Parameter error. |
+| 8300001 | Invalid parameter value. |
+| 8300002 | Operation failed. Cannot connect to service. |
+| 8300003 | System internal error. |
+| 8300999 | Unknown error code. |
+
+**Example**
+
+```js
+call.dialCall("138xxxxxxxx", {
+ accountId: 0,
+ videoState: 0,
+ dialScene: 0,
+ dialType: 0,
+}, (err, data) => {
+ console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
+});
+```
+
+
+## call.dialCall9+
+
+dialCall\(phoneNumber: string, options?: DialCallOptions\): Promise
+
+Initiates a call. You can set call options as needed. This API uses a promise to return the result.
+
+**System API**: This is a system API.
+
+**Required Permissions**: ohos.permission.PLACE_CALL
+
+**System capability**: SystemCapability.Telephony.CallManager
+
+**Parameters**
+
+| Name | Type | Mandatory| Description |
+| ----------- | ----------------------------------- | ---- | -------------------------------------- |
+| phoneNumber | string | Yes | Phone number. |
+| options | [DialCallOptions](#dialcalloptions9)| No | Call option, which indicates whether the call is a voice call or video call.|
+
+**Return value**
+
+| Type | Description |
+| ---------------------- | ------------------------------------------------------------ |
+| Promise<void> | Promise used to return the result. |
+
+**Error codes**
+For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
+
+| ID| Error Message |
+| -------- | -------------------------------------------- |
+| 201 | Permission denied. |
+| 401 | Parameter error. |
+| 8300001 | Invalid parameter value. |
+| 8300002 | Operation failed. Cannot connect to service. |
+| 8300003 | System internal error. |
+| 8300999 | Unknown error code. |
+
+**Example**
+
+```js
+try {
+ call.dialCall('138xxxxxxxx');
+ console.log(`dialCall success, promise: data->${JSON.stringify(data)}`);
+} catch (error) {
+ console.log(`dialCall fail, promise: err->${JSON.stringify(error)}`);
+}
+```
+
+
## call.makeCall7+
makeCall(phoneNumber: string, callback: AsyncCallback\): void
@@ -115,16 +251,27 @@ Launches the call screen and displays the dialed number. This API uses an asynch
**Parameters**
-| Name | Type | Mandatory | Description |
+| Name | Type | Mandatory| Description |
| ----------- | ------------------------- | ---- | ------------------------------------------ |
| phoneNumber | string | Yes | Phone number. |
-| callback | AsyncCallback<void> | Yes | Callback used to return the result. |
+| callback | AsyncCallback<void> | Yes | Callback used to return the result.|
+
+**Error codes**
+For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
+
+| ID| Error Message |
+| -------- | -------------------------------------------- |
+| 401 | Parameter error. |
+| 8300001 | Invalid parameter value. |
+| 8300002 | Operation failed. Cannot connect to service. |
+| 8300003 | System internal error. |
+| 8300999 | Unknown error code. |
**Example**
```js
-call.makeCall("138xxxxxxxx", err => {
- console.log(`makeCall callback: err->${JSON.stringify(err)}`);
+call.makeCall("138xxxxxxxx", err => {
+ console.log(`makeCall callback: err->${JSON.stringify(err)}`);
});
```
@@ -139,24 +286,35 @@ Launches the call screen and displays the dialed number. This API uses a promise
**Parameters**
-| Name | Type | Mandatory | Description |
+| Name | Type | Mandatory| Description |
| ----------- | ------ | ---- | ---------- |
-| phoneNumber | string | Yes | Phone number. |
+| phoneNumber | string | Yes | Phone number.|
**Return value**
| Type | Description |
| ------------------- | --------------------------------- |
-| Promise<void> | Promise used to return the result. |
+| Promise<void> | Promise used to return the result.|
+
+**Error codes**
+For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
+
+| ID| Error Message |
+| -------- | -------------------------------------------- |
+| 401 | Parameter error. |
+| 8300001 | Invalid parameter value. |
+| 8300002 | Operation failed. Cannot connect to service. |
+| 8300003 | System internal error. |
+| 8300999 | Unknown error code. |
**Example**
```js
-let promise = call.makeCall("138xxxxxxxx");
-promise.then(() => {
- console.log(`makeCall success`);
-}).catch(err => {
- console.error(`makeCall fail, promise: err->${JSON.stringify(err)}`);
+let promise = call.makeCall("138xxxxxxxx");
+promise.then(() => {
+ console.log(`makeCall success`);
+}).catch(err => {
+ console.error(`makeCall fail, promise: err->${JSON.stringify(err)}`);
});
```
@@ -170,9 +328,9 @@ Checks whether a call is in progress. This API uses an asynchronous callback to
**Parameters**
-| Name | Type | Mandatory | Description |
+| Name | Type | Mandatory| Description |
| -------- | ---------------------------- | ---- | ------------------------------------------------------------ |
-| callback | AsyncCallback<boolean> | Yes | Callback used to return the result. Callback used to return the result.
- **true**: A call is in progress.
- **false**: No call is in progress. |
+| callback | AsyncCallback<boolean> | Yes | Callback used to return the result. Callback used to return the result.
- **true**: A call is in progress.
- **false**: No call is in progress.|
**Example**
@@ -195,7 +353,7 @@ Checks whether a call is in progress. This API uses a promise to return the resu
| Type | Description |
| ---------------------- | --------------------------------------- |
-| Promise<boolean> | Promise used to return the result. |
+| Promise<boolean> | Promise used to return the result.|
**Example**
@@ -219,9 +377,9 @@ Obtains the call status. This API uses an asynchronous callback to return the re
**Parameters**
-| Name | Type | Mandatory | Description |
+| Name | Type | Mandatory| Description |
| -------- | -------------------------------------------- | ---- | ------------------------------------ |
-| callback | AsyncCallback<[CallState](#callstate)> | Yes | Callback used to return the result. |
+| callback | AsyncCallback<[CallState](#callstate)> | Yes | Callback used to return the result.|
**Example**
@@ -244,7 +402,7 @@ Obtains the call status. This API uses a promise to return the result.
| Type | Description |
| -------------------------------------- | --------------------------------------- |
-| Promise<[CallState](#callstate)> | Promise used to return the result. |
+| Promise<[CallState](#callstate)> | Promise used to return the result.|
**Example**
@@ -269,7 +427,7 @@ Checks whether a device supports voice calls.
| Type | Description |
| ------- | ------------------------------------------------------------ |
-| boolean | - **true**: The device supports voice calls.
- **false**: The device does not support voice calls. |
+| boolean | - **true**: The device supports voice calls.
- **false**: The device does not support voice calls.|
```js
let result = call.hasVoiceCapability();
@@ -286,10 +444,21 @@ Checks whether the called number is an emergency number. This API uses an asynch
**Parameters**
-| Name | Type | Mandatory | Description |
+| Name | Type | Mandatory| Description |
| ----------- | ---------------------------- | ---- | ------------------------------------------------------------ |
| phoneNumber | string | Yes | Phone number. |
-| callback | AsyncCallback<boolean> | Yes | Callback used to return the result.
- **true**: The called number is an emergency number.
- **false**: The called number is not an emergency number. |
+| callback | AsyncCallback<boolean> | Yes | Callback used to return the result. - **true**: The called number is an emergency number.
- **false**: The called number is not an emergency number.|
+
+**Error codes**
+For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
+
+| ID| Error Message |
+| -------- | -------------------------------------------- |
+| 401 | Parameter error. |
+| 8300001 | Invalid parameter value. |
+| 8300002 | Operation failed. Cannot connect to service. |
+| 8300003 | System internal error. |
+| 8300999 | Unknown error code. |
**Example**
@@ -304,17 +473,28 @@ call.isEmergencyPhoneNumber("138xxxxxxxx", (err, data) => {
isEmergencyPhoneNumber\(phoneNumber: string, options: EmergencyNumberOptions, callback: AsyncCallback\): void
-Checks whether the called number is an emergency number based on the specified phone number options. This API uses an asynchronous callback to return the result.
+Checks whether the called number is an emergency number based on the phone number. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Telephony.CallManager
**Parameters**
-| Name | Type | Mandatory | Description |
-| ----------- | -------------------------------------------------- | ---- | -------------------------------------------- |
-| phoneNumber | string | Yes | Phone number. |
-| options | [EmergencyNumberOptions](#emergencynumberoptions7) | No | Phone number options. |
-| callback | AsyncCallback<boolean> | Yes | Callback used to return the result.
- **true**: The called number is an emergency number.
- **false**: The called number is not an emergency number. |
+| Name | Type | Mandatory| Description |
+| ----------- | -------------------------------------------------- | ---- | ------------------------------------------------------------ |
+| phoneNumber | string | Yes | Phone number. |
+| options | [EmergencyNumberOptions](#emergencynumberoptions7) | Yes | Phone number. |
+| callback | AsyncCallback<boolean> | Yes | Callback used to return the result. - **true**: The called number is an emergency number.
- **false**: The called number is not an emergency number.|
+
+**Error codes**
+For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
+
+| ID| Error Message |
+| -------- | -------------------------------------------- |
+| 401 | Parameter error. |
+| 8300001 | Invalid parameter value. |
+| 8300002 | Operation failed. Cannot connect to service. |
+| 8300003 | System internal error. |
+| 8300999 | Unknown error code. |
**Example**
@@ -329,22 +509,33 @@ call.isEmergencyPhoneNumber("112", {slotId: 1}, (err, data) => {
isEmergencyPhoneNumber\(phoneNumber: string, options?: EmergencyNumberOptions\): Promise
-Checks whether the called number is an emergency number based on the specified phone number options. This API uses a promise to return the result.
+Checks whether the called number is an emergency number based on the phone number. This API uses a promise to return the result.
**System capability**: SystemCapability.Telephony.CallManager
**Parameters**
-| Name | Type | Mandatory | Description |
+| Name | Type | Mandatory| Description |
| ----------- | -------------------------------------------------- | ---- | -------------- |
| phoneNumber | string | Yes | Phone number. |
-| options | [EmergencyNumberOptions](#emergencynumberoptions7) | Yes | Phone number options. |
+| options | [EmergencyNumberOptions](#emergencynumberoptions7) | No | Phone number.|
**Return value**
| Type | Description |
| ---------------------- | --------------------------------------------------- |
-| Promise<boolean> | Promise used to return the result. |
+| Promise<boolean> | Promise used to return the result.|
+
+**Error codes**
+For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
+
+| ID| Error Message |
+| -------- | -------------------------------------------- |
+| 401 | Parameter error. |
+| 8300001 | Invalid parameter value. |
+| 8300002 | Operation failed. Cannot connect to service. |
+| 8300003 | System internal error. |
+| 8300999 | Unknown error code. |
**Example**
@@ -369,10 +560,21 @@ A formatted phone number is a standard numeric string, for example, 555 0100.
**Parameters**
-| Name | Type | Mandatory | Description |
+| Name | Type | Mandatory| Description |
| ----------- | --------------------------- | ---- | ------------------------------------ |
| phoneNumber | string | Yes | Phone number. |
-| callback | AsyncCallback<string> | Yes | Callback used to return the result. |
+| callback | AsyncCallback<string> | Yes | Callback used to return the result.|
+
+**Error codes**
+For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
+
+| ID| Error Message |
+| -------- | -------------------------------------------- |
+| 401 | Parameter error. |
+| 8300001 | Invalid parameter value. |
+| 8300002 | Operation failed. Cannot connect to service. |
+| 8300003 | System internal error. |
+| 8300999 | Unknown error code. |
**Example**
@@ -386,7 +588,7 @@ call.formatPhoneNumber("138xxxxxxxx", (err, data) => {
formatPhoneNumber\(phoneNumber: string, options: NumberFormatOptions, callback: AsyncCallback\): void
-Formats a phone number based on the specified formatting options. This API uses an asynchronous callback to return the result.
+Formats a phone number based on specified formatting options. This API uses an asynchronous callback to return the result.
A formatted phone number is a standard numeric string, for example, 555 0100.
@@ -394,11 +596,22 @@ A formatted phone number is a standard numeric string, for example, 555 0100.
**Parameters**
-| Name | Type | Mandatory | Description |
+| Name | Type | Mandatory| Description |
| ----------- | -------------------------------------------- | ---- | ------------------------------------ |
| phoneNumber | string | Yes | Phone number. |
-| options | [NumberFormatOptions](#numberformatoptions7) | No | Number formatting options, for example, country code. |
-| callback | AsyncCallback<string> | Yes | Callback used to return the result. |
+| options | [NumberFormatOptions](#numberformatoptions7) | Yes | Number formatting options, for example, country code. |
+| callback | AsyncCallback<string> | Yes | Callback used to return the result.|
+
+**Error codes**
+For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
+
+| ID| Error Message |
+| -------- | -------------------------------------------- |
+| 401 | Parameter error. |
+| 8300001 | Invalid parameter value. |
+| 8300002 | Operation failed. Cannot connect to service. |
+| 8300003 | System internal error. |
+| 8300999 | Unknown error code. |
**Example**
@@ -415,7 +628,7 @@ call.formatPhoneNumber("138xxxxxxxx", {
formatPhoneNumber\(phoneNumber: string, options?: NumberFormatOptions\): Promise
-Formats a phone number based on the specified formatting options. This API uses a promise to return the result.
+Formats a phone number based on specified formatting options. This API uses a promise to return the result.
A formatted phone number is a standard numeric string, for example, 555 0100.
@@ -423,16 +636,27 @@ A formatted phone number is a standard numeric string, for example, 555 0100.
**Parameters**
-| Name | Type | Mandatory | Description |
+| Name | Type | Mandatory| Description |
| ----------- | -------------------------------------------- | ---- | ---------------------- |
| phoneNumber | string | Yes | Phone number. |
-| options | [NumberFormatOptions](#numberformatoptions7) | Yes | Number formatting options, for example, country code. |
+| options | [NumberFormatOptions](#numberformatoptions7) | No | Number formatting options, for example, country code.|
**Return value**
| Type | Description |
| --------------------- | ------------------------------------------- |
-| Promise<string> | Promise used to return the result. |
+| Promise<string> | Promise used to return the result.|
+
+**Error codes**
+For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
+
+| ID| Error Message |
+| -------- | -------------------------------------------- |
+| 401 | Parameter error. |
+| 8300001 | Invalid parameter value. |
+| 8300002 | Operation failed. Cannot connect to service. |
+| 8300003 | System internal error. |
+| 8300999 | Unknown error code. |
**Example**
@@ -459,11 +683,22 @@ The phone number must match the specified country code. For example, for a China
**Parameters**
-| Name | Type | Mandatory | Description |
+| Name | Type | Mandatory| Description |
| ----------- | --------------------------- | ---- | ----------------------------------------------------- |
| phoneNumber | string | Yes | Phone number. |
| countryCode | string | Yes | Country code, for example, **CN** (China). All country codes are supported. |
-| callback | AsyncCallback<string> | Yes | Callback used to return the result. |
+| callback | AsyncCallback<string> | Yes | Callback used to return the result.|
+
+**Error codes**
+For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
+
+| ID| Error Message |
+| -------- | -------------------------------------------- |
+| 401 | Parameter error. |
+| 8300001 | Invalid parameter value. |
+| 8300002 | Operation failed. Cannot connect to service. |
+| 8300003 | System internal error. |
+| 8300999 | Unknown error code. |
**Example**
@@ -488,16 +723,27 @@ All country codes are supported.
**Parameters**
-| Name | Type | Mandatory | Description |
+| Name | Type | Mandatory| Description |
| ----------- | ------ | ---- | ---------------------------------------- |
| phoneNumber | string | Yes | Phone number. |
-| countryCode | string | Yes | Country code, for example, **CN** (China). All country codes are supported. |
+| countryCode | string | Yes | Country code, for example, **CN** (China). All country codes are supported.|
**Return value**
| Type | Description |
| --------------------- | ------------------------------------------------------------ |
-| Promise<string> | Promise used to return the result. |
+| Promise<string> | Promise used to return the result.|
+
+**Error codes**
+For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
+
+| ID| Error Message |
+| -------- | -------------------------------------------- |
+| 401 | Parameter error. |
+| 8300001 | Invalid parameter value. |
+| 8300002 | Operation failed. Cannot connect to service. |
+| 8300003 | System internal error. |
+| 8300999 | Unknown error code. |
**Example**
@@ -514,9 +760,9 @@ promise.then(data => {
muteRinger\(callback: AsyncCallback\): void
-Mutes the ringtone while it is playing. This API uses an asynchronous callback to return the result.
+Mutes the ringtone while it is playing. It does not work if the ringtone has been muted. This API uses an asynchronous callback to return the result.
-This is a system API.
+**System API**: This is a system API.
**Required permission**: ohos.permission.SET_TELEPHONY_STATE
@@ -528,6 +774,17 @@ This is a system API.
| ----------- | ------------------------- | ---- | ---------- |
| callback | AsyncCallback<void> | Yes | Callback used to return the result.|
+**Error codes**
+For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
+
+| ID| Error Message |
+| -------- | -------------------------------------------- |
+| 401 | Parameter error. |
+| 8300001 | Invalid parameter value. |
+| 8300002 | Operation failed. Cannot connect to service. |
+| 8300003 | System internal error. |
+| 8300999 | Unknown error code. |
+
**Example**
```js
@@ -541,9 +798,9 @@ call.muteRinger((err, data) => {
muteRinger\(\): Promise
-Mutes the ringtone while it is playing. This API uses a promise to return the result.
+Mutes the ringtone while it is playing. It does not work if the ringtone has been muted. This API uses a promise to return the result.
-This is a system API.
+**System API**: This is a system API.
**Required permission**: ohos.permission.SET_TELEPHONY_STATE
@@ -555,6 +812,18 @@ This is a system API.
| ------------------- | --------------------------- |
| Promise<void> | Promise used to return the result.|
+**Error codes**
+For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
+
+| ID| Error Message |
+| -------- | -------------------------------------------- |
+| 201 | Permission denied. |
+| 401 | Parameter error. |
+| 8300001 | Invalid parameter value. |
+| 8300002 | Operation failed. Cannot connect to service. |
+| 8300003 | System internal error. |
+| 8300999 | Unknown error code. |
+
**Example**
```js
@@ -566,13 +835,14 @@ promise.then(data => {
});
```
-## call.answer7+
-answer\(callId: number, callback: AsyncCallback\): void
+## call.answerCall7+
+
+answerCall\(callId: number, callback: AsyncCallback\): void
-Answers a call based on the specified call ID. This API uses an asynchronous callback to return the result.
+Answers a call. This API uses an asynchronous callback to return the result.
-This is a system API.
+**System API**: This is a system API.
**Required permission**: ohos.permission.ANSWER_CALL
@@ -585,22 +855,34 @@ This is a system API.
| callId | number | Yes | Call ID. You can obtain the value by subscribing to **callDetailsChange** events.|
| callback | AsyncCallback<void> | Yes | Callback used to return the result. |
+**Error codes**
+For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
+
+| ID| Error Message |
+| -------- | -------------------------------------------- |
+| 201 | Permission denied. |
+| 401 | Parameter error. |
+| 8300001 | Invalid parameter value. |
+| 8300002 | Operation failed. Cannot connect to service. |
+| 8300003 | System internal error. |
+| 8300999 | Unknown error code. |
+
**Example**
```js
-call.answer(1, (err, data) => {
+call.answerCall(1, (err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
});
```
-## call.answer7+
+## call.answerCall7+
-answer(callId?: number\): Promise
+answerCall(callId?: number\): Promise
-Answers a call based on the specified call ID. This API uses a promise to return the result.
+Answers a call. This API uses a promise to return the result.
-This is a system API.
+**System API**: This is a system API.
**Required permission**: ohos.permission.ANSWER_CALL
@@ -618,24 +900,37 @@ This is a system API.
| ------------------- | --------------------------- |
| Promise<void> | Promise used to return the result.|
+**Error codes**
+For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
+
+| ID| Error Message |
+| -------- | -------------------------------------------- |
+| 201 | Permission denied. |
+| 401 | Parameter error. |
+| 8300001 | Invalid parameter value. |
+| 8300002 | Operation failed. Cannot connect to service. |
+| 8300003 | System internal error. |
+| 8300999 | Unknown error code. |
+
**Example**
```js
-let promise = call.answer(1);
+let promise = call.answerCall(1);
promise.then(data => {
- console.log(`answer success, promise: data->${JSON.stringify(data)}`);
+ console.log(`answerCall success, promise: data->${JSON.stringify(data)}`);
}).catch(err => {
- console.error(`answer fail, promise: err->${JSON.stringify(err)}`);
+ console.error(`answerCall fail, promise: err->${JSON.stringify(err)}`);
});
```
-## call.hangup7+
-hangup\(callId: number, callback: AsyncCallback\): void
+## call.answerCall9+
-Ends a call. This API uses an asynchronous callback to return the result.
+answerCall\(callback: AsyncCallback\): void
+
+Answers a call. This API uses an asynchronous callback to return the result.
-This is a system API.
+**System API**: This is a system API.
**Required permission**: ohos.permission.ANSWER_CALL
@@ -645,25 +940,36 @@ This is a system API.
| Name | Type | Mandatory| Description |
| -------- | ------------------------- | ---- | ---------- |
-| callId | number | Yes | Call ID. You can obtain the value by subscribing to **callDetailsChange** events.|
| callback | AsyncCallback<void> | Yes | Callback used to return the result.|
+**Error codes**
+For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
+
+| ID| Error Message |
+| -------- | -------------------------------------------- |
+| 201 | Permission denied. |
+| 401 | Parameter error. |
+| 8300001 | Invalid parameter value. |
+| 8300002 | Operation failed. Cannot connect to service. |
+| 8300003 | System internal error. |
+| 8300999 | Unknown error code. |
+
**Example**
```js
-call.hangup(1, (err, data) => {
+call.answerCall((err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
});
```
-## call.answer9+
+## call.hangUpCall7+
-answer\(callback: AsyncCallback\): void
+hangUpCall\(callId: number, callback: AsyncCallback\): void
-Answers a call.This API uses an asynchronous callback to return the result.
+Ends a call. This API uses an asynchronous callback to return the result.
-This is a system API.
+**System API**: This is a system API.
**Required permission**: ohos.permission.ANSWER_CALL
@@ -673,24 +979,37 @@ This is a system API.
| Name | Type | Mandatory| Description |
| -------- | ------------------------- | ---- | ----------------------------------------------- |
+| callId | number | Yes | Call ID. You can obtain the value by subscribing to **callDetailsChange** events.|
| callback | AsyncCallback<void> | Yes | Callback used to return the result. |
+**Error codes**
+For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
+
+| ID| Error Message |
+| -------- | -------------------------------------------- |
+| 201 | Permission denied. |
+| 401 | Parameter error. |
+| 8300001 | Invalid parameter value. |
+| 8300002 | Operation failed. Cannot connect to service. |
+| 8300003 | System internal error. |
+| 8300999 | Unknown error code. |
+
**Example**
```js
-call.answer((err, data) => {
+call.hangUpCall(1, (err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
});
```
-## call.hangup7+
+## call.hangUpCall7+
-hangup\(callId?: number\): Promise
+hangUpCall\(callId?: number\): Promise
-Ends a call based on the specified call ID. This API uses a promise to return the result.
+Ends a call. This API uses a promise to return the result.
-This is a system API.
+**System API**: This is a system API.
**Required permission**: ohos.permission.ANSWER_CALL
@@ -708,24 +1027,37 @@ This is a system API.
| ------------------- | --------------------------- |
| Promise<void> | Promise used to return the result.|
+**Error codes**
+For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
+
+| ID| Error Message |
+| -------- | -------------------------------------------- |
+| 201 | Permission denied. |
+| 401 | Parameter error. |
+| 8300001 | Invalid parameter value. |
+| 8300002 | Operation failed. Cannot connect to service. |
+| 8300003 | System internal error. |
+| 8300999 | Unknown error code. |
+
**Example**
```js
-let promise = call.hangup(1);
+let promise = call.hangUpCall(1);
promise.then(data => {
- console.log(`hangup success, promise: data->${JSON.stringify(data)}`);
+ console.log(`hangUpCall success, promise: data->${JSON.stringify(data)}`);
}).catch(err => {
- console.error(`hangup fail, promise: err->${JSON.stringify(err)}`);
+ console.error(`hangUpCall fail, promise: err->${JSON.stringify(err)}`);
});
```
-## call.hangup9+
-hangup\(callback: AsyncCallback\): void
+## call.hangUpCall9+
+
+hangUpCall\(callback: AsyncCallback\): void
Ends a call. This API uses an asynchronous callback to return the result.
-This is a system API.
+**System API**: This is a system API.
**Required permission**: ohos.permission.ANSWER_CALL
@@ -737,22 +1069,35 @@ This is a system API.
| -------- | ------------------------- | ---- | ---------- |
| callback | AsyncCallback<void> | Yes | Callback used to return the result.|
+**Error codes**
+For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
+
+| ID| Error Message |
+| -------- | -------------------------------------------- |
+| 201 | Permission denied. |
+| 401 | Parameter error. |
+| 8300001 | Invalid parameter value. |
+| 8300002 | Operation failed. Cannot connect to service. |
+| 8300003 | System internal error. |
+| 8300999 | Unknown error code. |
+
+
**Example**
```js
-call.hangup((err, data) => {
+call.hangUpCall((err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
});
```
-## call.reject7+
+## call.rejectCall7+
-reject(callId: number, callback: AsyncCallback\): void
+rejectCall(callId: number, callback: AsyncCallback\): void
-Rejects a call based on the specified call ID. This API uses an asynchronous callback to return the result.
+Rejects a call. This API uses an asynchronous callback to return the result.
-This is a system API.
+**System API**: This is a system API.
**Required permission**: ohos.permission.ANSWER_CALL
@@ -765,22 +1110,35 @@ This is a system API.
| callId | number | Yes | Call ID. You can obtain the value by subscribing to **callDetailsChange** events.|
| callback | AsyncCallback<void> | Yes | Callback used to return the result. |
+**Error codes**
+For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
+
+| ID| Error Message |
+| -------- | -------------------------------------------- |
+| 201 | Permission denied. |
+| 401 | Parameter error. |
+| 8300001 | Invalid parameter value. |
+| 8300002 | Operation failed. Cannot connect to service. |
+| 8300003 | System internal error. |
+| 8300999 | Unknown error code. |
+
**Example**
```js
-call.reject(1, (err, data) => {
+call.rejectCall(1, (err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
});
```
-## call.reject7+
-reject\(callId: number, options: RejectMessageOptions, callback: AsyncCallback\): void
+## call.rejectCall7+
+
+rejectCall\(callId: number, options: RejectMessageOptions, callback: AsyncCallback\): void
-Rejects a call based on the specified call ID and options. This API uses an asynchronous callback to return the result.
+Rejects a call. This API uses an asynchronous callback to return the result.
-This is a system API.
+**System API**: This is a system API.
**Required permission**: ohos.permission.ANSWER_CALL
@@ -794,25 +1152,37 @@ This is a system API.
| options | [RejectMessageOptions](#rejectmessageoptions7) | Yes | Options for the call rejection message. |
| callback | AsyncCallback<void> | Yes | Callback used to return the result. |
+**Error codes**
+For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
+
+| ID| Error Message |
+| -------- | -------------------------------------------- |
+| 201 | Permission denied. |
+| 401 | Parameter error. |
+| 8300001 | Invalid parameter value. |
+| 8300002 | Operation failed. Cannot connect to service. |
+| 8300003 | System internal error. |
+| 8300999 | Unknown error code. |
+
**Example**
```js
let rejectMessageOptions={
messageContent: "Unknown number blocked"
}
-call.reject(1, rejectMessageOptions, (err, data) => {
+call.rejectCall(1, rejectMessageOptions, (err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
});
```
-## call.reject7+
+## call.rejectCall7+
-reject(callId?: number, options?: RejectMessageOptions\): Promise
+rejectCall(callId?: number, options?: RejectMessageOptions\): Promise
-Rejects a call based on the specified call ID and options. This API uses a promise to return the result.
+Rejects a call. This API uses a promise to return the result.
-This is a system API.
+**System API**: This is a system API.
**Required permission**: ohos.permission.ANSWER_CALL
@@ -831,28 +1201,40 @@ This is a system API.
| ------------------- | --------------------------- |
| Promise<void> | Promise used to return the result.|
+**Error codes**
+For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
+
+| ID| Error Message |
+| -------- | -------------------------------------------- |
+| 201 | Permission denied. |
+| 401 | Parameter error. |
+| 8300001 | Invalid parameter value. |
+| 8300002 | Operation failed. Cannot connect to service. |
+| 8300003 | System internal error. |
+| 8300999 | Unknown error code. |
+
**Example**
```js
let rejectMessageOptions={
messageContent: "Unknown number blocked"
}
-let promise = call.reject(1, rejectMessageOptions);
+let promise = call.rejectCall(1, rejectMessageOptions);
promise.then(data => {
- console.log(`reject success, promise: data->${JSON.stringify(data)}`);
+ console.log(`rejectCall success, promise: data->${JSON.stringify(data)}`);
}).catch(err => {
- console.error(`reject fail, promise: err->${JSON.stringify(err)}`);
+ console.error(`rejectCall fail, promise: err->${JSON.stringify(err)}`);
});
```
-## call.reject9+
+## call.rejectCall9+
-reject\(callback: AsyncCallback\): void
+rejectCall\(callback: AsyncCallback\): void
Rejects a call. This API uses an asynchronous callback to return the result.
-This is a system API.
+**System API**: This is a system API.
**Required permission**: ohos.permission.ANSWER_CALL
@@ -864,22 +1246,34 @@ This is a system API.
| -------- | ------------------------- | ---- | ---------- |
| callback | AsyncCallback<void> | Yes | Callback used to return the result.|
-**Example:**
+**Error codes**
+For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
+
+| ID| Error Message |
+| -------- | -------------------------------------------- |
+| 201 | Permission denied. |
+| 401 | Parameter error. |
+| 8300001 | Invalid parameter value. |
+| 8300002 | Operation failed. Cannot connect to service. |
+| 8300003 | System internal error. |
+| 8300999 | Unknown error code. |
+
+**Example**
```js
-call.reject((err, data) => {
+call.rejectCall((err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
});
```
-## call.reject9+
+## call.rejectCall9+
-reject\(options: RejectMessageOptions, callback: AsyncCallback\): void
+rejectCall\(options: RejectMessageOptions, callback: AsyncCallback\): void
Rejects a call. This API uses an asynchronous callback to return the result.
-This is a system API.
+**System API**: This is a system API.
**Required permission**: ohos.permission.ANSWER_CALL
@@ -892,13 +1286,25 @@ This is a system API.
| options | [RejectMessageOptions](#rejectmessageoptions7) | Yes | Options for the call rejection message.|
| callback | AsyncCallback<void> | Yes | Callback used to return the result. |
-**Example:**
+**Error codes**
+For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
+
+| ID| Error Message |
+| -------- | -------------------------------------------- |
+| 201 | Permission denied. |
+| 401 | Parameter error. |
+| 8300001 | Invalid parameter value. |
+| 8300002 | Operation failed. Cannot connect to service. |
+| 8300003 | System internal error. |
+| 8300999 | Unknown error code. |
+
+**Example**
```js
let rejectMessageOptions={
messageContent: "Unknown number blocked"
}
-call.reject(rejectMessageOptions, (err, data) => {
+call.rejectCall(rejectMessageOptions, (err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
});
```
@@ -910,7 +1316,7 @@ holdCall\(callId: number, callback: AsyncCallback\): void
Holds a call based on the specified call ID. This API uses an asynchronous callback to return the result.
-This is a system API.
+**System API**: This is a system API.
**Required permission**: ohos.permission.ANSWER_CALL
@@ -923,6 +1329,18 @@ This is a system API.
| callId | number | Yes | Call ID. |
| callback | AsyncCallback<void> | Yes | Callback used to return the result.|
+**Error codes**
+For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
+
+| ID| Error Message |
+| -------- | -------------------------------------------- |
+| 201 | Permission denied. |
+| 401 | Parameter error. |
+| 8300001 | Invalid parameter value. |
+| 8300002 | Operation failed. Cannot connect to service. |
+| 8300003 | System internal error. |
+| 8300999 | Unknown error code. |
+
**Example**
```js
@@ -938,7 +1356,7 @@ holdCall\(callId: number\): Promise
Holds a call based on the specified call ID. This API uses a promise to return the result.
-This is a system API.
+**System API**: This is a system API.
**Required permission**: ohos.permission.ANSWER_CALL
@@ -956,6 +1374,18 @@ This is a system API.
| ------------------- | --------------------------- |
| Promise<void> | Promise used to return the result.|
+**Error codes**
+For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
+
+| ID| Error Message |
+| -------- | -------------------------------------------- |
+| 201 | Permission denied. |
+| 401 | Parameter error. |
+| 8300001 | Invalid parameter value. |
+| 8300002 | Operation failed. Cannot connect to service. |
+| 8300003 | System internal error. |
+| 8300999 | Unknown error code. |
+
**Example**
```js
@@ -973,7 +1403,7 @@ unHoldCall\(callId: number, callback: AsyncCallback\): void
Unholds a call based on the specified call ID. This API uses an asynchronous callback to return the result.
-This is a system API.
+**System API**: This is a system API.
**Required permission**: ohos.permission.ANSWER_CALL
@@ -986,6 +1416,18 @@ This is a system API.
| callId | number | Yes | Call ID. |
| callback | AsyncCallback<void> | Yes | Callback used to return the result.|
+**Error codes**
+For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
+
+| ID| Error Message |
+| -------- | -------------------------------------------- |
+| 201 | Permission denied. |
+| 401 | Parameter error. |
+| 8300001 | Invalid parameter value. |
+| 8300002 | Operation failed. Cannot connect to service. |
+| 8300003 | System internal error. |
+| 8300999 | Unknown error code. |
+
**Example**
```js
@@ -1001,7 +1443,7 @@ unHoldCall\(callId: number\): Promise
Unholds a call based on the specified call ID. This API uses a promise to return the result.
-This is a system API.
+**System API**: This is a system API.
**Required permission**: ohos.permission.ANSWER_CALL
@@ -1019,6 +1461,18 @@ This is a system API.
| ------------------- | --------------------------- |
| Promise<void> | Promise used to return the result.|
+**Error codes**
+For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
+
+| ID| Error Message |
+| -------- | -------------------------------------------- |
+| 201 | Permission denied. |
+| 401 | Parameter error. |
+| 8300001 | Invalid parameter value. |
+| 8300002 | Operation failed. Cannot connect to service. |
+| 8300003 | System internal error. |
+| 8300999 | Unknown error code. |
+
**Example**
```js
@@ -1036,7 +1490,7 @@ switchCall\(callId: number, callback: AsyncCallback\): void
Switches a call. This API uses an asynchronous callback to return the result.
-This is a system API.
+**System API**: This is a system API.
**Required permission**: ohos.permission.ANSWER_CALL
@@ -1049,6 +1503,18 @@ This is a system API.
| callId | number | Yes | Call ID. |
| callback | AsyncCallback<void> | Yes | Callback used to return the result.|
+**Error codes**
+For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
+
+| ID| Error Message |
+| -------- | -------------------------------------------- |
+| 201 | Permission denied. |
+| 401 | Parameter error. |
+| 8300001 | Invalid parameter value. |
+| 8300002 | Operation failed. Cannot connect to service. |
+| 8300003 | System internal error. |
+| 8300999 | Unknown error code. |
+
**Example**
```js
@@ -1064,7 +1530,7 @@ switchCall\(callId: number\): Promise
Switches a call. This API uses a promise to return the result.
-This is a system API.
+**System API**: This is a system API.
**Required permission**: ohos.permission.ANSWER_CALL
@@ -1082,6 +1548,18 @@ This is a system API.
| ------------------- | --------------------------- |
| Promise<void> | Promise used to return the result.|
+**Error codes**
+For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
+
+| ID| Error Message |
+| -------- | -------------------------------------------- |
+| 201 | Permission denied. |
+| 401 | Parameter error. |
+| 8300001 | Invalid parameter value. |
+| 8300002 | Operation failed. Cannot connect to service. |
+| 8300003 | System internal error. |
+| 8300999 | Unknown error code. |
+
**Example**
```js
@@ -1099,7 +1577,7 @@ combineConference\(callId: number, callback: AsyncCallback\): void
Combines two calls into a conference call. This API uses an asynchronous callback to return the result.
-This is a system API.
+**System API**: This is a system API.
**System capability**: SystemCapability.Telephony.CallManager
@@ -1110,6 +1588,17 @@ This is a system API.
| callId | number | Yes | Call ID. |
| callback | AsyncCallback<void> | Yes | Callback used to return the result.|
+**Error codes**
+For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
+
+| ID| Error Message |
+| -------- | -------------------------------------------- |
+| 401 | Parameter error. |
+| 8300001 | Invalid parameter value. |
+| 8300002 | Operation failed. Cannot connect to service. |
+| 8300003 | System internal error. |
+| 8300999 | Unknown error code. |
+
**Example**
```js
@@ -1125,7 +1614,7 @@ combineConference\(callId: number\): Promise
Combines two calls into a conference call. This API uses a promise to return the result.
-This is a system API.
+**System API**: This is a system API.
**System capability**: SystemCapability.Telephony.CallManager
@@ -1141,6 +1630,17 @@ This is a system API.
| ------------------- | --------------------------- |
| Promise<void> | Promise used to return the result.|
+**Error codes**
+For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
+
+| ID| Error Message |
+| -------- | -------------------------------------------- |
+| 401 | Parameter error. |
+| 8300001 | Invalid parameter value. |
+| 8300002 | Operation failed. Cannot connect to service. |
+| 8300003 | System internal error. |
+| 8300999 | Unknown error code. |
+
**Example**
```js
@@ -1158,7 +1658,7 @@ getMainCallId\(callId: number, callback: AsyncCallback\): void
Obtains the main call ID. This API uses an asynchronous callback to return the result.
-This is a system API.
+**System API**: This is a system API.
**System capability**: SystemCapability.Telephony.CallManager
@@ -1169,6 +1669,18 @@ This is a system API.
| callId | number | Yes | Call ID. |
| callback | AsyncCallback<number> | Yes | Callback used to return the result. |
+**Error codes**
+For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
+
+| ID| Error Message |
+| -------- | -------------------------------------------- |
+| 401 | Parameter error. |
+| 8300001 | Invalid parameter value. |
+| 8300002 | Operation failed. Cannot connect to service. |
+| 8300003 | System internal error. |
+| 8300999 | Unknown error code. |
+
+
**Example**
```js
@@ -1184,7 +1696,7 @@ getMainCallId\(callId: number\): Promise
Obtains the main call ID. This API uses a promise to return the result.
-This is a system API.
+**System API**: This is a system API.
**System capability**: SystemCapability.Telephony.CallManager
@@ -1200,6 +1712,17 @@ This is a system API.
| ------------------- | ------------------------------- |
| Promise<void> | Promise used to return the result.|
+**Error codes**
+For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
+
+| ID| Error Message |
+| -------- | -------------------------------------------- |
+| 401 | Parameter error. |
+| 8300001 | Invalid parameter value. |
+| 8300002 | Operation failed. Cannot connect to service. |
+| 8300003 | System internal error. |
+| 8300999 | Unknown error code. |
+
**Example**
```js
@@ -1217,7 +1740,7 @@ getSubCallIdList\(callId: number, callback: AsyncCallback\>\): vo
Obtains the list of subcall IDs. This API uses an asynchronous callback to return the result.
-This is a system API.
+**System API**: This is a system API.
**System capability**: SystemCapability.Telephony.CallManager
@@ -1228,6 +1751,17 @@ This is a system API.
| callId | number | Yes | Call ID. |
| callback | AsyncCallback\> | Yes | Callback used to return the result. |
+**Error codes**
+For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
+
+| ID| Error Message |
+| -------- | -------------------------------------------- |
+| 401 | Parameter error. |
+| 8300001 | Invalid parameter value. |
+| 8300002 | Operation failed. Cannot connect to service. |
+| 8300003 | System internal error. |
+| 8300999 | Unknown error code. |
+
**Example**
```js
@@ -1243,7 +1777,7 @@ getSubCallIdList\(callId: number\): Promise\>
Obtains the list of subcall IDs. This API uses a promise to return the result.
-This is a system API.
+**System API**: This is a system API.
**System capability**: SystemCapability.Telephony.CallManager
@@ -1259,6 +1793,17 @@ This is a system API.
| ----------------------------- | ----------------------------------- |
| Promise<Array> | Promise used to return the result.|
+**Error codes**
+For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
+
+| ID| Error Message |
+| -------- | -------------------------------------------- |
+| 401 | Parameter error. |
+| 8300001 | Invalid parameter value. |
+| 8300002 | Operation failed. Cannot connect to service. |
+| 8300003 | System internal error. |
+| 8300999 | Unknown error code. |
+
**Example**
```js
@@ -1276,7 +1821,7 @@ getCallIdListForConference\(callId: number, callback: AsyncCallback> | Yes | Callback used to return the result. |
+**Error codes**
+For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
+
+| ID| Error Message |
+| -------- | -------------------------------------------- |
+| 401 | Parameter error. |
+| 8300001 | Invalid parameter value. |
+| 8300002 | Operation failed. Cannot connect to service. |
+| 8300003 | System internal error. |
+| 8300999 | Unknown error code. |
+
**Example**
```js
@@ -1302,7 +1858,7 @@ getCallIdListForConference\(callId: number\): Promise\>
Obtains the list of call IDs in a conference. This API uses a promise to return the result.
-This is a system API.
+**System API**: This is a system API.
**System capability**: SystemCapability.Telephony.CallManager
@@ -1318,6 +1874,17 @@ This is a system API.
| ----------------------------- | --------------------------------------- |
| Promise<Array> | Promise used to return the result.|
+**Error codes**
+For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
+
+| ID| Error Message |
+| -------- | -------------------------------------------- |
+| 401 | Parameter error. |
+| 8300001 | Invalid parameter value. |
+| 8300002 | Operation failed. Cannot connect to service. |
+| 8300003 | System internal error. |
+| 8300999 | Unknown error code. |
+
**Example**
```js
@@ -1335,7 +1902,7 @@ getCallWaitingStatus\(slotId: number, callback: AsyncCallback- **0**: card slot 1
- **1**: card slot 2 |
-| callback | AsyncCallback<[CallWaitingStatus](#callwaitingstatus7)\> | Yes | Callback used to return the result.
- **0**: Call waiting is disabled.
- **1**: Call waiting is enabled.|
+| slotId | number | Yes | Card slot ID.
- **0**: card slot 1
- **1**: card slot 2 |
+| callback | AsyncCallback<[CallWaitingStatus](#callwaitingstatus7)\> | Yes | Callback used to return the result.
- **0**: Call waiting is disabled.
- **1**: Call waiting is enabled.|
+
+**Error codes**
+For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
+
+| ID| Error Message |
+| -------- | -------------------------------------------- |
+| 201 | Permission denied. |
+| 401 | Parameter error. |
+| 8300001 | Invalid parameter value. |
+| 8300002 | Operation failed. Cannot connect to service. |
+| 8300003 | System internal error. |
+| 8300999 | Unknown error code. |
**Example**
@@ -1363,7 +1942,7 @@ getCallWaitingStatus\(slotId: number\): Promise
Obtains the call waiting status. This API uses a promise to return the result.
-This is a system API.
+**System API**: This is a system API.
**Required permission**: ohos.permission.GET_TELEPHONY_STATE
@@ -1381,6 +1960,18 @@ This is a system API.
| ------------------------------------------------------- | ------------------------------------------------------------ |
| Promise<[CallWaitingStatus](#callwaitingstatus7)> | Promise used to return the result.
- **0**: Call waiting is disabled.
- **1**: Call waiting is enabled.|
+**Error codes**
+For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
+
+| ID| Error Message |
+| -------- | -------------------------------------------- |
+| 201 | Permission denied. |
+| 401 | Parameter error. |
+| 8300001 | Invalid parameter value. |
+| 8300002 | Operation failed. Cannot connect to service. |
+| 8300003 | System internal error. |
+| 8300999 | Unknown error code. |
+
**Example**
```js
@@ -1398,7 +1989,7 @@ setCallWaiting\(slotId: number, activate: boolean, callback: AsyncCallback- **false**: Disable call waiting.
- **true**: Enable call waiting.|
| callback | AsyncCallback | Yes | Callback used to return the result. |
+**Error codes**
+For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
+
+| ID| Error Message |
+| -------- | -------------------------------------------- |
+| 201 | Permission denied. |
+| 401 | Parameter error. |
+| 8300001 | Invalid parameter value. |
+| 8300002 | Operation failed. Cannot connect to service. |
+| 8300003 | System internal error. |
+| 8300999 | Unknown error code. |
+
**Example**
```js
@@ -1427,7 +2030,7 @@ setCallWaiting\(slotId: number, activate: boolean\): Promise
Sets the call waiting switch. This API uses a promise to return the result.
-This is a system API.
+**System API**: This is a system API.
**Required permission**: ohos.permission.SET_TELEPHONY_STATE
@@ -1446,6 +2049,18 @@ This is a system API.
| ------------------- | --------------------------- |
| Promise<void> | Promise used to return the result.|
+**Error codes**
+For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
+
+| ID| Error Message |
+| -------- | -------------------------------------------- |
+| 201 | Permission denied. |
+| 401 | Parameter error. |
+| 8300001 | Invalid parameter value. |
+| 8300002 | Operation failed. Cannot connect to service. |
+| 8300003 | System internal error. |
+| 8300999 | Unknown error code. |
+
**Example**
```js
@@ -1461,9 +2076,9 @@ promise.then(data => {
startDTMF\(callId: number, character: string, callback: AsyncCallback\): void
-Enables dual-tone multifrequency (DTMF). This API uses an asynchronous callback to return the result.
+Enables DTMF. This API uses an asynchronous callback to return the result.
-This is a system API.
+**System API**: This is a system API.
**System capability**: SystemCapability.Telephony.CallManager
@@ -1475,6 +2090,17 @@ This is a system API.
| character | string | Yes | DTMF code. |
| callback | AsyncCallback | Yes | Callback used to return the result.|
+**Error codes**
+For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
+
+| ID| Error Message |
+| -------- | -------------------------------------------- |
+| 401 | Parameter error. |
+| 8300001 | Invalid parameter value. |
+| 8300002 | Operation failed. Cannot connect to service. |
+| 8300003 | System internal error. |
+| 8300999 | Unknown error code. |
+
**Example**
```js
@@ -1490,7 +2116,7 @@ startDTMF\(callId: number, character: string\): Promise
Enables DTMF. This API uses a promise to return the result.
-This is a system API.
+**System API**: This is a system API.
**System capability**: SystemCapability.Telephony.CallManager
@@ -1507,6 +2133,17 @@ This is a system API.
| ------------------- | ----------------------- |
| Promise<void> | Promise used to return the result.|
+**Error codes**
+For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
+
+| ID| Error Message |
+| -------- | -------------------------------------------- |
+| 401 | Parameter error. |
+| 8300001 | Invalid parameter value. |
+| 8300002 | Operation failed. Cannot connect to service. |
+| 8300003 | System internal error. |
+| 8300999 | Unknown error code. |
+
**Example**
```js
@@ -1524,7 +2161,7 @@ stopDTMF\(callId: number, callback: AsyncCallback\): void
Stops DTMF. This API uses an asynchronous callback to return the result.
-This is a system API.
+**System API**: This is a system API.
**System capability**: SystemCapability.Telephony.CallManager
@@ -1535,6 +2172,17 @@ This is a system API.
| callId | number | Yes | Call ID. |
| callback | AsyncCallback<void> | Yes | Callback used to return the result.|
+**Error codes**
+For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
+
+| ID| Error Message |
+| -------- | -------------------------------------------- |
+| 401 | Parameter error. |
+| 8300001 | Invalid parameter value. |
+| 8300002 | Operation failed. Cannot connect to service. |
+| 8300003 | System internal error. |
+| 8300999 | Unknown error code. |
+
**Example**
```js
@@ -1550,7 +2198,7 @@ stopDTMF\(callId: number\): Promise
Stops DTMF. This API uses a promise to return the result.
-This is a system API.
+**System API**: This is a system API.
**System capability**: SystemCapability.Telephony.CallManager
@@ -1566,6 +2214,17 @@ This is a system API.
| ------------------- | --------------------------- |
| Promise<void> | Promise used to return the result.|
+**Error codes**
+For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
+
+| ID| Error Message |
+| -------- | -------------------------------------------- |
+| 401 | Parameter error. |
+| 8300001 | Invalid parameter value. |
+| 8300002 | Operation failed. Cannot connect to service. |
+| 8300003 | System internal error. |
+| 8300999 | Unknown error code. |
+
**Example**
```js
@@ -1583,7 +2242,7 @@ isInEmergencyCall\(callback: AsyncCallback\): void
Checks whether a call is an emergency call. This API uses an asynchronous callback to return the result.
-This is a system API.
+**System API**: This is a system API.
**Required permission**: ohos.permission.SET_TELEPHONY_STATE
@@ -1595,6 +2254,18 @@ This is a system API.
| -------- | ---------------------------- | ---- | ---------- |
| callback | AsyncCallback<boolean> | Yes | Callback used to return the result.|
+**Error codes**
+For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
+
+| ID| Error Message |
+| -------- | -------------------------------------------- |
+| 201 | Permission denied. |
+| 401 | Parameter error. |
+| 8300001 | Invalid parameter value. |
+| 8300002 | Operation failed. Cannot connect to service. |
+| 8300003 | System internal error. |
+| 8300999 | Unknown error code. |
+
**Example**
```js
@@ -1610,7 +2281,7 @@ isInEmergencyCall\(\): Promise
Checks whether a call is an emergency call. This API uses a promise to return the result.
-This is a system API.
+**System API**: This is a system API.
**Required permission**: ohos.permission.SET_TELEPHONY_STATE
@@ -1622,6 +2293,18 @@ This is a system API.
| ---------------------- | --------------------------- |
| Promise<boolean> | Promise used to return the result.|
+**Error codes**
+For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
+
+| ID| Error Message |
+| -------- | -------------------------------------------- |
+| 201 | Permission denied. |
+| 401 | Parameter error. |
+| 8300001 | Invalid parameter value. |
+| 8300002 | Operation failed. Cannot connect to service. |
+| 8300003 | System internal error. |
+| 8300999 | Unknown error code. |
+
**Example**
```js
@@ -1639,7 +2322,7 @@ on\(type: 'callDetailsChange', callback: Callback\): void
Subscribes to **callDetailsChange** events. This API uses an asynchronous callback to return the result.
-This is a system API.
+**System API**: This is a system API.
**Required permission**: ohos.permission.SET_TELEPHONY_STATE
@@ -1652,6 +2335,18 @@ This is a system API.
| type | string | Yes | Call details change during a call.|
| callback | Callback<[CallAttributeOptions](#callattributeoptions7)> | Yes | Callback used to return the result. |
+**Error codes**
+For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
+
+| ID| Error Message |
+| -------- | -------------------------------------------- |
+| 201 | Permission denied. |
+| 401 | Parameter error. |
+| 8300001 | Invalid parameter value. |
+| 8300002 | Operation failed. Cannot connect to service. |
+| 8300003 | System internal error. |
+| 8300999 | Unknown error code. |
+
**Example**
```js
@@ -1666,7 +2361,7 @@ on\(type: 'callEventChange', callback: Callback\): void
Subscribes to **callEventChange** events. This API uses an asynchronous callback to return the result.
-This is a system API.
+**System API**: This is a system API.
**Required permission**: ohos.permission.SET_TELEPHONY_STATE
@@ -1679,6 +2374,18 @@ This is a system API.
| type | string | Yes | Call event change during a call.|
| callback | Callback<[CallEventOptions](#calleventoptions8)> | Yes | Callback used to return the result. |
+**Error codes**
+For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
+
+| ID| Error Message |
+| -------- | -------------------------------------------- |
+| 201 | Permission denied. |
+| 401 | Parameter error. |
+| 8300001 | Invalid parameter value. |
+| 8300002 | Operation failed. Cannot connect to service. |
+| 8300003 | System internal error. |
+| 8300999 | Unknown error code. |
+
**Example**
```js
@@ -1693,7 +2400,7 @@ on\(type: 'callDisconnectedCause', callback: Callback): vo
Subscribes to **callDisconnectedCause** events. This API uses an asynchronous callback to return the result.
-This is a system API.
+**System API**: This is a system API.
**Required permission**: ohos.permission.SET_TELEPHONY_STATE
@@ -1706,6 +2413,18 @@ This is a system API.
| type | string | Yes | Cause of the call disconnection.|
| callback | Callback<[DisconnectedDetails](#disconnecteddetails9)> | Yes | Callback used to return the result. |
+**Error codes**
+For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
+
+| ID| Error Message |
+| -------- | -------------------------------------------- |
+| 201 | Permission denied. |
+| 401 | Parameter error. |
+| 8300001 | Invalid parameter value. |
+| 8300002 | Operation failed. Cannot connect to service. |
+| 8300003 | System internal error. |
+| 8300999 | Unknown error code. |
+
**Example**
```js
@@ -1720,7 +2439,7 @@ on\(type: 'mmiCodeResult', callback: Callback\): void
Subscribes to **mmiCodeResult** events. This API uses an asynchronous callback to return the result.
-This is a system API.
+**System API**: This is a system API.
**Required permission**: ohos.permission.SET_TELEPHONY_STATE
@@ -1733,6 +2452,18 @@ This is a system API.
| type | string | Yes | Man-machine interface (MMI) code result.|
| callback | Callback<[MmiCodeResults](#mmicoderesults9)> | Yes | Callback used to return the result. |
+**Error codes**
+For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
+
+| ID| Error Message |
+| -------- | -------------------------------------------- |
+| 201 | Permission denied. |
+| 401 | Parameter error. |
+| 8300001 | Invalid parameter value. |
+| 8300002 | Operation failed. Cannot connect to service. |
+| 8300003 | System internal error. |
+| 8300999 | Unknown error code. |
+
**Example**
```js
@@ -1747,7 +2478,7 @@ off\(type: 'callDetailsChange', callback?: Callback\): vo
Unsubscribes from **callDetailsChange** events. This API uses an asynchronous callback to return the result.
-This is a system API.
+**System API**: This is a system API.
**Required permission**: ohos.permission.SET_TELEPHONY_STATE
@@ -1757,9 +2488,21 @@ This is a system API.
| Name | Type | Mandatory| Description |
| -------- | -------------------------------------------------------- | ---- | ---------------------------------- |
-| type | string | Yes | Unsubscription from call details changes when a call ends.|
+| type | string | Yes | IMS registration status changes.|
| callback | Callback<[CallAttributeOptions](#callattributeoptions7)> | No | Callback used to return the result. |
+**Error codes**
+For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
+
+| ID| Error Message |
+| -------- | -------------------------------------------- |
+| 201 | Permission denied. |
+| 401 | Parameter error. |
+| 8300001 | Invalid parameter value. |
+| 8300002 | Operation failed. Cannot connect to service. |
+| 8300003 | System internal error. |
+| 8300999 | Unknown error code. |
+
**Example**
```js
@@ -1774,7 +2517,7 @@ off\(type: 'callEventChange', callback?: Callback\): void
Unsubscribes from **callEventChange** events. This API uses an asynchronous callback to return the result.
-This is a system API.
+**System API**: This is a system API.
**Required permission**: ohos.permission.SET_TELEPHONY_STATE
@@ -1787,6 +2530,18 @@ This is a system API.
| type | string | Yes | Unsubscription from call event changes when a call ends.|
| callback | Callback<[CallEventOptions](#calleventoptions8)> | No | Callback used to return the result. |
+**Error codes**
+For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
+
+| ID| Error Message |
+| -------- | -------------------------------------------- |
+| 201 | Permission denied. |
+| 401 | Parameter error. |
+| 8300001 | Invalid parameter value. |
+| 8300002 | Operation failed. Cannot connect to service. |
+| 8300003 | System internal error. |
+| 8300999 | Unknown error code. |
+
**Example**
```js
@@ -1801,7 +2556,7 @@ off\(type: 'callDisconnectedCause', callback?: Callback\):
Unsubscribes from **callDisconnectedCause** events. This API uses an asynchronous callback to return the result.
-This is a system API.
+**System API**: This is a system API.
**Required permission**: ohos.permission.SET_TELEPHONY_STATE
@@ -1814,6 +2569,18 @@ This is a system API.
| type | 'callDisconnectedCause' | Yes | Unsubscription from the call disconnection cause when a call ends.|
| callback | Callback**<**[DisconnectedDetails](#disconnecteddetails9)> | No | Callback used to return the result. |
+**Error codes**
+For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
+
+| ID| Error Message |
+| -------- | -------------------------------------------- |
+| 201 | Permission denied. |
+| 401 | Parameter error. |
+| 8300001 | Invalid parameter value. |
+| 8300002 | Operation failed. Cannot connect to service. |
+| 8300003 | System internal error. |
+| 8300999 | Unknown error code. |
+
**Example**
```js
@@ -1828,7 +2595,7 @@ off\(type: 'mmiCodeResult', callback?: Callback\): void
Unsubscribes from **mmiCodeResult** events. This API uses an asynchronous callback to return the result.
-This is a system API.
+**System API**: This is a system API.
**Required permission**: ohos.permission.SET_TELEPHONY_STATE
@@ -1841,6 +2608,18 @@ This is a system API.
| type | 'mmiCodeResult' | Yes | MMI code result.|
| callback | Callback<[MmiCodeResults](#mmicoderesults9)> | No | Callback used to return the result. |
+**Error codes**
+For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
+
+| ID| Error Message |
+| -------- | -------------------------------------------- |
+| 201 | Permission denied. |
+| 401 | Parameter error. |
+| 8300001 | Invalid parameter value. |
+| 8300002 | Operation failed. Cannot connect to service. |
+| 8300003 | System internal error. |
+| 8300999 | Unknown error code. |
+
**Example**
```js
@@ -1855,7 +2634,7 @@ isNewCallAllowed\(callback: AsyncCallback\): void
Checks whether a new call is allowed. This API uses an asynchronous callback to return the result.
-This is a system API.
+**System API**: This is a system API.
**System capability**: SystemCapability.Telephony.CallManager
@@ -1865,6 +2644,17 @@ This is a system API.
| -------- | ---------------------------- | ---- | ---------- |
| callback | AsyncCallback<boolean> | Yes | Callback used to return the result.|
+**Error codes**
+For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
+
+| ID| Error Message |
+| -------- | -------------------------------------------- |
+| 401 | Parameter error. |
+| 8300001 | Invalid parameter value. |
+| 8300002 | Operation failed. Cannot connect to service. |
+| 8300003 | System internal error. |
+| 8300999 | Unknown error code. |
+
**Example**
```js
@@ -1880,7 +2670,7 @@ isNewCallAllowed\(\): Promise
Checks whether a new call is allowed. This API uses a promise to return the result.
-This is a system API.
+**System API**: This is a system API.
**System capability**: SystemCapability.Telephony.CallManager
@@ -1890,6 +2680,17 @@ This is a system API.
| ---------------------- | --------------------------- |
| Promise<boolean> | Promise used to return the result.|
+**Error codes**
+For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
+
+| ID| Error Message |
+| -------- | -------------------------------------------- |
+| 401 | Parameter error. |
+| 8300001 | Invalid parameter value. |
+| 8300002 | Operation failed. Cannot connect to service. |
+| 8300003 | System internal error. |
+| 8300999 | Unknown error code. |
+
**Example**
```js
@@ -1905,9 +2706,9 @@ promise.then(data => {
separateConference\(callId: number, callback: AsyncCallback\): void
-Separates a conference call. This API uses an asynchronous callback to return the result.
+Separates calls from a conference call. This API uses an asynchronous callback to return the result.
-This is a system API.
+**System API**: This is a system API.
**System capability**: SystemCapability.Telephony.CallManager
@@ -1918,6 +2719,17 @@ This is a system API.
| callId | number | Yes | Call ID. |
| callback | AsyncCallback<void> | Yes | Callback used to return the result.|
+**Error codes**
+For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
+
+| ID| Error Message |
+| -------- | -------------------------------------------- |
+| 401 | Parameter error. |
+| 8300001 | Invalid parameter value. |
+| 8300002 | Operation failed. Cannot connect to service. |
+| 8300003 | System internal error. |
+| 8300999 | Unknown error code. |
+
**Example**
```js
@@ -1931,9 +2743,9 @@ call.separateConference(1, (err, data) => {
separateConference\(callId: number\): Promise
-Separates a conference call. This API uses a promise to return the result.
+Separates calls from a conference call. This API uses a promise to return the result.
-This is a system API.
+**System API**: This is a system API.
**System capability**: SystemCapability.Telephony.CallManager
@@ -1949,6 +2761,17 @@ This is a system API.
| ------------------- | --------------------------- |
| Promise<void> | Promise used to return the result.|
+**Error codes**
+For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
+
+| ID| Error Message |
+| -------- | -------------------------------------------- |
+| 401 | Parameter error. |
+| 8300001 | Invalid parameter value. |
+| 8300002 | Operation failed. Cannot connect to service. |
+| 8300003 | System internal error. |
+| 8300999 | Unknown error code. |
+
**Example**
```js
@@ -1966,7 +2789,7 @@ getCallRestrictionStatus\(slotId: number, type: CallRestrictionType, callback: A
Obtains the call restriction status. This API uses an asynchronous callback to return the result.
-This is a system API.
+**System API**: This is a system API.
**Required permission**: ohos.permission.GET_TELEPHONY_STATE
@@ -1980,6 +2803,18 @@ This is a system API.
| type | [CallRestrictionType](#callrestrictiontype8) | Yes | Call restriction type. |
| callback | AsyncCallback<[RestrictionStatus](#restrictionstatus8)> | Yes | Callback used to return the result. |
+**Error codes**
+For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
+
+| ID| Error Message |
+| -------- | -------------------------------------------- |
+| 201 | Permission denied. |
+| 401 | Parameter error. |
+| 8300001 | Invalid parameter value. |
+| 8300002 | Operation failed. Cannot connect to service. |
+| 8300003 | System internal error. |
+| 8300999 | Unknown error code. |
+
**Example**
```js
@@ -1995,7 +2830,7 @@ getCallRestrictionStatus\(slotId: number, type: CallRestrictionType\): Promise
Sets the call restriction status. This API uses a promise to return the result.
-This is a system API.
+**System API**: This is a system API.
**Required permission**: ohos.permission.SET_TELEPHONY_STATE
@@ -2084,6 +2943,18 @@ This is a system API.
| ------------------- | --------------------------- |
| Promise<void> | Promise used to return the result.|
+**Error codes**
+For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
+
+| ID| Error Message |
+| -------- | -------------------------------------------- |
+| 201 | Permission denied. |
+| 401 | Parameter error. |
+| 8300001 | Invalid parameter value. |
+| 8300002 | Operation failed. Cannot connect to service. |
+| 8300003 | System internal error. |
+| 8300999 | Unknown error code. |
+
**Example**
```js
@@ -2106,7 +2977,7 @@ getCallTransferInfo\(slotId: number, type: CallTransferType, callback: AsyncCall
Obtains call transfer information. This API uses an asynchronous callback to return the result.
-This is a system API.
+**System API**: This is a system API.
**Required permission**: ohos.permission.GET_TELEPHONY_STATE
@@ -2120,10 +2991,22 @@ This is a system API.
| type | [CallTransferType](#calltransfertype8) | Yes | Call transfer type. |
| callback | AsyncCallback<[CallTransferResult](#calltransferresult8)> | Yes | Callback used to return the result. |
+**Error codes**
+For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
+
+| ID| Error Message |
+| -------- | -------------------------------------------- |
+| 201 | Permission denied. |
+| 401 | Parameter error. |
+| 8300001 | Invalid parameter value. |
+| 8300002 | Operation failed. Cannot connect to service. |
+| 8300003 | System internal error. |
+| 8300999 | Unknown error code. |
+
**Example**
```js
-call.getCallTransferInfo(0, callTransferTyp, (err, data) => {
+call.getCallTransferInfo(0, call.CallTransferType.TRANSFER_TYPE_BUSY, (err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
});
```
@@ -2135,7 +3018,7 @@ getCallTransferInfo\(slotId: number, type: CallTransferType): Promise
Sets call transfer information. This API uses a promise to return the result.
-This is a system API.
+**System API**: This is a system API.
**Required permission**: ohos.permission.SET_TELEPHONY_STATE
@@ -2224,6 +3131,18 @@ This is a system API.
| ------------------- | --------------------------- |
| Promise<void> | Promise used to return the result.|
+**Error codes**
+For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
+
+| ID| Error Message |
+| -------- | -------------------------------------------- |
+| 201 | Permission denied. |
+| 401 | Parameter error. |
+| 8300001 | Invalid parameter value. |
+| 8300002 | Operation failed. Cannot connect to service. |
+| 8300003 | System internal error. |
+| 8300999 | Unknown error code. |
+
**Example**
```js
@@ -2246,7 +3165,7 @@ isRinging\(callback: AsyncCallback\): void
Checks whether the ringtone is playing. This API uses an asynchronous callback to return the result.
-This is a system API.
+**System API**: This is a system API.
**Required permission**: ohos.permission.SET_TELEPHONY_STATE
@@ -2258,6 +3177,18 @@ This is a system API.
| -------- | ---------------------------- | ---- | ---------- |
| callback | AsyncCallback<boolean> | Yes | Callback used to return the result.|
+**Error codes**
+For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
+
+| ID| Error Message |
+| -------- | -------------------------------------------- |
+| 201 | Permission denied. |
+| 401 | Parameter error. |
+| 8300001 | Invalid parameter value. |
+| 8300002 | Operation failed. Cannot connect to service. |
+| 8300003 | System internal error. |
+| 8300999 | Unknown error code. |
+
**Example**
```js
@@ -2273,7 +3204,7 @@ isRinging\(\): Promise
Checks whether the ringtone is playing. This API uses a promise to return the result.
-This is a system API.
+**System API**: This is a system API.
**Required permission**: ohos.permission.SET_TELEPHONY_STATE
@@ -2285,6 +3216,18 @@ This is a system API.
| ---------------------- | --------------------------- |
| Promise<boolean> | Promise used to return the result.|
+**Error codes**
+For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
+
+| ID| Error Message |
+| -------- | -------------------------------------------- |
+| 201 | Permission denied. |
+| 401 | Parameter error. |
+| 8300001 | Invalid parameter value. |
+| 8300002 | Operation failed. Cannot connect to service. |
+| 8300003 | System internal error. |
+| 8300999 | Unknown error code. |
+
**Example**
```js
@@ -2302,7 +3245,7 @@ setMuted\(callback: AsyncCallback\): void
Sets call muting. This API uses an asynchronous callback to return the result.
-This is a system API.
+**System API**: This is a system API.
**System capability**: SystemCapability.Telephony.CallManager
@@ -2312,6 +3255,17 @@ This is a system API.
| -------- | ------------------------- | ---- | ---------- |
| callback | AsyncCallback<void> | Yes | Callback used to return the result.|
+**Error codes**
+For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
+
+| ID| Error Message |
+| -------- | -------------------------------------------- |
+| 401 | Parameter error. |
+| 8300001 | Invalid parameter value. |
+| 8300002 | Operation failed. Cannot connect to service. |
+| 8300003 | System internal error. |
+| 8300999 | Unknown error code. |
+
**Example**
```js
@@ -2327,7 +3281,7 @@ setMuted\(\): Promise
Sets call muting. This API uses a promise to return the result.
-This is a system API.
+**System API**: This is a system API.
**System capability**: SystemCapability.Telephony.CallManager
@@ -2337,6 +3291,17 @@ This is a system API.
| ------------------- | --------------------------- |
| Promise<void> | Promise used to return the result.|
+**Error codes**
+For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
+
+| ID| Error Message |
+| -------- | -------------------------------------------- |
+| 401 | Parameter error. |
+| 8300001 | Invalid parameter value. |
+| 8300002 | Operation failed. Cannot connect to service. |
+| 8300003 | System internal error. |
+| 8300999 | Unknown error code. |
+
**Example**
```js
@@ -2354,7 +3319,7 @@ cancelMuted(callback: AsyncCallback): void
Cancels call muting. This API uses an asynchronous callback to return the result.
-This is a system API.
+**System API**: This is a system API.
**System capability**: SystemCapability.Telephony.CallManager
@@ -2364,6 +3329,17 @@ This is a system API.
| -------- | ------------------------- | ---- | ---------- |
| callback | AsyncCallback<void> | Yes | Callback used to return the result.|
+**Error codes**
+For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
+
+| ID| Error Message |
+| -------- | -------------------------------------------- |
+| 401 | Parameter error. |
+| 8300001 | Invalid parameter value. |
+| 8300002 | Operation failed. Cannot connect to service. |
+| 8300003 | System internal error. |
+| 8300999 | Unknown error code. |
+
**Example**
```js
@@ -2379,7 +3355,7 @@ cancelMuted(): Promise
Cancels call muting. This API uses a promise to return the result.
-This is a system API.
+**System API**: This is a system API.
**System capability**: SystemCapability.Telephony.CallManager
@@ -2389,6 +3365,17 @@ This is a system API.
| ------------------- | --------------------------- |
| Promise<void> | Promise used to return the result.|
+**Error codes**
+For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
+
+| ID| Error Message |
+| -------- | -------------------------------------------- |
+| 401 | Parameter error. |
+| 8300001 | Invalid parameter value. |
+| 8300002 | Operation failed. Cannot connect to service. |
+| 8300003 | System internal error. |
+| 8300999 | Unknown error code. |
+
**Example**
```js
@@ -2400,13 +3387,13 @@ promise.then(data => {
});
```
-## call.setAudioDevice9+
+## call.setAudioDevice8+
setAudioDevice\(device: AudioDevice, callback: AsyncCallback\): void
Sets the audio device for a call. This API uses an asynchronous callback to return the result.
-This is a system API.
+**System API**: This is a system API.
**System capability**: SystemCapability.Telephony.CallManager
@@ -2417,6 +3404,17 @@ This is a system API.
| device | [AudioDevice](#audiodevice8) | Yes | Audio device.|
| callback | AsyncCallback<void> | Yes | Callback used to return the result.|
+**Error codes**
+For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
+
+| ID| Error Message |
+| -------- | -------------------------------------------- |
+| 401 | Parameter error. |
+| 8300001 | Invalid parameter value. |
+| 8300002 | Operation failed. Cannot connect to service. |
+| 8300003 | System internal error. |
+| 8300999 | Unknown error code. |
+
**Example**
```js
@@ -2432,7 +3430,7 @@ setAudioDevice\(device: AudioDevice, options: AudioDeviceOptions, callback: Asyn
Sets the audio device for a call based on the specified options. This API uses an asynchronous callback to return the result.
-This is a system API.
+**System API**: This is a system API.
**System capability**: SystemCapability.Telephony.CallManager
@@ -2444,6 +3442,17 @@ This is a system API.
| options | [AudioDeviceOptions](#audiodeviceoptions9) | Yes | Audio device parameters.|
| callback | AsyncCallback<void> | Yes | Callback used to return the result. |
+**Error codes**
+For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
+
+| ID| Error Message |
+| -------- | -------------------------------------------- |
+| 401 | Parameter error. |
+| 8300001 | Invalid parameter value. |
+| 8300002 | Operation failed. Cannot connect to service. |
+| 8300003 | System internal error. |
+| 8300999 | Unknown error code. |
+
**Example**
```js
@@ -2456,13 +3465,13 @@ call.setAudioDevice(1, audioDeviceOptions, (err, data) => {
```
-## call.setAudioDevice8+
+## call.setAudioDevice9+
setAudioDevice(device: AudioDevice, options?: AudioDeviceOptions): Promise
Sets the audio device for a call based on the specified options. This API uses a promise to return the result.
-This is a system API.
+**System API**: This is a system API.
**System capability**: SystemCapability.Telephony.CallManager
@@ -2479,6 +3488,17 @@ This is a system API.
| ------------------- | ------------------------------- |
| Promise<void> | Promise used to return the result.|
+**Error codes**
+For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
+
+| ID| Error Message |
+| -------- | -------------------------------------------- |
+| 401 | Parameter error. |
+| 8300001 | Invalid parameter value. |
+| 8300002 | Operation failed. Cannot connect to service. |
+| 8300003 | System internal error. |
+| 8300999 | Unknown error code. |
+
**Example**
```js
@@ -2499,7 +3519,7 @@ joinConference(mainCallId: number, callNumberList: Array, callback: Asy
Joins a conference call. This API uses an asynchronous callback to return the result.
-This is a system API.
+**System API**: This is a system API.
**System capability**: SystemCapability.Telephony.CallManager
@@ -2511,6 +3531,17 @@ This is a system API.
| callNumberList | Array | Yes | List of call numbers.|
| callback | AsyncCallback<void> | Yes | Callback used to return the result. |
+**Error codes**
+For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
+
+| ID| Error Message |
+| -------- | -------------------------------------------- |
+| 401 | Parameter error. |
+| 8300001 | Invalid parameter value. |
+| 8300002 | Operation failed. Cannot connect to service. |
+| 8300003 | System internal error. |
+| 8300999 | Unknown error code. |
+
**Example**
```js
@@ -2528,7 +3559,7 @@ joinConference(mainCallId: number, callNumberList: Array): Promise
Updates the IMS call mode. This API uses a promise to return the result.
-This is a system API.
+**System API**: This is a system API.
**System capability**: SystemCapability.Telephony.CallManager
@@ -2608,6 +3661,17 @@ This is a system API.
| ------------------- | --------------------------- |
| Promise<void> | Promise used to return the result.|
+**Error codes**
+For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
+
+| ID| Error Message |
+| -------- | -------------------------------------------- |
+| 401 | Parameter error. |
+| 8300001 | Invalid parameter value. |
+| 8300002 | Operation failed. Cannot connect to service. |
+| 8300003 | System internal error. |
+| 8300999 | Unknown error code. |
+
**Example**
```js
@@ -2625,7 +3689,7 @@ enableImsSwitch(slotId: number, callback: AsyncCallback): void
Enables the IMS switch. This API uses an asynchronous callback to return the result.
-This is a system API.
+**System API**: This is a system API.
**Required permission**: ohos.permission.SET_TELEPHONY_STATE
@@ -2638,6 +3702,18 @@ This is a system API.
| slotId | number | Yes | Card slot ID.
- **0**: card slot 1
- **1**: card slot 2|
| callback | AsyncCallback<void> | Yes | Callback used to return the result. |
+**Error codes**
+For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
+
+| ID| Error Message |
+| -------- | -------------------------------------------- |
+| 201 | Permission denied. |
+| 401 | Parameter error. |
+| 8300001 | Invalid parameter value. |
+| 8300002 | Operation failed. Cannot connect to service. |
+| 8300003 | System internal error. |
+| 8300999 | Unknown error code. |
+
**Example**
```js
@@ -2652,7 +3728,7 @@ enableImsSwitch(slotId: number): Promise
Enables the IMS switch. This API uses a promise to return the result.
-This is a system API.
+**System API**: This is a system API.
**Required permission**: ohos.permission.SET_TELEPHONY_STATE
@@ -2670,6 +3746,18 @@ This is a system API.
| ------------------- | --------------------------- |
| Promise<void> | Promise used to return the result.|
+**Error codes**
+For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
+
+| ID| Error Message |
+| -------- | -------------------------------------------- |
+| 201 | Permission denied. |
+| 401 | Parameter error. |
+| 8300001 | Invalid parameter value. |
+| 8300002 | Operation failed. Cannot connect to service. |
+| 8300003 | System internal error. |
+| 8300999 | Unknown error code. |
+
**Example**
```js
@@ -2687,7 +3775,7 @@ disableImsSwitch(slotId: number, callback: AsyncCallback): void
Disables the IMS switch. This API uses an asynchronous callback to return the result.
-This is a system API.
+**System API**: This is a system API.
**Required permission**: ohos.permission.SET_TELEPHONY_STATE
@@ -2700,6 +3788,18 @@ This is a system API.
| slotId | number | Yes | Card slot ID.
- **0**: card slot 1
- **1**: card slot 2|
| callback | AsyncCallback<void> | Yes | Callback used to return the result. |
+**Error codes**
+For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
+
+| ID| Error Message |
+| -------- | -------------------------------------------- |
+| 201 | Permission denied. |
+| 401 | Parameter error. |
+| 8300001 | Invalid parameter value. |
+| 8300002 | Operation failed. Cannot connect to service. |
+| 8300003 | System internal error. |
+| 8300999 | Unknown error code. |
+
**Example**
```js
@@ -2714,7 +3814,7 @@ disableImsSwitch(slotId: number): Promise
Disables the IMS switch. This API uses a promise to return the result.
-This is a system API.
+**System API**: This is a system API.
**Required permission**: ohos.permission.SET_TELEPHONY_STATE
@@ -2732,6 +3832,18 @@ This is a system API.
| ------------------- | --------------------------- |
| Promise<void> | Promise used to return the result.|
+**Error codes**
+For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
+
+| ID| Error Message |
+| -------- | -------------------------------------------- |
+| 201 | Permission denied. |
+| 401 | Parameter error. |
+| 8300001 | Invalid parameter value. |
+| 8300002 | Operation failed. Cannot connect to service. |
+| 8300003 | System internal error. |
+| 8300999 | Unknown error code. |
+
**Example**
```js
@@ -2749,7 +3861,7 @@ isImsSwitchEnabled(slotId: number, callback: AsyncCallback): void
Checks whether the IMS switch is enabled. This API uses an asynchronous callback to return the result.
-This is a system API.
+**System API**: This is a system API.
**System capability**: SystemCapability.Telephony.CallManager
@@ -2760,6 +3872,17 @@ This is a system API.
| slotId | number | Yes | Card slot ID.
- **0**: card slot 1
- **1**: card slot 2|
| callback | AsyncCallback<boolean> | Yes | Callback used to return the result. |
+**Error codes**
+For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
+
+| ID| Error Message |
+| -------- | -------------------------------------------- |
+| 401 | Parameter error. |
+| 8300001 | Invalid parameter value. |
+| 8300002 | Operation failed. Cannot connect to service. |
+| 8300003 | System internal error. |
+| 8300999 | Unknown error code. |
+
**Example**
```js
@@ -2774,7 +3897,7 @@ isImsSwitchEnabled(slotId: number): Promise
Checks whether the IMS switch is enabled. This API uses a promise to return the result.
-This is a system API.
+**System API**: This is a system API.
**System capability**: SystemCapability.Telephony.CallManager
@@ -2790,6 +3913,17 @@ This is a system API.
| ------------------- | --------------------------- |
| Promise<void> | Promise used to return the result.|
+**Error codes**
+For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
+
+| ID| Error Message |
+| -------- | -------------------------------------------- |
+| 401 | Parameter error. |
+| 8300001 | Invalid parameter value. |
+| 8300002 | Operation failed. Cannot connect to service. |
+| 8300003 | System internal error. |
+| 8300999 | Unknown error code. |
+
**Example**
```js
@@ -2801,20 +3935,32 @@ promise.then(data => {
});
```
-
## DialOptions
-Defines the dialup options.
+Provides an option for determining whether a call is a video call.
**System capability**: SystemCapability.Telephony.CallManager
-| Name | Type | Mandatory| Description |
-| ------------------------ | ---------------------------------- | ---- | ------------------------------------------------------------ |
+| Name | Type | Mandatory| Description |
+| ------------------------ | ---------------------------------- | ---- | ----------------------------------------------------------------------------------------------- |
| extras | boolean | No | Indication of a video call.
- **true**: video call
- **false** (default): voice call|
-| accountId 8+ | number | No | Account ID.
- **0**: card slot 1
- **1**: card slot 2
This is a system API. |
-| videoState 8+ | [VideoStateType](#videostatetype7) | No | Video state type. This is a system API. |
-| dialScene 8+ | [DialScene](#dialscene8) | No | Dialup scenario. This is a system API. |
-| dialType 8+ | [DialType](#dialtype8) | No | Dialup type. This is a system API. |
+| accountId 8+ | number | No | Account ID.
- **0**: card slot 1
- **1**: card slot 2
This is a system API. |
+| videoState 8+ | [VideoStateType](#videostatetype7) | No | Video state type. This is a system API. |
+| dialScene 8+ | [DialScene](#dialscene8) | No | Dialup scenario. This is a system API. |
+| dialType 8+ | [DialType](#dialtype8) | No | Dialup type. This is a system API. |
+
+## DialCallOptions9+
+
+Defines options for initiating a call.
+
+**System capability**: SystemCapability.Telephony.CallManager
+
+| Name | Type | Mandatory| Description |
+| ------------------------ | ---------------------------------- | ---- | ------------------------------------------------------------ |
+| accountId 9+ | number | No | Account ID.
- **0**: card slot 1
- **1**: card slot 2
This is a system API.|
+| videoState 9+ | [VideoStateType](#videostatetype7) | No | Video state type. This is a system API. |
+| dialScene 9+ | [DialScene](#dialscene8) | No | Dialup scenario. This is a system API. |
+| dialType 9+ | [DialType](#dialtype8) | No | Dialup type. This is a system API. |
## CallState
@@ -2827,33 +3973,33 @@ Enumerates call states.
| CALL_STATE_UNKNOWN | -1 | The call status fails to be obtained and is unknown. |
| CALL_STATE_IDLE | 0 | No call is in progress. |
| CALL_STATE_RINGING | 1 | The call is in the ringing or waiting state. |
-| CALL_STATE_OFFHOOK | 2 | At least one call is in dialing, active, or on hold, and no new incoming call is ringing or waiting. |
+| CALL_STATE_OFFHOOK | 2 | At least one call is in dialing, active, or on hold, and no new incoming call is ringing or waiting.|
## EmergencyNumberOptions7+
-Defines options for determining whether a number is an emergency number.
+Provides an option for determining whether a number is an emergency number for the SIM card in the specified slot.
**System capability**: SystemCapability.Telephony.CallManager
-| Name| Type | Mandatory | Description |
+| Name | Type | Mandatory| Description |
| ------ | ------ | ---- | ---------------------------------------------- |
| slotId | number | No | Card slot ID.
- **0**: card slot 1
- **1**: card slot 2|
## NumberFormatOptions7+
-Defines the number formatting options.
+Provides an option for number formatting.
**System capability**: SystemCapability.Telephony.CallManager
-| Name | Type | Mandatory | Description |
+| Name | Type | Mandatory| Description |
| ----------- | ------ | ---- | ---------------------------------------------------------- |
-| countryCode | string | No | Country code, for example, **CN** (China). All country codes are supported. The default value is **CN**. |
+| countryCode | string | No | Country code, for example, **CN** (China). All country codes are supported. The default value is **CN**.|
## ImsCallMode8+
Enumerates IMS call modes.
-This is a system API.
+**System API**: This is a system API.
**System capability**: SystemCapability.Telephony.CallManager
@@ -2869,23 +4015,23 @@ This is a system API.
Enumerates audio devices.
-This is a system API.
+**System API**: This is a system API.
**System capability**: SystemCapability.Telephony.CallManager
| Name | Value | Description |
| -------------------- | ---- | ------------ |
-| DEVICE_EARPIECE | 0 | Earpiece. |
-| DEVICE_SPEAKER | 1 | Speaker.|
-| DEVICE_WIRED_HEADSET | 2 | Wired headset.|
+| DEVICE_EARPIECE | 0 | Headset device. |
+| DEVICE_SPEAKER | 1 | Speaker device.|
+| DEVICE_WIRED_HEADSET | 2 | Wired headset device.|
| DEVICE_BLUETOOTH_SCO | 3 | Bluetooth SCO device. |
-| DEVICE_MIC | 4 | Microphone. |
+| DEVICE_MIC | 4 | Microphone device|
## CallRestrictionType8+
Enumerates call restriction types.
-This is a system API.
+**System API**: This is a system API.
**System capability**: SystemCapability.Telephony.CallManager
@@ -2904,7 +4050,7 @@ This is a system API.
Defines the call transfer information.
-This is a system API.
+**System API**: This is a system API.
**System capability**: SystemCapability.Telephony.CallManager
@@ -2915,14 +4061,14 @@ This is a system API.
| settingType | [CallTransferSettingType](#calltransfersettingtype8) | Yes | Call transfer setting type.|
| startHour9+ | number | No | Hour in the start time.|
| startMinute9+ | number | No | Minute in the start time.|
-| endHour9+ | number | No | Hour in the end time.|
+| endHour9+ | number | No | Minute in the end time.|
| endMinute9+ | number | No | Minute in the end time.|
## CallTransferType8+
Enumerates call transfer types.
-This is a system API.
+**System API**: This is a system API.
**System capability**: SystemCapability.Telephony.CallManager
@@ -2937,7 +4083,7 @@ This is a system API.
Enumerates call transfer setting types.
-This is a system API.
+**System API**: This is a system API.
**System capability**: SystemCapability.Telephony.CallManager
@@ -2952,11 +4098,11 @@ This is a system API.
Defines the call attribute options.
-This is a system API.
+**System API**: This is a system API.
**System capability**: SystemCapability.Telephony.CallManager
-| Name | Type | Mandatory| Description |
+| Name | Type | Mandatory| Description |
| --------------- | ---------------------------------------- | ---- | -------------- |
| accountNumber | string | Yes | Account number. |
| speakerphoneOn | boolean | Yes | Speakerphone on.|
@@ -2973,7 +4119,7 @@ This is a system API.
Enumerates conference states.
-This is a system API.
+**System API**: This is a system API.
**System capability**: SystemCapability.Telephony.CallManager
@@ -2988,7 +4134,7 @@ This is a system API.
Enumerates call types.
-This is a system API.
+**System API**: This is a system API.
**System capability**: SystemCapability.Telephony.CallManager
@@ -3001,9 +4147,9 @@ This is a system API.
## VideoStateType7+
-Enumerates video state types.
+Video state type.
-This is a system API.
+**System API**: This is a system API.
**System capability**: SystemCapability.Telephony.CallManager
@@ -3016,7 +4162,7 @@ This is a system API.
Enumerates detailed call states.
-This is a system API.
+**System API**: This is a system API.
**System capability**: SystemCapability.Telephony.CallManager
@@ -3036,11 +4182,11 @@ This is a system API.
Defines the call restriction information.
-This is a system API.
+**System API**: This is a system API.
**System capability**: SystemCapability.Telephony.CallManager
-| Name | Type | Mandatory| Description |
+| Name | Type | Mandatory| Description |
| -------- | -------------------------------------------- | ---- | ------------ |
| type | [CallRestrictionType](#callrestrictiontype8) | Yes | Call restriction type.|
| password | string | Yes | Password. |
@@ -3050,7 +4196,7 @@ This is a system API.
Enumerates call restriction modes.
-This is a system API.
+**System API**: This is a system API.
**System capability**: SystemCapability.Telephony.CallManager
@@ -3063,11 +4209,11 @@ This is a system API.
Defines the call event options.
-This is a system API.
+**System API**: This is a system API.
**System capability**: SystemCapability.Telephony.CallManager
-| Name | Type | Mandatory| Description |
+| Name | Type | Mandatory| Description |
| ------- | ------------------------------------------ | ---- | -------------- |
| eventId | [CallAbilityEventId](#callabilityeventid8) | Yes | Call ability event ID.|
@@ -3075,7 +4221,7 @@ This is a system API.
Enumerates call ability event IDs.
-This is a system API.
+**System API**: This is a system API.
**System capability**: SystemCapability.Telephony.CallManager
@@ -3088,7 +4234,7 @@ This is a system API.
Enumerates dialup scenarios.
-This is a system API.
+**System API**: This is a system API.
**System capability**: SystemCapability.Telephony.CallManager
@@ -3102,7 +4248,7 @@ This is a system API.
Enumerates dialup types.
-This is a system API.
+**System API**: This is a system API.
**System capability**: SystemCapability.Telephony.CallManager
@@ -3116,11 +4262,11 @@ This is a system API.
Defines options for the call rejection message.
-This is a system API.
+**System API**: This is a system API.
**System capability**: SystemCapability.Telephony.CallManager
-| Name | Type | Mandatory| Description |
+| Name | Type | Mandatory| Description |
| -------------- | ------ | ---- | -------- |
| messageContent | string | Yes | Message content.|
@@ -3128,7 +4274,7 @@ This is a system API.
Defines the call transfer result.
-This is a system API.
+**System API**: This is a system API.
**System capability**: SystemCapability.Telephony.CallManager
@@ -3138,14 +4284,14 @@ This is a system API.
| number | string | Yes | Call transfer number. |
| startHour9+ | number | Yes | Hour in the start time.|
| startMinute9+ | number | Yes | Minute in the start time.|
-| endHour9+ | number | Yes | Hour in the end time.|
+| endHour9+ | number | Yes | Minute in the end time.|
| endMinute9+ | number | Yes | Minute in the end time.|
## CallWaitingStatus7+
Enumerates call waiting states.
-This is a system API.
+**System API**: This is a system API.
**System capability**: SystemCapability.Telephony.CallManager
@@ -3158,7 +4304,7 @@ This is a system API.
Enumerates call restriction states.
-This is a system API.
+**System API**: This is a system API.
**System capability**: SystemCapability.Telephony.CallManager
@@ -3171,7 +4317,7 @@ This is a system API.
Enumerates call transfer states.
-This is a system API.
+**System API**: This is a system API.
**System capability**: SystemCapability.Telephony.CallManager
@@ -3184,7 +4330,7 @@ This is a system API.
Defines the cause of a call disconnection.
-This is a system API.
+**System API**: This is a system API.
**System capability**: SystemCapability.Telephony.CallManager
@@ -3197,7 +4343,7 @@ This is a system API.
Enumerates causes of call disconnection.
-This is a system API.
+**System API**: This is a system API.
**System capability**: SystemCapability.Telephony.CallManager
@@ -3287,7 +4433,7 @@ This is a system API.
Defines the MMI code result.
-This is a system API.
+**System API**: This is a system API.
**System capability**: SystemCapability.Telephony.CallManager
@@ -3298,9 +4444,9 @@ This is a system API.
## MmiCodeResult9+
-Enumerates MMI code results.
+Defines the MMI code result.
-This is a system API.
+**System API**: This is a system API.
**System capability**: SystemCapability.Telephony.CallManager
@@ -3313,7 +4459,7 @@ This is a system API.
Defines audio device options.
-This is a system API.
+**System API**: This is a system API.
**System capability**: SystemCapability.Telephony.CallManager
diff --git a/en/application-dev/reference/apis/js-apis-camera.md b/en/application-dev/reference/apis/js-apis-camera.md
index b30722bd2fddd6ef83914ffe6b8a3421831935ce..b2f7c32c5a1c513c7b910c3e61c612be7ea31731 100644
--- a/en/application-dev/reference/apis/js-apis-camera.md
+++ b/en/application-dev/reference/apis/js-apis-camera.md
@@ -2,7 +2,8 @@
> **NOTE**
>
-> The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version.
+> - The initial APIs of this module are supported since API version 9. 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
@@ -476,10 +477,10 @@ Listens for camera status changes. This API uses an asynchronous callback to ret
**Parameters**
-| Name | Type | Mandatory| Description |
-| -------- | ----------------------------------------------------- | ---- | --------- |
-| type | string | Yes | Event type. The value is fixed at **'cameraStatus'**. The callback function returns the camera information, including the device and device status (available or unavailable). The event can be listened for only when a **CameraManager** instance is obtained.|
-| callback | AsyncCallback<[CameraStatusInfo](#camerastatusinfo)\> | Yes | Callback used to return the camera status change. |
+| Name | Type | Mandatory| Description |
+| -------- | -----------------| ---- | --------- |
+| type | string | Yes | Event type. The value is fixed at **'cameraStatus'**. The event can be listened for when a **CameraManager** instance is obtained. This event is triggered and the corresponding information is returned only when the device is enabled or disabled.|
+| callback | AsyncCallback<[CameraStatusInfo](#camerastatusinfo)\> | Yes | Callback used to return the camera status change.| |
**Example**
@@ -504,8 +505,8 @@ This is a system API.
| Name | Type | Mandatory| Description |
| -------- | --------------- | ---- | --------- |
-| type | string | Yes | Event type. The value is fixed at **'cameraMute'**. The callback function returns the mute status changes. The event can be listened for only when a **CameraManager** instance is obtained.|
-| callback | AsyncCallback\ | Yes | Callback used to return the camera mute status. |
+| type | string | Yes | Event type. The value is fixed at **'cameraMute'**, indicating the camera mute status. The event can be listened for when a **CameraManager** instance is obtained. This event is triggered and the status is returned when the camera is enabled or disabled.|
+| callback | AsyncCallback\ | Yes | Callback used to return the mute status. The value **true** means that the camera is enabled, and **false** means that the camera is disabled. |
**Example**
@@ -727,7 +728,7 @@ Listens for **CameraInput** errors. This API uses a callback to return the resul
| Name | Type | Mandatory| Description |
| -------- | -------------------------------- | --- | ------------------------------------------- |
-| type | string | Yes | Event type. The value is fixed at **'error'**. The callback function returns an error code, for example, an error code indicating that the device is unavailable or a conflict occurs. The event can be listened for only when a **CameraInput** instance is obtained.|
+| type | string | Yes | Event type. The value is fixed at **'error'**. The event can be listened for when a **CameraInput** instance is created. This event is triggered and the result is returned when an error occurs on the camera. For example, if the device is unavailable or a conflict occurs, the error information is returned.|
| cameraDevice | [CameraDevice](#cameradevice) | Yes | **CameraDevice** object.|
| callback | ErrorCallback | Yes | Callback used to return an error code defined in [CameraErrorCode](#cameraerrorcode). |
@@ -1391,7 +1392,7 @@ try {
setMeteringPoint(point: Point): void
-Sets the metering point for the device.
+Sets the metering point, which is the center point of the metering rectangle.
**System capability**: SystemCapability.Multimedia.Camera.Core
@@ -1448,7 +1449,7 @@ try {
setExposureBias(exposureBias: number): void
-Sets an exposure compensation value for the device.
+Sets an exposure compensation value (EV).
Before the setting, you are advised to use **[getExposureBiasRange](#getexposurebiasrange)** to obtain the supported values.
@@ -1590,7 +1591,7 @@ try {
setFocusPoint(point: Point): void
-Sets a focal point for the device.
+Sets the focal point.
**System capability**: SystemCapability.Multimedia.Camera.Core
@@ -1697,7 +1698,7 @@ try {
setZoomRatio(zoomRatio: number): void
-Sets a zoom ratio for the device.
+Sets a zoom ratio.
**System capability**: SystemCapability.Multimedia.Camera.Core
@@ -1849,7 +1850,7 @@ Listens for focus state changes. This API uses an asynchronous callback to retur
| Name | Type | Mandatory| Description |
| -------- | ----------------------------------------- | ---- | ------------------------ |
-| type | string | Yes | Event type. The value is fixed at **'focusStateChange'**. The callback function returns the focus state change. The event can be listened for only when the session is created.|
+| type | string | Yes | Event type. The value is fixed at **'focusStateChange'**. The event can be listened for when a session is created. This event is triggered only when the camera focus state changes in auto focus mode.|
| callback | AsyncCallback<[FocusState](#focusstate)\> | Yes | Callback used to return the focus state change. |
**Example**
@@ -1872,7 +1873,7 @@ Listens for **CaptureSession** errors. This API uses a callback to return the er
| Name | Type | Mandatory| Description |
| -------- | ----------------------------------------------------------- | ---- | ------------------------------ |
-| type | string | Yes | Event type. The value is fixed at **'error'**. The callback function returns the error code corresponding to an error that occurs during the call of a **CaptureSession** API, for example, **beginConfig()**, **commitConfig()**, or **addInput()**.|
+| type | string | Yes | Event type. The value is fixed at **'error'**. The event can be listened for when a session is created. This event is triggered and the error message is returned when an error occurs during the calling of a session-related API such as **beginConfig()**, **commitConfig()**, and **addInput**.|
| callback | ErrorCallback | Yes | Callback used to return an error code defined in [CameraErrorCode](#cameraerrorcode). |
**Example**
@@ -2053,8 +2054,8 @@ Listens for preview frame start events. This API uses an asynchronous callback t
| Name | Type | Mandatory| Description |
| -------- | -------------------- | ---- | --------------------------------------- |
-| type | string | Yes | Event type. The value is fixed at **'frameStart'**. The callback is invoked when the preview on the first frame starts. This event can be listened for only when a **previewOutput** instance is created.|
-| callback | AsyncCallback | Yes | Callback used to return the result. |
+| type | string | Yes | Event type. The value is fixed at **'frameStart'**. The event can be listened for when a **previewOutput** instance is created. This event is triggered and returned when the bottom layer starts exposure for the first time.|
+| callback | AsyncCallback | Yes | Callback used to return the result. The preview starts as long as this event is returned. |
**Example**
@@ -2076,8 +2077,8 @@ Listens for preview frame end events. This API uses an asynchronous callback to
| Name | Type | Mandatory| Description |
| -------- | -------------------- | ---- | ------------------------------------- |
-| type | string | Yes | Event type. The value is fixed at **'frameEnd'**. The callback is invoked when the preview on the last frame ends. This event can be listened for only when a **previewOutput** instance is created.|
-| callback | AsyncCallback | Yes | Callback used to return the result. |
+| type | string | Yes | Event type. The value is fixed at **'frameEnd'**. The event can be listened for when a **previewOutput** instance is created. This event is triggered and returned when the last frame of preview ends.|
+| callback | AsyncCallback | Yes | Callback used to return the result. The preview ends as long as this event is returned. |
**Example**
@@ -2097,9 +2098,9 @@ Listens for **PreviewOutput** errors. This API uses a callback to return the err
**Parameters**
-| Name | Type | Mandatory| Description |
-| -------- | ----------------------------------------------------------------- | ---- | ------------------------ |
-| type | string | Yes | Event type. The value is fixed at **'error'**. The callback function returns the error code corresponding to an error that occurs during the call of a **PreviewOutput** API, for example, **start()** or **release()**.|
+| Name | Type | Mandatory| Description |
+| -------- | --------------| ---- | ------------------------ |
+| type | string | Yes | Event type. The value is fixed at **'error'**. The event can be listened for when a **previewOutput** instance is created. This event is triggered and the corresponding error message is returned when an error occurs during the use of a preview-related API such as **start()** or **release()**.|
| callback | ErrorCallback | Yes | Callback used to return an error code defined in [CameraErrorCode](#cameraerrorcode). |
**Example**
@@ -2366,7 +2367,7 @@ Listens for shooting start events. This API uses an asynchronous callback to ret
| Name | Type | Mandatory| Description |
| -------- | ---------------------- | ---- | ------------------------------------------ |
-| type | string | Yes | Event type. The value is fixed at **'captureStart'**. The callback function returns the shooting start event.|
+| type | string | Yes | Event type. The value is fixed at **'captureStart'**. The event can be listened for when a **photoOutput** instance is created. This event is triggered and returned when the bottom layer starts exposure each time a photo is taken.|
| callback | AsyncCallback | Yes | Callback used to return the capture ID. |
**Example**
@@ -2387,10 +2388,10 @@ Listens for frame shutter events. This API uses an asynchronous callback to retu
**Parameters**
-| Name | Type | Mandatory| Description |
-| -------- | ----------------------------------------------------- | --- | ------------------------------------ |
-| type | string | Yes | Event type. The value is fixed at **'frameShutter'**. The callback function returns the captured frame information (captureId and time).|
-| callback | AsyncCallback<[FrameShutterInfo](#frameshutterinfo)\> | Yes | Callback used to return the result. |
+| Name | Type | Mandatory| Description |
+| -------- | ---------- | --- | ------------------------------------ |
+| type | string | Yes | Event type. The value is fixed at **'frameShutter'**. The event can be listened for when a **photoOutput** instance is created.|
+| callback | AsyncCallback<[FrameShutterInfo](#frameshutterinfo)\> | Yes | Callback used to return the result. A new photographing request can be delivered as long as this event is returned. |
**Example**
@@ -2411,9 +2412,9 @@ Listens for shooting end events. This API uses an asynchronous callback to retur
**Parameters**
-| Name | Type | Mandatory| Description |
-| -------- | ------------------------------------------------- | ---- | ---------------------------------------- |
-| type | string | Yes | Event type. The value is fixed at **'captureEnd'**. The callback function returns the shooting end event.|
+| Name | Type | Mandatory| Description |
+| -------- | --------------- | ---- | ---------------------------------------- |
+| type | string | Yes | Event type. The value is fixed at **'captureEnd'**. The event can be listened for when a **photoOutput** instance is created. This event is triggered and the corresponding information is returned when the photographing is complete.|
| callback | AsyncCallback<[CaptureEndInfo](#captureendinfo)\> | Yes | Callback used to return the result. |
**Example**
@@ -2435,9 +2436,9 @@ Listens for **PhotoOutput** errors. This API uses a callback to return the error
**Parameters**
-| Name | Type | Mandatory| Description |
-| -------- | ----------------------------------------------------- | ---- | ----------------------------------- |
-| type | string | Yes | Event type. The value is fixed at **'error'**. The callback function returns an error code when an API call fails.|
+| Name | Type | Mandatory| Description |
+| -------- | ------------- | ---- | ----------------------------------- |
+| type | string | Yes | Event type. The value is fixed at **'error'**. The event can be listened for when a **photoOutput** instance is created. This event is triggered and the corresponding error message is returned when an error occurs during the calling of a photographing-related API.|
| callback | ErrorCallback | Yes | Callback used to return an error code defined in [CameraErrorCode](#cameraerrorcode). |
**Example**
@@ -2637,8 +2638,8 @@ Listens for video recording start events. This API uses an asynchronous callback
| Name | Type | Mandatory| Description |
| -------- | -------------------- | ---- | ----------------------------------------- |
-| type | string | Yes | Event type. The value is fixed at **'frameStart'**. The callback is invoked when the recording on the first frame of an image starts.|
-| callback | AsyncCallback | Yes | Callback used to return the result. |
+| type | string | Yes | Event type. The value is fixed at **'frameStart'**. The event can be listened for when a **videoOutput** instance is created. The event is triggered and the corresponding information is returned when the bottom layer starts exposure for the first time.|
+| callback | AsyncCallback | Yes | Callback used to return the result. The recording starts as long as this event is returned. |
**Example**
@@ -2660,8 +2661,8 @@ Listens for video recording stop events. This API uses an asynchronous callback
| Name | Type | Mandatory| Description |
| -------- | -------------------- | ---- | ------------------------------------------ |
-| type | string | Yes | Event type. The value is fixed at **'frameEnd'**. The callback is invoked when the recording on the last frame of an image stops.|
-| callback | AsyncCallback | Yes | Callback used to return the result. |
+| type | string | Yes | Event type. The value is fixed at **'frameEnd'**. The event can be listened for when a **videoOutput** instance is created. This event is triggered and returned when the last frame of recording is complete.|
+| callback | AsyncCallback | Yes | Callback used to return the result. The recording ends as long as this event is returned. |
**Example**
@@ -2681,9 +2682,9 @@ Listens for errors that occur during video recording. This API uses a callback t
**Parameters**
-| Name | Type | Mandatory| Description |
-| -------- | ------------------------------------------------ | ---- | -------------------------------------- |
-| type | string | Yes | Event type. The value is fixed at **'error'**. The callback function returns the error code corresponding to an error that occurs during the call of a **VideoOutput** API, for example, **start()** or **release()**.|
+| Name | Type | Mandatory| Description |
+| -------- | ----------- | ---- | -------------------------------------- |
+| type | string | Yes | Event type. The value is fixed at **'error'**. The event can be listened for when a **videoOutput** instance is created. This event is triggered and the corresponding error message is returned when an error occurs during the calling of a recording-related API such as **start()** and **release()**.|
| callback | Callback | Yes | Callback used to return an error code defined in [CameraErrorCode](#cameraerrorcode). |
**Example**
@@ -2808,9 +2809,9 @@ Listens for metadata objects. This API uses an asynchronous callback to return t
**Parameters**
-| Name | Type | Mandatory| Description |
-| -------- | ------------------------------------------------ | ---- | ------------------------------------ |
-| type | string | Yes | Event type. The value is fixed at **'metadataObjectsAvailable'**. The callback function returns the valid metadata. This event can be listened for only when a **MetadataOutput** instance is created.|
+| Name | Type | Mandatory| Description |
+| -------- | -------------- | ---- | ------------------------------------ |
+| type | string | Yes | Event type. The value is fixed at **'metadataObjectsAvailable'**. The event can be listened for when a **metadataOutput** instance is created. This event is triggered and the corresponding metadata is returned when valid metadata is detected.|
| callback | Callback