From 9dbb03aff970bb830ca535f71a6b1aa16f64ba75 Mon Sep 17 00:00:00 2001 From: Gloria Date: Wed, 24 May 2023 13:51:26 +0800 Subject: [PATCH] Update docs against 17813 Signed-off-by: wusongqing --- ...is-app-ability-abilityLifecycleCallback.md | 2 - .../apis/js-apis-app-ability-appRecovery.md | 3 +- .../js-apis-app-ability-contextConstant.md | 9 +- .../js-apis-inner-ability-abilityResult.md | 10 +- .../js-apis-inner-ability-connectOptions.md | 12 +- ...js-apis-inner-ability-dataAbilityHelper.md | 196 +++++++----- ...apis-inner-ability-dataAbilityOperation.md | 8 +- ...js-apis-inner-ability-dataAbilityResult.md | 101 +++--- ...pis-inner-ability-startAbilityParameter.md | 8 +- .../apis/js-apis-inner-ability-want.md | 14 +- .../apis/js-apis-inner-app-appVersionInfo.md | 6 + .../apis/js-apis-inner-app-context.md | 293 +++++++++++------- .../apis/js-apis-inner-app-processInfo.md | 6 + ...apis-inner-application-abilityDelegator.md | 4 +- ...-inner-application-abilityDelegatorArgs.md | 10 +- ...s-apis-inner-application-abilityMonitor.md | 16 +- ...is-inner-application-abilityRunningInfo.md | 6 + ...s-inner-application-abilityStageContext.md | 6 + ...s-inner-application-abilityStageMonitor.md | 10 +- ...apis-inner-application-abilityStateData.md | 24 +- .../js-apis-inner-application-appStateData.md | 9 +- ...is-inner-application-applicationContext.md | 19 +- ...er-application-applicationStateObserver.md | 22 +- .../js-apis-inner-application-baseContext.md | 8 +- .../apis/js-apis-inner-application-context.md | 48 ++- ...js-apis-inner-application-errorObserver.md | 26 +- .../js-apis-inner-application-eventHub.md | 18 +- ...apis-inner-application-extensionContext.md | 6 + ...-inner-application-extensionRunningInfo.md | 20 +- ...-inner-application-formExtensionContext.md | 2 +- .../js-apis-inner-application-missionInfo.md | 10 + ...-apis-inner-application-missionListener.md | 16 +- ...-apis-inner-application-missionSnapshot.md | 6 + .../js-apis-inner-application-processData.md | 17 +- ...is-inner-application-processInformation.md | 6 + ...is-inner-application-processRunningInfo.md | 6 + ...ner-application-serviceExtensionContext.md | 6 + ...s-apis-inner-application-shellCmdResult.md | 9 +- ...apis-inner-application-uiAbilityContext.md | 149 +++++---- .../js-apis-inner-wantAgent-triggerInfo.md | 10 + .../js-apis-inner-wantAgent-wantAgentInfo.md | 10 + 41 files changed, 788 insertions(+), 379 deletions(-) diff --git a/en/application-dev/reference/apis/js-apis-app-ability-abilityLifecycleCallback.md b/en/application-dev/reference/apis/js-apis-app-ability-abilityLifecycleCallback.md index d5a1bcde1d..05ad66e89b 100644 --- a/en/application-dev/reference/apis/js-apis-app-ability-abilityLifecycleCallback.md +++ b/en/application-dev/reference/apis/js-apis-app-ability-abilityLifecycleCallback.md @@ -7,14 +7,12 @@ The **AbilityLifecycleCallback** module defines the callbacks to receive lifecyc > 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 AbilityLifecycleCallback from '@ohos.app.ability.AbilityLifecycleCallback'; ``` - ## AbilityLifecycleCallback.onAbilityCreate onAbilityCreate(ability: UIAbility): void; 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 dda2798d7f..cf901653e1 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 @@ -11,7 +11,6 @@ The **appRecovery** module provides APIs for recovering faulty applications. import appRecovery from '@ohos.app.ability.appRecovery'; ``` - ## appRecovery.RestartFlag Enumerates the application restart flags. This enum is used as an input parameter of [enableAppRecovery](#apprecoveryenableapprecovery). @@ -51,7 +50,7 @@ Enumerates the application state saving modes. This enum is used as an input par enableAppRecovery(restart?: [RestartFlag](#apprecoveryrestartflag), saveOccasion?: [SaveOccasionFlag](#apprecoverysaveoccasionflag), saveMode?: [SaveModeFlag](#apprecoverysavemodeflag)) : void; -Enables application recovery. +Enables application recovery. After this API is called, the first ability that is displayed when the application is started from the initiator can be restored. **System capability**: SystemCapability.Ability.AbilityRuntime.Core diff --git a/en/application-dev/reference/apis/js-apis-app-ability-contextConstant.md b/en/application-dev/reference/apis/js-apis-app-ability-contextConstant.md index 0c39c8fa01..cb5ec417ab 100644 --- a/en/application-dev/reference/apis/js-apis-app-ability-contextConstant.md +++ b/en/application-dev/reference/apis/js-apis-app-ability-contextConstant.md @@ -1,10 +1,11 @@ # @ohos.app.ability.contextConstant (ContextConstant) -The **ContextConstant** module defines context-related enums. Currently, it defines only the enum of data encryption levels. +The **ContextConstant** module defines context-related enums. Currently, it defines only the enum of encryption levels. > **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 @@ -21,5 +22,5 @@ You can obtain the value of this constant by calling the **ContextConstant.AreaM | Name| Value| Description| | -------- | -------- | -------- | -| EL1 | 0 | Device-level encryption area, which is accessible after the device is powered on.| -| EL2 | 1 | User-level encryption area, which is accessible only after the device is powered on and the password is entered (for the first time).| +| EL1 | 0 | Device-level encryption. Directories with this encryption level are accessible after the device is powered on. | +| EL2 | 1 | User-level encryption. Directories with this encryption level are accessible only after the device is powered on and the password is entered (for the first time). | diff --git a/en/application-dev/reference/apis/js-apis-inner-ability-abilityResult.md b/en/application-dev/reference/apis/js-apis-inner-ability-abilityResult.md index d2107197d2..12dd28f2c5 100644 --- a/en/application-dev/reference/apis/js-apis-inner-ability-abilityResult.md +++ b/en/application-dev/reference/apis/js-apis-inner-ability-abilityResult.md @@ -6,9 +6,15 @@ The **AbilityResult** module defines the result code and data returned when an a > > The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version. +## Modules to Import + +```ts +import ability from '@ohos.ability.ability'; +``` + **System capability**: SystemCapability.Ability.AbilityBase | Name | Readable | Writable | Type | Mandatory| Description | | ----------- | -------- |-------- | -------------------- | ---- | ------------------------------------------------------------ | -| resultCode | Yes | Yes | number | Yes | Result code returned after the started ability is terminated. | -| want | Yes | Yes | [Want](./js-apis-app-ability-want.md) | No | Data returned after the started ability is terminated. | +| resultCode | Yes | No | number | No | Result code returned when the ability is started or terminated. | +| want | Yes | No | [Want](./js-apis-app-ability-want.md) | No | Data returned when the ability is terminated.| diff --git a/en/application-dev/reference/apis/js-apis-inner-ability-connectOptions.md b/en/application-dev/reference/apis/js-apis-inner-ability-connectOptions.md index 126adb9256..4076e57bf9 100644 --- a/en/application-dev/reference/apis/js-apis-inner-ability-connectOptions.md +++ b/en/application-dev/reference/apis/js-apis-inner-ability-connectOptions.md @@ -2,6 +2,16 @@ **ConnectOptions** can be used as an input parameter to receive status changes during the connection to a background service. For example, it is used as an input parameter of [connectServiceExtensionAbility](js-apis-inner-application-serviceExtensionContext.md#serviceextensioncontextconnectserviceextensionability) to connect to a ServiceExtensionAbility. +> **NOTE** +> +> The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version. + +## Modules to Import + +```ts +import common from '@ohos.app.ability.common'; +``` + **System capability**: SystemCapability.Ability.AbilityRuntime.Core | Name | Type | Mandatory | Description | @@ -18,7 +28,7 @@ abilityName: 'MyAbility' }; - let connectOptions = { + let connectOptions: common.ConnectOptions = { onConnect(elementName, remote) { console.log('onConnect elementName: ' + elementName); }, diff --git a/en/application-dev/reference/apis/js-apis-inner-ability-dataAbilityHelper.md b/en/application-dev/reference/apis/js-apis-inner-ability-dataAbilityHelper.md index bed4cf0eee..c294c6e2ea 100644 --- a/en/application-dev/reference/apis/js-apis-inner-ability-dataAbilityHelper.md +++ b/en/application-dev/reference/apis/js-apis-inner-ability-dataAbilityHelper.md @@ -7,6 +7,12 @@ The **DataAbilityHelper** object is obtained through [acquireDataAbilityHelper]( > The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version. > The APIs of this module can be used only in the FA model. +## Modules to Import + +```ts +import ability from '@ohos.ability.ability'; +``` + ## Usage Import the following modules based on the actual situation before using the current module: @@ -19,7 +25,7 @@ import ohos_data_rdb from '@ohos.data.rdb'; openFile(uri: string, mode: string, callback: AsyncCallback\): void -Opens a file with a specified URI. This API uses an asynchronous callback to return a file descriptor. +Opens a file with a specified URI. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.Ability.AbilityRuntime.FAModel @@ -28,14 +34,14 @@ Opens a file with a specified URI. This API uses an asynchronous callback to ret | Name | Type | Mandatory| Description | | -------- | ---------------------- | ---- | ---------------------------------- | | uri | string | Yes | URI of the file to open. | -| mode | string | Yes | Mode for opening the file. The value **r** indicates read-only access, **w** indicates **write-only** access, and **rw** indicates read-write access. | +| mode | string | Yes | Mode for opening the file. The value can be **rwt**. | | callback | AsyncCallback\ | Yes | Callback used to return the file descriptor.| **Example** ```ts import featureAbility from '@ohos.ability.featureAbility'; -let DAHelper = featureAbility.acquireDataAbilityHelper( +let DAHelper: ability.DataAbilityHelper = featureAbility.acquireDataAbilityHelper( 'dataability:///com.example.DataAbility' ); let mode = 'rwt'; @@ -48,7 +54,7 @@ DAHelper.openFile('dataability:///com.example.DataAbility', mode, (err) => { openFile(uri: string, mode: string): Promise\ -Opens a file with a specified URI. This API uses a promise to return a file descriptor. +Opens a file with a specified URI. This API uses a promise to return the result. **System capability**: SystemCapability.Ability.AbilityRuntime.FAModel @@ -57,7 +63,7 @@ Opens a file with a specified URI. This API uses a promise to return a file desc | Name| Type | Mandatory| Description | | ---- | ------ | ---- | ------------------------ | | uri | string | Yes | URI of the file to open.| -| mode | string | Yes | Mode for opening the file. The value **r** indicates read-only access, **w** indicates **write-only** access, and **rw** indicates read-write access. | +| mode | string | Yes | Mode for opening the file. The value can be **rwt**. | **Return value** @@ -69,7 +75,7 @@ Opens a file with a specified URI. This API uses a promise to return a file desc ```ts import featureAbility from '@ohos.ability.featureAbility'; -let DAHelper = featureAbility.acquireDataAbilityHelper( +let DAHelper: ability.DataAbilityHelper = featureAbility.acquireDataAbilityHelper( 'dataability:///com.example.DataAbility' ); let mode = 'rwt'; @@ -90,7 +96,7 @@ Registers an observer to listen for changes in the data specified by a given URI | Name | Type | Mandatory| Description | | -------- | -------------------- | ---- | ------------------------ | -| type | string | Yes | The value **dataChange** means data changes. | +| type | string | Yes | Event type. The value is **dataChange**. | | uri | string | Yes | URI of the data.| | callback | AsyncCallback\ | Yes | Callback invoked when the data is changed. | @@ -98,13 +104,13 @@ Registers an observer to listen for changes in the data specified by a given URI ```ts import featureAbility from '@ohos.ability.featureAbility'; -let helper = featureAbility.acquireDataAbilityHelper( +let DAHelper: ability.DataAbilityHelper = featureAbility.acquireDataAbilityHelper( 'dataability:///com.example.DataAbility' ); function onChangeNotify() { console.info('==========================>onChangeNotify=======================>'); }; -helper.on( +DAHelper.on( 'dataChange', 'dataability:///com.example.DataAbility', onChangeNotify @@ -123,25 +129,25 @@ Deregisters the observer that listens for changes in the data specified by a giv | Name | Type | Mandatory| Description | | -------- | -------------------- | ---- | ------------------------ | -| type | string | Yes | The value **dataChange** means data changes. | +| type | string | Yes | Event type. The value is **dataChange**. | | uri | string | Yes | URI of the data.| -| callback | AsyncCallback\ | No | Callback of the listener to deregister. If the callback is set to **null**, all data change listeners are canceled. | +| callback | AsyncCallback\ | No | Callback used to return the result. | **Example** ```ts import featureAbility from '@ohos.ability.featureAbility'; -let helper = featureAbility.acquireDataAbilityHelper( +let DAHelper: ability.DataAbilityHelper = featureAbility.acquireDataAbilityHelper( 'dataability:///com.example.DataAbility' ); function onChangeNotify() { console.info('==========================>onChangeNotify=======================>'); }; -helper.off( +DAHelper.off( 'dataChange', 'dataability:///com.example.DataAbility', ); -helper.off( +DAHelper.off( 'dataChange', 'dataability:///com.example.DataAbility', onChangeNotify @@ -152,7 +158,7 @@ helper.off( getType(uri: string, callback: AsyncCallback\): void -Obtains the media resource type of the data specified by a given URI. This API uses an asynchronous callback to return the result. +Obtains the MIME type of the data specified by a given URI. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.Ability.AbilityRuntime.FAModel @@ -161,13 +167,13 @@ Obtains the media resource type of the data specified by a given URI. This API u | Name | Type | Mandatory| Description | | -------- | ---------------------- | ---- | --------------------------------------------- | | uri | string | Yes | URI of the data. | -| callback | AsyncCallback\ | Yes | Callback used to return the media resource type.| +| callback | AsyncCallback\ | Yes | Callback used to return the MIME type.| **Example** ```ts import featureAbility from '@ohos.ability.featureAbility'; -let DAHelper = featureAbility.acquireDataAbilityHelper( +let DAHelper: ability.DataAbilityHelper = featureAbility.acquireDataAbilityHelper( 'dataability:///com.example.DataAbility' ); DAHelper.getType('dataability:///com.example.DataAbility', (err, data) => { @@ -179,7 +185,7 @@ DAHelper.getType('dataability:///com.example.DataAbility', (err, data) => { getType(uri: string): Promise\ -Obtains the media resource type of the data specified by a given URI. This API uses a promise to return the result. +Obtains the MIME type of the data specified by a given URI. This API uses a promise to return the result. **System capability**: SystemCapability.Ability.AbilityRuntime.FAModel @@ -193,13 +199,13 @@ Obtains the media resource type of the data specified by a given URI. This API u | Type | Description | | ---------------- | ----------------------------------- | -| Promise\ | Promise used to return the media resource type.| +| Promise\ | Promise used to return the MIME type.| **Example** ```ts import featureAbility from '@ohos.ability.featureAbility'; -let DAHelper = featureAbility.acquireDataAbilityHelper( +let DAHelper: ability.DataAbilityHelper = featureAbility.acquireDataAbilityHelper( 'dataability:///com.example.DataAbility' ); DAHelper.getType('dataability:///com.example.DataAbility').then((data) => { @@ -211,7 +217,7 @@ DAHelper.getType('dataability:///com.example.DataAbility').then((data) => { getFileTypes(uri: string, mimeTypeFilter: string, callback: AsyncCallback>): void -Obtains the supported media resource types of a specified file. This API uses an asynchronous callback to return the result. +Obtains the supported MIME types of a specified file. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.Ability.AbilityRuntime.FAModel @@ -220,14 +226,14 @@ Obtains the supported media resource types of a specified file. This API uses an | Name | Type | Mandatory| Description | | -------------- | ------------------------------ | ---- | ---------------------------------- | | uri | string | Yes | URI of the file. | -| mimeTypeFilter | string | Yes | Media resource type of the file to obtain. | -| callback | AsyncCallback\> | Yes | Callback used to return an array holding the media resource type.| +| mimeTypeFilter | string | Yes | MIME types to match. | +| callback | AsyncCallback\> | Yes | Callback used to return the supported MIME types.| **Example** ```ts import featureAbility from '@ohos.ability.featureAbility'; -let DAHelper = featureAbility.acquireDataAbilityHelper( +let DAHelper: ability.DataAbilityHelper = featureAbility.acquireDataAbilityHelper( 'dataability:///com.example.DataAbility' ); DAHelper.getFileTypes( 'dataability:///com.example.DataAbility', @@ -242,7 +248,7 @@ DAHelper.getFileTypes( 'dataability:///com.example.DataAbility', getFileTypes(uri: string, mimeTypeFilter: string): Promise\> -Obtains the supported media resource types of a specified file. This API uses a promise to return the result. +Obtains the supported MIME types of a specified file. This API uses a promise to return the result. **System capability**: SystemCapability.Ability.AbilityRuntime.FAModel @@ -251,19 +257,19 @@ Obtains the supported media resource types of a specified file. This API uses a | Name | Type | Mandatory| Description | | -------------- | ------ | ---- | ---------------------------- | | uri | string | Yes | URI of the file. | -| mimeTypeFilter | string | Yes | Media resource type of the file to obtain.| +| mimeTypeFilter | string | Yes | MIME types to match.| **Return value** | Type | Description | | ------------------------ | ------------------------ | -| Promise\> | Promise used to return an array holding the media resource type.| +| Promise\> | Promise used to return the supported MIME types.| **Example** ```ts import featureAbility from '@ohos.ability.featureAbility'; -let DAHelper = featureAbility.acquireDataAbilityHelper( +let DAHelper: ability.DataAbilityHelper = featureAbility.acquireDataAbilityHelper( 'dataability:///com.example.DataAbility' ); DAHelper.getFileTypes('dataability:///com.example.DataAbility', @@ -276,7 +282,7 @@ DAHelper.getFileTypes('dataability:///com.example.DataAbility', normalizeUri(uri: string, callback: AsyncCallback\): void -Converts the URI that refers to a Data ability into a normalized URI. This API uses an asynchronous callback to return the result. +Converts the URI that refers to a DataAbility into a normalized URI. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.Ability.AbilityRuntime.FAModel @@ -285,13 +291,13 @@ Converts the URI that refers to a Data ability into a normalized URI. This API u | Name | Type | Mandatory| Description | | -------- | ---------------------- | ---- | ------------------------------------------------------------ | | uri | string | Yes | URI object to normalize. | -| callback | AsyncCallback\ | Yes | Callback used to return the normalized URI object if the Data ability supports URI normalization. If the Data ability does not support URI normalization, **null** is returned.| +| callback | AsyncCallback\ | Yes | Callback used to return the normalized URI object if the DataAbility supports URI normalization. If the DataAbility does not support URI normalization, **null** is returned.| **Example** ```ts import featureAbility from '@ohos.ability.featureAbility'; -let DAHelper = featureAbility.acquireDataAbilityHelper( +let DAHelper: ability.DataAbilityHelper = featureAbility.acquireDataAbilityHelper( 'dataability:///com.example.DataAbility' ); DAHelper.normalizeUri('dataability:///com.example.DataAbility', (err, data) => { @@ -303,7 +309,7 @@ DAHelper.normalizeUri('dataability:///com.example.DataAbility', (err, data) => { normalizeUri(uri: string): Promise\ -Converts the URI that refers to a Data ability into a normalized URI. This API uses a promise to return the result. +Converts the URI that refers to a DataAbility into a normalized URI. This API uses a promise to return the result. **System capability**: SystemCapability.Ability.AbilityRuntime.FAModel @@ -317,13 +323,13 @@ Converts the URI that refers to a Data ability into a normalized URI. This API u | Type | Description | | ---------------- | ------------------------------------------------------ | -| Promise\ | Promise used to return the normalized URI object if the Data ability supports URI normalization. If the Data ability does not support URI normalization, **null** is returned.| +| Promise\ | Promise used to return the normalized URI object if the DataAbility supports URI normalization. If the DataAbility does not support URI normalization, **null** is returned.| **Example** ```ts import featureAbility from '@ohos.ability.featureAbility'; -let DAHelper = featureAbility.acquireDataAbilityHelper( +let DAHelper: ability.DataAbilityHelper = featureAbility.acquireDataAbilityHelper( 'dataability:///com.example.DataAbility' ); DAHelper.normalizeUri('dataability:///com.example.DataAbility',).then((data) => { @@ -343,14 +349,14 @@ Converts a normalized URI generated by **DataAbilityHelper.normalizeUri(uri: str | Name | Type | Mandatory| Description | | -------- | ---------------------- | ---- | --------------------------------------------------- | -| uri | string | Yes | URI object to denormalize. | +| uri | string | Yes | URI object to normalize. | | callback | AsyncCallback\ | Yes | Callback used to return the denormalized URI object.| **Example** ```ts import featureAbility from '@ohos.ability.featureAbility'; -let DAHelper = featureAbility.acquireDataAbilityHelper( +let DAHelper: ability.DataAbilityHelper = featureAbility.acquireDataAbilityHelper( 'dataability:///com.example.DataAbility' ); DAHelper.denormalizeUri('dataability:///com.example.DataAbility', (err, data) => { @@ -384,7 +390,7 @@ Converts a normalized URI generated by **DataAbilityHelper.normalizeUri(uri: str ```ts import featureAbility from '@ohos.ability.featureAbility'; -let DAHelper = featureAbility.acquireDataAbilityHelper( +let DAHelper: ability.DataAbilityHelper = featureAbility.acquireDataAbilityHelper( 'dataability:///com.example.DataAbility' ); DAHelper.denormalizeUri('dataability:///com.example.DataAbility',).then((data) => { @@ -404,17 +410,17 @@ Notifies the registered observer of a change to the data specified by the URI. T | Name | Type | Mandatory| Description | | -------- | -------------------- | ---- | ------------------------ | -| uri | string | Yes | URI of the data that changes.| +| uri | string | Yes | URI of the data.| | callback | AsyncCallback\ | Yes | Callback used to return the result. | **Example** ```ts import featureAbility from '@ohos.ability.featureAbility'; -let helper = featureAbility.acquireDataAbilityHelper( +let DAHelper: ability.DataAbilityHelper = featureAbility.acquireDataAbilityHelper( 'dataability:///com.example.DataAbility' ); -helper.notifyChange('dataability:///com.example.DataAbility', (err) => { +DAHelper.notifyChange('dataability:///com.example.DataAbility', (err) => { console.info('==========================>Called=======================>'); }); ``` @@ -431,7 +437,7 @@ Notifies the registered observer of a change to the data specified by the URI. T | Name| Type | Mandatory| Description | | ---- | ------ | ---- | ------------------------ | -| uri | string | Yes | URI of the data that changes.| +| uri | string | Yes | URI of the data.| **Return value** @@ -443,7 +449,7 @@ Notifies the registered observer of a change to the data specified by the URI. T ```ts import featureAbility from '@ohos.ability.featureAbility'; -let DAHelper = featureAbility.acquireDataAbilityHelper( +let DAHelper: ability.DataAbilityHelper = featureAbility.acquireDataAbilityHelper( 'dataability:///com.example.DataAbility' ); DAHelper.notifyChange('dataability:///com.example.DataAbility').then(() => { @@ -471,7 +477,7 @@ Inserts a single data record into the database. This API uses an asynchronous ca ```ts import featureAbility from '@ohos.ability.featureAbility'; -let DAHelper = featureAbility.acquireDataAbilityHelper( +let DAHelper: ability.DataAbilityHelper = featureAbility.acquireDataAbilityHelper( 'dataability:///com.example.DataAbility' ); const valueBucket = { @@ -511,7 +517,7 @@ Inserts a single data record into the database. This API uses a promise to retur ```ts import featureAbility from '@ohos.ability.featureAbility'; -let DAHelper = featureAbility.acquireDataAbilityHelper( +let DAHelper: ability.DataAbilityHelper = featureAbility.acquireDataAbilityHelper( 'dataability:///com.example.DataAbility' ); const valueBucket = { @@ -538,14 +544,14 @@ Inserts multiple data records into the database. This API uses an asynchronous c | Name | Type | Mandatory| Description | | ------------ | ----------------------- | ---- | -------------------------------- | | uri | string | Yes | URI of the data to insert. | -| valuesBucket | Array\ | Yes | Data records to insert. | +| valuesBucket | Array\ | Yes | Data record to insert. | | callback | AsyncCallback\ | Yes | Callback used to return the number of inserted data records.| **Example** ```ts import featureAbility from '@ohos.ability.featureAbility'; -let DAHelper = featureAbility.acquireDataAbilityHelper( +let DAHelper: ability.DataAbilityHelper = featureAbility.acquireDataAbilityHelper( 'dataability:///com.example.DataAbility' ); let cars = new Array({'name': 'roe11', 'age': 21, 'salary': 20.5, 'blobType': 'u8',}, @@ -570,7 +576,7 @@ Inserts multiple data records into the database. This API uses a promise to retu | Name | Type | Mandatory| Description | | ------------ | ----------------------- | ---- | ------------------------ | | uri | string | Yes | URI of the data to insert.| -| valuesBucket | Array | Yes | Data records to insert. | +| valuesBucket | Array | Yes | Data record to insert. | **Return value** @@ -582,7 +588,7 @@ Inserts multiple data records into the database. This API uses a promise to retu ```ts import featureAbility from '@ohos.ability.featureAbility'; -let DAHelper = featureAbility.acquireDataAbilityHelper( +let DAHelper: ability.DataAbilityHelper = featureAbility.acquireDataAbilityHelper( 'dataability:///com.example.DataAbility' ); let cars = new Array({'name': 'roe11', 'age': 21, 'salary': 20.5, 'blobType': 'u8',}, @@ -614,7 +620,7 @@ Deletes one or more data records from the database. This API uses an asynchronou ```ts import featureAbility from '@ohos.ability.featureAbility'; import ohos_data_ability from '@ohos.data.dataAbility'; -let DAHelper = featureAbility.acquireDataAbilityHelper( +let DAHelper: ability.DataAbilityHelper = featureAbility.acquireDataAbilityHelper( 'dataability:///com.example.DataAbility' ); let da = new ohos_data_ability.DataAbilityPredicates(); @@ -650,7 +656,7 @@ Deletes one or more data records from the database. This API uses a promise to r ```ts import featureAbility from '@ohos.ability.featureAbility'; import ohos_data_ability from '@ohos.data.dataAbility'; -let DAHelper = featureAbility.acquireDataAbilityHelper( +let DAHelper: ability.DataAbilityHelper = featureAbility.acquireDataAbilityHelper( 'dataability:///com.example.DataAbility' ); let da = new ohos_data_ability.DataAbilityPredicates(); @@ -681,7 +687,7 @@ Updates data records in the database. This API uses an asynchronous callback to ```ts import featureAbility from '@ohos.ability.featureAbility'; import ohos_data_ability from '@ohos.data.dataAbility'; -let DAHelper = featureAbility.acquireDataAbilityHelper( +let DAHelper: ability.DataAbilityHelper = featureAbility.acquireDataAbilityHelper( 'dataability:///com.example.DataAbility' ); const va = { @@ -723,7 +729,7 @@ Updates data records in the database. This API uses a promise to return the resu ```ts import featureAbility from '@ohos.ability.featureAbility'; import ohos_data_ability from '@ohos.data.dataAbility'; -let DAHelper = featureAbility.acquireDataAbilityHelper( +let DAHelper: ability.DataAbilityHelper = featureAbility.acquireDataAbilityHelper( 'dataability:///com.example.DataAbility' ); const va = { @@ -760,7 +766,7 @@ Queries data in the database. This API uses an asynchronous callback to return t ```ts import featureAbility from '@ohos.ability.featureAbility'; import ohos_data_ability from '@ohos.data.dataAbility'; -let DAHelper = featureAbility.acquireDataAbilityHelper( +let DAHelper: ability.DataAbilityHelper = featureAbility.acquireDataAbilityHelper( 'dataability:///com.example.DataAbility' ); let cars=new Array('value1', 'value2', 'value3', 'value4'); @@ -799,13 +805,49 @@ Queries data in the database. This API uses a promise to return the result. ```ts import featureAbility from '@ohos.ability.featureAbility'; import ohos_data_ability from '@ohos.data.dataAbility'; -let DAHelper = featureAbility.acquireDataAbilityHelper( +let DAHelper: ability.DataAbilityHelper = featureAbility.acquireDataAbilityHelper( 'dataability:///com.example.DataAbility' ); let cars = new Array('value1', 'value2', 'value3', 'value4'); let da = new ohos_data_ability.DataAbilityPredicates(); DAHelper.query('dataability:///com.example.DataAbility', cars, da).then((data) => { - console.info('==========================>queryCallback=======================>'); + console.info('query data: ${JSON.stringify(data)}'); +}); +``` + +## DataAbilityHelper.call + +call(uri: string, method: string, arg: string, extras: PacMap, callback: AsyncCallback\): void + +Calls an extended API of the DataAbility. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.Ability.AbilityRuntime.FAModel + +**Parameters** + +| Name | Type | Mandatory| Description | +| ---------- | --------------------------------- | ---- | ------------------------------------------------ | +| uri | string | Yes | URI of the DataAbility. Example: 'dataability:///com.example.xxx.xxxx'. | +| method | string | Yes | Name of the API to call. | +| arg | string | Yes | Parameter to pass in. | +| extras | [PacMap](#pacmap) | Yes | Key-value pair parameter. | +| callback | AsyncCallback\<[PacMap](#pacmap)> | Yes| Callback used to return the result. | + +**Example** + +```ts +import featureAbility from '@ohos.ability.featureAbility'; + +let dataAbilityHelper: ability.DataAbilityHelper = featureAbility.acquireDataAbilityHelper( + 'dataability:///com.example.jsapidemo.UserDataAbility' +); +dataAbilityHelper.call('dataability:///com.example.jsapidemo.UserDataAbility', + 'method', 'arg', {'key1':'value1'}, (error, data) => { + if (error && error.code !== 0) { + console.error('call fail, error: ${JSON.stringify(error)}'); + } else { + console.log('call success, data: ${JSON.stringify(data)}'); + } }); ``` @@ -823,7 +865,7 @@ Calls an extended API of the DataAbility. This API uses a promise to return the | ---------- | --------------------------------- | ---- | ------------------------------------------------ | | uri | string | Yes | URI of the DataAbility. Example: 'dataability:///com.example.xxx.xxxx'. | | method | string | Yes | Name of the API to call. | -| arg | string | Yes | Parameter to pass in. | +| arg | string | Yes |Parameter to pass in. | | extras | [PacMap](#pacmap) | Yes | Key-value pair parameter. | **Return value** @@ -837,8 +879,9 @@ Calls an extended API of the DataAbility. This API uses a promise to return the ```ts import featureAbility from '@ohos.ability.featureAbility'; -let dataAbilityHelper = featureAbility.acquireDataAbilityHelper( - 'dataability:///com.example.jsapidemo.UserDataAbility'); +let dataAbilityHelper: ability.DataAbilityHelper = featureAbility.acquireDataAbilityHelper( + 'dataability:///com.example.jsapidemo.UserDataAbility' +); dataAbilityHelper.call('dataability:///com.example.jsapidemo.UserDataAbility', 'method', 'arg', {'key1':'value1'}).then((data) => { console.info('Operation succeeded: ' + data); @@ -861,9 +904,9 @@ Calls an extended API of the DataAbility. This API uses an asynchronous callback | ---------- | --------------------------------- | ---- | ------------------------------------------------ | | uri | string | Yes | URI of the DataAbility. Example: 'dataability:///com.example.xxx.xxxx'. | | method | string | Yes | Name of the API to call. | -| arg | string | Yes | Parameter to pass in. | +| arg | string | Yes |Parameter to pass in. | | extras | [PacMap](#pacmap) | Yes | Key-value pair parameter. | -| callback | AsyncCallback\<[PacMap](#pacmap)> | Yes | Callback used to return the result. | +| callback | AsyncCallback\<[PacMap](#pacmap)> | Yes| Callback used to return the result. | **Example** @@ -892,10 +935,10 @@ Operates data in the database in batches. This API uses an asynchronous callback **Parameters** -| Name | Type | Mandatory| Description | -| ----------| ---------------------------------| ---- | ------------------------------------------------ | -| uri | string | Yes | URI of the DataAbility. Example: 'dataability:///com.example.xxx.xxxx'.| -| operations | Array\<[DataAbilityOperation](js-apis-inner-ability-dataAbilityOperation.md)> | Yes | An array holding the data operations on the database. | +| Name | Type | Mandatory| Description | +| ---------- | --------------------------------- | ---- | ------------------------------------------------ | +| uri | string | Yes | URI of the DataAbility. Example: 'dataability:///com.example.xxx.xxxx'.| +| operations | Array\<[DataAbilityOperation](js-apis-inner-ability-dataAbilityOperation.md)> | Yes | An array holding the data operations on the database. | | callback | AsyncCallback\> | Yes | Callback used to return the result of each operation in the **DataAbilityResult** array. | **Example** @@ -905,13 +948,14 @@ import featureAbility from '@ohos.ability.featureAbility'; // Select the operations to be performed on the database according to the DataAbilityOperation array. let op=new Array(); -let dataAbilityHelper = featureAbility.acquireDataAbilityHelper( - 'dataability:///com.example.jsapidemo.UserDataAbility'); -dataAbilityHelper.executeBatch('dataability:///com.example.jsapidemo.UserDataAbility', - op, (err, data) => { - if (err) { - console.error('Operation failed. Cause: ' + err); - return; +let dataAbilityHelper: ability.DataAbilityHelper = featureAbility.acquireDataAbilityHelper( + 'dataability:///com.example.jsapidemo.UserDataAbility' +); +dataAbilityHelper.executeBatch('dataability:///com.example.jsapidemo.UserDataAbility', op, (error, data) => { + if (error && error.code !== 0) { + console.error('executeBatch fail, error: ${JSON.stringify(error)}'); + } else { + console.log('executeBatch success, data: ${JSON.stringify(data)}'); } console.info('Operation succeeded: ' + data); }); @@ -945,11 +989,11 @@ import featureAbility from '@ohos.ability.featureAbility'; // Select the operations to be performed on the database according to the DataAbilityOperation array. let op=new Array(); -let dataAbilityHelper = featureAbility.acquireDataAbilityHelper( - 'dataability:///com.example.jsapidemo.UserDataAbility'); -dataAbilityHelper.executeBatch('dataability:///com.example.jsapidemo.UserDataAbility', - op).then((data) => { - console.info('Operation succeeded: ' + data); +let dataAbilityHelper: ability.DataAbilityHelper = featureAbility.acquireDataAbilityHelper( + 'dataability:///com.example.jsapidemo.UserDataAbility' +); +dataAbilityHelper.executeBatch('dataability:///com.example.jsapidemo.UserDataAbility', op).then((data) => { + console.info('executeBatch success, data: ${data}'); }).catch((error) => { console.error('Operation failed. Cause: ' + error); }); diff --git a/en/application-dev/reference/apis/js-apis-inner-ability-dataAbilityOperation.md b/en/application-dev/reference/apis/js-apis-inner-ability-dataAbilityOperation.md index 0b96b8caa9..a0d3e71468 100644 --- a/en/application-dev/reference/apis/js-apis-inner-ability-dataAbilityOperation.md +++ b/en/application-dev/reference/apis/js-apis-inner-ability-dataAbilityOperation.md @@ -7,11 +7,17 @@ The **DataAbilityOperation** module defines the operation on DataAbilities. It c > The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version. > The APIs of this module can be used only in the FA model. +## Modules to Import + +```ts +import ability from '@ohos.ability.ability'; +``` + **System capability**: SystemCapability.Ability.AbilityRuntime.FAModel | Name | Template | Mandatory| Description | | -------- | -------- | --------| -------- | -| uri | string | Yes | URI of the DataAbility. Example: "dataability:///com.example.xxx.xxxx". | +| uri | string | Yes | URI of the DataAbility. Example: dataability:///com.example.xxx.xxxx. | | type | featureAbility.DataAbilityOperationType | Yes | Operation type. | | valuesBucket? | rdb.ValuesBucket | No | Data value to set. | | valueBackReferences? | rdb.ValuesBucket | No | **ValuesBucket** object that contains a set of key-value pairs. | diff --git a/en/application-dev/reference/apis/js-apis-inner-ability-dataAbilityResult.md b/en/application-dev/reference/apis/js-apis-inner-ability-dataAbilityResult.md index 34c73e5cf4..2a3cb7f384 100644 --- a/en/application-dev/reference/apis/js-apis-inner-ability-dataAbilityResult.md +++ b/en/application-dev/reference/apis/js-apis-inner-ability-dataAbilityResult.md @@ -7,6 +7,12 @@ The **DataAbilityResult** module defines the operation result on DataAbilities. > The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version. > The APIs of this module can be used only in the FA model. +## Modules to Import + +```ts +import ability from '@ohos.ability.ability'; +``` + **System capability**: SystemCapability.Ability.AbilityRuntime.FAModel | Name | Type | Mandatory | Description | @@ -19,54 +25,57 @@ The **DataAbilityResult** module defines the operation result on DataAbilities. ```ts import featureAbility from '@ohos.ability.featureAbility'; -let dataAbilityUri = ('dataability:///com.example.myapplication.TestDataAbility'); -let DAHelper; -try { - DAHelper = featureAbility.acquireDataAbilityHelper(dataAbilityUri); - if (DAHelper == null) { - console.error('DAHelper is null'); +// Perform database operations in batches. +function executeBatchOperation() { + let dataAbilityUri = ('dataability:///com.example.myapplication.TestDataAbility'); + let DAHelper: ability.DataAbilityHelper; + try { + DAHelper = featureAbility.acquireDataAbilityHelper(dataAbilityUri); + if (DAHelper === null) { + console.error('DAHelper is null'); + } + } catch (err) { + console.error('acquireDataAbilityHelper fail, error: ${JSON.stringify(err)}'); } -} catch (err) { - console.error('acquireDataAbilityHelper fail, error:' + JSON.stringify(err)); -} -let valueBucket = { - 'name': 'DataAbilityHelperTest', - 'age': 24, - 'salary': 2024.20, -}; -let operations = [ -{ - uri: dataAbilityUri, - type: featureAbility.DataAbilityOperationType.TYPE_INSERT, - valuesBucket: valueBucket, - predicates: null, - expectedCount: 1, - PredicatesBackReferences: {}, - interrupted: true, -}, -{ - uri: dataAbilityUri, - type: featureAbility.DataAbilityOperationType.TYPE_INSERT, - valuesBucket: valueBucket, - predicates: null, - expectedCount: 1, - PredicatesBackReferences: {}, - interrupted: true, -} -]; + let valueBucket = { + 'name': 'DataAbilityHelperTest', + 'age': 24, + 'salary': 2024.20, + }; + let operations = [ + { + uri: dataAbilityUri, + type: featureAbility.DataAbilityOperationType.TYPE_INSERT, + valuesBucket: valueBucket, + predicates: null, + expectedCount: 1, + PredicatesBackReferences: {}, + interrupted: true, + }, + { + uri: dataAbilityUri, + type: featureAbility.DataAbilityOperationType.TYPE_INSERT, + valuesBucket: valueBucket, + predicates: null, + expectedCount: 1, + PredicatesBackReferences: {}, + interrupted: true, + } + ]; -try { - let promise = DAHelper.executeBatch(dataAbilityUri, operations).then((data) => { - for (let i = 0; i < data.length; i++) { - let dataAbilityResult = data[i]; - console.log('dataAbilityResult.uri: ' + dataAbilityResult.uri); - console.log('dataAbilityResult.count: ' + dataAbilityResult.count); - } - }).catch(err => { - console.error('executeBatch error: ' + JSON.stringify(err)); - }); -} catch (err) { - console.error('executeBatch error: ' + JSON.stringify(err)); + try { + DAHelper.executeBatch(dataAbilityUri, operations).then((data) => { + for (let i = 0; i < data.length; i++) { + let dataAbilityResult: ability.DataAbilityResult = data[i]; + console.log('dataAbilityResult.uri: ${dataAbilityResult.uri}'); + console.log('dataAbilityResult.count: ${dataAbilityResult.count}'); + } + }).catch(err => { + console.error('executeBatch error: ${JSON.stringify(err)}'); + }); + } catch (err) { + console.error('executeBatch error: ${JSON.stringify(err)}'); + } } ``` diff --git a/en/application-dev/reference/apis/js-apis-inner-ability-startAbilityParameter.md b/en/application-dev/reference/apis/js-apis-inner-ability-startAbilityParameter.md index f383eee416..6b3f3450e2 100644 --- a/en/application-dev/reference/apis/js-apis-inner-ability-startAbilityParameter.md +++ b/en/application-dev/reference/apis/js-apis-inner-ability-startAbilityParameter.md @@ -7,6 +7,12 @@ The **StartAbilityParameter** module defines the parameters for starting an abil > The initial APIs of this module are supported since API version 6. Newly added APIs will be marked with a superscript to indicate their earliest API version. > The APIs of this module can be used only in the FA model. +## Modules to Import + +```ts +import ability from '@ohos.ability.ability'; +``` + **System capability**: SystemCapability.Ability.AbilityRuntime.FAModel | Name | Type | Mandatory | Description | @@ -30,7 +36,7 @@ let abilityStartSetting ={ [featureAbility.AbilityStartSetting.DISPLAY_ID_KEY] : 1, }; -let startAbilityParameter = { +let startAbilityParameter: ability.StartAbilityParameter = { want : Want, abilityStartSetting : abilityStartSetting }; diff --git a/en/application-dev/reference/apis/js-apis-inner-ability-want.md b/en/application-dev/reference/apis/js-apis-inner-ability-want.md index 89204aeac9..e4bba9fa23 100644 --- a/en/application-dev/reference/apis/js-apis-inner-ability-want.md +++ b/en/application-dev/reference/apis/js-apis-inner-ability-want.md @@ -6,19 +6,25 @@ Want is a carrier for information transfer between objects (application componen > > The APIs of this module are supported since API version 6 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 + +```ts +import Want from '@ohos.app.ability.Want'; +``` + **System capability**: SystemCapability.Ability.AbilityBase | Name | Type | Mandatory| Description | | ----------- | -------------------- | ---- | ------------------------------------------------------------ | | deviceId | string | No | ID of the device running the ability. | -| bundleName | string | No | Bundle name. If both **bundleName** and **abilityName** are specified in a **Want**, the **Want** can directly match the specified ability.| +| bundleName | string | No | Bundle name.| | 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. 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. | -| 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#wantconstantflags).| -| 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. | +| flags | number | No | How the **Want** object will be handled. By default, numbers are passed in. For details, see [flags](js-apis-app-ability-wantConstant.md#wantconstantflags).| +| 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]: Object} | 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 target ability. It is a supplement to **action** in implicit Want and is used to filter ability types. | +| entities | Array\ | No | Additional category information (such as browser and video player) of the target ability. It is a supplement to **action** in implicit Want and is used to filter ability types. | | moduleName9+ | string | No | Module to which the ability belongs.| **Example** diff --git a/en/application-dev/reference/apis/js-apis-inner-app-appVersionInfo.md b/en/application-dev/reference/apis/js-apis-inner-app-appVersionInfo.md index 39c846bb6e..f5da165225 100644 --- a/en/application-dev/reference/apis/js-apis-inner-app-appVersionInfo.md +++ b/en/application-dev/reference/apis/js-apis-inner-app-appVersionInfo.md @@ -6,6 +6,12 @@ The **AppVersionInfo** module defines the application version information. You c > > The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version. +## Modules to Import + +```ts +import featureAbility from '@ohos.ability.featureAbility'; +``` + **System capability**: SystemCapability.Ability.AbilityRuntime.Core | Name | Type | Readable| Writable| Description | diff --git a/en/application-dev/reference/apis/js-apis-inner-app-context.md b/en/application-dev/reference/apis/js-apis-inner-app-context.md index 22da49708e..6dc9d21ad4 100644 --- a/en/application-dev/reference/apis/js-apis-inner-app-context.md +++ b/en/application-dev/reference/apis/js-apis-inner-app-context.md @@ -5,16 +5,21 @@ The **Context** module provides context for abilities or applications. It allows > **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. -> > The APIs of this module can be used only in the FA model. +## Modules to Import + +```ts +import featureAbility from '@ohos.ability.featureAbility'; +``` + ## Usage The **Context** object is created in a **featureAbility** and returned through its [getContext](js-apis-ability-featureAbility.md#featureabilitygetcontext) API. Therefore, you must import the **@ohos.ability.featureAbility** package before using the **Context** module. An example is as follows: ```ts import featureAbility from '@ohos.ability.featureAbility'; -let context = featureAbility.getContext(); +let context: featureAbility.Context = featureAbility.getContext(); context.getOrCreateLocalDir().then((data) => { console.info('getOrCreateLocalDir data: ' + JSON.stringify(data)); }); @@ -40,9 +45,13 @@ If this API is called for the first time, a root directory will be created. ```ts import featureAbility from '@ohos.ability.featureAbility'; -let context = featureAbility.getContext(); -context.getOrCreateLocalDir((err, data)=>{ - console.info('getOrCreateLocalDir err: ' + JSON.stringify(err) + 'data: ' + JSON.stringify(data)); +let context: featureAbility.Context = featureAbility.getContext(); +context.getOrCreateLocalDir((error, data)=>{ + if (error && error.code !== 0) { + console.error('getOrCreateLocalDir fail, error: ${JSON.stringify(error)}'); + } else { + console.log('getOrCreateLocalDir success, data: ${JSON.stringify(data)}'); + } }); ``` @@ -68,7 +77,7 @@ If this API is called for the first time, a root directory will be created. ```ts import featureAbility from '@ohos.ability.featureAbility'; -let context = featureAbility.getContext(); +let context: featureAbility.Context = featureAbility.getContext(); context.getOrCreateLocalDir().then((data) => { console.info('getOrCreateLocalDir data: ' + JSON.stringify(data)); }); @@ -94,10 +103,10 @@ Verifies whether a specific PID and UID have the given permission. This API uses ```ts import featureAbility from '@ohos.ability.featureAbility'; -import bundle from '@ohos.bundle'; -let context = featureAbility.getContext(); +import bundle from '@ohos.bundle.bundleManager'; +let context: featureAbility.Context = featureAbility.getContext(); bundle.getBundleInfo('com.context.test', 1, (err, datainfo) =>{ - context.verifyPermission('com.example.permission', {uid:datainfo.uid}, (err, data) =>{ + context.verifyPermission('com.example.permission', {uid:datainfo.appInfo.uid}, (err, data) =>{ console.info('verifyPermission err: ' + JSON.stringify(err) + 'data: ' + JSON.stringify(data)); }); }); @@ -124,9 +133,13 @@ Verifies whether the current PID and UID have the given permission. This API use ```ts import featureAbility from '@ohos.ability.featureAbility'; -let context = featureAbility.getContext(); -context.verifyPermission('com.example.permission', (err, data) =>{ - console.info('verifyPermission err: ' + JSON.stringify(err) + 'data: ' + JSON.stringify(data)); +let context: featureAbility.Context = featureAbility.getContext(); +context.verifyPermission('com.example.permission', (error, data) =>{ + if (error && error.code !== 0) { + console.error('verifyPermission fail, error: ${JSON.stringify(error)}'); + } else { + console.log('verifyPermission success, data: ${JSON.stringify(data)}'); + } }); ``` @@ -155,7 +168,7 @@ Verifies whether a specific PID and UID have the given permission. This API uses ```ts import featureAbility from '@ohos.ability.featureAbility'; -let context = featureAbility.getContext(); +let context: featureAbility.Context = featureAbility.getContext(); let Permission = {pid:1}; context.verifyPermission('com.context.permission',Permission).then((data) => { console.info('verifyPermission data: ' + JSON.stringify(data)); @@ -184,7 +197,7 @@ Requests certain permissions from the system. This API uses an asynchronous call ```ts import featureAbility from '@ohos.ability.featureAbility'; -let context = featureAbility.getContext(); +let context: featureAbility.Context = featureAbility.getContext(); context.requestPermissionsFromUser( ['com.example.permission1', 'com.example.permission2', @@ -224,7 +237,7 @@ Requests certain permissions from the system. This API uses a promise to return ```ts import featureAbility from '@ohos.ability.featureAbility'; -let context = featureAbility.getContext(); +let context: featureAbility.Context = featureAbility.getContext(); context.requestPermissionsFromUser( ['com.example.permission1', 'com.example.permission2', @@ -257,9 +270,13 @@ Obtains information about the current application. This API uses an asynchronous ```ts import featureAbility from '@ohos.ability.featureAbility'; -let context = featureAbility.getContext(); -context.getApplicationInfo((err, data) => { - console.info('getApplicationInfo err: ' + JSON.stringify(err) + 'data: ' + JSON.stringify(data)); +let context: featureAbility.Context = featureAbility.getContext(); +context.getApplicationInfo((error, data) => { + if (error && error.code !== 0) { + console.error('getApplicationInfo fail, error: ${JSON.stringify(error)}'); + } else { + console.log('getApplicationInfo success, data: ${JSON.stringify(data)}'); + } }); ``` @@ -283,7 +300,7 @@ Obtains information about the current application. This API uses a promise to re ```ts import featureAbility from '@ohos.ability.featureAbility'; -let context = featureAbility.getContext(); +let context: featureAbility.Context = featureAbility.getContext(); context.getApplicationInfo().then((data) => { console.info('getApplicationInfo data: ' + JSON.stringify(data)); }); @@ -309,9 +326,13 @@ Obtains the bundle name of this ability. This API uses an asynchronous callback ```ts import featureAbility from '@ohos.ability.featureAbility'; -let context = featureAbility.getContext(); -context.getBundleName((err, data) => { - console.info('getBundleName err: ' + JSON.stringify(err) + 'data: ' + JSON.stringify(data)); +let context: featureAbility.Context = featureAbility.getContext(); +context.getBundleName((error, data) => { + if (error && error.code !== 0) { + console.error('getBundleName fail, error: ${JSON.stringify(error)}'); + } else { + console.log('getBundleName success, data: ${JSON.stringify(data)}'); + } }); ``` @@ -335,7 +356,7 @@ Obtains the bundle name of this ability. This API uses a promise to return the r ```ts import featureAbility from '@ohos.ability.featureAbility'; -let context = featureAbility.getContext(); +let context: featureAbility.Context = featureAbility.getContext(); context.getBundleName().then((data) => { console.info('getBundleName data: ' + JSON.stringify(data)); }); @@ -359,9 +380,13 @@ Obtains the display orientation of this ability. This API uses an asynchronous c ```ts import featureAbility from '@ohos.ability.featureAbility'; -let context = featureAbility.getContext(); -context.getDisplayOrientation((err, data) => { - console.info('getDisplayOrientation err: ' + JSON.stringify(err) + 'data: ' + JSON.stringify(data)); +let context: featureAbility.Context = featureAbility.getContext(); +context.getDisplayOrientation((error, data) => { + if (error && error.code !== 0) { + console.error('getDisplayOrientation fail, error: ${JSON.stringify(error)}'); + } else { + console.log('getDisplayOrientation success, data: ${JSON.stringify(data)}'); + } }); ``` @@ -383,7 +408,7 @@ Obtains the display orientation of this ability. This API uses a promise to retu ```ts import featureAbility from '@ohos.ability.featureAbility'; -let context = featureAbility.getContext(); +let context: featureAbility.Context = featureAbility.getContext(); context.getDisplayOrientation().then((data) => { console.info('getDisplayOrientation data: ' + JSON.stringify(data)); }); @@ -407,9 +432,13 @@ Obtains the external cache directory of the application. This API uses an asynch ```ts import featureAbility from '@ohos.ability.featureAbility'; -let context = featureAbility.getContext(); -context.getExternalCacheDir((err, data) => { - console.info('getExternalCacheDir err: ' + JSON.stringify(err) + 'data: ' + JSON.stringify(data)); +let context: featureAbility.Context = featureAbility.getContext(); +context.getExternalCacheDir((error, data) => { + if (error && error.code !== 0) { + console.error('getExternalCacheDir fail, error: ${JSON.stringify(error)}'); + } else { + console.log('getExternalCacheDir success, data: ${JSON.stringify(data)}'); + } }); ``` @@ -431,7 +460,7 @@ Obtains the external cache directory of the application. This API uses a promise ```ts import featureAbility from '@ohos.ability.featureAbility'; -let context = featureAbility.getContext(); +let context: featureAbility.Context = featureAbility.getContext(); context.getExternalCacheDir().then((data) => { console.info('getExternalCacheDir data: ' + JSON.stringify(data)); }); @@ -457,10 +486,10 @@ Sets the display orientation for this ability. This API uses an asynchronous cal ```ts import featureAbility from '@ohos.ability.featureAbility'; import bundle from '@ohos.bundle'; -let context = featureAbility.getContext(); -let orientation=bundle.DisplayOrientation.UNSPECIFIED -context.setDisplayOrientation(orientation, (err) => { - console.info('setDisplayOrientation err: ' + JSON.stringify(err)); +let context: featureAbility.Context = featureAbility.getContext(); +let orientation = bundle.DisplayOrientation.UNSPECIFIED; +context.setDisplayOrientation(orientation, (error) => { + console.error('setDisplayOrientation fail, error: ${JSON.stringify(error)}'); }); ``` @@ -484,18 +513,19 @@ Sets the display orientation for this ability. This API uses a promise to return ```ts import featureAbility from '@ohos.ability.featureAbility'; import bundle from '@ohos.bundle'; -let context = featureAbility.getContext(); -let orientation=bundle.DisplayOrientation.UNSPECIFIED +let context: featureAbility.Context = featureAbility.getContext(); +let orientation = bundle.DisplayOrientation.UNSPECIFIED; context.setDisplayOrientation(orientation).then((data) => { console.info('setDisplayOrientation data: ' + JSON.stringify(data)); }); ``` -## Context.setShowOnLockScreen7+ +## Context.setShowOnLockScreen(deprecated) setShowOnLockScreen(show: boolean, callback: AsyncCallback\): void Sets whether to show this feature at the top of the lock screen so that the feature remains activated. This API uses an asynchronous callback to return the result. +> This API is deprecated since API version 9. You are advised to use [window.setShowOnLockScreen](js-apis-window.md#setShowOnLockScreen9). **System capability**: SystemCapability.Ability.AbilityRuntime.Core @@ -510,18 +540,19 @@ Sets whether to show this feature at the top of the lock screen so that the feat ```ts import featureAbility from '@ohos.ability.featureAbility'; -let context = featureAbility.getContext(); -let show=true -context.setShowOnLockScreen(show, (err) => { - console.info('setShowOnLockScreen err: ' + JSON.stringify(err)); +let context: featureAbility.Context = featureAbility.getContext(); +let show = true; +context.setShowOnLockScreen(show, (error) => { + console.error('setShowOnLockScreen fail, error: ${JSON.stringify(error)}'); }); ``` -## Context.setShowOnLockScreen7+ +## Context.setShowOnLockScreen(deprecated) setShowOnLockScreen(show: boolean): Promise\; Sets whether to show this feature at the top of the lock screen so that the feature remains activated. This API uses a promise to return the result. +> This API is deprecated since API version 9. You are advised to use [window.setShowOnLockScreen](js-apis-window.md#setShowOnLockScreen9). **System capability**: SystemCapability.Ability.AbilityRuntime.Core @@ -541,8 +572,8 @@ Sets whether to show this feature at the top of the lock screen so that the feat ```ts import featureAbility from '@ohos.ability.featureAbility'; -let context = featureAbility.getContext(); -let show=true +let context: featureAbility.Context = featureAbility.getContext(); +let show = true; context.setShowOnLockScreen(show).then((data) => { console.info('setShowOnLockScreen data: ' + JSON.stringify(data)); }); @@ -567,16 +598,16 @@ Sets whether to wake up the screen when this feature is restored. This API uses ```ts import featureAbility from '@ohos.ability.featureAbility'; -let context = featureAbility.getContext(); -let wakeUp=true -context.setWakeUpScreen(wakeUp, (err) => { - console.info('setWakeUpScreen err: ' + JSON.stringify(err)); +let context: featureAbility.Context = featureAbility.getContext(); +let wakeUp = true; +context.setWakeUpScreen(wakeUp, (error) => { + console.error('setWakeUpScreen fail, error: ${JSON.stringify(error)}'); }); ``` ## Context.setWakeUpScreen7+ -setWakeUpScreen(wakeUp: boolean): Promise\; +setWakeUpScreen(wakeUp: boolean): Promise\; Sets whether to wake up the screen when this feature is restored. This API uses a promise to return the result. @@ -598,8 +629,8 @@ Sets whether to wake up the screen when this feature is restored. This API uses ```ts import featureAbility from '@ohos.ability.featureAbility'; -let context = featureAbility.getContext(); -let wakeUp=true +let context: featureAbility.Context = featureAbility.getContext(); +let wakeUp = true; context.setWakeUpScreen(wakeUp).then((data) => { console.info('setWakeUpScreen data: ' + JSON.stringify(data)); }); @@ -626,9 +657,13 @@ Obtains information about the current process, including the PID and process nam ```ts import featureAbility from '@ohos.ability.featureAbility'; -let context = featureAbility.getContext(); -context.getProcessInfo((err, data) => { - console.info('getProcessInfo err: ' + JSON.stringify(err) + 'data: ' + JSON.stringify(data)); +let context: featureAbility.Context = featureAbility.getContext(); +context.getProcessInfo((error, data) => { + if (error && error.code !== 0) { + console.error('getProcessInfo fail, error: ${JSON.stringify(error)}'); + } else { + console.log('getProcessInfo success, data: ${JSON.stringify(data)}'); + } }); ``` @@ -652,7 +687,7 @@ Obtains information about the current process, including the PID and process nam ```ts import featureAbility from '@ohos.ability.featureAbility'; -let context = featureAbility.getContext(); +let context: featureAbility.Context = featureAbility.getContext(); context.getProcessInfo().then((data) => { console.info('getProcessInfo data: ' + JSON.stringify(data)); }); @@ -680,9 +715,13 @@ This API is available only to Page abilities. ```ts import featureAbility from '@ohos.ability.featureAbility'; -let context = featureAbility.getContext(); -context.getElementName((err, data) => { - console.info('getElementName err: ' + JSON.stringify(err) + 'data: ' + JSON.stringify(data)); +let context: featureAbility.Context = featureAbility.getContext(); +context.getElementName((error, data) => { + if (error && error.code !== 0) { + console.error('getElementName fail, error: ${JSON.stringify(error)}'); + } else { + console.log('getElementName success, data: ${JSON.stringify(data)}'); + } }); ``` @@ -708,7 +747,7 @@ This API is available only to Page abilities. ```ts import featureAbility from '@ohos.ability.featureAbility'; -let context = featureAbility.getContext(); +let context: featureAbility.Context = featureAbility.getContext(); context.getElementName().then((data) => { console.info('getElementName data: ' + JSON.stringify(data)); }); @@ -732,9 +771,13 @@ Obtains the name of the current process. This API uses an asynchronous callback ```ts import featureAbility from '@ohos.ability.featureAbility'; -let context = featureAbility.getContext(); -context.getProcessName((err, data) => { - console.info('getProcessName err: ' + JSON.stringify(err) + 'data: ' + JSON.stringify(data)); +let context: featureAbility.Context = featureAbility.getContext(); +context.getProcessName((error, data) => { + if (error && error.code !== 0) { + console.error('getProcessName fail, error: ${JSON.stringify(error)}'); + } else { + console.log('getProcessName success, data: ${JSON.stringify(data)}'); + } }); ``` @@ -758,7 +801,7 @@ Obtains the name of the current process. This API uses a promise to return the r ```ts import featureAbility from '@ohos.ability.featureAbility'; -let context = featureAbility.getContext(); +let context: featureAbility.Context = featureAbility.getContext(); context.getProcessName().then((data) => { console.info('getProcessName data: ' + JSON.stringify(data)); }); @@ -770,7 +813,7 @@ context.getProcessName().then((data) => { getCallingBundle(callback: AsyncCallback\): void -Obtains the bundle name of the caller ability. This API uses an asynchronous callback to return the result. +Obtains the bundle name of the calling ability. This API uses an asynchronous callback to return the result. **System capability**: SystemCapability.Ability.AbilityRuntime.Core @@ -784,9 +827,13 @@ Obtains the bundle name of the caller ability. This API uses an asynchronous cal ```ts import featureAbility from '@ohos.ability.featureAbility'; -let context = featureAbility.getContext(); -context.getCallingBundle((err, data) => { - console.info('getCallingBundle err: ' + JSON.stringify(err) + 'data: ' + JSON.stringify(data)); +let context: featureAbility.Context = featureAbility.getContext(); +context.getCallingBundle((error, data) => { + if (error && error.code !== 0) { + console.error('getCallingBundle fail, error: ${JSON.stringify(error)}'); + } else { + console.log('getCallingBundle success, data: ${JSON.stringify(data)}'); + } }); ``` @@ -796,7 +843,7 @@ context.getCallingBundle((err, data) => { getCallingBundle(): Promise\ -Obtains the bundle name of the caller ability. This API uses a promise to return the result. +Obtains the bundle name of the calling ability. This API uses a promise to return the result. **System capability**: SystemCapability.Ability.AbilityRuntime.Core @@ -810,7 +857,7 @@ Obtains the bundle name of the caller ability. This API uses a promise to return ```ts import featureAbility from '@ohos.ability.featureAbility'; -let context = featureAbility.getContext(); +let context: featureAbility.Context = featureAbility.getContext(); context.getCallingBundle().then((data) => { console.info('getCallingBundle data: ' + JSON.stringify(data)); }); @@ -834,9 +881,13 @@ Obtains the cache directory of the application in the internal storage. This API ```ts import featureAbility from '@ohos.ability.featureAbility'; -let context = featureAbility.getContext(); -context.getCacheDir((err, data) => { - console.info('getCacheDir err: ' + JSON.stringify(err) + 'data: ' + JSON.stringify(data)); +let context: featureAbility.Context = featureAbility.getContext(); +context.getCacheDir((error, data) => { + if (error && error.code !== 0) { + console.error('getCacheDir fail, error: ${JSON.stringify(error)}'); + } else { + console.log('getCacheDir success, data: ${JSON.stringify(data)}'); + } }); ``` @@ -858,7 +909,7 @@ Obtains the cache directory of the application in the internal storage. This API ```ts import featureAbility from '@ohos.ability.featureAbility'; -let context = featureAbility.getContext(); +let context: featureAbility.Context = featureAbility.getContext(); context.getCacheDir().then((data) => { console.info('getCacheDir data: ' + JSON.stringify(data)); }); @@ -882,9 +933,13 @@ Obtains the file directory of the application in the internal storage. This API ```ts import featureAbility from '@ohos.ability.featureAbility'; -let context = featureAbility.getContext(); -context.getFilesDir((err, data) => { - console.info('getFilesDir err: ' + JSON.stringify(err) + 'data: ' + JSON.stringify(data)); +let context: featureAbility.Context = featureAbility.getContext(); +context.getFilesDir((error, data) => { + if (error && error.code !== 0) { + console.error('getFilesDir fail, error: ${JSON.stringify(error)}'); + } else { + console.log('getFilesDir success, data: ${JSON.stringify(data)}'); + } }); ``` @@ -906,7 +961,7 @@ Obtains the file directory of the application in the internal storage. This API ```ts import featureAbility from '@ohos.ability.featureAbility'; -let context = featureAbility.getContext(); +let context: featureAbility.Context = featureAbility.getContext(); context.getFilesDir().then((data) => { console.info('getFilesDir data: ' + JSON.stringify(data)); }); @@ -918,7 +973,7 @@ getOrCreateDistributedDir(callback: AsyncCallback\): void Obtains the distributed file path for storing ability or application data files. This API uses an asynchronous callback to return the result. -If the distributed file path does not exist, the system will create one and return the created path. +If the file path does not exist, the system will create one and return the created path. **System capability**: SystemCapability.Ability.AbilityRuntime.Core @@ -926,15 +981,19 @@ If the distributed file path does not exist, the system will create one and retu | Name | Type | Mandatory | Description | | -------- | ---------------------- | ---- | ---------------------------------------- | -| callback | AsyncCallback\ | Yes | Callback used to return the distributed file path.
If the path does not exist, the system will create one and return the created path.| +| callback | AsyncCallback\ | Yes | Callback used to return the distributed file path. If the file path does not exist, the system will create one and return the created path.| **Example** ```ts import featureAbility from '@ohos.ability.featureAbility'; -let context = featureAbility.getContext(); -context.getOrCreateDistributedDir((err, data) => { - console.info('getOrCreateDistributedDir err: ' + JSON.stringify(err) + 'data: ' + JSON.stringify(data)); +let context: featureAbility.Context = featureAbility.getContext(); +context.getOrCreateDistributedDir((error, data) => { + if (error && error.code !== 0) { + console.error('getOrCreateDistributedDir fail, error: ${JSON.stringify(error)}'); + } else { + console.log('getOrCreateDistributedDir success, data: ${JSON.stringify(data)}'); + } }); ``` @@ -958,7 +1017,7 @@ If the distributed file path does not exist, the system will create one and retu ```ts import featureAbility from '@ohos.ability.featureAbility'; -let context = featureAbility.getContext(); +let context: featureAbility.Context = featureAbility.getContext(); context.getOrCreateDistributedDir().then((data) => { console.info('getOrCreateDistributedDir data: ' + JSON.stringify(data)); }); @@ -982,9 +1041,13 @@ Obtains the application type. This API uses an asynchronous callback to return t ```ts import featureAbility from '@ohos.ability.featureAbility'; -let context = featureAbility.getContext(); -context.getAppType((err, data) => { - console.info('getAppType err: ' + JSON.stringify(err) + 'data: ' + JSON.stringify(data)); +let context: featureAbility.Context = featureAbility.getContext(); +context.getAppType((error, data) => { + if (error && error.code !== 0) { + console.error('getAppType fail, error: ${JSON.stringify(error)}'); + } else { + console.log('getAppType success, data: ${JSON.stringify(data)}'); + } }); ``` @@ -1006,7 +1069,7 @@ Obtains the application type. This API uses a promise to return the result. ```ts import featureAbility from '@ohos.ability.featureAbility'; -let context = featureAbility.getContext(); +let context: featureAbility.Context = featureAbility.getContext(); context.getAppType().then((data) => { console.info('getAppType data: ' + JSON.stringify(data)); }); @@ -1030,9 +1093,13 @@ Obtains the **ModuleInfo** object of the application. This API uses an asynchron ```ts import featureAbility from '@ohos.ability.featureAbility'; -let context = featureAbility.getContext(); -context.getHapModuleInfo((err, data) => { - console.info('getHapModuleInfo err: ' + JSON.stringify(err) + 'data: ' + JSON.stringify(data)); +let context: featureAbility.Context = featureAbility.getContext(); +context.getHapModuleInfo((error, data) => { + if (error && error.code !== 0) { + console.error('getHapModuleInfo fail, error: ${JSON.stringify(error)}'); + } else { + console.log('getHapModuleInfo success, data: ${JSON.stringify(data)}'); + } }); ``` @@ -1054,7 +1121,7 @@ Obtains the **ModuleInfo** object of the application. This API uses a promise to ```ts import featureAbility from '@ohos.ability.featureAbility'; -let context = featureAbility.getContext(); +let context: featureAbility.Context = featureAbility.getContext(); context.getHapModuleInfo().then((data) => { console.info('getHapModuleInfo data: ' + JSON.stringify(data)); }); @@ -1078,9 +1145,13 @@ Obtains the version information of the application. This API uses an asynchronou ```ts import featureAbility from '@ohos.ability.featureAbility'; -let context = featureAbility.getContext(); -context.getAppVersionInfo((err, data) => { - console.info('getAppVersionInfo err: ' + JSON.stringify(err) + 'data: ' + JSON.stringify(data)); +let context: featureAbility.Context = featureAbility.getContext(); +context.getAppVersionInfo((error, data) => { + if (error && error.code !== 0) { + console.error('getAppVersionInfo fail, error: ${JSON.stringify(error)}'); + } else { + console.log('getAppVersionInfo success, data: ${JSON.stringify(data)}'); + } }); ``` @@ -1102,7 +1173,7 @@ Obtains the version information of the application. This API uses a promise to r ```ts import featureAbility from '@ohos.ability.featureAbility'; -let context = featureAbility.getContext(); +let context: featureAbility.Context = featureAbility.getContext(); context.getAppVersionInfo().then((data) => { console.info('getAppVersionInfo data: ' + JSON.stringify(data)); }); @@ -1126,9 +1197,13 @@ Obtains information about this ability. This API uses an asynchronous callback t ```ts import featureAbility from '@ohos.ability.featureAbility'; -let context = featureAbility.getContext(); -context.getAbilityInfo((err, data) => { - console.info('getAbilityInfo err: ' + JSON.stringify(err) + 'data: ' + JSON.stringify(data)); +let context: featureAbility.Context = featureAbility.getContext(); +context.getAbilityInfo((error, data) => { + if (error && error.code !== 0) { + console.error('getAbilityInfo fail, error: ${JSON.stringify(error)}'); + } else { + console.log('getAbilityInfo success, data: ${JSON.stringify(data)}'); + } }); ``` @@ -1150,7 +1225,7 @@ Obtains information about this ability. This API uses a promise to return the re ```ts import featureAbility from '@ohos.ability.featureAbility'; -let context = featureAbility.getContext(); +let context: featureAbility.Context = featureAbility.getContext(); context.getAbilityInfo().then((data) => { console.info('getAbilityInfo data: ' + JSON.stringify(data)); }); @@ -1174,7 +1249,7 @@ Obtains the context of the application. ```ts import featureAbility from '@ohos.ability.featureAbility'; -let context = featureAbility.getContext().getApplicationContext(); +let context: featureAbility.Context = featureAbility.getContext().getApplicationContext(); ``` ## Context.isUpdatingConfigurations7+ @@ -1195,9 +1270,13 @@ Checks whether the configuration of this ability is being updated. This API uses ```ts import featureAbility from '@ohos.ability.featureAbility'; -let context = featureAbility.getContext(); -context.isUpdatingConfigurations((err, data) => { - console.info('isUpdatingConfigurations err: ' + JSON.stringify(err) + 'data: ' + JSON.stringify(data)); +let context: featureAbility.Context = featureAbility.getContext(); +context.isUpdatingConfigurations((error, data) => { + if (error && error.code !== 0) { + console.error('isUpdatingConfigurations fail, error: ${JSON.stringify(error)}'); + } else { + console.log('isUpdatingConfigurations success, data: ${JSON.stringify(data)}'); + } }); ``` @@ -1219,7 +1298,7 @@ Checks whether the configuration of this ability is being updated. This API uses ```ts import featureAbility from '@ohos.ability.featureAbility'; -let context = featureAbility.getContext(); +let context: featureAbility.Context = featureAbility.getContext(); context.isUpdatingConfigurations().then((data) => { console.info('isUpdatingConfigurations data: ' + JSON.stringify(data)); }); @@ -1243,7 +1322,7 @@ Notifies the system of the time required to draw this page function. This API us ```ts import featureAbility from '@ohos.ability.featureAbility'; -let context = featureAbility.getContext(); +let context: featureAbility.Context = featureAbility.getContext(); context.printDrawnCompleted((err) => { console.error('printDrawnCompleted err: ' + JSON.stringify(err)); }); @@ -1267,7 +1346,7 @@ Notifies the system of the time required to draw this page function. This API us ```ts import featureAbility from '@ohos.ability.featureAbility'; -let context = featureAbility.getContext(); +let context: featureAbility.Context = featureAbility.getContext(); context.printDrawnCompleted().then((data) => { console.info('printDrawnCompleted data: ' + JSON.stringify(data)); }); diff --git a/en/application-dev/reference/apis/js-apis-inner-app-processInfo.md b/en/application-dev/reference/apis/js-apis-inner-app-processInfo.md index 8127343de9..1cec0c79db 100644 --- a/en/application-dev/reference/apis/js-apis-inner-app-processInfo.md +++ b/en/application-dev/reference/apis/js-apis-inner-app-processInfo.md @@ -6,6 +6,12 @@ The **ProcessInfo** module defines process information. You can use [getProcessI > > The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version. +## Modules to Import + +```ts +import featureAbility from '@ohos.ability.featureAbility'; +``` + **System capability**: SystemCapability.Ability.AbilityRuntime.Core | Name| Type| Readable| Writable| Description| diff --git a/en/application-dev/reference/apis/js-apis-inner-application-abilityDelegator.md b/en/application-dev/reference/apis/js-apis-inner-application-abilityDelegator.md index a384e64396..5a85f3f5e6 100644 --- a/en/application-dev/reference/apis/js-apis-inner-application-abilityDelegator.md +++ b/en/application-dev/reference/apis/js-apis-inner-application-abilityDelegator.md @@ -16,7 +16,7 @@ import AbilityDelegatorRegistry from '@ohos.app.ability.abilityDelegatorRegistry An **AbilityDelegator** object is obtained by calling [getAbilityDelegator](js-apis-app-ability-abilityDelegatorRegistry.md#abilitydelegatorregistrygetabilitydelegator) in **AbilityDelegatorRegistry**. ```ts -import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'; +import AbilityDelegatorRegistry from '@ohos.app.ability.abilityDelegatorRegistry'; ``` ## AbilityDelegator @@ -163,7 +163,7 @@ abilityDelegator.removeAbilityMonitor(monitor, (err : any) => { removeAbilityMonitor(monitor: AbilityMonitor): Promise\; -删除已经添加的AbilityMonitor实例(promise形式) +Removes an **AbilityMonitor** instance. This API uses a promise to return the result. **System capability**: SystemCapability.Ability.AbilityRuntime.Core diff --git a/en/application-dev/reference/apis/js-apis-inner-application-abilityDelegatorArgs.md b/en/application-dev/reference/apis/js-apis-inner-application-abilityDelegatorArgs.md index e95c459583..85fac0ea7a 100644 --- a/en/application-dev/reference/apis/js-apis-inner-application-abilityDelegatorArgs.md +++ b/en/application-dev/reference/apis/js-apis-inner-application-abilityDelegatorArgs.md @@ -6,6 +6,12 @@ The **AbilityDelegatorArgs** module provides a global register to store the regi > > The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version. +## Modules to Import + +```ts +import AbilityDelegatorRegistry from '@ohos.app.ability.abilityDelegatorRegistry'; +``` + ## Usage An **AbilityDelegatorArgs** object is obtained by calling [getArguments](js-apis-app-ability-abilityDelegatorRegistry.md#abilitydelegatorregistrygetarguments) in **AbilityDelegatorRegistry**. @@ -26,7 +32,5 @@ Describes the ability delegator arguments. **Example** ```ts -import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'; - -let args = AbilityDelegatorRegistry.getArguments(); +let args: AbilityDelegatorRegistry.AbilityDelegatorArgs = AbilityDelegatorRegistry.getArguments(); ``` diff --git a/en/application-dev/reference/apis/js-apis-inner-application-abilityMonitor.md b/en/application-dev/reference/apis/js-apis-inner-application-abilityMonitor.md index 0e9b919995..47cd991ce7 100644 --- a/en/application-dev/reference/apis/js-apis-inner-application-abilityMonitor.md +++ b/en/application-dev/reference/apis/js-apis-inner-application-abilityMonitor.md @@ -6,6 +6,12 @@ The **AbilityMonitor** module provides monitors for abilities that meet specifie > > 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 AbilityDelegatorRegistry from '@ohos.app.ability.abilityDelegatorRegistry'; +``` + ## Usage **AbilityMonitor** can be used as an input parameter of [addAbilityMonitor](js-apis-inner-application-abilityDelegator.md#addabilitymonitor9) in **abilityDelegator** to listen for lifecycle changes of an ability. @@ -31,8 +37,6 @@ Describes an ability monitor. **Example** ```ts -import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'; - function onAbilityCreateCallback(data) { console.info('onAbilityCreateCallback'); } @@ -43,9 +47,11 @@ let monitor = { onAbilityCreate: onAbilityCreateCallback }; -let abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator(); -abilityDelegator.addAbilityMonitor(monitor, (err : any) => { - console.info('addAbilityMonitor callback'); +let abilityDelegator: AbilityDelegatorRegistry.AbilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator(); +abilityDelegator.addAbilityMonitor(monitor, (error : any) => { + if (error && error.code !== 0) { + console.error('addAbilityMonitor fail, error: ${JSON.stringify(error)}'); + } }); ``` diff --git a/en/application-dev/reference/apis/js-apis-inner-application-abilityRunningInfo.md b/en/application-dev/reference/apis/js-apis-inner-application-abilityRunningInfo.md index 01bf2d71fd..46f4220f76 100644 --- a/en/application-dev/reference/apis/js-apis-inner-application-abilityRunningInfo.md +++ b/en/application-dev/reference/apis/js-apis-inner-application-abilityRunningInfo.md @@ -6,6 +6,12 @@ The **AbilityRunningInfo** module defines the running information and state of a > > The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version. +## Modules to Import + +```ts +import abilitymanager from '@ohos.app.ability.abilityManager'; +``` + ## Usage The ability running information is obtained by calling [getAbilityRunningInfos](js-apis-app-ability-abilityManager.md#getabilityrunninginfos) in **abilityManager**. diff --git a/en/application-dev/reference/apis/js-apis-inner-application-abilityStageContext.md b/en/application-dev/reference/apis/js-apis-inner-application-abilityStageContext.md index aa037839a6..0ce8ddfa86 100644 --- a/en/application-dev/reference/apis/js-apis-inner-application-abilityStageContext.md +++ b/en/application-dev/reference/apis/js-apis-inner-application-abilityStageContext.md @@ -9,6 +9,12 @@ This module provides APIs for accessing a specific ability stage. You can use th > 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 common from '@ohos.app.ability.common'; +``` + ## Usage The ability stage context is obtained through an **AbilityStage** instance. diff --git a/en/application-dev/reference/apis/js-apis-inner-application-abilityStageMonitor.md b/en/application-dev/reference/apis/js-apis-inner-application-abilityStageMonitor.md index 9605509b0e..879c0859d5 100644 --- a/en/application-dev/reference/apis/js-apis-inner-application-abilityStageMonitor.md +++ b/en/application-dev/reference/apis/js-apis-inner-application-abilityStageMonitor.md @@ -1,13 +1,17 @@ # AbilityStageMonitor -The **AbilityStageMonitor** module provides conditions for matching **AbilityStage** instances. The most recently matched **AbilityStage** instance is saved in an **AbilityStageMonitor** instance. +The **AbilityStageMonitor** module provides conditions for matching **AbilityStage** instances. The most recently matched **AbilityStage** instance is saved in an **AbilityStageMonitor** instance. + +> **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. **System capability**: SystemCapability.Ability.AbilityRuntime.Core | Name | Type | Readable| Writable| Description | | ------------------------------------------------------------ | -------- | ---- | ---- | ------------------------------------------------------------ | -| moduleName9+ | string | Yes | Yes | Module name of the **AbilityStage** instance.| -| srcEntrance9+ | string | Yes | Yes | Source path of the **AbilityStage** instance.| +| moduleName | string | Yes | Yes | Module name of the **AbilityStage** instance.| +| srcEntrance | string | Yes | Yes | Source path of the **AbilityStage** instance.| **Example** ```ts diff --git a/en/application-dev/reference/apis/js-apis-inner-application-abilityStateData.md b/en/application-dev/reference/apis/js-apis-inner-application-abilityStateData.md index eb539bd981..89737dea19 100644 --- a/en/application-dev/reference/apis/js-apis-inner-application-abilityStateData.md +++ b/en/application-dev/reference/apis/js-apis-inner-application-abilityStateData.md @@ -2,17 +2,27 @@ The **AbilityStateData** module defines the ability state information, which can be obtained through the **onAbilityStateChanged** lifecycle callback of [ApplicationStateObserver](js-apis-inner-application-applicationStateObserver.md). The callback can be invoked after a lifecycle change listener is registered through [registerApplicationStateObserver](js-apis-application-appManager.md#appmanagerregisterapplicationstateobserver8). +> **NOTE** +> +> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version. + +## Modules to Import + +```ts +import appManager from '@ohos.application.appManager'; +``` + **System capability**: SystemCapability.Ability.AbilityRuntime.Core | Name | Type | Readable| Writable| Description | | ----------------------- | ---------| ---- | ---- | ------------------------- | -| pid8+ | number | Yes | No | Process ID. | -| bundleName8+ | string | Yes | No | Bundle name. | -| abilityName8+ | string | Yes | No | Ability name. | -| uid8+ | number | Yes | No | User ID. | -| state8+ | number | Yes | No | [Ability state](#ability-states). | +| pid | number | Yes | No | Process ID. | +| bundleName | string | Yes | No | Bundle name. | +| abilityName | string | Yes | No | Ability name. | +| uid | number | Yes | No | User ID. | +| state | number | Yes | No | [Ability state](#ability-states). | | moduleName9+ | string | Yes | No | Name of the HAP file to which the ability belongs. | -| abilityType8+ | number | Yes | No | [Ability type](#ability-types), which can be **page** or **service**.| +| abilityType | number | Yes | No | [Ability type](#ability-types), which can be **page** or **service**.| #### Ability States @@ -29,7 +39,7 @@ The **AbilityStateData** module defines the ability state information, which can #### Ability Types -| Value | Status | Description | +| Value | State | Description | | ---- | ------- | --------------------- | | 0 | UNKNOWN | Unknown type. | | 1 | PAGE | Ability that has the UI. | diff --git a/en/application-dev/reference/apis/js-apis-inner-application-appStateData.md b/en/application-dev/reference/apis/js-apis-inner-application-appStateData.md index 08909d57aa..85be86e0c5 100644 --- a/en/application-dev/reference/apis/js-apis-inner-application-appStateData.md +++ b/en/application-dev/reference/apis/js-apis-inner-application-appStateData.md @@ -2,6 +2,12 @@ The **AppStateData** module defines the application state data, which can be obtained through [getForegroundApplications](js-apis-app-ability-appManager.md#appmanagergetforegroundapplications). +## Modules to Import + +```ts +import appManager from '@ohos.app.ability.appManager'; +``` + **System capability**: SystemCapability.Ability.AbilityRuntime.Core **System API**: This is a system API and cannot be called by third-party applications. @@ -9,7 +15,7 @@ The **AppStateData** module defines the application state data, which can be obt | Name | Type | Mandatory | Description | | ------------------------- | ------ | ---- | --------- | | bundleName8+ | string | No | Bundle name.| -| uid8+ | number | No | UID of the application. | +| uid8+ | number | No | User ID. | | state8+ | number | No | Application state.| **Example** @@ -25,3 +31,4 @@ appManager.getForegroundApplications((error, data) => { } }); ``` + diff --git a/en/application-dev/reference/apis/js-apis-inner-application-applicationContext.md b/en/application-dev/reference/apis/js-apis-inner-application-applicationContext.md index b6f0a5480b..4c61373325 100644 --- a/en/application-dev/reference/apis/js-apis-inner-application-applicationContext.md +++ b/en/application-dev/reference/apis/js-apis-inner-application-applicationContext.md @@ -7,12 +7,18 @@ The **ApplicationContext** module provides application-level context. You can us > 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 common from '@ohos.app.ability.common'; +``` + ## Usage Before calling any APIs in **ApplicationContext**, obtain an **ApplicationContext** instance through the **context** instance. ```ts -let applicationContext = this.context.getApplicationContext(); +let applicationContext: common.ApplicationContext = this.context.getApplicationContext(); ``` ## ApplicationContext.on(type: 'abilityLifecycle', callback: AbilityLifecycleCallback) @@ -295,7 +301,6 @@ For details about the error codes, see [Ability Error Codes](../errorcodes/error **Example** ```ts -let applicationContext = this.context.getApplicationContext(); applicationContext.getRunningProcessInformation().then((data) => { console.log('The process running information is:' + JSON.stringify(data)); }).catch((error) => { @@ -333,7 +338,6 @@ For details about the error codes, see [Ability Error Codes](../errorcodes/error **Example** ```ts -let applicationContext = this.context.getApplicationContext(); applicationContext.getRunningProcessInformation((err, data) => { if (err.code !== 0) { console.error('getRunningProcessInformation faile, err: ' + JSON.stringify(err)); @@ -388,7 +392,7 @@ Kills all the processes where the application is located. This API uses an async | Type| Description| | -------- | -------- | -|AsyncCallback\ | Callback used to return the result.| +|AsyncCallback\ | Callback used to return the result.| **Error codes** @@ -401,10 +405,9 @@ For details about the error codes, see [Ability Error Codes](../errorcodes/error **Example** ```ts -let applicationContext = this.context.getApplicationContext(); -applicationContext.killProcessesBySelf(err => { - if (err.code !== 0) { - console.error('killProcessesBySelf faile, err: ' + JSON.stringify(err)); +applicationContext.killAllProcesses(error => { + if (error) { + console.error('killAllProcesses fail, error: ${JSON.stringify(error)}'); } }) ``` diff --git a/en/application-dev/reference/apis/js-apis-inner-application-applicationStateObserver.md b/en/application-dev/reference/apis/js-apis-inner-application-applicationStateObserver.md index baa8975bb7..d4ab30623d 100644 --- a/en/application-dev/reference/apis/js-apis-inner-application-applicationStateObserver.md +++ b/en/application-dev/reference/apis/js-apis-inner-application-applicationStateObserver.md @@ -2,22 +2,30 @@ The **ApplicationStateObserver** module defines an observer to listen for application state changes. It can be used as an input parameter in [registerApplicationStateObserver](js-apis-application-appManager.md#appmanagerregisterapplicationstateobserver8) to listen for lifecycle changes of the current application. +> **NOTE** +> +> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version. + +## Modules to Import + +```ts +import appManager from '@ohos.app.ability.appManager'; +``` + **System capability**: SystemCapability.Ability.AbilityRuntime.Core **System API**: This is a system API and cannot be called by third-party applications. | Name | | Type | Readable| Writable| Description | | ----------------------- | ---------| ---- | ---- | ------------------------- | ------------------------- | -| onForegroundApplicationChanged8+ | [AppStateData](js-apis-inner-application-appStateData.md) | AsyncCallback\ | Yes | No | Callback invoked when the foreground or background state of an application changes. | -| onAbilityStateChanged8+ | [AbilityStateData](js-apis-inner-application-abilityStateData.md) | AsyncCallback\ | Yes | No | Callback invoked when the ability state changes. | -| onProcessCreated8+ | [ProcessData](js-apis-inner-application-processData.md) | AsyncCallback\ | Yes | No | Callback invoked when a process is created. | -| onProcessDied8+ | [ProcessData](js-apis-inner-application-processData.md) | AsyncCallback\ | Yes | No | Callback invoked when a process is destroyed. | -| onProcessStateChanged8+ | [ProcessData](js-apis-inner-application-processData.md) | AsyncCallback\ | Yes | No | Callback invoked when the process state is changed. | +| onForegroundApplicationChanged | [AppStateData](js-apis-inner-application-appStateData.md) | AsyncCallback\ | Yes | No | Callback invoked when the foreground or background state of an application changes. | +| onAbilityStateChanged | [AbilityStateData](js-apis-inner-application-abilityStateData.md) | AsyncCallback\ | Yes | No | Callback invoked when the ability state changes. | +| onProcessCreated | [ProcessData](js-apis-inner-application-processData.md) | AsyncCallback\ | Yes | No | Callback invoked when a process is created. | +| onProcessDied | [ProcessData](js-apis-inner-application-processData.md) | AsyncCallback\ | Yes | No | Callback invoked when a process is destroyed. | +| onProcessStateChanged9+ | [ProcessData](js-apis-inner-application-processData.md) | AsyncCallback\ | Yes | No | Callback invoked when the process state is changed. | **Example** ```ts -import appManager from "@ohos.application.appManager"; - let applicationStateObserver = { onForegroundApplicationChanged(appStateData) { console.log('onForegroundApplicationChanged appStateData: ' + JSON.stringify(appStateData)); diff --git a/en/application-dev/reference/apis/js-apis-inner-application-baseContext.md b/en/application-dev/reference/apis/js-apis-inner-application-baseContext.md index 208e363227..a556a7b98d 100644 --- a/en/application-dev/reference/apis/js-apis-inner-application-baseContext.md +++ b/en/application-dev/reference/apis/js-apis-inner-application-baseContext.md @@ -6,11 +6,17 @@ > > The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version. +## Modules to Import + +```ts +import common from '@ohos.app.ability.common'; +``` + **System capability**: SystemCapability.Ability.AbilityRuntime.Core | Name | Type | Readable | Writable | Description | | -------- | ------ | ---- | ---- | ------- | -| stageMode | boolean | Yes | Yes | Whether the child class **Context** is used for the stage model.
**true**: used for the stage model.
**false**: used for the FA model.| +| stageMode | boolean | Yes | Yes | Whether the child class **Context** is used for the stage model.| **Example** diff --git a/en/application-dev/reference/apis/js-apis-inner-application-context.md b/en/application-dev/reference/apis/js-apis-inner-application-context.md index 339eb62bd5..492ff93d33 100644 --- a/en/application-dev/reference/apis/js-apis-inner-application-context.md +++ b/en/application-dev/reference/apis/js-apis-inner-application-context.md @@ -4,8 +4,14 @@ The **Context** module provides context for abilities or applications. It allows > **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. +> 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 common from '@ohos.app.ability.common'; +``` ## Attributes @@ -20,7 +26,7 @@ The **Context** module provides context for abilities or applications. It allows | filesDir | string | Yes | No | File directory.| | databaseDir | string | Yes | No | Database directory.| | preferencesDir | string | Yes | No | Preferences directory.| -| bundleCodeDir | string | Yes | No | Bundle code directory. A resource file cannot be accessed by combining paths. Use [Resource Manager](js-apis-resource-manager.md) to access it. | +| bundleCodeDir | string | Yes | No | Bundle code directory. Do not access resource files by concatenating paths. Use the [resourceManager API](js-apis-resource-manager.md) instead.| | distributedFilesDir | string | Yes | No | Distributed file directory.| | eventHub | [EventHub](js-apis-inner-application-eventHub.md) | Yes | No | Event hub that implements event subscription, unsubscription, and triggering.| | area | [AreaMode](#areamode) | Yes | No | Area in which the file to be access is located.| @@ -49,7 +55,12 @@ Creates the context based on the bundle name. **Example** ```ts -let bundleContext = this.context.createBundleContext('com.example.test'); +let bundleContext: common.Context; +try { + bundleContext = this.context.createBundleContext('com.example.test'); +} catch (error) { + console.error('createBundleContext failed, error.code: ${error.code}, error.message: ${error.message}'); +} ``` ## Context.createModuleContext @@ -75,7 +86,12 @@ Creates the context based on the module name. **Example** ```ts -let moduleContext = this.context.createModuleContext('entry'); +let moduleContext: common.Context; +try { + moduleContext = this.context.createModuleContext('entry'); +} catch (error) { + console.error('createModuleContext failed, error.code: ${error.code}, error.message: ${error.message}'); +} ``` ## Context.createModuleContext @@ -102,14 +118,19 @@ Creates the context based on the bundle name and module name. **Example** ```ts -let moduleContext = this.context.createModuleContext('com.example.test', 'entry'); +let moduleContext: common.Context; +try { + moduleContext = this.context.createModuleContext('com.example.test', 'entry'); +} catch (error) { + console.error('createModuleContext failed, error.code: ${error.code}, error.message: ${error.message}'); +} ``` ## Context.getApplicationContext getApplicationContext(): ApplicationContext; -Obtains the context of this application. +Obtains the application context. **System capability**: SystemCapability.Ability.AbilityRuntime.Core @@ -122,16 +143,21 @@ Obtains the context of this application. **Example** ```ts -let applicationContext = this.context.getApplicationContext(); +let applicationContext: common.Context; +try { + applicationContext = this.context.getApplicationContext(); +} catch (error) { + console.error('getApplicationContext failed, error.code: ${error.code}, error.message: ${error.message}'); +} ``` ## AreaMode -Enumerates the areas in which the file to be access can be located. +Enumerates the encryption levels of directories. **System capability**: SystemCapability.Ability.AbilityRuntime.Core | Name| Value| Description| | -------- | -------- | -------- | -| EL1 | 0 | Device-level encryption area, which is accessible after the device is powered on.| -| EL2 | 1 | User-level encryption area, which is accessible only after the device is powered on and the password is entered (for the first time).| +| EL1 | 0 | Device-level encryption. Directories with this encryption level are accessible after the device is powered on.| +| EL2 | 1 | User-level encryption. Directories with this encryption level are accessible only after the device is powered on and the password is entered (for the first time).| diff --git a/en/application-dev/reference/apis/js-apis-inner-application-errorObserver.md b/en/application-dev/reference/apis/js-apis-inner-application-errorObserver.md index 69bf3aabe4..d8c4d76dff 100644 --- a/en/application-dev/reference/apis/js-apis-inner-application-errorObserver.md +++ b/en/application-dev/reference/apis/js-apis-inner-application-errorObserver.md @@ -2,7 +2,17 @@ The **ErrorObserver** module defines an observer to listen for application errors. It can be used as an input parameter in [errorManager.on](js-apis-app-ability-errorManager.md#errormanageron) to listen for errors that occur in the current application. -## onUnhandledException +> **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'; +``` + +## ErrorObserver.onUnhandledException onUnhandledException(errMsg: string): void; @@ -22,9 +32,15 @@ Called when an unhandled exception occurs in the JS runtime. import errorManager from '@ohos.app.ability.errorManager'; let observer = { - onUnhandledException(errorMsg) { - console.log('onUnhandledException, errorMsg: ' + JSON.stringify(errorMsg)); - } + onUnhandledException(errorMsg) { + console.error('onUnhandledException, errorMsg: ', errorMsg); + } }; -errorManager.on('error',observer); + +try { + errorManager.on('error', observer); +} catch (error) { + console.error('registerErrorObserver failed, error.code: ${error.code}, error.message: ${error.message}'); +} +``` ``` diff --git a/en/application-dev/reference/apis/js-apis-inner-application-eventHub.md b/en/application-dev/reference/apis/js-apis-inner-application-eventHub.md index ef9ee1153f..7461c09d3c 100644 --- a/en/application-dev/reference/apis/js-apis-inner-application-eventHub.md +++ b/en/application-dev/reference/apis/js-apis-inner-application-eventHub.md @@ -3,9 +3,15 @@ The **EventHub** module provides APIs to subscribe to, unsubscribe from, and trigger events. > **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. +> +> 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 common from '@ohos.app.ability.common'; +``` ## Usage @@ -65,7 +71,7 @@ Subscribes to an event. off(event: string, callback?: Function): void; -Unsubscribes from an event. +Unsubscribes from an event. If **callback** is specified, this API unsubscribes from the specified callback. If **callback** is not specified, this API unsubscribes from all callbacks in the event. **System capability**: SystemCapability.Ability.AbilityRuntime.Core @@ -84,10 +90,10 @@ Unsubscribes from an event. export default class MainAbility extends Ability { onForeground() { this.context.eventHub.on('123', this.func1); - this.context.eventHub.off('123', this.func1); // Unsubscribe from the myEvent event with the callback eventFunc1. + this.context.eventHub.off('123', this.func1); // Unsubscribe from func1. this.context.eventHub.on('123', this.func1); this.context.eventHub.on('123', this.func2); - this.context.eventHub.off('123'); // Unsubscribe from the myEvent event with all the callbacks (eventFunc1 and eventFunc2). + this.context.eventHub.off('123'); // Unsubscribe from func1 and func2. } func1() { console.log('func1 is called'); diff --git a/en/application-dev/reference/apis/js-apis-inner-application-extensionContext.md b/en/application-dev/reference/apis/js-apis-inner-application-extensionContext.md index ce0a916f3c..0c730f3c95 100644 --- a/en/application-dev/reference/apis/js-apis-inner-application-extensionContext.md +++ b/en/application-dev/reference/apis/js-apis-inner-application-extensionContext.md @@ -9,6 +9,12 @@ This module provides APIs for accessing resources of a specific Extension abilit > - 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 common from '@ohos.app.ability.common'; +``` + ## Attributes **System capability**: SystemCapability.Ability.AbilityRuntime.Core diff --git a/en/application-dev/reference/apis/js-apis-inner-application-extensionRunningInfo.md b/en/application-dev/reference/apis/js-apis-inner-application-extensionRunningInfo.md index 8121aeba92..be7c4710a9 100644 --- a/en/application-dev/reference/apis/js-apis-inner-application-extensionRunningInfo.md +++ b/en/application-dev/reference/apis/js-apis-inner-application-extensionRunningInfo.md @@ -1,15 +1,21 @@ # ExtensionRunningInfo -The **ExtensionRunningInfo** module encapsulates ExtensionAbility running information, which can be obtained through [getExtensionRunningInfos](js-apis-app-ability-abilityManager.md#getextensionrunninginfos). +The **ExtensionRunningInfo** module provides APIs for setting and querying ExtensionAbility running information, which can be obtained through [getExtensionRunningInfos](js-apis-app-ability-abilityManager.md#getextensionrunninginfos). > **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 system APIs and cannot be called by third-party applications. +> 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 system APIs and cannot be called by third-party applications. + +## Modules to Import + +```ts +import abilityManager from '@ohos.app.ability.abilityManager'; +``` ## Usage -Import the **abilityManager** module and obtain the ExtensionAbility running information by calling the method in the **abilityManager** module. +The ExtensionAbility running information is obtained through an **abilityManager** instance. ## Attributes @@ -17,11 +23,11 @@ Import the **abilityManager** module and obtain the ExtensionAbility running inf | Name| Type| Readable| Writable| Description| | -------- | -------- | -------- | -------- | -------- | -| extension | ElementName | Yes| No| ExtensionAbility information.| +| extension | ElementName | Yes| No| ExtensionAbility information..| | pid | number | Yes| No| Process ID.| -| uid | number | Yes| No| UID of the application.| +| uid | number | Yes| No| User ID.| | processName | string | Yes| No| Process name.| -| startTime | number | Yes| No| Timestamp when the ExtensionAbility is started.| +| startTime | number | Yes| No| Start time of the ExtensionAbility.| | clientPackage | Array<String> | Yes| No| Names of all packages in the process.| | type | [bundle.ExtensionAbilityType](js-apis-Bundle.md) | Yes| No| ExtensionAbility type.| diff --git a/en/application-dev/reference/apis/js-apis-inner-application-formExtensionContext.md b/en/application-dev/reference/apis/js-apis-inner-application-formExtensionContext.md index 3f839c466d..d59eaac0f7 100644 --- a/en/application-dev/reference/apis/js-apis-inner-application-formExtensionContext.md +++ b/en/application-dev/reference/apis/js-apis-inner-application-formExtensionContext.md @@ -24,7 +24,7 @@ import FormExtensionAbility from '@ohos.app.form.FormExtensionAbility'; import formBindingData from '@ohos.app.form.formBindingData'; export default class MyFormExtensionAbility extends FormExtensionAbility { onAddForm() { - let formContext = this.context; // 获取FormExtensionContext + let formContext = this.context; // Obtain a FormExtensionContext instance. // ... let dataObj1 = { temperature:'11c', diff --git a/en/application-dev/reference/apis/js-apis-inner-application-missionInfo.md b/en/application-dev/reference/apis/js-apis-inner-application-missionInfo.md index 1aabfc1961..bb7fd23a4d 100644 --- a/en/application-dev/reference/apis/js-apis-inner-application-missionInfo.md +++ b/en/application-dev/reference/apis/js-apis-inner-application-missionInfo.md @@ -2,6 +2,16 @@ The **MissionInfo** module defines detailed information about a mission. The information can be obtained through [getMissionInfo](js-apis-app-ability-missionManager.md#missionmanagergetmissioninfo). +> **NOTE** +> +> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version. + +## Modules to Import + +```ts +import missionManager from '@ohos.app.ability.missionManager'; +``` + **System capability**: SystemCapability.Ability.AbilityRuntime.Mission **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-inner-application-missionListener.md b/en/application-dev/reference/apis/js-apis-inner-application-missionListener.md index 54ad07799f..f4462d50cd 100644 --- a/en/application-dev/reference/apis/js-apis-inner-application-missionListener.md +++ b/en/application-dev/reference/apis/js-apis-inner-application-missionListener.md @@ -2,6 +2,16 @@ The **MissionListener** module defines the listeners used to observe the mission status. The listeners can be registered by using [registerMissionListener](js-apis-application-missionManager.md#missionmanagerregistermissionlistener). +> **NOTE** +> +> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version. + +## Modules to Import + +```ts +import missionManager from '@ohos.app.ability.missionManager'; +``` + **System capability**: SystemCapability.Ability.AbilityRuntime.Mission | Name | Type | Mandatory| Description | @@ -10,9 +20,9 @@ The **MissionListener** module defines the listeners used to observe the mission | onMissionDestroyed | function | No | Called when the system destroys the mission.| | onMissionSnapshotChanged | function | No | Called when the system updates the mission snapshot.| | onMissionMovedToFront | function | No | Called when the system moves the mission to the foreground.| -| onMissionLabelUpdated | function | No | Called when the system updates the mission label.| -| onMissionIconUpdated | function | No | Called when the system updates the mission icon.| -| onMissionClosed | function | No | Called when the system closes the mission.| +| onMissionLabelUpdated9+ | function | No | Called when the system updates the mission label.| +| onMissionIconUpdated9+ | function | No | Called when the system updates the mission icon.| +| onMissionClosed9+ | function | No | Called when the system closes the mission.| **Example** ```ts diff --git a/en/application-dev/reference/apis/js-apis-inner-application-missionSnapshot.md b/en/application-dev/reference/apis/js-apis-inner-application-missionSnapshot.md index cee807663f..d8690dd167 100644 --- a/en/application-dev/reference/apis/js-apis-inner-application-missionSnapshot.md +++ b/en/application-dev/reference/apis/js-apis-inner-application-missionSnapshot.md @@ -7,6 +7,12 @@ The **MissionSnapshot** module defines the snapshot of a mission. The snapshot c > The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version. > The APIs of this module are system APIs and cannot be called by third-party applications. +## Modules to Import + +```ts +import missionManager from '@ohos.app.ability.missionManager'; +``` + **System capability**: SystemCapability.Ability.AbilityRuntime.Mission | Name| Type| Readable| Writable| Description| diff --git a/en/application-dev/reference/apis/js-apis-inner-application-processData.md b/en/application-dev/reference/apis/js-apis-inner-application-processData.md index 975a3df799..5d7bead4f2 100644 --- a/en/application-dev/reference/apis/js-apis-inner-application-processData.md +++ b/en/application-dev/reference/apis/js-apis-inner-application-processData.md @@ -2,17 +2,28 @@ The **ProcessData** module defines process data. If a lifecycle change listener is registered by calling [registerApplicationStateObserver](js-apis-application-appManager.md#appmanagerregisterapplicationstateobserver8), the **onProcessCreated** callback in [ApplicationStateObserver](js-apis-inner-application-applicationStateObserver.md) is invoked when the lifecycle of an application or ability changes. +> **NOTE** +> +> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version. + +## Modules to Import + +```ts +import appManager from '@ohos.application.appManager'; +``` + **System capability**: SystemCapability.Ability.AbilityRuntime.Core **System API**: This is a system API and cannot be called by third-party applications. | Name | Type | Readable| Writable| Description | | ----------------------- | ---------| ---- | ---- | ------------------------- | -| pid8+ | number | Yes | No | Process ID. | -| bundleName8+ | string | Yes | No | Bundle name of the application. | -| uid8+ | number | Yes | No | UID of the application. | +| pid | number | Yes | No | Process ID. | +| bundleName | string | Yes | No | Bundle name of the application. | +| uid | number | Yes | No | UID of the application. | | isContinuousTask9+ | boolean | Yes | No | Whether the task is a continuous task. The value **true** means that the task is a continuous task, and **false** means the opposite. | | isKeepAlive9+ | boolean | Yes | No | Whether the process is a resident task. The value **true** means that the process is a resident, and **false** means the opposite. | +| state9+ | number | Yes | No | Application state. The value can be **0** (newly created), **2** (foreground), **4** (background), or **5** (terminated). | **Example** ```ts diff --git a/en/application-dev/reference/apis/js-apis-inner-application-processInformation.md b/en/application-dev/reference/apis/js-apis-inner-application-processInformation.md index 2f247b7223..1d48ebcd54 100644 --- a/en/application-dev/reference/apis/js-apis-inner-application-processInformation.md +++ b/en/application-dev/reference/apis/js-apis-inner-application-processInformation.md @@ -6,6 +6,12 @@ The **ProcessInformation** module defines the running information of a process. > > 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 appManager from '@ohos.app.ability.appManager'; +``` + ## How to Use The process information is obtained by calling [getRunningProcessInformation](js-apis-app-ability-appManager.md#appmanagergetrunningprocessinformation9) of the **appManager** module. diff --git a/en/application-dev/reference/apis/js-apis-inner-application-processRunningInfo.md b/en/application-dev/reference/apis/js-apis-inner-application-processRunningInfo.md index 50f9418381..5b66d465dc 100644 --- a/en/application-dev/reference/apis/js-apis-inner-application-processRunningInfo.md +++ b/en/application-dev/reference/apis/js-apis-inner-application-processRunningInfo.md @@ -6,6 +6,12 @@ The **ProcessRunningInfo** module defines the running information of a process. > - The APIs provided by this module are deprecated since API version 9. You are advised to use [ProcessInformation9+](js-apis-inner-application-processInformation.md) instead. > - The initial APIs of this module are supported since API version 8. +## Modules to Import + +```ts +import appManager from '@ohos.app.ability.appManager'; +``` + ## Attributes **System capability**: SystemCapability.Ability.AbilityRuntime.Mission diff --git a/en/application-dev/reference/apis/js-apis-inner-application-serviceExtensionContext.md b/en/application-dev/reference/apis/js-apis-inner-application-serviceExtensionContext.md index 2777b77dca..f9675c8121 100644 --- a/en/application-dev/reference/apis/js-apis-inner-application-serviceExtensionContext.md +++ b/en/application-dev/reference/apis/js-apis-inner-application-serviceExtensionContext.md @@ -9,6 +9,12 @@ You can use the APIs of this module to start, terminate, connect, and disconnect > - 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 common from '@ohos.app.ability.common'; +``` + ## Usage Before using the **ServiceExtensionContext** module, you must define a child class that inherits from **ServiceExtensionAbility**. diff --git a/en/application-dev/reference/apis/js-apis-inner-application-shellCmdResult.md b/en/application-dev/reference/apis/js-apis-inner-application-shellCmdResult.md index fede94a87e..583bad7509 100644 --- a/en/application-dev/reference/apis/js-apis-inner-application-shellCmdResult.md +++ b/en/application-dev/reference/apis/js-apis-inner-application-shellCmdResult.md @@ -6,6 +6,12 @@ The **ShellCmdResult** module provides the shell command execution result. > > The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version. +## Modules to Import + +```ts +import AbilityDelegatorRegistry from '@ohos.app.ability.abilityDelegatorRegistry'; +``` + **System capability**: SystemCapability.Ability.AbilityRuntime.Core | Name | Type | Readable| Writable| Description | @@ -19,8 +25,7 @@ The result is obtained by calling [executeShellCommand](js-apis-inner-applicatio **Example** ```ts -import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'; -let abilityDelegator; +let abilityDelegator: AbilityDelegatorRegistry.AbilityDelegator; let cmd = 'cmd'; abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator(); diff --git a/en/application-dev/reference/apis/js-apis-inner-application-uiAbilityContext.md b/en/application-dev/reference/apis/js-apis-inner-application-uiAbilityContext.md index a0afb7f047..adcba16c24 100644 --- a/en/application-dev/reference/apis/js-apis-inner-application-uiAbilityContext.md +++ b/en/application-dev/reference/apis/js-apis-inner-application-uiAbilityContext.md @@ -9,6 +9,12 @@ This module provides APIs for accessing UIAbility-specific resources. You can us > - 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 common from '@ohos.app.ability.common'; +``` + ## Attributes **System capability**: SystemCapability.Ability.AbilityRuntime.Core @@ -360,23 +366,20 @@ For details about the error codes, see [Ability Error Codes](../errorcodes/error 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)); - } +try { + this.context.startAbilityForResult(want, options, (err, result) => { + if (err.code) { + // Process service logic errors. + console.error(`startAbilityForResult failed, code is ${err.code}, message is ${err.message}`); + return; + } + // Carry out normal service processing. + console.info('startAbilityForResult succeed'); + }); +} catch (err) { + // Process input parameter errors. + console.error(`startAbilityForResult failed, code is ${err.code}, message is ${err.message}`); +} ``` @@ -779,22 +782,20 @@ For details about the error codes, see [Ability Error Codes](../errorcodes/error abilityName: 'MainAbility' }; - 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)); - } +try { + this.context.startServiceExtensionAbility(want) + .then(() => { + // Carry out normal service processing. + console.info('startServiceExtensionAbility succeed'); + }) + .catch((err) => { + // Process service logic errors. + console.error(`startServiceExtensionAbility failed, code is ${err.code}, message is ${err.message}`); + }); +} catch (err) { + // Process input parameter errors. + console.error(`startServiceExtensionAbility failed, code is ${err.code}, message is ${err.message}`); +} ``` ## UIAbilityContext.startServiceExtensionAbilityWithAccount @@ -1404,15 +1405,22 @@ For details about the error codes, see [Ability Error Codes](../errorcodes/error **Example** ```ts - let want = { - deviceId: '', - bundleName: 'com.extreme.test', - abilityName: 'MainAbility' - }; - let options = { - onConnect(elementName, remote) { console.log('----------- onConnect -----------') }, - onDisconnect(elementName) { console.log('----------- onDisconnect -----------') }, - onFailed(code) { console.log('----------- onFailed -----------') } +let want = { + deviceId: '', + bundleName: 'com.example.myapplication', + abilityName: 'ServiceExtensionAbility' +}; +let commRemote; +let options = { + onConnect(elementName, remote) { + commRemote = remote; + console.info('onConnect...') + }, + onDisconnect(elementName) { + console.info('onDisconnect...') + }, + onFailed(code) { + console.info('onFailed...') } let connection = null; @@ -1466,16 +1474,23 @@ For details about the error codes, see [Ability Error Codes](../errorcodes/error **Example** ```ts - let want = { - deviceId: '', - bundleName: 'com.extreme.test', - abilityName: 'MainAbility' - }; - let accountId = 100; - let options = { - onConnect(elementName, remote) { console.log('----------- onConnect -----------') }, - onDisconnect(elementName) { console.log('----------- onDisconnect -----------') }, - onFailed(code) { console.log('----------- onFailed -----------') } +let want = { + deviceId: '', + bundleName: 'com.example.myapplication', + abilityName: 'ServiceExtensionAbility' +}; +let accountId = 100; +let commRemote; +let options = { + onConnect(elementName, remote) { + commRemote = remote; + console.info('onConnect...') + }, + onDisconnect(elementName) { + console.info('onDisconnect...') + }, + onFailed(code) { + console.info('onFailed...') } let connection = null; @@ -1520,8 +1535,8 @@ For details about the error codes, see [Ability Error Codes](../errorcodes/error **Example** ```ts - // connection is the return value of connectServiceExtensionAbility. - let connection = 1; +// connection is the return value of connectServiceExtensionAbility. +let connection = 1; try { this.context.disconnectServiceExtensionAbility(connection) @@ -1568,8 +1583,26 @@ For details about the error codes, see [Ability Error Codes](../errorcodes/error **Example** ```ts - // connection is the return value of connectServiceExtensionAbility. - let connection = 1; +// connection is the return value of connectServiceExtensionAbility. +let connection = 1; +let commRemote; + +try { + this.context.disconnectServiceExtensionAbility(connection, (err) => { + commRemote = null; + if (err.code) { + // Process service logic errors. + console.error(`disconnectServiceExtensionAbility failed, code is ${err.code}, message is ${err.message}`); + return; + } + // Carry out normal service processing. + console.info('disconnectServiceExtensionAbility succeed'); + }); +} catch (err) { + commRemote = null; + // Process input parameter errors. + console.error(`disconnectServiceExtensionAbility failed, code is ${err.code}, message is ${err.message}`); +} try { this.context.disconnectServiceExtensionAbility(connection, (error) => { @@ -1925,7 +1958,7 @@ Requests permissions from the user by displaying a dialog box. This API uses an | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | | permissions | Array<string> | Yes| Permissions to request.| -| callback | AsyncCallback<[PermissionRequestResult](js-apis-permissionRequestResult.md)> | Yes| Callback used to return the result.| +| callback | AsyncCallback<[PermissionRequestResult](js-apis-permissionrequestresult.md)> | Yes| Callback used to return the result.| **Example** @@ -1956,7 +1989,7 @@ Requests permissions from the user by displaying a dialog box. This API uses a p | Type| Description| | -------- | -------- | -| Promise<[PermissionRequestResult](js-apis-permissionRequestResult.md)> | Promise used to return the result.| +| Promise<[PermissionRequestResult](js-apis-permissionrequestresult.md)> | Promise used to return the result.| **Example** diff --git a/en/application-dev/reference/apis/js-apis-inner-wantAgent-triggerInfo.md b/en/application-dev/reference/apis/js-apis-inner-wantAgent-triggerInfo.md index bdd437754a..2f8529db42 100644 --- a/en/application-dev/reference/apis/js-apis-inner-wantAgent-triggerInfo.md +++ b/en/application-dev/reference/apis/js-apis-inner-wantAgent-triggerInfo.md @@ -2,6 +2,16 @@ The **TriggerInfo** module defines the information required for triggering the WantAgent. The information is used as an input parameter of [trigger](js-apis-app-ability-wantAgent.md#wantagenttrigger). +> **NOTE** +> +> The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version. + +## Modules to Import + +```ts +import wantAgent from '@ohos.app.ability.wantAgent'; +``` + **System capability**: SystemCapability.Ability.AbilityRuntime.Core | Name | Type | Mandatory| Description | diff --git a/en/application-dev/reference/apis/js-apis-inner-wantAgent-wantAgentInfo.md b/en/application-dev/reference/apis/js-apis-inner-wantAgent-wantAgentInfo.md index 289a5ebef3..cffcba65b1 100644 --- a/en/application-dev/reference/apis/js-apis-inner-wantAgent-wantAgentInfo.md +++ b/en/application-dev/reference/apis/js-apis-inner-wantAgent-wantAgentInfo.md @@ -2,6 +2,16 @@ The **WantAgentInfo** module defines the information required for triggering a **WantAgent** object. The information can be used as an input parameter in [getWantAgent](js-apis-app-ability-wantAgent.md#wantagentgetwantagent) to obtain a specified **WantAgent** object. +> **NOTE** +> +> The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version. + +## Modules to Import + +```ts +import wantAgent from '@ohos.app.ability.wantAgent'; +``` + **System capability**: SystemCapability.Ability.AbilityRuntime.Core | Name | Type | Mandatory| Description | -- GitLab