diff --git a/en/application-dev/reference/apis/js-apis-Context.md b/en/application-dev/reference/apis/js-apis-Context.md index 62ab1faf7ec09a0323252ce17873d1aca9ba13f1..e70973d986d19ff05a92145cd7ec41e880521a6d 100644 --- a/en/application-dev/reference/apis/js-apis-Context.md +++ b/en/application-dev/reference/apis/js-apis-Context.md @@ -1,7 +1,10 @@ -# Context Module +# Context -> **NOTE**
+> **NOTE** +> > The initial APIs of this module are supported since API version 6. Newly added APIs will be marked with a superscript to indicate their earliest API version. +> +> The APIs of this module can be used only in the FA module. ## Modules to Import @@ -96,8 +99,8 @@ Verifies whether a specific PID and UID have the given permission. This API uses import featureAbility from '@ohos.ability.featureAbility' import bundle from '@ohos.bundle' var context = featureAbility.getContext(); -bundle.getBundleInfo('com.context.test', 1, (datainfo) =>{ - context.verifyPermission("com.example.permission", datainfo.uid); +bundle.getBundleInfo('com.context.test', 1, (err,datainfo) =>{ + context.verifyPermission("com.example.permission", {uid:datainfo.uid}); }); ``` @@ -152,7 +155,7 @@ Verifies whether a specific PID and UID have the given permission. This API uses ```js import featureAbility from '@ohos.ability.featureAbility' var context = featureAbility.getContext(); -var Permission = context.PermissionOptions(1,1); +var Permission = {pid:1}; context.verifyPermission('com.context.permission',Permission).then((data) => { console.info("======================>verifyPermissionCallback====================>"); console.info("====>data====>" + JSON.stringify(data)); diff --git a/en/application-dev/reference/apis/js-apis-DataUriUtils.md b/en/application-dev/reference/apis/js-apis-DataUriUtils.md index 1434ebb8d645af7ae531374769b8534bd5de0910..ceac4f5d700a69d0fd41585ca6ab2efc4f4ea3fe 100644 --- a/en/application-dev/reference/apis/js-apis-DataUriUtils.md +++ b/en/application-dev/reference/apis/js-apis-DataUriUtils.md @@ -1,6 +1,7 @@ -# DataUriUtils Module +# DataUriUtils -> **NOTE**
+> **NOTE** +> > The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version. ## Modules to Import @@ -32,7 +33,7 @@ Obtains the ID attached to the end of a given URI. **Example** ```js -dataUriUtils.getIdSync("com.example.dataUriUtils/1221") +dataUriUtils.getId("com.example.dataUriUtils/1221") ``` diff --git a/en/application-dev/reference/apis/js-apis-ability-context.md b/en/application-dev/reference/apis/js-apis-ability-context.md index b938552925150af55ec98375d48af7d9c4a78e54..cd2aa03316a50c658e7e9b2c5b7725ac368201c9 100644 --- a/en/application-dev/reference/apis/js-apis-ability-context.md +++ b/en/application-dev/reference/apis/js-apis-ability-context.md @@ -1,19 +1,25 @@ # AbilityContext -> **NOTE**
+> **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. Implements the ability context. This module is inherited from **Context**. +## Modules to Import + +```js +import Ability from '@ohos.application.Ability' +``` ## Usage Before using the **AbilityContext** module, you must define a child class that inherits from **Ability**. - - ```js import Ability from '@ohos.application.Ability' class MainAbility extends Ability { @@ -28,10 +34,10 @@ class MainAbility extends Ability { **System capability**: SystemCapability.Ability.AbilityRuntime.Core -| Name | Type | Readable | Writable | Description | +| Name | Type | Readable | Writable | Description | | -------- | -------- | -------- | -------- | -------- | -| abilityInfo | AbilityInfo | Yes| No| Ability information.| -| currentHapModuleInfo | HapModuleInfo | Yes| No| Information about the current HAP.| +| abilityInfo | AbilityInfo | Yes| No| Ability information.| +| currentHapModuleInfo | HapModuleInfo | Yes| No| Information about the current HAP.| ## AbilityContext.startAbility @@ -44,10 +50,10 @@ Starts an ability. This API uses a callback to return the result. **Parameters** - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | want | [Want](js-apis-application-Want.md) | Yes| Information about the **Want** used for starting an ability.| - | callback | AsyncCallback<void> | Yes| Callback used to return the result.| +| Name | Type | Mandatory | Description | +| -------- | -------- | -------- | -------- | +| want | [Want](js-apis-application-Want.md) | Yes| Information about the **Want** used for starting an ability.| +| callback | AsyncCallback<void> | Yes| Callback used to return the result.| **Example** @@ -55,7 +61,7 @@ Starts an ability. This API uses a callback to return the result. var want = { "deviceId": "", "bundleName": "com.extreme.test", - "abilityName": "com.extreme.test.MainAbility" + "abilityName": "MainAbility" }; this.context.startAbility(want, (error) => { console.log("error.code = " + error.code) @@ -73,11 +79,11 @@ Starts an ability. This API uses a callback to return the result. **Parameters** - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | want | [Want](js-apis-application-Want.md) | Yes| Information about the **Want** used for starting an ability.| - | options | StartOptions | Yes| Parameters used for starting the ability.| - | callback | AsyncCallback<void> | Yes| Callback used to return the result.| +| Name | Type | Mandatory | Description | +| -------- | -------- | -------- | -------- | +| want | [Want](js-apis-application-Want.md) | Yes| Information about the **Want** used for starting an ability.| +| options | StartOptions | Yes| Parameters used for starting the ability.| +| callback | AsyncCallback<void> | Yes| Callback used to return the result.| **Example** @@ -85,7 +91,7 @@ Starts an ability. This API uses a callback to return the result. var want = { "deviceId": "", "bundleName": "com.extreme.test", - "abilityName": "com.extreme.test.MainAbility" + "abilityName": "MainAbility" }; var options = { windowMode: 0, @@ -106,16 +112,16 @@ Starts an ability. This API uses a promise to return the result. **Parameters** - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | want | [Want](js-apis-application-Want.md) | Yes| Information about the **Want** used for starting an ability.| - | options | StartOptions | No| Parameters used for starting the ability.| +| Name | Type | Mandatory | Description | +| -------- | -------- | -------- | -------- | +| want | [Want](js-apis-application-Want.md) | Yes| Information about the **Want** used for starting an ability.| +| options | StartOptions | No| Parameters used for starting the ability.| **Return value** - | Type | Description | - | -------- | -------- | - | Promise<void> | Promise used to return the result.| +| Type | Description | +| -------- | -------- | +| Promise<void> | Promise used to return the result.| **Example** @@ -123,7 +129,7 @@ Starts an ability. This API uses a promise to return the result. var want = { "deviceId": "", "bundleName": "com.extreme.test", - "abilityName": "com.extreme.test.MainAbility" + "abilityName": "MainAbility" }; var options = { windowMode: 0, @@ -147,10 +153,10 @@ Starts an ability. This API uses a callback to return the execution result when **Parameters** - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | want |[Want](js-apis-application-Want.md) | Yes| Information about the **Want** used for starting an ability.| - | callback | AsyncCallback<[AbilityResult](js-apis-featureAbility.md#abilityresult)> | Yes| Callback used to return the result.| +| Name | Type | Mandatory | Description | +| -------- | -------- | -------- | -------- | +| want |[Want](js-apis-application-Want.md) | Yes| Information about the **Want** used for starting an ability.| +| callback | AsyncCallback<[AbilityResult](js-apis-featureAbility.md#abilityresult)> | Yes| Callback used to return the result.| **Example** @@ -175,11 +181,11 @@ Starts an ability. This API uses a callback to return the execution result when **Parameters** - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | want |[Want](js-apis-application-Want.md) | Yes| Information about the **Want** used for starting an ability.| - | options | StartOptions | Yes| Parameters used for starting the ability.| - | callback | AsyncCallback<[AbilityResult](js-apis-featureAbility.md#abilityresult)> | Yes| Callback used to return the result.| +| Name | Type | Mandatory | Description | +| -------- | -------- | -------- | -------- | +| want |[Want](js-apis-application-Want.md) | Yes| Information about the **Want** used for starting an ability.| +| options | StartOptions | Yes| Parameters used for starting the ability.| +| callback | AsyncCallback<[AbilityResult](js-apis-featureAbility.md#abilityresult)> | Yes| Callback used to return the result.| **Example** @@ -208,17 +214,17 @@ Starts an ability. This API uses a promise to return the execution result when t **Parameters** - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | want | [Want](js-apis-application-Want.md) | Yes| Information about the **Want** used for starting an ability.| - | options | StartOptions | No| Parameters used for starting the ability.| +| Name | Type | Mandatory | Description | +| -------- | -------- | -------- | -------- | +| want | [Want](js-apis-application-Want.md) | Yes| Information about the **Want** used for starting an ability.| +| options | StartOptions | No| Parameters used for starting the ability.| **Return value** - | Type | Description | - | -------- | -------- | - | Promise<[AbilityResult](js-apis-featureAbility.md#abilityresult)> | Promise used to return the result.| +| Type | Description | +| -------- | -------- | +| Promise<[AbilityResult](js-apis-featureAbility.md#abilityresult)> | Promise used to return the result.| **Example** @@ -244,9 +250,9 @@ Terminates this ability. This API uses a callback to return the result. **Parameters** - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | callback | AsyncCallback<void> | Yes| Callback used to return the result indicating whether the API is successfully called.| +| Name | Type | Mandatory | Description | +| -------- | -------- | -------- | -------- | +| callback | AsyncCallback<void> | Yes| Callback used to return the result indicating whether the API is successfully called.| **Example** @@ -267,9 +273,9 @@ Terminates this ability. This API uses a promise to return the result. **Return value** - | Type | Description | - | -------- | -------- | - | Promise<void> | Promise used to return the result indicating whether the API is successfully called.| +| Type | Description | +| -------- | -------- | +| Promise<void> | Promise used to return the result indicating whether the API is successfully called.| **Example** @@ -292,10 +298,10 @@ Terminates this ability. This API uses a callback to return the information to t **Parameters** - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | parameter | [AbilityResult](js-apis-featureAbility.md#abilityresult) | Yes| Information returned to the caller.| - | callback | AsyncCallback<void> | Yes| Callback used to return the result.| +| Name | Type | Mandatory | Description | +| -------- | -------- | -------- | -------- | +| parameter | [AbilityResult](js-apis-featureAbility.md#abilityresult) | Yes| Information returned to the caller.| +| callback | AsyncCallback<void> | Yes| Callback used to return the result.| **Example** @@ -321,15 +327,15 @@ Terminates this ability. This API uses a promise to return information to the ca **Parameters** - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | parameter | [AbilityResult](js-apis-featureAbility.md#abilityresult) | Yes| Information returned to the caller.| +| Name | Type | Mandatory | Description | +| -------- | -------- | -------- | -------- | +| parameter | [AbilityResult](js-apis-featureAbility.md#abilityresult) | Yes| Information returned to the caller.| **Return value** - | Type | Description | - | -------- | -------- | - | Promise<void> | Promise used to return the result.| +| Type | Description | +| -------- | -------- | +| Promise<void> | Promise used to return the result.| **Example** @@ -355,18 +361,18 @@ Obtains the caller interface of the specified ability, and if the specified abil **Parameters** - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | want | [Want](js-apis-application-Want.md) | Yes| Information about the ability to start, including the ability name, bundle name, and device ID. If the device ID is left blank or the default value is used, the local ability will be started.| +| Name | Type | Mandatory | Description | +| -------- | -------- | -------- | -------- | +| want | [Want](js-apis-application-Want.md) | Yes| Information about the ability to start, including the ability name, bundle name, and device ID. If the device ID is left blank or the default value is used, the local ability will be started.| **Return value** - | Type | Description | - | -------- | -------- | - | Promise<Caller> | Promise used to return the caller object to communicate with.| +| Type | Description | +| -------- | -------- | +| Promise<Caller> | Promise used to return the caller object to communicate with.| **Example** - + ```js import Ability from '@ohos.application.Ability'; var caller; @@ -374,11 +380,11 @@ Obtains the caller interface of the specified ability, and if the specified abil onWindowStageCreate(windowStage) { this.context.startAbilityByCall({ bundleName: "com.example.myservice", - abilityName: "com.example.myservice.MainAbility", + abilityName: "MainAbility", deviceId: "" }).then((obj) => { caller = obj; - console.log('Caller GetCaller Get ' + call); + console.log('Caller GetCaller Get ' + caller); }).catch((e) => { console.log('Caller GetCaller error ' + e); }); @@ -397,17 +403,19 @@ Requests permissions from the user by displaying a pop-up window. This API uses **Parameters** - | 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 indicating whether the API is successfully called.| +| 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 indicating whether the API is successfully called.| -**Example** - - ``` - this.context.requestPermissionsFromUser(permissions,(result) => { - console.log('requestPermissionsFromUserresult:' + JSON.stringify(result)); +**Example** + + ```js + var permissions=['com.example.permission'] + this.context.requestPermissionsFromUser(permissions,(result) => { + console.log('requestPermissionsFromUserresult:' + JSON.stringify(result)); }); + ``` @@ -421,24 +429,26 @@ Requests permissions from the user by displaying a pop-up window. This API uses **Parameters** - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | permissions | Array<string> | Yes| Permissions to request.| +| Name | Type | Mandatory | Description | +| -------- | -------- | -------- | -------- | +| permissions | Array<string> | Yes| Permissions to request.| **Return value** - | Type | Description | - | -------- | -------- | - | Promise<[PermissionRequestResult](js-apis-permissionrequestresult.md)> | Promise used to return the result indicating whether the API is successfully called.| +| Type | Description | +| -------- | -------- | +| Promise<[PermissionRequestResult](js-apis-permissionrequestresult.md)> | Promise used to return the result indicating whether the API is successfully called.| -**Example** - - ``` - this.context.requestPermissionsFromUser(permissions).then((data) => { +**Example** + + ```js + var permissions=['com.example.permission'] + this.context.requestPermissionsFromUser(permissions).then((data) => { console.log('success:' + JSON.stringify(data)); }).catch((error) => { console.log('failed:' + JSON.stringify(error)); }); + ``` @@ -452,13 +462,13 @@ Sets the label of the ability displayed in the task. This API uses a callback to **Parameters** - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | label | string | Yes| Label of the ability to set.| - | callback | AsyncCallback<void> | Yes| Callback used to return the result indicating whether the API is successfully called.| +| Name | Type | Mandatory | Description | +| -------- | -------- | -------- | -------- | +| label | string | Yes| Label of the ability to set.| +| callback | AsyncCallback<void> | Yes| Callback used to return the result indicating whether the API is successfully called.| + +**Example** -**Example** - ```js this.context.setMissionLabel("test",(result) => { console.log('requestPermissionsFromUserresult:' + JSON.stringify(result)); @@ -476,18 +486,18 @@ Sets the label of the ability displayed in the task. This API uses a promise to **Parameters** - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | label | string | Yes| Label of the ability to set.| +| Name | Type | Mandatory | Description | +| -------- | -------- | -------- | -------- | +| label | string | Yes| Label of the ability to set.| **Return value** - | Type | Description | - | -------- | -------- | - | Promise<void> | Promise used to return the result indicating whether the API is successfully called.| +| Type | Description | +| -------- | -------- | +| Promise<void> | Promise used to return the result indicating whether the API is successfully called.| + +**Example** -**Example** - ```js this.context.setMissionLabel("test").then((data) => { console.log('success:' + JSON.stringify(data)); @@ -495,3 +505,4 @@ Sets the label of the ability displayed in the task. This API uses a promise to console.log('failed:' + JSON.stringify(error)); }); ``` + diff --git a/en/application-dev/reference/apis/js-apis-abilityAccessCtrl.md b/en/application-dev/reference/apis/js-apis-abilityAccessCtrl.md index 19a4ec0d9226f01e4a695bf5b9bb60369562a8ed..6d09f46222f1557b0348db066ebe62417cc8a92b 100644 --- a/en/application-dev/reference/apis/js-apis-abilityAccessCtrl.md +++ b/en/application-dev/reference/apis/js-apis-abilityAccessCtrl.md @@ -1,6 +1,7 @@ -# Ability Access Control +# AbilityAccessCtrl -> **NOTE**
+> **NOTE** +> > The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version. ## Modules to Import @@ -20,9 +21,9 @@ Creates an **AtManager** instance, which is used for ability access control. **Return value** - | Type | Description | - | -------- | -------- | - | [AtManager](#atmanager) | **AtManager** instance obtained. | +| Type | Description | +| -------- | -------- | +| [AtManager](#atmanager) | **AtManager** instance obtained. | **Example** @@ -44,16 +45,16 @@ Checks whether an application has been granted the specified permission. This AP **Parameters** - | Name | Type | Mandatory | Description | - | -------- | ------------------- | ---- | ------------------------------------------ | - | tokenID | number | Yes | ID of the application. | - | permissionName | string | Yes | Name of the permission to verify. | +| Name | Type | Mandatory | Description | +| -------- | ------------------- | ---- | ------------------------------------------ | +| tokenID | number | Yes | ID of the application. | +| permissionName | string | Yes | Name of the permission to verify. | **Return value** - | Type | Description | - | :------------ | :---------------------------------- | - | Promise<GrantStatus> | Promise used to return the result. | +| Type | Description | +| :------------ | :---------------------------------- | +| Promise<GrantStatus> | Promise used to return the result. | **Example** @@ -78,24 +79,25 @@ Grants a user granted permission to an application. This API uses a promise to r **Parameters** - | Name | Type | Mandatory | Description | - | --------- | ------------------- | ---- | ------------------------------------------------------------ | - | tokenID | number | Yes | ID of the application. | - | permissionName | string | Yes | Name of the permission to grant. | - | permissionFlag | number | Yes | Permission flag. The value **1** means that a dialog box will still be displayed after the user grants or denies the permission. The value **2** means that no dialog box will be displayed after the user grants or denies the permission. The value **3** means a system permission that cannot be changed. | +| Name | Type | Mandatory | Description | +| --------- | ------------------- | ---- | ------------------------------------------------------------ | +| tokenID | number | Yes | ID of the application. | +| permissionName | string | Yes | Name of the permission to grant. | +| permissionFlag | number | Yes | Permission flag. The value **1** means that a dialog box will still be displayed after the user grants or denies the permission. The value **2** means that no dialog box will be displayed after the user grants or denies the permission. The value **3** means a system permission that cannot be changed. | **Return value** - | Type | Description | - | :------------ | :---------------------------------- | - | Promise<number> | Promise used to return the result. | +| Type | Description | +| :------------ | :---------------------------------- | +| Promise<number> | Promise used to return the result. | **Example** ```js var AtManager = abilityAccessCtrl.createAtManager(); let tokenID = 0; -let promise = AtManager.grantUserGrantedPermission(tokenID, "ohos.permission.GRANT_SENSITIVE_PERMISSIONS"); +let permissionFlag = 1; +let promise = AtManager.grantUserGrantedPermission(tokenID, "ohos.permission.GRANT_SENSITIVE_PERMISSIONS",permissionFlag); promise.then(data => { console.log(`promise: data->${JSON.stringify(data)}`); }); @@ -115,12 +117,12 @@ Grants a user granted permission to an application. This API uses an asynchronou **Parameters** - | Name | Type | Mandatory | Description | - | --------- | ------------------- | ---- | ------------------------------------------------------------ | - | tokenID | number | Yes | ID of the application. | - | permissionName | string | Yes | Name of the permission to grant. | - | permissionFlag | number | Yes | Permission flag. The value **1** means that a dialog box will still be displayed after the user grants or denies the permission. The value **2** means that no dialog box will be displayed after the user grants or denies the permission. The value **3** means a system permission that cannot be changed. | - | callback | AsyncCallback<number> | Yes | Callback used to return the result. | +| Name | Type | Mandatory | Description | +| --------- | ------------------- | ---- | ------------------------------------------------------------ | +| tokenID | number | Yes | ID of the application. | +| permissionName | string | Yes | Name of the permission to grant. | +| permissionFlag | number | Yes | Permission flag. The value **1** means that a dialog box will still be displayed after the user grants or denies the permission. The value **2** means that no dialog box will be displayed after the user grants or denies the permission. The value **3** means a system permission that cannot be changed. | +| callback | AsyncCallback<number> | Yes | Callback used to return the result. | **Example** @@ -145,17 +147,17 @@ Revokes a user granted permission given to an application. This API uses a promi **Parameters** - | Name | Type | Mandatory | Description | - | --------- | ------------------- | ---- | ------------------------------------------------------------ | - | tokenID | number | Yes | ID of the application. | - | permissionName | string | Yes | Name of the permission to revoke. | - | permissionFlag | number | Yes | Permission flag. The value **1** means that a dialog box will still be displayed after the user grants or denies the permission. The value **2** means that no dialog box will be displayed after the user grants or denies the permission. The value **3** means a system permission that cannot be changed. | +| Name | Type | Mandatory | Description | +| --------- | ------------------- | ---- | ------------------------------------------------------------ | +| tokenID | number | Yes | ID of the application. | +| permissionName | string | Yes | Name of the permission to revoke. | +| permissionFlag | number | Yes | Permission flag. The value **1** means that a dialog box will still be displayed after the user grants or denies the permission. The value **2** means that no dialog box will be displayed after the user grants or denies the permission. The value **3** means a system permission that cannot be changed. | **Return value** - | Type | Description | - | :------------ | :---------------------------------- | - | Promise<number> | Promise used to return the result. | +| Type | Description | +| :------------ | :---------------------------------- | +| Promise<number> | Promise used to return the result. | **Example** @@ -181,18 +183,19 @@ Revokes a user granted permission given to an application. This API uses an asyn **Parameters** - | Name | Type | Mandatory | Description | - | --------- | ------------------- | ---- | ------------------------------------------------------------ | - | tokenID | number | Yes | ID of the application. | - | permissionName | string | Yes | Name of the permission to revoke. | - | permissionFlag | number | Yes | Permission flag. The value **1** means that a dialog box will still be displayed after the user grants or denies the permission. The value **2** means that no dialog box will be displayed after the user grants or denies the permission. The value **3** means a system permission that cannot be changed. | - | callback | AsyncCallback<number> | Yes | Callback used to return the result. | +| Name | Type | Mandatory | Description | +| --------- | ------------------- | ---- | ------------------------------------------------------------ | +| tokenID | number | Yes | ID of the application. | +| permissionName | string | Yes | Name of the permission to revoke. | +| permissionFlag | number | Yes | Permission flag. The value **1** means that a dialog box will still be displayed after the user grants or denies the permission. The value **2** means that no dialog box will be displayed after the user grants or denies the permission. The value **3** means a system permission that cannot be changed. | +| callback | AsyncCallback<number> | Yes | Callback used to return the result. | **Example** ```js var AtManager = abilityAccessCtrl.createAtManager(); let tokenID = 0; +let permissionFlag = 1; AtManager.revokeUserGrantedPermission(tokenID, "ohos.permission.GRANT_SENSITIVE_PERMISSIONS",permissionFlag, data => { console.log(`callback: data->${JSON.stringify(data)}`); }); @@ -210,16 +213,16 @@ Obtains the flags of the specified permission of a given application. This API u **Parameters** - | Name | Type | Mandatory | Description | - | --------- | ------------------- | ---- | ------------------------------------------------------------ | - | tokenID | number | Yes | ID of the application. | - | permissionName | string | Yes | Name of the permission to query. | +| Name | Type | Mandatory | Description | +| --------- | ------------------- | ---- | ------------------------------------------------------------ | +| tokenID | number | Yes | ID of the application. | +| permissionName | string | Yes | Name of the permission to query. | **Return value** - | Type | Description | - | :------------ | :---------------------------------- | - | Promise<number> | Promise used to return the result. | +| Type | Description | +| :------------ | :---------------------------------- | +| Promise<number> | Promise used to return the result. | **Example** @@ -238,7 +241,7 @@ Enumerates the permission grant states. **System capability**: SystemCapability.Security.AccessToken - | Name | Default Value | Description | - | ----------------------------- | ---------------------- | ----------------------- | - | PERMISSION_DENIED | -1 | Permission denied. | - | PERMISSION_GRANTED | 0 | Permission granted. | +| Name | Default Value | Description | +| ----------------------------- | ---------------------- | ----------------------- | +| PERMISSION_DENIED | -1 | Permission denied. | +| PERMISSION_GRANTED | 0 | Permission granted. | diff --git a/en/application-dev/reference/apis/js-apis-abilityrunninginfo.md b/en/application-dev/reference/apis/js-apis-abilityrunninginfo.md index b516987cb8fd30b49f1aa2152b1024feb3a81b15..eb10aeecbacb98d0c045800ba0922fbc09fdf6dd 100644 --- a/en/application-dev/reference/apis/js-apis-abilityrunninginfo.md +++ b/en/application-dev/reference/apis/js-apis-abilityrunninginfo.md @@ -1,18 +1,21 @@ # AbilityRunningInfo -> **NOTE**
+> **NOTE** +> > The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version. - Provides ability running information. - -## Usage +## Modules to Import -The ability running information is obtained by using the **getAbilityRunningInfos** API in **abilityManager**. +```js +import abilitymanager from '@ohos.application.abilityManager'; +``` +## Usage +The ability running information is obtained by using the **getAbilityRunningInfos** API in **abilityManager**. ```js import abilitymanager from '@ohos.application.abilityManager'; @@ -25,14 +28,14 @@ abilitymanager.getAbilityRunningInfos((err,data) => { **System capability**: SystemCapability.Ability.AbilityRuntime.Core - | Name | Type | Readable | Writable | Description | - | -------- | -------- | -------- | -------- | -------- | - | ability | ElementName | Yes | No | Information that matches an ability. | - | pid | number | Yes | No | Process ID. | - | uid | number | Yes | No | User ID. | - | processName | string | Yes | No | Process name. | - | startTime | number | Yes | No | Ability start time. | - | abilityState | [abilityManager.AbilityState](#abilitymanagerabilitystate) | Yes | No | Ability state. | +| Name | Type | Readable | Writable | Description | +| -------- | -------- | -------- | -------- | -------- | +| ability | ElementName | Yes | No | Information that matches an ability. | +| pid | number | Yes | No | Process ID. | +| uid | number | Yes | No | User ID. | +| processName | string | Yes | No | Process name. | +| startTime | number | Yes | No | Ability start time. | +| abilityState | [abilityManager.AbilityState](#abilitymanagerabilitystate) | Yes | No | Ability state. | ## abilityManager.AbilityState @@ -41,10 +44,10 @@ Enumerates the ability states. **System capability**: SystemCapability.Ability.AbilityRuntime.Core - | Name | Value | Description | - | -------- | -------- | -------- | - | INITIAL | 0 | The ability is in the initial state. | - | FOREGROUND | 9 | The ability is in the foreground state. | - | BACKGROUND | 10 | The ability is in the background state. | - | FOREGROUNDING | 11 | The ability is in the foregrounding state. | - | BACKGROUNDING | 12 | The ability is in the backgrounding state. | +| Name | Value | Description | +| -------- | -------- | -------- | +| INITIAL | 0 | The ability is in the initial state. | +| FOREGROUND | 9 | The ability is in the foreground state. | +| BACKGROUND | 10 | The ability is in the background state. | +| FOREGROUNDING | 11 | The ability is in the foregrounding state. | +| BACKGROUNDING | 12 | The ability is in the backgrounding state. | diff --git a/en/application-dev/reference/apis/js-apis-abilitystagecontext.md b/en/application-dev/reference/apis/js-apis-abilitystagecontext.md index b2d4b885de5f85efcda7f0f5d8f4b9031d027bbd..e3a7efd0dcbe8257a2eae6ddf30b4d4e0b35436e 100644 --- a/en/application-dev/reference/apis/js-apis-abilitystagecontext.md +++ b/en/application-dev/reference/apis/js-apis-abilitystagecontext.md @@ -1,11 +1,17 @@ # AbilityStageContext -> **NOTE**
+> **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. Implements the context of an ability stage. This module is inherited from [Context](js-apis-application-context.md). +## Modules to Import + +```js +import AbilityStage from '@ohos.application.AbilityStage'; +``` ## Usage @@ -13,7 +19,7 @@ Implements the context of an ability stage. This module is inherited from [Conte The ability stage context is obtained through an **AbilityStage** instance. - + ```js import AbilityStage from '@ohos.application.AbilityStage'; class MyAbilityStage extends AbilityStage { @@ -28,7 +34,7 @@ class MyAbilityStage extends AbilityStage { **System capability**: SystemCapability.Ability.AbilityRuntime.Core -| Name| Type | Readable | Writable | Description | +| Name| Type | Readable | Writable | Description | | -------- | -------- | -------- | -------- | -------- | -| currentHapModuleInfo | HapModuleInfo | Yes | No | **ModuleInfo** object corresponding to the **AbilityStage**. | -| config | [Configuration](js-apis-configuration.md) | Yes| No| Configuration for the environment where the application is running. | +| currentHapModuleInfo | HapModuleInfo | Yes | No | **ModuleInfo** object corresponding to the **AbilityStage**. | +| config | [Configuration](js-apis-configuration.md) | Yes| No| Configuration for the environment where the application is running. | diff --git a/en/application-dev/reference/apis/js-apis-application-MissionSnapshot.md b/en/application-dev/reference/apis/js-apis-application-MissionSnapshot.md index 864fc6a90893ac05bb92089cfbd9c4f8e4cc0514..1882e93e462df6ac24e2445af2d84ca8fc1d4662 100644 --- a/en/application-dev/reference/apis/js-apis-application-MissionSnapshot.md +++ b/en/application-dev/reference/apis/js-apis-application-MissionSnapshot.md @@ -1,7 +1,8 @@ # MissionSnapshot -> **NOTE**
+> **NOTE** +> > The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version. @@ -12,8 +13,9 @@ Provides the snapshot of a mission. ``` -import { ElementName } from '../bundle/elementName'; -import { image } from '../@ohos.multimedia.image'; +import missionManager from '@ohos.application.missionManager' +import ElementName from '@ohos.bundle'; +import image from '@ohos.multimedia.image'; ``` diff --git a/en/application-dev/reference/apis/js-apis-application-ability.md b/en/application-dev/reference/apis/js-apis-application-ability.md index bca94a28134524a76e3e2f77f9b832ab620a86af..cc21b752081b8dd32df0173c8e05b2a8df39b71c 100644 --- a/en/application-dev/reference/apis/js-apis-application-ability.md +++ b/en/application-dev/reference/apis/js-apis-application-ability.md @@ -1,7 +1,10 @@ # Ability -> **NOTE**
+> **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. Manages the ability lifecycle and context. @@ -9,7 +12,7 @@ Manages the ability lifecycle and context. ## Modules to Import - + ``` import Ability from '@ohos.application.Ability'; ``` @@ -18,11 +21,12 @@ import Ability from '@ohos.application.Ability'; **System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore - | Name | Type | Readable | Writable | Description | - | -------- | -------- | -------- | -------- | -------- | - | context | [AbilityContext](js-apis-ability-context.md) | Yes | No | Context of an ability. | - | launchWant | [Want](js-apis-application-Want.md) | Yes | No | Parameters for starting the ability. | - | lastRequestWant | [Want](js-apis-application-Want.md) | Yes | No | Parameters used when the ability was started last time. | +| Name | Type | Readable | Writable | Description | +| -------- | -------- | -------- | -------- | -------- | +| context | [AbilityContext](js-apis-ability-context.md) | Yes | No | Context of an ability. | +| launchWant | [Want](js-apis-application-Want.md) | Yes | No | Parameters for starting the ability. | +| lastRequestWant | [Want](js-apis-application-Want.md) | Yes | No | Parameters used when the ability was started last time. | +| callee | [Callee](#callee) | Yes | No | Object that invokes the stub service. | ## Ability.onCreate @@ -35,10 +39,10 @@ Called to initialize the service logic when an ability is created. **Parameters** - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | want | [Want](js-apis-application-Want.md) | Yes | Information related to this ability, including the ability name and bundle name. | - | param | AbilityConstant.LaunchParam | Yes | Parameters for starting the ability, and the reason for the last abnormal exit. | +| Name | Type | Mandatory | Description | +| -------- | -------- | -------- | -------- | +| want | [Want](js-apis-application-Want.md) | Yes | Information related to this ability, including the ability name and bundle name. | +| param | AbilityConstant.LaunchParam | Yes | Parameters for starting the ability, and the reason for the last abnormal exit. | **Example** @@ -61,9 +65,9 @@ Called when a **WindowStage** is created for this ability. **Parameters** - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | windowStage | window.WindowStage | Yes | **WindowStage** information. | +| Name | Type | Mandatory | Description | +| -------- | -------- | -------- | -------- | +| windowStage | window.WindowStage | Yes | **WindowStage** information. | **Example** @@ -105,9 +109,9 @@ Called when the **WindowStage** is restored during the migration of this ability **Parameters** - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | windowStage | window.WindowStage | Yes | **WindowStage** information. | +| Name | Type | Mandatory | Description | +| -------- | -------- | -------- | -------- | +| windowStage | window.WindowStage | Yes | **WindowStage** information. | **Example** @@ -187,24 +191,25 @@ Called to save data during the ability migration preparation process. **Parameters** - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | wantParam | {[key: string]: any} | Yes | **want** parameter. | +| Name | Type | Mandatory | Description | +| -------- | -------- | -------- | -------- | +| wantParam | {[key: string]: any} | Yes | **want** parameter. | **Return value** - | Type | Description | - | -------- | -------- | - | AbilityConstant.OnContinueResult | Continuation result. | +| Type | Description | +| -------- | -------- | +| AbilityConstant.OnContinueResult | Continuation result. | **Example** ```js + import AbilityConstant from "@ohos.application.AbilityConstant" class myAbility extends Ability { onContinue(wantParams) { console.log('onContinue'); wantParams["myData"] = "my1234567"; - return true; + return AbilityConstant.OnContinueResult.AGREE; } } ``` @@ -220,9 +225,9 @@ Called when the ability startup mode is set to singleton. **Parameters** - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | want | [Want](js-apis-application-Want.md) | Yes | Want parameters, such as the ability name and bundle name. | +| Name | Type | Mandatory | Description | +| -------- | -------- | -------- | -------- | +| want | [Want](js-apis-application-Want.md) | Yes | Want parameters, such as the ability name and bundle name. | **Example** @@ -245,12 +250,12 @@ Called when the configuration of the environment where the ability is running is **Parameters** - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | config | [Configuration](js-apis-configuration.md) | Yes | New configuration. | +| Name | Type | Mandatory | Description | +| -------- | -------- | -------- | -------- | +| config | [Configuration](js-apis-configuration.md) | Yes | New configuration. | + +**Example** -**Example** - ```js class myAbility extends Ability { onConfigurationUpdated(config) { @@ -259,6 +264,32 @@ Called when the configuration of the environment where the ability is running is } ``` +## Ability.dump + +dump(params: Array\): Array\; + + Called when the client information is dumped. + +**System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore + +**Parameters** + +| Name | Type | Mandatory | Description | +| -------- | -------- | -------- | -------- | +| params | Array\ | Yes | Parameters in the form of a command. | + +**Example** + + ```js + class myAbility extends Ability { + dump(params) { + console.log('dump, params:' + JSON.stringify(params)); + return ["params"] + } + } + ``` + + ## Caller @@ -275,22 +306,25 @@ Sends sequenceable data to the target ability. **Parameters** - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | method | string | Yes | Notification message string negotiated between the two abilities. The message is used to instruct the callee to register a function to receive the sequenceable data. | - | data | rpc.Sequenceable | Yes | Sequenceable data. You need to customize the data. | +| Name | Type | Mandatory | Description | +| -------- | -------- | -------- | -------- | +| method | string | Yes | Notification message string negotiated between the two abilities. The message is used to instruct the callee to register a function to receive the sequenceable data. | +| data | rpc.Sequenceable | Yes | Sequenceable data. You need to customize the data. | **Return value** - | Type | Description | - | -------- | -------- | - | Promise<void> | Promise used to return a response. | +| Type | Description | +| -------- | -------- | +| Promise<void> | Promise used to return a response. | **Example** ```js import Ability from '@ohos.application.Ability'; class MyMessageAble{ // Custom sequenceable data structure + name:"" + str:"" + num: 1 constructor(name, str) { this.name = name; this.str = str; @@ -314,7 +348,7 @@ Sends sequenceable data to the target ability. onWindowStageCreate(windowStage) { this.context.startAbilityByCall({ bundleName: "com.example.myservice", - abilityName: "com.example.myservice.MainAbility", + abilityName: "MainAbility", deviceId: "" }).then((obj) => { caller = obj; @@ -345,22 +379,25 @@ Sends sequenceable data to the target ability and obtains the sequenceable data **Parameters** - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | method | string | Yes | Notification message string negotiated between the two abilities. The message is used to instruct the callee to register a function to receive the sequenceable data. | - | data | rpc.Sequenceable | Yes | Sequenceable data. You need to customize the data. | +| Name | Type | Mandatory | Description | +| -------- | -------- | -------- | -------- | +| method | string | Yes | Notification message string negotiated between the two abilities. The message is used to instruct the callee to register a function to receive the sequenceable data. | +| data | rpc.Sequenceable | Yes | Sequenceable data. You need to customize the data. | **Return value** - | Type | Description | - | -------- | -------- | - | Promise<rpc.MessageParcel> | Promise used to return the sequenceable data from the target ability. | +| Type | Description | +| -------- | -------- | +| Promise<rpc.MessageParcel> | Promise used to return the sequenceable data from the target ability. | **Example** ```js import Ability from '@ohos.application.Ability'; class MyMessageAble{ + name:"" + str:"" + num: 1 constructor(name, str) { this.name = name; this.str = str; @@ -384,7 +421,7 @@ Sends sequenceable data to the target ability and obtains the sequenceable data onWindowStageCreate(windowStage) { this.context.startAbilityByCall({ bundleName: "com.example.myservice", - abilityName: "com.example.myservice.MainAbility", + abilityName: "MainAbility", deviceId: "" }).then((obj) => { caller = obj; @@ -423,7 +460,7 @@ Releases the caller interface of the target ability. onWindowStageCreate(windowStage) { this.context.startAbilityByCall({ bundleName: "com.example.myservice", - abilityName: "com.example.myservice.MainAbility", + abilityName: "MainAbility", deviceId: "" }).then((obj) => { caller = obj; @@ -451,9 +488,9 @@ Registers a callback that is invoked when the Stub on the target ability is disc **Parameters** - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | callback | OnReleaseCallBack | Yes | Callback used for the **onRelease** API. | +| Name | Type | Mandatory | Description | +| -------- | -------- | -------- | -------- | +| callback | OnReleaseCallBack | Yes | Callback used for the **onRelease** API. | **Example** @@ -464,7 +501,7 @@ Registers a callback that is invoked when the Stub on the target ability is disc onWindowStageCreate(windowStage) { this.context.startAbilityByCall({ bundleName: "com.example.myservice", - abilityName: "com.example.myservice.MainAbility", + abilityName: "MainAbility", deviceId: "" }).then((obj) => { caller = obj; @@ -499,16 +536,19 @@ Registers a caller notification callback, which is invoked when the target abili **Parameters** - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | method | string | Yes | Notification message string negotiated between the two abilities. | - | callback | CaleeCallBack | Yes | JS notification synchronization callback of the **rpc.MessageParcel** type. The callback must return at least one empty **rpc.Sequenceable** object. Otherwise, the function execution fails. | +| Name | Type | Mandatory | Description | +| -------- | -------- | -------- | -------- | +| method | string | Yes | Notification message string negotiated between the two abilities. | +| callback | CaleeCallBack | Yes | JS notification synchronization callback of the **rpc.MessageParcel** type. The callback must return at least one empty **rpc.Sequenceable** object. Otherwise, the function execution fails. | **Example** ```js import Ability from '@ohos.application.Ability'; class MyMessageAble{ + name:"" + str:"" + num: 1 constructor(name, str) { this.name = name; this.str = str; @@ -552,9 +592,9 @@ Unregisters a caller notification callback, which is invoked when the target abi **Parameters** - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | method | string | Yes | Registered notification message string. | +| Name | Type | Mandatory | Description | +| -------- | -------- | -------- | -------- | +| method | string | Yes | Registered notification message string. | **Example** @@ -575,10 +615,10 @@ Unregisters a caller notification callback, which is invoked when the target abi **System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore - | Name | Type | Readable | Writable | Description | - | -------- | -------- | -------- | -------- | -------- | - | (msg: string) | function | Yes | No | Prototype of the listener function interface registered by the caller. | - +| Name | Type | Readable | Writable | Description | +| -------- | -------- | -------- | -------- | -------- | +| (msg: string) | function | Yes | No | Prototype of the listener function interface registered by the caller. | + ## CaleeCallBack @@ -586,6 +626,6 @@ Unregisters a caller notification callback, which is invoked when the target abi **System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore - | Name | Type | Readable | Writable | Description | - | -------- | -------- | -------- | -------- | -------- | - | (indata: rpc.MessageParcel) | rpc.Sequenceable | Yes | No | Prototype of the message listener function interface registered by the callee. | +| Name | Type | Readable | Writable | Description | +| -------- | -------- | -------- | -------- | -------- | +| (indata: rpc.MessageParcel) | rpc.Sequenceable | Yes | No | Prototype of the message listener function interface registered by the callee. | diff --git a/en/application-dev/reference/apis/js-apis-application-abilityDelegator.md b/en/application-dev/reference/apis/js-apis-application-abilityDelegator.md index 9e0d3e602e74c621b139bdc45857f2ce3d395490..2fcc67558f9430412f7ad6b0c03f2ae997ff9a14 100644 --- a/en/application-dev/reference/apis/js-apis-application-abilityDelegator.md +++ b/en/application-dev/reference/apis/js-apis-application-abilityDelegator.md @@ -1,6 +1,6 @@ # AbilityDelegator -> **NOTE**
+> **NOTE** > > The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version. @@ -747,7 +747,7 @@ abilityDelegator.executeShellCommand(cmd, timeout, (err : any, data : any) => { ### executeShellCommand -executeShellCommand(cmd: string, timeoutSecs: number): Promise\ +executeShellCommand(cmd: string, timeoutSecs?: number): Promise\ Executes a shell command with the timeout period specified. This API uses a promise to return the result. diff --git a/en/application-dev/reference/apis/js-apis-application-context.md b/en/application-dev/reference/apis/js-apis-application-context.md index 1955bc22b4ae2cb4ec80c1c7e51e7aa616f47a26..b073c2b41c7bf5d23e1309b6bfd455d40f74b7da 100644 --- a/en/application-dev/reference/apis/js-apis-application-context.md +++ b/en/application-dev/reference/apis/js-apis-application-context.md @@ -1,11 +1,17 @@ # Context -> **NOTE**
+> **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. Provides the context for running code, including **applicationInfo** and **resourceManager**. +## Modules to Import + +``` +import AbilityContext from '@ohos.application.Ability'; +``` ## Usage @@ -17,18 +23,19 @@ You must extend **AbilityContext** to implement this module. **System capability**: SystemCapability.Ability.AbilityRuntime.Core - | Name | Type | Readable | Writable | Description | - | -------- | -------- | -------- | -------- | -------- | - | resourceManager | ResourceManager | Yes | No | **ResourceManager** object. | - | applicationInfo | ApplicationInfo | Yes | No | Information about the application. | - | cacheDir | string | Yes | No | Cache directory of the application on the internal storage. | - | tempDir | string | Yes | No | Temporary file directory of the application. | - | filesDir | string | Yes | No | File directory of the application on the internal storage. | - | databaseDir | string | Yes | No | Storage directory of local data. | - | storageDir | string | Yes | No | Storage directory of lightweight data. | - | bundleCodeDir | string | Yes | No | Application installation path. | - | distributedFilesDir | string | Yes | No | Storage directory of distributed application data files. | - | eventHub | [EventHub](js-apis-eventhub.md) | Yes | No | Event hub information. | +| Name | Type | Readable | Writable | Description | +| -------- | -------- | -------- | -------- | -------- | +| resourceManager | ResourceManager | Yes | No | **ResourceManager** object. | +| applicationInfo | ApplicationInfo | Yes | No | Information about the application. | +| cacheDir | string | Yes | No | Cache directory of the application on the internal storage. | +| tempDir | string | Yes | No | Temporary file directory of the application. | +| filesDir | string | Yes | No | File directory of the application on the internal storage. | +| databaseDir | string | Yes | No | Storage directory of local data. | +| storageDir | string | Yes | No | Storage directory of lightweight data. | +| bundleCodeDir | string | Yes | No | Application installation path. | +| distributedFilesDir | string | Yes | No | Storage directory of distributed application data files. | +| eventHub | [EventHub](js-apis-eventhub.md) | Yes | No | Event hub information. | +| area | [AreaMode](#areamode) | Yes | Yes | Area in which the file to be access is located. | ## Context.createBundleContext @@ -41,27 +48,33 @@ Creates an application context. **Parameters** - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | bundleName | string | Yes | Application bundle name. | +| Name | Type | Mandatory | Description | +| -------- | -------- | -------- | -------- | +| bundleName | string | Yes | Application bundle name. | **Return value** - | Type | Description | - | -------- | -------- | - | Context | Context of the application created. | +| Type | Description | +| -------- | -------- | +| Context | Context of the application created. | **Example** ```js - let test = "com.example.test"; - let context = this.context.createBundleContext(test); + import AbilityContext from '@ohos.application.Ability' + class MainAbility extends AbilityContext { + onWindowStageCreate(windowStage) { + let test = "com.example.test"; + let context = this.context.createBundleContext(test); + } +} + ``` ## Context.getApplicationContext -getApplicationContext(): Context; +getApplicationContext(): ApplicationContext; Obtains the context of this application. @@ -69,13 +82,25 @@ Obtains the context of this application. **Return value** - | Type | Description | - | -------- | -------- | - | Context | Context obtained. | +| Type | Description | +| -------- | -------- | +| ApplicationContext | Application context obtained. | **Example** ```js // This part is mandatory. - let context = this.context.getApplicationContext(); + let applicationContext = this.context.getApplicationContext(); ``` + + +## AreaMode + + Defines the area where the file to be access is located. Each area has its own content. + +**System capability**: SystemCapability.Ability.AbilityRuntime.Core + +| Name | Value | Description | +| --------------- | ---- | --------------- | +| EL1 | 0 | Device-level encryption area. | +| EL2 | 1 | User credential encryption area. The default value is **EL2**. | diff --git a/en/application-dev/reference/apis/js-apis-application-shellCmdResult.md b/en/application-dev/reference/apis/js-apis-application-shellCmdResult.md index 6a956dad3ed19cbaa506302cb19227a441af5d0c..751ab23b122c6e039326349221cacdbd98208325 100644 --- a/en/application-dev/reference/apis/js-apis-application-shellCmdResult.md +++ b/en/application-dev/reference/apis/js-apis-application-shellCmdResult.md @@ -10,8 +10,6 @@ import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry' ``` - - ## ShellCmdResult Describes the shell command execution result. diff --git a/en/application-dev/reference/apis/js-apis-appmanager.md b/en/application-dev/reference/apis/js-apis-appmanager.md index 70becd563ec1143c93110fc9381eed8f903a82c8..a459f2d6ead9422bdf9e5172a202bda52c89d20e 100644 --- a/en/application-dev/reference/apis/js-apis-appmanager.md +++ b/en/application-dev/reference/apis/js-apis-appmanager.md @@ -1,6 +1,7 @@ # appManager -> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** +> **NOTE** +> > The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version. @@ -25,16 +26,16 @@ Checks whether this application is undergoing a stability test. This API uses an **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | callback | AsyncCallback<boolean> | No| Callback used to return the result. If the application is undergoing a stability test, **true** will be returned; otherwise, **false** will be returned.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| callback | AsyncCallback<boolean> | No| Callback used to return the result. If the application is undergoing a stability test, **true** will be returned; otherwise, **false** will be returned.| **Example** ```js import app from '@ohos.application.appManager'; app.isRunningInStabilityTest((err, flag) => { - console.log('startAbility result:' + JSON.stringfy(err)); + console.log('startAbility result:' + JSON.stringify(err)); }) ``` @@ -49,18 +50,18 @@ Checks whether this application is undergoing a stability test. This API uses a **Return value** - | Type| Description| - | -------- | -------- | - | Promise<boolean> | Promise used to return the result. If the application is undergoing a stability test, **true** will be returned; otherwise, **false** will be returned.| +| Type| Description| +| -------- | -------- | +| Promise<boolean> | Promise used to return the result. If the application is undergoing a stability test, **true** will be returned; otherwise, **false** will be returned.| **Example** ```js import app from '@ohos.application.appManager'; app.isRunningInStabilityTest().then((flag) => { - console.log('success:' + JSON.stringfy(flag)); + console.log('success:' + JSON.stringify(flag)); }).catch((error) => { - console.log('failed:' + JSON.stringfy(error)); + console.log('failed:' + JSON.stringify(error)); }); ``` @@ -75,14 +76,14 @@ Checks whether this application is running on a RAM constrained device. This API **Return value** - | Type| Description| - | -------- | -------- | - | Promise<boolean> | Promise used to return whether the application is running on a RAM constrained device. If the application is running on a RAM constrained device, **true** will be returned; otherwise, **false** will be returned.| +| Type| Description| +| -------- | -------- | +| Promise<boolean> | Promise used to return whether the application is running on a RAM constrained device. If the application is running on a RAM constrained device, **true** will be returned; otherwise, **false** will be returned.| **Example** ```js - app.isRamConstrainedDevicePromise().then((data) => { + app.isRamConstrainedDevice().then((data) => { console.log('success:' + JSON.stringify(data)); }).catch((error) => { console.log('failed:' + JSON.stringify(error)); @@ -99,14 +100,14 @@ Checks whether this application is running on a RAM constrained device. This API **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | callback | AsyncCallback<boolean> | No| Callback used to return whether the application is running on a RAM constrained device. If the application is running on a RAM constrained device, **true** will be returned; otherwise, **false** will be returned.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| callback | AsyncCallback<boolean> | No| Callback used to return whether the application is running on a RAM constrained device. If the application is running on a RAM constrained device, **true** will be returned; otherwise, **false** will be returned.| **Example** ```js - app.isRamConstrainedDevicePromise((err, data) => { + app.isRamConstrainedDevice((err, data) => { console.log('startAbility result failed:' + JSON.stringify(err)); console.log('startAbility result success:' + JSON.stringify(data)); }) @@ -122,9 +123,9 @@ Obtains the memory size of this application. This API uses a promise to return t **Return value** - | Type| Description| - | -------- | -------- | - | Promise<number> | Size of the application memory.| +| Type| Description| +| -------- | -------- | +| Promise<number> | Size of the application memory.| **Example** @@ -146,9 +147,9 @@ Obtains the memory size of this application. This API uses an asynchronous callb **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | callback | AsyncCallback<number> | No| Size of the application memory.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| callback | AsyncCallback<number> | No| Size of the application memory.| **Example** @@ -160,7 +161,7 @@ Obtains the memory size of this application. This API uses an asynchronous callb ``` ## appManager.getProcessRunningInfos8+ -getProcessRunningInfos(): Promise>; +getProcessRunningInfos(): Promise>; Obtains information about the running processes. This API uses a promise to return the result. @@ -168,14 +169,14 @@ Obtains information about the running processes. This API uses a promise to retu **Return value** - | Type| Description| - | -------- | -------- | - | Promise> | Promise used to return the process information.| +| Type| Description| +| -------- | -------- | +| Promise> | Promise used to return the process information.| **Example** ```js - app.GetProcessRunningInfos().then((data) => { + app.getProcessRunningInfos().then((data) => { console.log('success:' + JSON.stringify(data)); }).catch((error) => { console.log('failed:' + JSON.stringify(error)); @@ -184,7 +185,7 @@ Obtains information about the running processes. This API uses a promise to retu ## appManager.getProcessRunningInfos8+ -getProcessRunningInfos(callback: AsyncCallback>): void; +getProcessRunningInfos(callback: AsyncCallback>): void; Obtains information about the running processes. This API uses an asynchronous callback to return the result. @@ -192,14 +193,14 @@ Obtains information about the running processes. This API uses an asynchronous c **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | callback | AsyncCallback> | No| Callback used to return the process information.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| callback | AsyncCallback> | No| Callback used to return the process information.| **Example** ```js - app.GetProcessRunningInfos((err, data) => { + app.getProcessRunningInfos((err, data) => { console.log('startAbility result failed :' + JSON.stringify(err)); console.log('startAbility result success:' + JSON.stringify(data)); }) diff --git a/en/application-dev/reference/apis/js-apis-dataAbilityHelper.md b/en/application-dev/reference/apis/js-apis-dataAbilityHelper.md index 10d36843925949c185a431ddb60dd33c1493d7b8..e158249758e680683ece547a5f7758876edeebb5 100644 --- a/en/application-dev/reference/apis/js-apis-dataAbilityHelper.md +++ b/en/application-dev/reference/apis/js-apis-dataAbilityHelper.md @@ -1,16 +1,18 @@ -# DataAbilityHelper Module (JavaScript SDK APIs) +# DataAbilityHelper -> ![icon-note.gif](public_sys-resources/icon-note.gif)**NOTE** +> **NOTE** +> > The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version. +> +> The APIs of this module can be used only in the stage model. ## Modules to Import -``` +```js import featureAbility from '@ohos.ability.featureAbility' -import ohos_data_ability from '@ohos.data.dataability' +import ohos_data_ability from '@ohos.data.dataAbility' import ohos_data_rdb from '@ohos.data.rdb' ``` - ## DataAbilityHelper.openFile openFile(uri: string, mode: string, callback: AsyncCallback\): void @@ -21,11 +23,11 @@ Opens a file with a specified URI. This API uses an asynchronous callback to ret **Parameters** -| Name | Type | Mandatory| Description | -| -------- | ---------------------- | ---- | ---------------------------------- | -| uri | string | Yes | URI of the file to open. | -| mode | string | Yes | Mode for opening the file. The value can be **rwt**. | -| callback | AsyncCallback\ | Yes | Callback used to return the file descriptor.| +| Name | Type | Mandatory | Description | +| -------- | ---------------------- | --------- | ---------------------------------------------------- | +| uri | string | Yes | URI of the file to open. | +| mode | string | Yes | Mode for opening the file. The value can be **rwt**. | +| callback | AsyncCallback\ | Yes | Callback used to return the file descriptor. | **Example** @@ -499,7 +501,7 @@ const valueBucket = { "name": "rose", "age": 22, "salary": 200.5, - "blobType": u8, + "blobType": "u8", } DAHelper.insert( "dataability:///com.example.DataAbility", @@ -541,7 +543,7 @@ const valueBucket = { "name": "rose1", "age": 221, "salary": 20.5, - "blobType": u8, + "blobType": "u8", } DAHelper.insert( "dataability:///com.example.DataAbility", @@ -574,9 +576,9 @@ import featureAbility from '@ohos.ability.featureAbility' var DAHelper = featureAbility.acquireDataAbilityHelper( "dataability:///com.example.DataAbility" ); -var cars = new Array({"name": "roe11", "age": 21, "salary": 20.5, "blobType": u8,}, - {"name": "roe12", "age": 21, "salary": 20.5, "blobType": u8,}, - {"name": "roe13", "age": 21, "salary": 20.5, "blobType": u8,}) +var cars = new Array({"name": "roe11", "age": 21, "salary": 20.5, "blobType": "u8",}, + {"name": "roe12", "age": 21, "salary": 20.5, "blobType": "u8",}, + {"name": "roe13", "age": 21, "salary": 20.5, "blobType": "u8",}) DAHelper.batchInsert( "dataability:///com.example.DataAbility", cars, @@ -613,9 +615,9 @@ import featureAbility from '@ohos.ability.featureAbility' var DAHelper = featureAbility.acquireDataAbilityHelper( "dataability:///com.example.DataAbility" ); -var cars = new Array({"name": "roe11", "age": 21, "salary": 20.5, "blobType": u8,}, - {"name": "roe12", "age": 21, "salary": 20.5, "blobType": u8,}, - {"name": "roe13", "age": 21, "salary": 20.5, "blobType": u8,}) +var cars = new Array({"name": "roe11", "age": 21, "salary": 20.5, "blobType": "u8",}, + {"name": "roe12", "age": 21, "salary": 20.5, "blobType": "u8",}, + {"name": "roe13", "age": 21, "salary": 20.5, "blobType": "u8",}) DAHelper.batchInsert( "dataability:///com.example.DataAbility", cars @@ -682,6 +684,7 @@ Deletes one or more data records from the database. This API uses a promise to r ```js import featureAbility from '@ohos.ability.featureAbility' +import ohos_data_ability from '@ohos.data.dataability' var DAHelper = featureAbility.acquireDataAbilityHelper( "dataability:///com.example.DataAbility" ); @@ -723,7 +726,7 @@ const va = { "name": "roe1", "age": 21, "salary": 20.5, - "blobType": u8, + "blobType": "u8", } let da = new ohos_data_ability.DataAbilityPredicates() DAHelper.update( @@ -769,7 +772,7 @@ const va = { "name": "roe1", "age": 21, "salary": 20.5, - "blobType": u8, + "blobType": "u8", } let da = new ohos_data_ability.DataAbilityPredicates() DAHelper.update( diff --git a/en/application-dev/reference/apis/js-apis-eventhub.md b/en/application-dev/reference/apis/js-apis-eventhub.md index b7afbb435c747c4b411aeaa72fb1806c47b39f60..b6dabe5f6dd613e55858cc20f49d68fecfc9fe6f 100644 --- a/en/application-dev/reference/apis/js-apis-eventhub.md +++ b/en/application-dev/reference/apis/js-apis-eventhub.md @@ -1,22 +1,31 @@ # EventHub -> **NOTE**
+> **NOTE** +> > The initial APIs of this module are supported since API 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. Implements event subscription, unsubscription, and triggering. +## Modules to Import + +```js +import Ability from '@ohos.application.Ability' +``` ## Usage Before using any APIs in the **EventHub**, you must obtain an **EventHub** instance through the member variable **context** of the **Ability** instance. - - ```js import Ability from '@ohos.application.Ability' export default class MainAbility extends Ability { + func1(){ + console.log("func1 is called"); + } onForeground() { this.context.eventHub.on("123", this.func1); } @@ -34,10 +43,10 @@ Subscribes to an event. **Parameters** - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | event | string | Yes | Event name. | - | callback | Function | Yes | Callback invoked when the event is triggered. | +| Name | Type | Mandatory | Description | +| -------- | -------- | -------- | -------- | +| event | string | Yes | Event name. | +| callback | Function | Yes | Callback invoked when the event is triggered. | **Example** @@ -72,10 +81,10 @@ Unsubscribes from an event. If **callback** is specified, this API unsubscribes **Parameters** - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | event | string | Yes | Event name. | - | callback | Function | No | Callback for the event. If **callback** is unspecified, all callbacks of the event are unsubscribed. | +| Name | Type | Mandatory | Description | +| -------- | -------- | -------- | -------- | +| event | string | Yes | Event name. | +| callback | Function | No | Callback for the event. If **callback** is unspecified, all callbacks of the event are unsubscribed. | **Example** @@ -110,10 +119,10 @@ Triggers an event. **Parameters** - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | event | string | Yes | Event name. | - | ...args | Object[] | Yes | Variable parameters, which are passed to the callback when the event is triggered. | +| Name | Type | Mandatory | Description | +| -------- | -------- | -------- | -------- | +| event | string | Yes | Event name. | +| ...args | Object[] | Yes | Variable parameters, which are passed to the callback when the event is triggered. | **Example** diff --git a/en/application-dev/reference/apis/js-apis-extension-context.md b/en/application-dev/reference/apis/js-apis-extension-context.md index 0c73786fda860a84008d7736aa42959daca67934..a43b67cf48ea2ea4f6217a99bf8a5d25af98ea2e 100644 --- a/en/application-dev/reference/apis/js-apis-extension-context.md +++ b/en/application-dev/reference/apis/js-apis-extension-context.md @@ -1,17 +1,25 @@ # ExtensionContext -> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**
+> **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. Implements the extension context. This module is inherited from **Context**. +## Modules to Import + +```js +import DataShareExtensionAbility from '@ohos.application.DataShareExtensionAbility'; +``` ## Attributes **System capability**: SystemCapability.Ability.AbilityRuntime.Core -| Name | Type | Readable | Writable | Description | +| Name | Type | Readable | Writable | Description | | -------- | -------- | -------- | -------- | -------- | -| currentHapModuleInfo | HapModuleInfo | Yes| No | Information about the current HAP. | +| currentHapModuleInfo | HapModuleInfo | Yes| No | Information about the current HAP. | | config | Configuration | Yes| No | Module configuration information. | diff --git a/en/application-dev/reference/apis/js-apis-extensionrunninginfo.md b/en/application-dev/reference/apis/js-apis-extensionrunninginfo.md index fc1542d64377ca689f9a94314a5b488471679f17..68c0c2b7bf914439fcedf77a0b4193909b092bc5 100644 --- a/en/application-dev/reference/apis/js-apis-extensionrunninginfo.md +++ b/en/application-dev/reference/apis/js-apis-extensionrunninginfo.md @@ -1,21 +1,26 @@ # ExtensionRunningInfo -> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**
+> **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. Provides extension running information. +## Modules to Import + +```js +import abilitymanager from '@ohos.application.abilityManager'; +``` ## Usage The extension running information is obtained through an **abilityManager** instance. - - -``` +```js import abilitymanager from '@ohos.application.abilityManager'; +let upperLimit=1 abilitymanager.getExtensionRunningInfos(upperLimit, (err,data) => { console.log("getExtensionRunningInfos err: " + err + " data: " + JSON.stringify(data)); }); @@ -43,15 +48,15 @@ Enumerates extension types. **System capability**: SystemCapability.BundleManager.BundleFramework - | Name| Value| Description| +| Name| Value| Description| | -------- | -------- | -------- | -| FORM | 0 | Extension information of the form type.< | -| WORK_SCHEDULER | 1 | Extension information of the work scheduler type.< | -| INPUT_METHOD | 2 | Extension information of the input method type.< | -| SERVICE | 3 | Extension information of the service type.< | -| ACCESSIBILITY | 4 | Extension information of the accessibility type.< | -| DATA_SHARE | 5 | Extension information of the data share type.< | -| FILE_SHARE | 6 | Extension information of the file share type.< | -| STATIC_SUBSCRIBER | 7 | Extension information of the static subscriber type.< | -| WALLPAPER | 8 | Extension information of the wallpaper type.< | -| UNSPECIFIED | 9 | Extension information of the unspecified type.< | +| FORM | 0 | Extension information of the form type.< | +| WORK_SCHEDULER | 1 | Extension information of the work scheduler type.< | +| INPUT_METHOD | 2 | Extension information of the input method type.< | +| SERVICE | 3 | Extension information of the service type.< | +| ACCESSIBILITY | 4 | Extension information of the accessibility type.< | +| DATA_SHARE | 5 | Extension information of the data share type.< | +| FILE_SHARE | 6 | Extension information of the file share type.< | +| STATIC_SUBSCRIBER | 7 | Extension information of the static subscriber type.< | +| WALLPAPER | 8 | Extension information of the wallpaper type.< | +| UNSPECIFIED | 9 | Extension information of the unspecified type.< | diff --git a/en/application-dev/reference/apis/js-apis-featureAbility.md b/en/application-dev/reference/apis/js-apis-featureAbility.md index b57f529219338640cc0494bd24611063bcc4661d..f4751909bed50248a55fe0145eeb1d3f0d384816 100644 --- a/en/application-dev/reference/apis/js-apis-featureAbility.md +++ b/en/application-dev/reference/apis/js-apis-featureAbility.md @@ -1,9 +1,12 @@ -# FeatureAbility Module (JavaScript) +# FeatureAbility -> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**
+> **NOTE** +> > The initial APIs of this module are supported since API version 6. Newly added APIs will be marked with a superscript to indicate their earliest API version. +> +> The APIs of this module can be used only in the FA model. -## Constraints +## Usage APIs of the **FeatureAbility** module can be called only by Page abilities. @@ -139,7 +142,7 @@ Starts an ability. This API uses a callback to return the execution result when **Example** ```javascript -import featureAbility from '@ohos.ability.featureability'; +import featureAbility from '@ohos.ability.featureAbility'; import wantConstant from '@ohos.ability.wantConstant' featureAbility.startAbilityForResult( { @@ -157,7 +160,7 @@ featureAbility.startAbilityForResult( }, }, (err, data) => { - console.info("err: " + JSON.stringfy(err) + "data: " + JSON.stringfy(data)) + console.info("err: " + JSON.stringify(err) + "data: " + JSON.stringify(data)) } ) ``` @@ -185,7 +188,7 @@ Starts an ability. This API uses a promise to return the execution result when t **Example** ```javascript -import featureAbility from '@ohos.ability.featureability'; +import featureAbility from '@ohos.ability.featureAbility'; import wantConstant from '@ohos.ability.wantConstant' featureAbility.startAbilityForResult( { @@ -291,7 +294,7 @@ Destroys this Page ability, with the result code and data sent to the caller. Th **Example** ```javascript -import featureAbility from '@ohos.ability.featureability'; +import featureAbility from '@ohos.ability.featureAbility'; import wantConstant from '@ohos.ability.wantConstant' featureAbility.terminateSelfWithResult( { @@ -343,7 +346,7 @@ Checks whether the main window of this ability has the focus. This API uses a ca **Example** ```javascript -import featureAbility from '@ohos.ability.featureability'; +import featureAbility from '@ohos.ability.featureAbility'; featureAbility.hasWindowFocus() ``` @@ -391,7 +394,7 @@ Obtains the **Want** object sent from this ability. This API uses a callback to **Example** ```javascript -import featureAbility from '@ohos.ability.featureability'; +import featureAbility from '@ohos.ability.featureAbility'; featureAbility.getWant() ``` @@ -414,7 +417,7 @@ Obtains the **Want** object sent from this ability. This API uses a promise to r **Example** ```javascript -import featureAbility from '@ohos.ability.featureability'; +import featureAbility from '@ohos.ability.featureAbility'; featureAbility.getWant().then((data) => { console.info("==========================>getWantCallBack=======================>"); }); @@ -437,7 +440,7 @@ Obtains the application context. **Example** ```javascript -import featureAbility from '@ohos.ability.featureability'; +import featureAbility from '@ohos.ability.featureAbility'; var context = featureAbility.getContext() context.getBundleName() ``` @@ -461,7 +464,7 @@ Destroys this Page ability, with the result code and data sent to the caller. Th **Example** ```javascript -import featureAbility from '@ohos.ability.featureability'; +import featureAbility from '@ohos.ability.featureAbility'; featureAbility.terminateSelf() ``` @@ -484,7 +487,7 @@ Destroys this Page ability, with the result code and data sent to the caller. Th **Example** ```javascript -import featureAbility from '@ohos.ability.featureability'; +import featureAbility from '@ohos.ability.featureAbility'; featureAbility.terminateSelf().then((data) => { console.info("==========================>terminateSelfCallBack=======================>"); }); diff --git a/en/application-dev/reference/apis/js-apis-formbindingdata.md b/en/application-dev/reference/apis/js-apis-formbindingdata.md index 5f92677ec4a9856d96bc78b8787059ad5fb180ac..2405a07b35e0ed01933bbe74dea8a29a9879011c 100644 --- a/en/application-dev/reference/apis/js-apis-formbindingdata.md +++ b/en/application-dev/reference/apis/js-apis-formbindingdata.md @@ -1,6 +1,7 @@ # FormBindingData -> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** +> **NOTE** +> > The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version. ## Modules to Import @@ -38,12 +39,20 @@ Creates a **FormBindingData** object. **Example** ```js - let fd = fileio.openSync(path); - let obj = { - "temperature": "21°", - "formImages": {"image": fd} - }; - let formBindingDataObj = formBindingData.createFormBindingData(obj); + import featureAbility from '@ohos.ability.featureAbility'; + import fileio from '@ohos.fileio'; + let context=featureAbility.getContext(); + context.getOrCreateLocalDir((err,data)=>{ + let path=data+"/xxx.jpg"; + let fd = fileio.openSync(path); + let obj = { + "temperature": "21°", + "formImages": {"image": fd} + }; + let formBindingDataObj = formBindingData.createFormBindingData(obj); + }) + + ``` ## Attributes diff --git a/en/application-dev/reference/apis/js-apis-formextension.md b/en/application-dev/reference/apis/js-apis-formextension.md index dea964de0b45fdeca88defea6cb06cd70d8eb43a..556cd0899d47436654c6778b379ec931682781c4 100644 --- a/en/application-dev/reference/apis/js-apis-formextension.md +++ b/en/application-dev/reference/apis/js-apis-formextension.md @@ -1,7 +1,10 @@ # FormExtension -> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**
+> **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. Provides **FormExtension** APIs. @@ -33,19 +36,20 @@ Called to notify the widget provider that a **Form** instance (widget) has been **Parameters** - | Name| Type | Mandatory| Description | - | ------ | -------------------------------------- | ---- | ------------------------------------------------------------ | - | want | [Want](js-apis-application-Want.md) | Yes | Information related to the extension, including the widget ID, name, and style. The information must be managed as persistent data to facilitate subsequent widget update and deletion.| +| Name| Type | Mandatory| Description | +| ------ | -------------------------------------- | ---- | ------------------------------------------------------------ | +| want | [Want](js-apis-application-Want.md) | Yes | Information related to the extension, including the widget ID, name, and style. The information must be managed as persistent data to facilitate subsequent widget update and deletion.| **Return value** - | Type | Description | - | ------------------------------------------------------------ | ----------------------------------------------------------- | - | [formBindingData.FormBindingData](js-apis-formbindingdata.md#formbindingdata) | A **formBindingData.FormBindingData** object containing the data to be displayed on the widget.| +| Type | Description | +| ------------------------------------------------------------ | ----------------------------------------------------------- | +| [formBindingData.FormBindingData](js-apis-formbindingdata.md#formbindingdata) | A **formBindingData.FormBindingData** object containing the data to be displayed on the widget.| **Example** ```js + import formBindingData from '@ohos.application.formBindingData' export default class MyFormExtension extends FormExtension { onCreate(want) { console.log('FormExtension onCreate, want:' + want.abilityName); @@ -69,9 +73,9 @@ Called to notify the widget provider that a temporary widget has been converted **Parameters** - | Name| Type | Mandatory| Description | - | ------ | ------ | ---- | ------------------------ | - | formId | string | Yes | ID of the widget that requests to be converted to a normal one.| +| Name| Type | Mandatory| Description | +| ------ | ------ | ---- | ------------------------ | +| formId | string | Yes | ID of the widget that requests to be converted to a normal one.| **Example** @@ -93,13 +97,14 @@ Called to notify the widget provider that a widget has been updated. After obtai **Parameters** - | Name| Type | Mandatory| Description | - | ------ | ------ | ---- | ------------------ | - | formId | string | Yes | ID of the widget that requests to be updated.| +| Name| Type | Mandatory| Description | +| ------ | ------ | ---- | ------------------ | +| formId | string | Yes | ID of the widget that requests to be updated.| **Example** ```js + import formBindingData from '@ohos.application.formBindingData' export default class MyFormExtension extends FormExtension { onUpdate(formId) { console.log('FormExtension onUpdate, formId:' + formId); @@ -123,13 +128,14 @@ Called to notify the widget provider of the change of visibility. **Parameters** - | Name | Type | Mandatory| Description | - | --------- | ------------------------- | ---- | ---------------------------- | - | newStatus | { [key: string]: number } | Yes | ID and visibility status of the widget to be changed.| +| Name | Type | Mandatory| Description | +| --------- | ------------------------- | ---- | ---------------------------- | +| newStatus | { [key: string]: number } | Yes | ID and visibility status of the widget to be changed.| **Example** ```js + import formBindingData from '@ohos.application.formBindingData' export default class MyFormExtension extends FormExtension { onVisibilityChange(newStatus) { console.log('FormExtension onVisibilityChange, newStatus:' + newStatus); @@ -157,10 +163,10 @@ Called to instruct the widget provider to receive and process the widget event. **Parameters** - | Name | Type | Mandatory| Description | - | ------- | ------ | ---- | ---------------------- | - | formId | string | Yes | ID of the widget that requests the event.| - | message | string | Yes | Event message. | +| Name | Type | Mandatory| Description | +| ------- | ------ | ---- | ---------------------- | +| formId | string | Yes | ID of the widget that requests the event.| +| message | string | Yes | Event message. | **Example** @@ -182,9 +188,9 @@ Called to notify the widget provider that a **Form** instance (widget) has been **Parameters** - | Name| Type | Mandatory| Description | - | ------ | ------ | ---- | ------------------ | - | formId | string | Yes | ID of the widget to be destroyed.| +| Name| Type | Mandatory| Description | +| ------ | ------ | ---- | ------------------ | +| formId | string | Yes | ID of the widget to be destroyed.| **Example** @@ -206,16 +212,42 @@ Called when the configuration of the environment where the ability is running is **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | config | [Configuration](#section188911144124715) | Yes| New configuration.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| config | [Configuration](#section188911144124715) | Yes| New configuration.| + +**Example** -**Example** - ```js - class MyFormExtension extends MyFormExtension { + class MyFormExtension extends FormExtension { onConfigurationUpdated(config) { console.log('onConfigurationUpdated, config:' + JSON.stringify(config)); } } ``` + + ## FormExtension.onAcquireFormState + +onAcquireFormState?(want: Want): formInfo.FormState; + +Called when the widget provider receives the status query result of a specified service widget. By default, the initial state is returned. + +**System capability**: SystemCapability.Ability.Form + +**Parameters** + +| Name | Type | Mandatory | Description | +| -------- | -------- | -------- | -------- | +| want | [Want](js-apis-application-Want.md) | No | Description of the widget state, including the bundle name, ability name, module name, widget name, and widget dimension. | + +**Example** + + ```js + import fromInfo from '@ohos.application.fromInfo' + class MyFormExtension extends FormExtension { + onAcquireFormState(want) { + console.log('FormExtension onAcquireFormState, want:' + want); + return fromInfo.FormState.UNKNOWN; + } + } + ``` \ No newline at end of file diff --git a/en/application-dev/reference/apis/js-apis-formextensioncontext.md b/en/application-dev/reference/apis/js-apis-formextensioncontext.md index c4eb1e6ae45c9352c9c099692d32c68613f28d39..6586152194aae73c75be480020cd4e7769a77484 100644 --- a/en/application-dev/reference/apis/js-apis-formextensioncontext.md +++ b/en/application-dev/reference/apis/js-apis-formextensioncontext.md @@ -1,10 +1,19 @@ # FormExtensionContext -> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**
+> **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. Implements the context that provides the capabilities and APIs of **FormExtension**. This class is inherited from **ExtensionContext**. +## Modules to Import + +```js +import FormExtension from '@ohos.application.FormExtension'; +``` + ## FormExtensionContext.updateForm updateForm(formId: string, formBindingData: formBindingData.FormBindingData, callback: AsyncCallback\): void @@ -15,19 +24,27 @@ Updates a widget. This method uses a callback to return the result. **Parameters** - | Name | Type | Mandatory| Description | - | --------------- | ------------------------------------------------------------ | ---- | -------------------------------------- | - | formId | string | Yes | ID of the widget that requests to be updated. | - | formBindingData | [formBindingData.FormBindingData](js-apis-formbindingdata.md#formbindingdata) | Yes | New data of the widget. | - | callback | AsyncCallback\ | Yes | Callback used to return the result indicating whether the method is successfully called.| +| Name | Type | Mandatory| Description | +| --------------- | ------------------------------------------------------------ | ---- | -------------------------------------- | +| formId | string | Yes | ID of the widget that requests to be updated. | +| formBindingData | [formBindingData.FormBindingData](js-apis-formbindingdata.md#formbindingdata) | Yes | New data of the widget. | +| callback | AsyncCallback\ | Yes | Callback used to return the result indicating whether the method is successfully called.| **Example** ```js - let obj2 = formBindingData.createFormBindingData({temperature:"22c", time:"22:00"}); - this.context.updateForm(formId, obj2, (data)=>{ - console.log('FormExtension context updateForm, data:' + data); - }); + import formBindingData from '@ohos.application.formBindingData' + export default class MyFormExtension extends FormExtension { + onUpdate(formId) { + console.log('FormExtension onUpdate, formId:' + formId); + let obj2 = formBindingData.createFormBindingData({temperature:"22c", time:"22:00"}); + this.context.updateForm(formId, obj2, (data)=>{ + console.log('FormExtension context updateForm, data:' + data); + }); + } + } + + ``` ## FormExtensionContext.updateForm @@ -40,24 +57,31 @@ Updates a widget. This method uses a promise to return the result. **Parameters** - | Name | Type | Mandatory| Description | - | --------------- | ------------------------------------------------------------ | ---- | ------------------ | - | formId | string | Yes | ID of the widget that requests to be updated.| - | formBindingData | [formBindingData.FormBindingData](js-apis-formbindingdata.md#formbindingdata) | Yes | New data of the widget. | +| Name | Type | Mandatory| Description | +| --------------- | ------------------------------------------------------------ | ---- | ------------------ | +| formId | string | Yes | ID of the widget that requests to be updated.| +| formBindingData | [formBindingData.FormBindingData](js-apis-formbindingdata.md#formbindingdata) | Yes | New data of the widget. | **Return value** - | Type | Description | - | -------------- | --------------------------------- | - | Promise\ | Promise returned with the result indicating whether the method is successfully called.| +| Type | Description | +| -------------- | --------------------------------- | +| Promise\ | Promise returned with the result indicating whether the method is successfully called.| **Example** - ``` - let obj2 = formBindingData.createFormBindingData({temperature:"22c", time:"22:00"}); - this.context.updateForm(formId, obj2) - .then((data)=>{ - console.log('FormExtension context updateForm, data:' + data); - }).catch((error) => { - console.error('Operation updateForm failed. Cause: ' + error);}); + ```js + import formBindingData from '@ohos.application.formBindingData' + export default class MyFormExtension extends FormExtension { + onUpdate(formId) { + console.log('FormExtension onUpdate, formId:' + formId); + let obj2 = formBindingData.createFormBindingData({temperature:"22c", time:"22:00"}); + this.context.updateForm(formId, obj2) + .then((data)=>{ + console.log('FormExtension context updateForm, data:' + data); + }).catch((error) => { + console.error('Operation updateForm failed. Cause: ' + error);}); + } + } + ``` diff --git a/en/application-dev/reference/apis/js-apis-formhost.md b/en/application-dev/reference/apis/js-apis-formhost.md index 0c01c3bcbca95cfd5fd9b2b5c42f06faa1b83fbb..8301d7fb336ab740e591be81d5a4b4193b06412b 100644 --- a/en/application-dev/reference/apis/js-apis-formhost.md +++ b/en/application-dev/reference/apis/js-apis-formhost.md @@ -1,6 +1,7 @@ # FormHost -> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**
+> **NOTE** +> > The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version. Provides APIs related to the widget host. @@ -57,15 +58,15 @@ SystemCapability.Ability.Form **Parameters** - | Name| Type | Mandatory| Description | - | ------ | ------ | ---- | ------- | - | formId | string | Yes | ID of a widget.| +| Name| Type | Mandatory| Description | +| ------ | ------ | ---- | ------- | +| formId | string | Yes | ID of a widget.| **Return value** - | Type| Description| - | -------- | -------- | - | Promise<void> | Promise used to return the result indicating whether the API is successfully called.| +| Type| Description| +| -------- | -------- | +| Promise<void> | Promise used to return the result indicating whether the API is successfully called.| **Parameters** @@ -147,16 +148,16 @@ SystemCapability.Ability.Form **Parameters** - | Name | Type | Mandatory| Description | - | -------------- | ------ | ---- | ----------- | - | formId | string | Yes | ID of a widget. | - | isReleaseCache | boolean | No | Whether to release the cache.| +| Name | Type | Mandatory| Description | +| -------------- | ------ | ---- | ----------- | +| formId | string | Yes | ID of a widget. | +| isReleaseCache | boolean | No | Whether to release the cache.| **Return value** - | Type| Description| - | -------- | -------- | - | Promise<void> | Promise used to return the result indicating whether the API is successfully called.| +| Type| Description| +| -------- | -------- | +| Promise<void> | Promise used to return the result indicating whether the API is successfully called.| **Example** @@ -209,15 +210,15 @@ SystemCapability.Ability.Form **Parameters** - | Name| Type | Mandatory| Description | - | ------ | ------ | ---- | ------- | - | formId | string | Yes | ID of a widget.| +| Name| Type | Mandatory| Description | +| ------ | ------ | ---- | ------- | +| formId | string | Yes | ID of a widget.| **Return value** - | Type| Description| - | -------- | -------- | - | Promise<void> | Promise used to return the result indicating whether the API is successfully called.| +| Type| Description| +| -------- | -------- | +| Promise<void> | Promise used to return the result indicating whether the API is successfully called.| **Example** @@ -270,15 +271,15 @@ SystemCapability.Ability.Form **Parameters** - | Name| Type | Mandatory| Description | - | ------ | ------ | ---- | ------- | - | formId | string | Yes | ID of a widget.| +| Name| Type | Mandatory| Description | +| ------ | ------ | ---- | ------- | +| formId | string | Yes | ID of a widget.| **Return value** - | Type| Description| - | -------- | -------- | - | Promise<void> | Promise used to return the result indicating whether the API is successfully called.| +| Type| Description| +| -------- | -------- | +| Promise<void> | Promise used to return the result indicating whether the API is successfully called.| **Example** @@ -311,7 +312,7 @@ SystemCapability.Ability.Form **Example** ```js - var formId = "12400633174999288"; + var formId = ["12400633174999288"]; formHost.notifyVisibleForms(formId, (error, data) => { if (error.code) { console.log('formHost notifyVisibleForms, error:' + JSON.stringify(error)); @@ -337,14 +338,14 @@ SystemCapability.Ability.Form **Return value** - | Type| Description| - | -------- | -------- | - | Promise<void> | Promise used to return the result indicating whether the API is successfully called.| +| Type| Description| +| -------- | -------- | +| Promise<void> | Promise used to return the result indicating whether the API is successfully called.| **Example** ```js - var formId = "12400633174999288"; + var formId = ["12400633174999288"]; formHost.notifyVisibleForms(formId).then(() => { console.log('formHost notifyVisibleForms success'); }).catch((error) => { @@ -372,7 +373,7 @@ SystemCapability.Ability.Form **Example** ```js - var formId = "12400633174999288"; + var formId = ["12400633174999288"]; formHost.notifyInvisibleForms(formId, (error, data) => { if (error.code) { console.log('formHost notifyInvisibleForms, error:' + JSON.stringify(error)); @@ -398,14 +399,14 @@ SystemCapability.Ability.Form **Return value** - | Type| Description| - | -------- | -------- | - | Promise<void> | Promise used to return the result indicating whether the API is successfully called.| +| Type| Description| +| -------- | -------- | +| Promise<void> | Promise used to return the result indicating whether the API is successfully called.| **Example** ```js - var formId = "12400633174999288"; + var formId = ["12400633174999288"]; formHost.notifyInvisibleForms(formId).then(() => { console.log('formHost notifyInvisibleForms success'); }).catch((error) => { @@ -433,7 +434,7 @@ SystemCapability.Ability.Form **Example** ```js - var formId = "12400633174999288"; + var formId = ["12400633174999288"]; formHost.enableFormsUpdate(formId, (error, data) => { if (error.code) { console.log('formHost enableFormsUpdate, error:' + JSON.stringify(error)); @@ -459,14 +460,14 @@ SystemCapability.Ability.Form **Return value** - | Type| Description| - | -------- | -------- | - | Promise<void> | Promise used to return the result indicating whether the API is successfully called.| +| Type| Description| +| -------- | -------- | +| Promise<void> | Promise used to return the result indicating whether the API is successfully called.| **Example** ```js - var formId = "12400633174999288"; + var formId = ["12400633174999288"]; formHost.enableFormsUpdate(formId).then(() => { console.log('formHost enableFormsUpdate success'); }).catch((error) => { @@ -494,7 +495,7 @@ SystemCapability.Ability.Form **Example** ```js - var formId = "12400633174999288"; + var formId = ["12400633174999288"]; formHost.disableFormsUpdate(formId, (error, data) => { if (error.code) { console.log('formHost disableFormsUpdate, error:' + JSON.stringify(error)); @@ -520,14 +521,14 @@ SystemCapability.Ability.Form **Return value** - | Type| Description| - | -------- | -------- | - | Promise<void> | Promise used to return the result indicating whether the API is successfully called.| +| Type| Description| +| -------- | -------- | +| Promise<void> | Promise used to return the result indicating whether the API is successfully called.| **Example** ```js - var formId = "12400633174999288"; + var formId = ["12400633174999288"]; formHost.disableFormsUpdate(formId).then(() => { console.log('formHost disableFormsUpdate success'); }).catch((error) => { @@ -574,9 +575,9 @@ SystemCapability.Ability.Form **Return value** - | Type| Description| - | -------- | -------- | - | Promise<void> | Promise used to return the result indicating whether the API is successfully called.| +| Type| Description| +| -------- | -------- | +| Promise<void> | Promise used to return the result indicating whether the API is successfully called.| **Example** @@ -591,7 +592,7 @@ SystemCapability.Ability.Form ## getAllFormsInfo -getAllFormsInfo(callback: AsyncCallback<Array<FormInfo>>): void; +getAllFormsInfo(callback: AsyncCallback<Array<formInfo.FormInfo>>): void; Obtains the widget information provided by all applications on the device. This API uses an asynchronous callback to return the result. @@ -601,9 +602,9 @@ SystemCapability.Ability.Form **Parameters** - | Name| Type | Mandatory| Description | - | ------ | ------ | ---- | ------- | - | callback | AsyncCallback<Array<[FormInfo](./js-apis-formInfo.md#forminfo-1)>> | Yes| Callback used to return the widget information.| +| Name| Type | Mandatory| Description | +| ------ | ------ | ---- | ------- | +| callback | AsyncCallback<Array<[FormInfo](./js-apis-formInfo.md#forminfo-1)>> | Yes| Callback used to return the widget information.| **Example** @@ -619,7 +620,7 @@ SystemCapability.Ability.Form ## getAllFormsInfo -getAllFormsInfo(): Promise<Array<FormInfo>>; +getAllFormsInfo(): Promise<Array<formInfo.FormInfo>>; Obtains the widget information provided by all applications on the device. This API uses a promise to return the result. @@ -645,7 +646,7 @@ SystemCapability.Ability.Form ## getFormsInfo -getFormsInfo(bundleName: string, callback: AsyncCallback<Array<FormInfo>>): void; +getFormsInfo(bundleName: string, callback: AsyncCallback<Array<formInfo.FormInfo>>): void; Obtains the widget information provided by a given application on the device. This API uses an asynchronous callback to return the result. @@ -655,10 +656,10 @@ SystemCapability.Ability.Form **Parameters** - | Name| Type | Mandatory| Description | - | ------ | ------ | ---- | ------- | - | bundleName | string | Yes| Bundle name of the target application.| - | callback | AsyncCallback<Array<[FormInfo](./js-apis-formInfo.md#forminfo-1)>> | Yes| Callback used to return the widget information.| +| Name| Type | Mandatory| Description | +| ------ | ------ | ---- | ------- | +| bundleName | string | Yes| Bundle name of the target application.| +| callback | AsyncCallback<Array<[FormInfo](./js-apis-formInfo.md#forminfo-1)>> | Yes| Callback used to return the widget information.| **Example** @@ -674,7 +675,7 @@ SystemCapability.Ability.Form ## getFormsInfo -getFormsInfo(bundleName: string, moduleName: string, callback: AsyncCallback<Array<FormInfo>>): void; +getFormsInfo(bundleName: string, moduleName: string, callback: AsyncCallback<Array<formInfo.FormInfo>>): void; Obtains the widget information provided by a given application on the device. This API uses an asynchronous callback to return the result. @@ -684,11 +685,11 @@ SystemCapability.Ability.Form **Parameters** - | Name| Type | Mandatory| Description | - | ------ | ------ | ---- | ------- | - | bundleName | string | Yes| Bundle name of the target application.| - | moduleName | string | Yes| Module name.| - | callback | AsyncCallback<Array<[FormInfo](./js-apis-formInfo.md#forminfo-1)>> | Yes| Callback used to return the widget information.| +| Name| Type | Mandatory| Description | +| ------ | ------ | ---- | ------- | +| bundleName | string | Yes| Bundle name of the target application.| +| moduleName | string | Yes| Module name.| +| callback | AsyncCallback<Array<[FormInfo](./js-apis-formInfo.md#forminfo-1)>> | Yes| Callback used to return the widget information.| **Example** @@ -704,7 +705,7 @@ SystemCapability.Ability.Form ## getFormsInfo -getFormsInfo(bundleName: string, moduleName?: string): Promise<Array<FormInfo>>; +getFormsInfo(bundleName: string, moduleName?: string): Promise<Array<formInfo.FormInfo>>; Obtains the widget information provided by a given application on the device. This API uses a promise to return the result. @@ -714,10 +715,10 @@ SystemCapability.Ability.Form **Parameters** - | Name| Type | Mandatory| Description | - | ------ | ------ | ---- | ------- | - | bundleName | string | Yes| Bundle name of the target application.| - | moduleName | string | No| Module name.| +| Name| Type | Mandatory| Description | +| ------ | ------ | ---- | ------- | +| bundleName | string | Yes| Bundle name of the target application.| +| moduleName | string | No| Module name.| **Return value** @@ -767,7 +768,7 @@ SystemCapability.Ability.Form ## deleteInvalidForms -function deleteInvalidForms(formIds: Array<string>): Promise<number>; +deleteInvalidForms(formIds: Array<string>): Promise<number>; Deletes invalid widgets from the list. This API uses a promise to return the result. @@ -800,7 +801,7 @@ SystemCapability.Ability.Form ## acquireFormState -acquireFormState(want: Want, callback: AsyncCallback<FormStateInfo>): void; +acquireFormState(want: Want, callback: AsyncCallback<formInfo.FormStateInfo>): void; Obtains the widget state. This API uses an asynchronous callback to return the result. @@ -834,7 +835,7 @@ SystemCapability.Ability.Form ## acquireFormState -function acquireFormState(want: Want): Promise<FormStateInfo>; +acquireFormState(want: Want): Promise<formInfo.FormStateInfo>; Obtains the widget state. This API uses a promise to return the result. @@ -962,16 +963,16 @@ SystemCapability.Ability.Form **Parameters** - | Name| Type | Mandatory| Description | - | ------ | ------ | ---- | ------- | - | formIds | Array<string> | Yes | List of widget IDs.| - | isVisible | boolean | Yes | Whether to be visible.| +| Name| Type | Mandatory| Description | +| ------ | ------ | ---- | ------- | +| formIds | Array<string> | Yes | List of widget IDs.| +| isVisible | boolean | Yes | Whether to be visible.| **Return value** - | Type| Description| - | -------- | -------- | - | Promise<void> | Promise used to return the result indicating whether the API is successfully called.| +| Type| Description| +| -------- | -------- | +| Promise<void> | Promise used to return the result indicating whether the API is successfully called.| **Example** @@ -1025,16 +1026,16 @@ SystemCapability.Ability.Form **Parameters** - | Name| Type | Mandatory| Description | - | ------ | ------ | ---- | ------- | - | formIds | Array<string> | Yes | List of widget IDs.| - | isEnableUpdate | boolean | Yes | Whether to enable update.| +| Name| Type | Mandatory| Description | +| ------ | ------ | ---- | ------- | +| formIds | Array<string> | Yes | List of widget IDs.| +| isEnableUpdate | boolean | Yes | Whether to enable update.| **Return value** - | Type| Description| - | -------- | -------- | - | Promise<void> | Promise used to return the result indicating whether the API is successfully called.| +| Type| Description| +| -------- | -------- | +| Promise<void> | Promise used to return the result indicating whether the API is successfully called.| **Example** diff --git a/en/application-dev/reference/apis/js-apis-missionManager.md b/en/application-dev/reference/apis/js-apis-missionManager.md index a9c0c75becf3397a933fe15dc57429029759624b..5ee9388c1e6196ae503dd5cb6f91213c588c3d22 100644 --- a/en/application-dev/reference/apis/js-apis-missionManager.md +++ b/en/application-dev/reference/apis/js-apis-missionManager.md @@ -1,7 +1,8 @@ # missionManager -> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**
+> **NOTE** +> > The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version. @@ -15,6 +16,9 @@ missionManager provides APIs to lock, unlock, and clear missions, and switch a m import missionManager from '@ohos.application.missionManager' ``` +## Required Permissions + +ohos.permission.MANAGE_MISSIONS ## missionManager.registerMissionListener @@ -26,24 +30,25 @@ Registers a listener to observe the mission status. **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | listener | MissionListener | Yes| Listener to register.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| listener | MissionListener | Yes| Listener to register.| **Return value** - | Type| Description| - | -------- | -------- | - | number | Returns the unique index of the mission status listener, which is created by the system and allocated when the listener is registered.| +| Type| Description| +| -------- | -------- | +| number | Returns the unique index of the mission status listener, which is created by the system and allocated when the listener is registered.| **Example** ```js var listener = { - onMissionCreated: this.onMissionCreatedCallback, - onMissionDestroyed: this.onMissionDestroyedCallback, - onMissionSnapshotChanged: this.onMissionSnapshotChangedCallback, - onMissionMovedToFront: this.onMissionMovedToFrontCallback + onMissionCreated: function(mission){"--------onMissionCreated-------"}, + onMissionDestroyed: function(mission){"--------onMissionDestroyed-------"}, + onMissionSnapshotChanged: function(mission){"--------onMissionSnapshotChanged-------"}, + onMissionMovedToFront: function(mission){"--------onMissionMovedToFront-------"}, + onMissionIconUpdated: function(mission,icon){"--------onMissionIconUpdated-------"} }; console.log("registerMissionListener") var listenerid = missionManager.registerMissionListener(listener); @@ -61,19 +66,20 @@ Deregisters a mission status listener. This API uses an asynchronous callback to **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | listenerId | number | Yes| Unique index of the mission status listener to unregister. It is returned by **registerMissionListener**.| - | callback | AsyncCallback<void> | Yes| Callback used to return the result.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| listenerId | number | Yes| Unique index of the mission status listener to unregister. It is returned by **registerMissionListener**.| +| callback | AsyncCallback<void> | Yes| Callback used to return the result.| **Example** ```js var listener = { - onMissionCreated: this.onMissionCreatedCallback, - onMissionDestroyed: this.onMissionDestroyedCallback, - onMissionSnapshotChanged: this.onMissionSnapshotChangedCallback, - onMissionMovedToFront: this.onMissionMovedToFrontCallback + onMissionCreated: function(mission){"--------onMissionCreated-------"}, + onMissionDestroyed: function(mission){"--------onMissionDestroyed-------"}, + onMissionSnapshotChanged: function(mission){"--------onMissionSnapshotChanged-------"}, + onMissionMovedToFront: function(mission){"--------onMissionMovedToFront-------"}, + onMissionIconUpdated: function(mission,icon){"--------onMissionIconUpdated-------"} }; console.log("registerMissionListener") var listenerid = missionManager.registerMissionListener(listener); @@ -94,31 +100,32 @@ Deregisters a mission status listener. This API uses a promise to return the res **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | listenerId | number | Yes| Unique index of the mission status listener to unregister. It is returned by **registerMissionListener**.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| listenerId | number | Yes| Unique index of the mission status listener to unregister. It is returned by **registerMissionListener**.| **Return value** - | Type| Description| - | -------- | -------- | - | Promise<void> | Promise used to return the result.| +| Type| Description| +| -------- | -------- | +| Promise<void> | Promise used to return the result.| **Example** ```js var listener = { - onMissionCreated: this.onMissionCreatedCallback, - onMissionDestroyed: this.onMissionDestroyedCallback, - onMissionSnapshotChanged: this.onMissionSnapshotChangedCallback, - onMissionMovedToFront: this.onMissionMovedToFrontCallback - }; - console.log("registerMissionListener") - var listenerid = missionManager.registerMissionListener(listener); - - missionManager.unregisterMissionListener(listenerid).catch(function (err){ - console.log(err); - }); + onMissionCreated: function(mission){"--------onMissionCreated-------"}, + onMissionDestroyed: function(mission){"--------onMissionDestroyed-------"}, + onMissionSnapshotChanged: function(mission){"--------onMissionSnapshotChanged-------"}, + onMissionMovedToFront: function(mission){"--------onMissionMovedToFront-------"}, + onMissionIconUpdated: function(mission,icon){"--------onMissionIconUpdated-------"} + }; + console.log("registerMissionListener") + var listenerid = missionManager.registerMissionListener(listener); + + missionManager.unregisterMissionListener(listenerid).catch(function (err){ + console.log(err); + }); ``` @@ -132,26 +139,27 @@ Obtains the information about a given mission. This API uses an asynchronous cal **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | deviceId | string | Yes| Device ID. It is a null string by default for the local device.| - | missionId | number | Yes| Mission ID.| - | callback | AsyncCallback<[MissionInfo](#missioninfo)> | Yes| Callback used to return the mission information obtained.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| deviceId | string | Yes| Device ID. It is a null string by default for the local device.| +| missionId | number | Yes| Mission ID.| +| callback | AsyncCallback<[MissionInfo](#missioninfo)> | Yes| Callback used to return the mission information obtained.| **Example** ```js import missionManager from '@ohos.application.missionManager' - missionManager.getMissionInfo("", allMissions[0].missionId, (error, mission) => { - console.log("getMissionInfo is called, error.code = " + error.code) - console.log("mission.missionId = " + mission.missionId); - console.log("mission.runningState = " + mission.runningState); - console.log("mission.lockedState = " + mission.lockedState); - console.log("mission.timestamp = " + mission.timestamp); - console.log("mission.label = " + mission.label); - console.log("mission.iconPath = " + mission.iconPath); - }); + var allMissions=missionManager.getMissionInfos("",10).catch(function(err){console.log(err);}); + missionManager.getMissionInfo("", allMissions[0].missionId, (error, mission) => { + console.log("getMissionInfo is called, error.code = " + error.code) + console.log("mission.missionId = " + mission.missionId); + console.log("mission.runningState = " + mission.runningState); + console.log("mission.lockedState = " + mission.lockedState); + console.log("mission.timestamp = " + mission.timestamp); + console.log("mission.label = " + mission.label); + console.log("mission.iconPath = " + mission.iconPath); + }); ``` @@ -165,23 +173,23 @@ Obtains the information about a given mission. This API uses a promise to return **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | deviceId | string | Yes| Device ID. It is a null string by default for the local device.| - | missionId | number | Yes| Mission ID.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| deviceId | string | Yes| Device ID. It is a null string by default for the local device.| +| missionId | number | Yes| Mission ID.| **Return value** - | Type| Description| - | -------- | -------- | - | Promise<[MissionInfo](#missioninfo)> | Promise used to return the mission information obtained.| +| Type| Description| +| -------- | -------- | +| Promise<[MissionInfo](#missioninfo)> | Promise used to return the mission information obtained.| **Example** ```js import missionManager from '@ohos.application.missionManager' - var mission = missionManager.getMissionInfo("", id).catch(function (err){ + var mission = missionManager.getMissionInfo("", 10).catch(function (err){ console.log(err); }); ``` @@ -197,11 +205,11 @@ Obtains information about all missions. This API uses an asynchronous callback t **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | deviceId | string | Yes| Device ID. It is a null string by default for the local device.| - | numMax | number | Yes| Maximum number of missions whose information can be obtained.| - | callback | AsyncCallback<Array<[MissionInfo](#missioninfo)>> | Yes| Callback used to return the array of mission information obtained.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| deviceId | string | Yes| Device ID. It is a null string by default for the local device.| +| numMax | number | Yes| Maximum number of missions whose information can be obtained.| +| callback | AsyncCallback<Array<[MissionInfo](#missioninfo)>> | Yes| Callback used to return the array of mission information obtained.| **Example** @@ -226,16 +234,16 @@ Obtains information about all missions. This API uses a promise to return the re **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | deviceId | string | Yes| Device ID. It is a null string by default for the local device.| - | numMax | number | Yes| Maximum number of missions whose information can be obtained.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| deviceId | string | Yes| Device ID. It is a null string by default for the local device.| +| numMax | number | Yes| Maximum number of missions whose information can be obtained.| **Return value** - | Type| Description| - | -------- | -------- | - | Promise<Array<[MissionInfo](#missioninfo)>> | Promise used to return the array of mission information obtained.| +| Type| Description| +| -------- | -------- | +| Promise<Array<[MissionInfo](#missioninfo)>> | Promise used to return the array of mission information obtained.| **Example** @@ -258,11 +266,11 @@ Obtains the snapshot of a given mission. This API uses an asynchronous callback **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | deviceId | string | Yes| Device ID. It is a null string by default for the local device.| - | missionId | number | Yes| Mission ID.| - | callback | AsyncCallback<[MissionSnapshot](js-apis-application-MissionSnapshot.md)> | Yes| Callback used to return the snapshot information obtained.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| deviceId | string | Yes| Device ID. It is a null string by default for the local device.| +| missionId | number | Yes| Mission ID.| +| callback | AsyncCallback<[MissionSnapshot](js-apis-application-MissionSnapshot.md)> | Yes| Callback used to return the snapshot information obtained.| **Example** @@ -293,31 +301,33 @@ Obtains the snapshot of a given mission. This API uses a promise to return the r **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | deviceId | string | Yes| Device ID. It is a null string by default for the local device.| - | missionId | number | Yes| Mission ID.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| deviceId | string | Yes| Device ID. It is a null string by default for the local device.| +| missionId | number | Yes| Mission ID.| **Return value** - | Type| Description| - | -------- | -------- | - | Promise<[MissionSnapshot](js-apis-application-MissionSnapshot.md)> | Promise used to return the snapshot information obtained.| +| Type| Description| +| -------- | -------- | +| Promise<[MissionSnapshot](js-apis-application-MissionSnapshot.md)> | Promise used to return the snapshot information obtained.| **Example** ```js import missionManager from '@ohos.application.missionManager' - var allMissions = missionManager.getMissionInfos("", 10).catch(function (err){ - console.log(err); - }); - console.log("size = " + allMissions.length); - console.log("missions = " + JSON.stringify(allMissions)); - var id = allMissions[0].missionId; - var snapshot = missionManager.getMissionSnapShot("", id).catch(function (err){ - console.log(err); - }); + var allMissions; + missionManager.getMissionInfos("",10).then(function(res){ + allMissions=res; + }).catch(function(err){console.log(err);}); + console.log("size = " + allMissions.length); + console.log("missions = " + JSON.stringify(allMissions)); + var id = allMissions[0].missionId; + + var snapshot = missionManager.getMissionSnapShot("", id).catch(function (err){ + console.log(err); + }); ``` @@ -331,10 +341,10 @@ Locks a given mission. This API uses an asynchronous callback to return the resu **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | missionId | number | Yes| Mission ID.| - | callback | AsyncCallback<void> | Yes| Callback used to return the result.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| missionId | number | Yes| Mission ID.| +| callback | AsyncCallback<void> | Yes| Callback used to return the result.| **Example** @@ -364,24 +374,24 @@ Locks a given mission. This API uses a promise to return the result. **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | missionId | number | Yes| Mission ID.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| missionId | number | Yes| Mission ID.| **Return value** - | Type| Description| - | -------- | -------- | - | Promise<void> | Promise used to return the result.| +| Type| Description| +| -------- | -------- | +| Promise<void> | Promise used to return the result.| **Example** ```js import missionManager from '@ohos.application.missionManager' - - var allMissions = missionManager.getMissionInfos("", 10).catch(function (err){ - console.log(err); - }); + var allMissions; + missionManager.getMissionInfos("",10).then(function(res){ + allMissions=res; + }).catch(function(err){console.log(err);}); console.log("size = " + allMissions.length); console.log("missions = " + JSON.stringify(allMissions)); var id = allMissions[0].missionId; @@ -435,24 +445,25 @@ Unlocks a given mission. This API uses a promise to return the result. **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | missionId | number | Yes| Mission ID.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| missionId | number | Yes| Mission ID.| **Return value** - | Type| Description| - | -------- | -------- | - | Promise<void> | Promise used to return the result.| +| Type| Description| +| -------- | -------- | +| Promise<void> | Promise used to return the result.| **Example** ```js import missionManager from '@ohos.application.missionManager' - var allMissions = missionManager.getMissionInfos("", 10).catch(function (err){ - console.log(err); - }); + var allMissions; + missionManager.getMissionInfos("",10).then(function(res){ + allMissions=res; + }).catch(function(err){console.log(err);}); console.log("size = " + allMissions.length); console.log("missions = " + JSON.stringify(allMissions)); var id = allMissions[0].missionId; @@ -476,10 +487,10 @@ Clears a given mission, regardless of whether it is locked. This API uses an asy **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | missionId | number | Yes| Mission ID.| - | callback | AsyncCallback<void> | Yes| Callback used to return the result.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| missionId | number | Yes| Mission ID.| +| callback | AsyncCallback<void> | Yes| Callback used to return the result.| **Example** @@ -509,24 +520,25 @@ Clears a given mission, regardless of whether it is locked. This API uses a prom **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | missionId | number | Yes| Mission ID.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| missionId | number | Yes| Mission ID.| **Return value** - | Type| Description| - | -------- | -------- | - | Promise<void> | Promise used to return the result.| +| Type| Description| +| -------- | -------- | +| Promise<void> | Promise used to return the result.| **Example** ```js import missionManager from '@ohos.application.missionManager' - var allMissions = missionManager.getMissionInfos("", 10).catch(function (err){ - console.log(err); - }); + var allMissions; + missionManager.getMissionInfos("",10).then(function(res){ + allMissions=res; + }).catch(function(err){console.log(err);}); console.log("size = " + allMissions.length); console.log("missions = " + JSON.stringify(allMissions)); var id = allMissions[0].missionId; @@ -566,9 +578,9 @@ Clears all unlocked missions. This API uses a promise to return the result. **Return value** - | Type| Description| - | -------- | -------- | - | Promise<void> | Promise used to return the result.| +| Type| Description| +| -------- | -------- | +| Promise<void> | Promise used to return the result.| **Example** @@ -590,10 +602,10 @@ Switches a given mission to the foreground. This API uses an asynchronous callba **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | missionId | number | Yes| Mission ID.| - | callback | AsyncCallback<void> | Yes| Callback used to return the result.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| missionId | number | Yes| Mission ID.| +| callback | AsyncCallback<void> | Yes| Callback used to return the result.| **Example** @@ -623,11 +635,11 @@ Switches a given mission to the foreground, with the startup parameters for the **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | missionId | number | Yes| Mission ID.| - | options | StartOptions | Yes| Startup parameters, which are used to specify the window mode and device ID for switching the mission to the foreground.| - | callback | AsyncCallback<void> | Yes| Callback used to return the result.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| missionId | number | Yes| Mission ID.| +| options | StartOptions | Yes| Startup parameters, which are used to specify the window mode and device ID for switching the mission to the foreground.| +| callback | AsyncCallback<void> | Yes| Callback used to return the result.| **Example** @@ -657,25 +669,26 @@ Switches a given mission to the foreground, with the startup parameters for the **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | missionId | number | Yes| Mission ID.| - | options | StartOptions | No| Startup parameters, which are used to specify the window mode and device ID for switching the mission to the foreground.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| missionId | number | Yes| Mission ID.| +| options | StartOptions | No| Startup parameters, which are used to specify the window mode and device ID for switching the mission to the foreground.| **Return value** - | Type| Description| - | -------- | -------- | - | Promise<void> | Promise used to return the result.| +| Type| Description| +| -------- | -------- | +| Promise<void> | Promise used to return the result.| **Example** ```js import missionManager from '@ohos.application.missionManager' - var allMissions = missionManager.getMissionInfos("", 10).catch(function (err){ - console.log(err); - }); + var allMissions; + missionManager.getMissionInfos("",10).then(function(res){ + allMissions=res; + }).catch(function(err){console.log(err);}); console.log("size = " + allMissions.length); console.log("missions = " + JSON.stringify(allMissions)); var id = allMissions[0].missionId; @@ -691,13 +704,13 @@ Describes the mission information. **System capability**: SystemCapability.Ability.AbilityBase -| Name| Type| Readable| Writable| Description| +| Name| Type| Readable| Writable| Description| | -------- | -------- | -------- | -------- | -------- | -| missionId | number | Yes| Yes| Mission ID.| -| runningState | number | Yes| Yes| Running state of the mission.| -| lockedState | boolean | Yes| Yes| Locked state of the mission.| -| timestamp | string | Yes| Yes| Latest time when the mission was created or updated.| -| want | [Want](js-apis-application-Want.md) | Yes| Yes| **Want** information of the mission.| -| label | string | Yes| Yes| Label of the mission.| -| iconPath | string | Yes| Yes| Path of the mission icon.| -| continuable | boolean | Yes| Yes| Whether the mission is continuable.| +| missionId | number | Yes| Yes| Mission ID.| +| runningState | number | Yes| Yes| Running state of the mission.| +| lockedState | boolean | Yes| Yes| Locked state of the mission.| +| timestamp | string | Yes| Yes| Latest time when the mission was created or updated.| +| want | [Want](js-apis-application-Want.md) | Yes| Yes| **Want** information of the mission.| +| label | string | Yes| Yes| Label of the mission.| +| iconPath | string | Yes| Yes| Path of the mission icon.| +| continuable | boolean | Yes| Yes| Whether the mission is continuable.| diff --git a/en/application-dev/reference/apis/js-apis-particleAbility.md b/en/application-dev/reference/apis/js-apis-particleAbility.md index a5a215f95741a7467179df5e59fef4115012d5c3..e07a8944cadf3233c040daba28f429f46adbafa1 100644 --- a/en/application-dev/reference/apis/js-apis-particleAbility.md +++ b/en/application-dev/reference/apis/js-apis-particleAbility.md @@ -1,9 +1,12 @@ -# ParticleAbility Module +# ParticleAbility -> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**
+> **NOTE** +> > The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version. +> +> The APIs of this module can be used only in the FA module. -## Constraints +## Usage The ParticleAbility module is used to perform operations on abilities of the Data and Service types. @@ -196,11 +199,11 @@ Requests a continuous task from the system. This API uses an asynchronous callba **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | id | number | Yes| Notification ID of a continuous task.| - | request | NotificationRequest | Yes| Notification parameter, which is used to display information in the notification bar.| - | callback | AsyncCallback<void> | Yes| Callback used to return the result.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| id | number | Yes| Notification ID of a continuous task.| +| request | NotificationRequest | Yes| Notification parameter, which is used to display information in the notification bar.| +| callback | AsyncCallback<void> | Yes| Callback used to return the result.| **Example** @@ -226,7 +229,7 @@ let wantAgentInfo = { ], operationType: wantAgent.OperationType.START_ABILITY, requestCode: 0, - wantAgentFlags: [wantAgent.WantAgentFlags.UPDATE_PRESET_FLAG] + wantAgentFlags: [wantAgent.WantAgentFlags.UPDATE_PRESENT_FLAG] }; wantAgent.getWantAgent(wantAgentInfo).then((wantAgentObj) => { @@ -235,11 +238,11 @@ wantAgent.getWantAgent(wantAgentInfo).then((wantAgentObj) => { text: "text" }; let notificationContent = { - contentType: notification.ContentType.NOTIFICATION_CONTENT_TEXT, + contentType: notification.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, normal: basicContent }; let request = { - content: notificatonContent, + content: notificationContent, wantAgent: wantAgentObj }; let id = 1; @@ -287,7 +290,7 @@ let wantAgentInfo = { ], operationType: wantAgent.OperationType.START_ABILITY, requestCode: 0, - wantAgentFlags: [wantAgent.WantAgentFlags.UPDATE_PRESET_FLAG] + wantAgentFlags: [wantAgent.WantAgentFlags.UPDATE_PRESENT_FLAG] }; wantAgent.getWantAgent(wantAgentInfo).then((wantAgentObj) => { @@ -296,11 +299,11 @@ wantAgent.getWantAgent(wantAgentInfo).then((wantAgentObj) => { text: "text" }; let notificationContent = { - contentType: notification.ContentType.NOTIFICATION_CONTENT_TEXT, + contentType: notification.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, normal: basicContent }; let request = { - content: notificatonContent, + content: notificationContent, wantAgent: wantAgentObj }; let id = 1; @@ -323,9 +326,9 @@ Requests to cancel a continuous task from the system. This API uses an asynchron **Parameters** - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | callback | AsyncCallback<void> | Yes | Callback used to return the result. | +| Name | Type | Mandatory | Description | +| -------- | -------- | -------- | -------- | +| callback | AsyncCallback<void> | Yes | Callback used to return the result. | **Example** @@ -401,6 +404,7 @@ Connects this ability to a specific Service ability. This API uses a callback to **Example** ```js + import rpc from '@ohos.rpc' function onConnectCallback(element, remote){ console.log('ConnectAbility onConnect remote is proxy:' + (remote instanceof rpc.RemoteProxy)); } @@ -422,8 +426,10 @@ Connects this ability to a specific Service ability. This API uses a callback to }, ); - particleAbility.disconnectAbility(connId).then((error,data)=>{ - console.log('particleAbilityTest result errCode : ' + error.code + " data: " + data); + particleAbility.disconnectAbility(connId).then((data)=>{ + console.log( " data: " + data); + }).catch((error)=>{ + console.log('particleAbilityTest result errCode : ' + error.code ) }); @@ -440,13 +446,14 @@ Disconnects this ability from the Service ability. This API uses a callback to r **Parameters** - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | callback | AsyncCallback<void> | Yes | Callback used to return the result. | +| Name | Type | Mandatory | Description | +| -------- | -------- | -------- | -------- | +| callback | AsyncCallback<void> | Yes | Callback used to return the result. | **Example** ```js +import rpc from '@ohos.rpc' function onConnectCallback(element, remote){ console.log('ConnectAbility onConnect remote is proxy:' + (remote instanceof rpc.RemoteProxy)); } @@ -467,11 +474,11 @@ Disconnects this ability from the Service ability. This API uses a callback to r onFailed: onFailedCallback, }, ); - var result = particleAbility.disconnectAbility(connId, - (error,data) => { - console.log('particleAbilityTest DisConnectJsSameBundleName result errCode : ' + error.code + " data: " + data) - }, - ); + var result = particleAbility.disconnectAbility(connId).then((data)=>{ + console.log( " data: " + data); + }).catch((error)=>{ + console.log('particleAbilityTest result errCode : ' + error.code ) + }); ``` @@ -493,6 +500,7 @@ Disconnects this ability from the Service ability. This API uses a promise to re **Example** ```js +import rpc from '@ohos.rpc' function onConnectCallback(element, remote){ console.log('ConnectAbility onConnect remote is proxy:' + (remote instanceof rpc.RemoteProxy)); } @@ -514,8 +522,10 @@ function onConnectCallback(element, remote){ }, ); - particleAbility.disconnectAbility(connId).then((error,data)=>{ - console.log('particleAbilityTest result errCode : ' + error.code + " data: " + data); + particleAbility.disconnectAbility(connId).then((data)=>{ + console.log( " data: " + data); + }).catch((error)=>{ + console.log('particleAbilityTest result errCode : ' + error.code ) }); ``` diff --git a/en/application-dev/reference/apis/js-apis-permissionrequestresult.md b/en/application-dev/reference/apis/js-apis-permissionrequestresult.md index 20f6b7859945481356f504b2bc8b64b41cdd58ff..1e4e5491471284db24e7a2733fd40d770a3a8915 100644 --- a/en/application-dev/reference/apis/js-apis-permissionrequestresult.md +++ b/en/application-dev/reference/apis/js-apis-permissionrequestresult.md @@ -1,17 +1,48 @@ # PermissionRequestResult -> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** +> **NOTE** +> > The initial APIs of this module are supported since API 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. Provides the permission request result. +## Modules to Import + +```js +import Ability from '@ohos.application.Ability' +``` + +## Usage + + The permission request result is obtained through an **AbilityStage** instance. + +```js +import Ability from '@ohos.application.Ability' +export default class MainAbility extends Ability { + onWindowStageCreate(windowStage) { + var permissions=['com.example.permission'] + var permissionRequestResult; + this.context.requestPermissionsFromUser(permissions,(err,result) => { + if(err){ + console.log('requestPermissionsFromUserError: ' + JSON.stringify(err)); + }else{ + permissionRequestResult=result; + console.log('permissionRequestResult: ' + JSON.stringify(permissionRequestResult)); + } + }); + } +} +``` + ## Attributes **System capability**: SystemCapability.Ability.AbilityRuntime.Core - | Name| Type| Readable| Writable| Description| +| Name| Type| Readable| Writable| Description| | -------- | -------- | -------- | -------- | -------- | -| permissions | Array<string> | Yes| No| Permissions requested.| -| authResults | Array<number> | Yes| No| Whether the requested permissions are granted or denied. The value **0** means that the requests permissions are granted, and **-1** means the opposite. | +| permissions | Array<string> | Yes| No| Permissions requested.| +| authResults | Array<number> | Yes| No| Whether the requested permissions are granted or denied. The value **0** means that the requests permissions are granted, and **-1** means the opposite. | diff --git a/en/application-dev/reference/apis/js-apis-processrunninginfo.md b/en/application-dev/reference/apis/js-apis-processrunninginfo.md index 29d055c83fc1e408404a3d91c81ea0ab090a6258..167d216652325fa4f48f4aec5a1c9d923bd48ec4 100644 --- a/en/application-dev/reference/apis/js-apis-processrunninginfo.md +++ b/en/application-dev/reference/apis/js-apis-processrunninginfo.md @@ -1,19 +1,23 @@ # ProcessRunningInfo -> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** +> **NOTE** +> > The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version. Provides process running information. +## Modules to Import + +```js +import appManager from '@ohos.application.appManager' +``` ## Usage The process running information is obtained through an **appManager** instance. - - ```js import appManager from '@ohos.application.appManager'; appManager.getProcessRunningInfos((error,data) => { @@ -26,9 +30,9 @@ appManager.getProcessRunningInfos((error,data) => { **System capability**: SystemCapability.Ability.AbilityRuntime.Core - | Name| Type| Readable| Writable| Description| +| Name| Type| Readable| Writable| Description| | -------- | -------- | -------- | -------- | -------- | -| pid | number | Yes| No| Process ID.| -| uid | number | Yes| No| User ID.| -| processName | string | Yes| No| Process name.| -| bundleNames | Array<string> | Yes| No| Names of all bundles running in the process.| +| pid | number | Yes| No| Process ID.| +| uid | number | Yes| No| User ID.| +| processName | string | Yes| No| Process name.| +| bundleNames | Array<string> | Yes| No| Names of all bundles running in the process.| diff --git a/en/application-dev/reference/apis/js-apis-service-extension-ability.md b/en/application-dev/reference/apis/js-apis-service-extension-ability.md index 09033e607f88b02a42885b02eeb468dd8de6ec4b..b2bfc7a85941381a40ed099e759a8d007220a318 100644 --- a/en/application-dev/reference/apis/js-apis-service-extension-ability.md +++ b/en/application-dev/reference/apis/js-apis-service-extension-ability.md @@ -1,7 +1,10 @@ # ServiceExtensionAbility -> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**
+> **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. Provides APIs related to **ServiceExtension**. @@ -23,9 +26,9 @@ None. **System capability**: SystemCapability.Ability.AbilityRuntime.Core -| Name| Type| Readable| Writable| Description| +| Name| Type| Readable| Writable| Description| | -------- | -------- | -------- | -------- | -------- | -| context | [ServiceExtensionContext](js-apis-service-extension-context.md) | Yes| No| Service extension context, which is inherited from **ExtensionContext**.| +| context | [ServiceExtensionContext](js-apis-service-extension-context.md) | Yes| No| Service extension context, which is inherited from **ExtensionContext**.| ## ServiceExtensionAbility.onCreate @@ -38,9 +41,9 @@ Called when an extension is created to initialize the service logic. **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | want | [Want](js-apis-application-Want.md) | Yes| Information related to this extension, including the ability name and bundle name.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| want | [Want](js-apis-application-Want.md) | Yes| Information related to this extension, including the ability name and bundle name.| **Example** @@ -82,10 +85,10 @@ Called after **onCreate** is invoked when an ability is started by calling **sta **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | want | [Want](js-apis-application-Want.md) | Yes| Information related to this extension, including the ability name and bundle name.| - | startId | number | Yes| Number of ability start times. The initial value is **1**, and the value is automatically incremented for each ability started.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| want | [Want](js-apis-application-Want.md) | Yes| Information related to this extension, including the ability name and bundle name.| +| startId | number | Yes| Number of ability start times. The initial value is **1**, and the value is automatically incremented for each ability started.| **Example** @@ -108,15 +111,15 @@ Called after **onCreate** is invoked when an ability is started by calling **con **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | want | [Want](js-apis-application-Want.md)| Yes| Information related to this extension, including the ability name and bundle name.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| want | [Want](js-apis-application-Want.md)| Yes| Information related to this extension, including the ability name and bundle name.| **Return value** - | Type| Description| - | -------- | -------- | - | rpc.RemoteObject | A **RemoteObject** object used for communication with the client.| +| Type| Description| +| -------- | -------- | +| rpc.RemoteObject | A **RemoteObject** object used for communication with the client.| **Example** @@ -126,7 +129,7 @@ Called after **onCreate** is invoked when an ability is started by calling **con constructor(des) { super(des); } - onRemoteRequest(code, data, reply, option) { + onConnect(code, data, reply, option) { } } class ServiceExt extends ServiceExtension { @@ -148,9 +151,9 @@ Called when the ability is disconnected. **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | want |[Want](js-apis-application-Want.md)| Yes| Information related to this extension, including the ability name and bundle name.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| want |[Want](js-apis-application-Want.md)| Yes| Information related to this extension, including the ability name and bundle name.| **Example** diff --git a/en/application-dev/reference/apis/js-apis-service-extension-context.md b/en/application-dev/reference/apis/js-apis-service-extension-context.md index a11942cf16b785967a8491e46a06d8ad820359aa..b6997fa308a25b6056361edcf88fb1271bf854db 100644 --- a/en/application-dev/reference/apis/js-apis-service-extension-context.md +++ b/en/application-dev/reference/apis/js-apis-service-extension-context.md @@ -1,11 +1,19 @@ # ServiceExtensionContext -> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**
+> **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. Implements the context that provides the capabilities and APIs of **ServiceExtension**. This class is inherited from **ExtensionContext**. +## Modules to Import + +``` +import ExtensionContext from '@ohos.application.ServiceExtensionAbility'; +``` ## startAbility @@ -17,21 +25,26 @@ Starts an ability. This API uses a callback to return the result. **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | want | [Want](js-apis-application-Want.md) | Yes| Information about the ability to start, such as the ability name and bundle name.| - | callback | AsyncCallback<void> | No| Callback used to return the result indicating whether the API is successfully called.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| want | [Want](js-apis-application-Want.md) | Yes| Information about the ability to start, such as the ability name and bundle name.| +| callback | AsyncCallback<void> | No| Callback used to return the result indicating whether the API is successfully called.| **Example** ```js - let want = { - "bundleName": "com.example.myapp", - "abilityName": "com.example.myapp.MyAbility" - }; - this.context.startAbility(want, (err) => { - console.log('startAbility result:' + JSON.stringfy(err)); - }); + import ExtensionContext from '@ohos.application.ServiceExtensionAbility'; + class MainAbility extends ExtensionContext { + onWindowStageCreate(windowStage) { + let want = { + "bundleName": "com.example.myapp", + "abilityName": "MyAbility"}; + this.context.startAbility(want, (err) => { + console.log('startAbility result:' + JSON.stringify(err)); + }); + } + } + ``` @@ -45,28 +58,35 @@ Starts an ability. This API uses a promise to return the result. **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | want | [Want](js-apis-application-Want.md) | Yes| Information about the ability to start, such as the ability name and bundle name.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| want | [Want](js-apis-application-Want.md) | Yes| Information about the ability to start, such as the ability name and bundle name.| **Return value** - | Type| Description| - | -------- | -------- | - | Promise<void> | Promise used to return the result indicating whether the API is successfully called.| +| Type| Description| +| -------- | -------- | +| Promise<void> | Promise used to return the result indicating whether the API is successfully called.| **Example** ```js - let want = { - "bundleName": "com.example.myapp", - "abilityName": "com.example.myapp.MyAbility" - }; - this.context.startAbility(want).then((data) => { - console.log('success:' + JSON.stringfy(data)); - }).catch((error) => { - console.log('failed:' + JSON.stringfy(error)); - }); + import ExtensionContext from '@ohos.application.ServiceExtensionAbility'; + class MainAbility extends ExtensionContext { + onWindowStageCreate(windowStage) { + let want = { + "bundleName": "com.example.myapp", + "abilityName": "MyAbility" + }; + this.context.startAbility(want).then((data) => { + console.log('success:' + JSON.stringify(data)); + }).catch((error) => { + console.log('failed:' + JSON.stringify(error)); + }); + } + } + + ``` @@ -80,16 +100,23 @@ Terminates this ability. This API uses a callback to return the result. **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | callback | AsyncCallback<void> | No| Callback used to return the result indicating whether the API is successfully called.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| callback | AsyncCallback<void> | No| Callback used to return the result indicating whether the API is successfully called.| **Example** ```js - this.context.terminateSelf((err) => { - console.log('terminateSelf result:' + JSON.stringfy(err)); - }); + import ExtensionContext from '@ohos.application.ServiceExtensionAbility'; + class MainAbility extends ExtensionContext { + onWindowStageCreate(windowStage) { + this.context.terminateSelf((err) => { + console.log('terminateSelf result:' + JSON.stringify(err)); + }); + } + } + + ``` @@ -103,18 +130,24 @@ Terminates this ability. This API uses a promise to return the result. **Return value** - | Type| Description| - | -------- | -------- | - | Promise<void> | Promise used to return the result indicating whether the API is successfully called.| +| Type| Description| +| -------- | -------- | +| Promise<void> | Promise used to return the result indicating whether the API is successfully called.| **Example** ```js - this.context.terminateSelf(want).then((data) => { - console.log('success:' + JSON.stringfy(data)); - }).catch((error) => { - console.log('failed:' + JSON.stringfy(error)); - }); + import ExtensionContext from '@ohos.application.ServiceExtensionAbility'; + class MainAbility extends ExtensionContext { + onWindowStageCreate(windowStage) { + this.context.terminateSelf().then((data) => { + console.log('success:' + JSON.stringify(data)); + }).catch((error) => { + console.log('failed:' + JSON.stringify(error)); + }); + } +} + ``` @@ -128,23 +161,23 @@ Connects this ability to a Service ability. **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | want | [Want](js-apis-application-Want.md) | Yes| Information about the ability to connect to, such as the ability name and bundle name.| - | options | [ConnectOptions](#connectoptions) | Yes| Callback used to return the information indicating that the connection is successful, interrupted, or failed.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| want | [Want](js-apis-application-Want.md) | Yes| Information about the ability to connect to, such as the ability name and bundle name.| +| options | [ConnectOptions](#connectoptions) | Yes| Callback used to return the information indicating that the connection is successful, interrupted, or failed.| **Return value** - | Type| Description| - | -------- | -------- | - | number | A number, based on which the connection will be interrupted.| +| Type| Description| +| -------- | -------- | +| number | A number, based on which the connection will be interrupted.| **Example** ```js let want = { "bundleName": "com.example.myapp", - "abilityName": "com.example.myapp.MyAbility" + "abilityName": "MyAbility" }; let options = { onConnect: function(elementName, proxy) {}, @@ -165,17 +198,26 @@ Disconnects this ability from the Service ability. This API uses a callback to r **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | connection | number | Yes| Number returned after **connectAbility** is called.| - | callback | AsyncCallback<void> | No| Callback used to return the result indicating whether the API is successfully called.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| connection | number | Yes| Number returned after **connectAbility** is called.| +| callback | AsyncCallback<void> | No| Callback used to return the result indicating whether the API is successfully called.| **Example** ```js - this.context.disconnectAbility(connection, (err) => { // connection is the return value of connectAbility. - console.log('terminateSelf result:' + JSON.stringfy(err)); - }); + import ExtensionContext from '@ohos.application.ServiceExtensionAbility'; + class MainAbility extends ExtensionContext { + onWindowStageCreate(windowStage) { + let connection=1 + this.context.disconnectAbility(connection, (err) => { + // connection is the return value of connectAbility. + console.log('terminateSelf result:' + JSON.stringify(err)); + }); + } + } + + ``` @@ -189,24 +231,31 @@ Disconnects this ability from the Service ability. This API uses a promise to re **Parameters** - | Name| Type| Mandatory| Description| - | -------- | -------- | -------- | -------- | - | connection | number | Yes| Number returned after **connectAbility** is called.| +| Name| Type| Mandatory| Description| +| -------- | -------- | -------- | -------- | +| connection | number | Yes| Number returned after **connectAbility** is called.| **Return value** - | Type| Description| - | -------- | -------- | - | Promise<void> | Promise used to return the result indicating whether the API is successfully called.| - +| Type| Description| +| -------- | -------- | +| Promise<void> | Promise used to return the result indicating whether the API is successfully called.| + **Example** ```js - this.context.disconnectAbility(connection).then((data) => { // connection is the return value of connectAbility. - console.log('success:' + JSON.stringfy(data)); - }).catch((error) => { - console.log('failed:' + JSON.stringfy(error)); - }); + import ExtensionContext from '@ohos.application.ServiceExtensionAbility'; + class MainAbility extends ExtensionContext { + onWindowStageCreate(windowStage) { + let connection=1 + this.context.disconnectAbility(connection).then((data) => { // connection is the return value of connectAbility. + console.log('success:' + JSON.stringify(data)); + }).catch((error) => { + console.log('failed:' + JSON.stringify(error)); + }); + } + } + ``` @@ -216,8 +265,8 @@ Defines the **ConnectOptions** data structure. **System capability**: SystemCapability.Ability.AbilityRuntime.Core -| Name| Description| +| Name| Description| | -------- | -------- | -| onConnect(elementName:ElementName, remote:IRemoteObject) | Called when this ability is connected to a Service ability.| -| onDisconnect(elementName:ElementName) | Called when the peer service is abnormal or killed.| -| onFailed(code: number) | Called when the connection fails.| +| onConnect(elementName:ElementName, remote:IRemoteObject) | Called when this ability is connected to a Service ability.| +| onDisconnect(elementName:ElementName) | Called when the peer service is abnormal or killed.| +| onFailed(code: number) | Called when the connection fails.| diff --git a/en/application-dev/reference/apis/js-apis-uripermissionmanager.md b/en/application-dev/reference/apis/js-apis-uripermissionmanager.md index 506611ba4807edf47d583bd57bd8a4d656496010..0de14d40bd00dc6ec5fe8f6c0953e36401e7cd7c 100644 --- a/en/application-dev/reference/apis/js-apis-uripermissionmanager.md +++ b/en/application-dev/reference/apis/js-apis-uripermissionmanager.md @@ -1,6 +1,7 @@ # uriPermissionManager -> **NOTE**
+> **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. @@ -11,7 +12,7 @@ Implements URI permission management. ``` -import uriPermissionManager from '@ohos.application.uriPermissionManager'; +import UriPermissionManager from '@ohos.application.uriPermissionManager'; ``` @@ -27,18 +28,20 @@ SystemCapability.Ability.AbilityRuntime.Core **Parameters** - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | uri | string | Yes | URI of a file, for example, **fileshare:///com.samples.filesharetest.FileShare/person/10**. | - | flag | wantConstant.Flags | Yes | Read or write permission on the file specified by the URI. | - | accessTokenId | number | Yes | Unique ID of an application, which is obtained through the **BundleManager** API. | - | callback | AsyncCallback<number> | Yes | Callback used to return the check result. The value **0** means that the application has the specified permission, and **-1** means the opposite. | +| Name | Type | Mandatory | Description | +| -------- | -------- | -------- | -------- | +| uri | string | Yes | URI of a file, for example, **fileshare:///com.samples.filesharetest.FileShare/person/10**. | +| flag | wantConstant.Flags | Yes | Read or write permission on the file specified by the URI. | +| accessTokenId | number | Yes | Unique ID of an application, which is obtained through the **BundleManager** API. | +| callback | AsyncCallback<number> | Yes | Callback used to return the check result. The value **0** means that the application has the specified permission, and **-1** means the opposite. | **Example** - ``` + ```js + import WantConstant from '@ohos.ability.wantConstant'; + let accessTokenId =1 let uri = "fileshare:///com.samples.filesharetest.FileShare/person/10" - UriPermissionManager.verifyUriPermission(uri, wantConstant.Flags.FLAG_AUTH_READ_URI_PERMISSION, accessTokenId, (result) => { + UriPermissionManager.verifyUriPermission(uri, WantConstant.Flags.FLAG_AUTH_READ_URI_PERMISSION, accessTokenId, (result) => { console.log("result.code = " + result.code) }) // accessTokenId is obtained through the **BundleManager** API. ``` @@ -56,21 +59,23 @@ SystemCapability.Ability.AbilityRuntime.Core **Parameters** - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | uri | string | Yes | URI of a file, for example, **fileshare:///com.samples.filesharetest.FileShare/person/10**. | - | flag | wantConstant.Flags | Yes | Read or write permission on the file specified by the URI. | - | accessTokenId | number | Yes | Unique ID of an application, which is obtained through the **BundleManager** API. | +| Name | Type | Mandatory | Description | +| -------- | -------- | -------- | -------- | +| uri | string | Yes | URI of a file, for example, **fileshare:///com.samples.filesharetest.FileShare/person/10**. | +| flag | wantConstant.Flags | Yes | Read or write permission on the file specified by the URI. | +| accessTokenId | number | Yes | Unique ID of an application, which is obtained through the **BundleManager** API. | **Return value** - | Type | Description | - | -------- | -------- | - | Promise<number> | Promise used to return the check result. The value **0** means that the application has the specified permission, and **-1** means the opposite. | +| Type | Description | +| -------- | -------- | +| Promise<number> | Promise used to return the check result. The value **0** means that the application has the specified permission, and **-1** means the opposite. | **Example** - ``` + ```js + import WantConstant from '@ohos.ability.wantConstant'; + let accessTokenId =1 let uri = "fileshare:///com.samples.filesharetest.FileShare/person/10" UriPermissionManager.verifyUriPermission(uri, wantConstant.Flags.FLAG_AUTH_READ_URI_PERMISSION, accessTokenId) .then((data) => { diff --git a/en/application-dev/reference/apis/js-apis-wantAgent.md b/en/application-dev/reference/apis/js-apis-wantAgent.md index d3d17810360c3ffa6074118413daddcb67fce31f..971c27adb786b1341706c97a064b85a70a0d9a6a 100644 --- a/en/application-dev/reference/apis/js-apis-wantAgent.md +++ b/en/application-dev/reference/apis/js-apis-wantAgent.md @@ -29,7 +29,6 @@ Obtains a **WantAgent** object. This API uses an asynchronous callback to return ```js import WantAgent from '@ohos.wantAgent'; -import { OperationType, WantAgentFlags } from '@ohos.wantagent'; // getWantAgent callback function getWantAgentCallback(err, data) { @@ -58,9 +57,9 @@ var wantAgentInfo = { } } ], - operationType: OperationType.START_ABILITIES, + operationType: WantAgent.OperationType.START_ABILITIES, requestCode: 0, - wantAgentFlags:[WantAgentFlags.UPDATE_PRESENT_FLAG] + wantAgentFlags:[WantAgent.WantAgentFlags.UPDATE_PRESENT_FLAG] } WantAgent.getWantAgent(wantAgentInfo, getWantAgentCallback) @@ -92,7 +91,7 @@ Obtains a **WantAgent** object. This API uses a promise to return the result. ```js import WantAgent from '@ohos.wantAgent'; -import { OperationType, WantAgentFlags } from '@ohos.wantagent'; + // WantAgentInfo object var wantAgentInfo = { @@ -117,9 +116,9 @@ var wantAgentInfo = { } } ], - operationType: OperationType.START_ABILITIES, + operationType: WantAgent.OperationType.START_ABILITIES, requestCode: 0, - wantAgentFlags:[WantAgentFlags.UPDATE_PRESENT_FLAG] + wantAgentFlags:[WantAgent.WantAgentFlags.UPDATE_PRESENT_FLAG] } WantAgent.getWantAgent(wantAgentInfo).then((data) => { @@ -148,7 +147,7 @@ Obtains the bundle name of a **WantAgent** object. This API uses an asynchronous ```js import WantAgent from '@ohos.wantAgent'; -import { OperationType, WantAgentFlags } from '@ohos.wantagent'; + // WantAgent object var wantAgent; @@ -185,9 +184,9 @@ var wantAgentInfo = { } } ], - operationType: OperationType.START_ABILITIES, + operationType: WantAgent.OperationType.START_ABILITIES, requestCode: 0, - wantAgentFlags:[WantAgentFlags.UPDATE_PRESENT_FLAG] + wantAgentFlags:[WantAgent.WantAgentFlags.UPDATE_PRESENT_FLAG] } WantAgent.getWantAgent(wantAgentInfo, getWantAgentCallback) @@ -225,7 +224,7 @@ Obtains the bundle name of a **WantAgent** object. This API uses a promise to re ```js import WantAgent from '@ohos.wantAgent'; -import { OperationType, WantAgentFlags } from '@ohos.wantagent'; + // WantAgent object var wantAgent; @@ -253,9 +252,9 @@ var wantAgentInfo = { } } ], - operationType: OperationType.START_ABILITIES, + operationType: WantAgent.OperationType.START_ABILITIES, requestCode: 0, - wantAgentFlags:[WantAgentFlags.UPDATE_PRESENT_FLAG] + wantAgentFlags:[WantAgent.WantAgentFlags.UPDATE_PRESENT_FLAG] } WantAgent.getWantAgent(wantAgentInfo).then((data) => { @@ -289,7 +288,7 @@ Obtains the user ID of a **WantAgent** object. This API uses an asynchronous cal ```js import WantAgent from '@ohos.wantAgent'; -import { OperationType, WantAgentFlags } from '@ohos.wantagent'; + // WantAgent object var wantAgent; @@ -326,9 +325,9 @@ var wantAgentInfo = { } } ], - operationType: OperationType.START_ABILITIES, + operationType: WantAgent.OperationType.START_ABILITIES, requestCode: 0, - wantAgentFlags:[WantAgentFlags.UPDATE_PRESENT_FLAG] + wantAgentFlags:[WantAgent.WantAgentFlags.UPDATE_PRESENT_FLAG] } WantAgent.getWantAgent(wantAgentInfo, getWantAgentCallback) @@ -366,7 +365,7 @@ Obtains the user ID of a **WantAgent** object. This API uses a promise to return ```js import WantAgent from '@ohos.wantAgent'; -import { OperationType, WantAgentFlags } from '@ohos.wantagent'; + // WantAgent object var wantAgent; @@ -394,9 +393,9 @@ var wantAgentInfo = { } } ], - operationType: OperationType.START_ABILITIES, + operationType: WantAgent.OperationType.START_ABILITIES, requestCode: 0, - wantAgentFlags:[WantAgentFlags.UPDATE_PRESENT_FLAG] + wantAgentFlags:[WantAgent.WantAgentFlags.UPDATE_PRESENT_FLAG] } WantAgent.getWantAgent(wantAgentInfo).then((data) => { @@ -430,7 +429,7 @@ Obtains the want in a **WantAgent** object. This API uses an asynchronous callba ```js import WantAgent from '@ohos.wantAgent'; -import { OperationType, WantAgentFlags } from '@ohos.wantagent'; + // WantAgent object var wantAgent; @@ -467,9 +466,9 @@ var wantAgentInfo = { } } ], - operationType: OperationType.START_ABILITIES, + operationType: WantAgent.OperationType.START_ABILITIES, requestCode: 0, - wantAgentFlags:[WantAgentFlags.UPDATE_PRESENT_FLAG] + wantAgentFlags:[WantAgent.WantAgentFlags.UPDATE_PRESENT_FLAG] } WantAgent.getWantAgent(wantAgentInfo, getWantAgentCallback) @@ -507,7 +506,7 @@ Obtains the want in a **WantAgent** object. This API uses a promise to return th ```js import WantAgent from '@ohos.wantAgent'; -import { OperationType, WantAgentFlags } from '@ohos.wantagent'; + // WantAgent object var wantAgent; @@ -535,9 +534,9 @@ var wantAgentInfo = { } } ], - operationType: OperationType.START_ABILITIES, + operationType: WantAgent.OperationType.START_ABILITIES, requestCode: 0, - wantAgentFlags:[WantAgentFlags.UPDATE_PRESENT_FLAG] + wantAgentFlags:[WantAgent.WantAgentFlags.UPDATE_PRESENT_FLAG] } WantAgent.getWantAgent(wantAgentInfo).then((data) => { @@ -571,7 +570,7 @@ Cancels a **WantAgent** object. This API uses an asynchronous callback to return ```js import WantAgent from '@ohos.wantAgent'; -import { OperationType, WantAgentFlags } from '@ohos.wantagent'; + // WantAgent object var wantAgent; @@ -608,9 +607,9 @@ var wantAgentInfo = { } } ], - operationType: OperationType.START_ABILITIES, + operationType: WantAgent.OperationType.START_ABILITIES, requestCode: 0, - wantAgentFlags:[WantAgentFlags.UPDATE_PRESENT_FLAG] + wantAgentFlags:[WantAgent.WantAgentFlags.UPDATE_PRESENT_FLAG] } WantAgent.getWantAgent(wantAgentInfo, getWantAgentCallback) @@ -648,7 +647,7 @@ Cancels a **WantAgent** object. This API uses a promise to return the result. ```js import WantAgent from '@ohos.wantAgent'; -import { OperationType, WantAgentFlags } from '@ohos.wantagent'; + // WantAgent object var wantAgent; @@ -676,9 +675,9 @@ var wantAgentInfo = { } } ], - operationType: OperationType.START_ABILITIES, + operationType: WantAgent.OperationType.START_ABILITIES, requestCode: 0, - wantAgentFlags:[WantAgentFlags.UPDATE_PRESENT_FLAG] + wantAgentFlags:[WantAgent.WantAgentFlags.UPDATE_PRESENT_FLAG] } WantAgent.getWantAgent(wantAgentInfo).then((data) => { @@ -713,7 +712,7 @@ Triggers a **WantAgent** object. This API uses an asynchronous callback to retur ```js import WantAgent from '@ohos.wantAgent'; -import { OperationType, WantAgentFlags } from '@ohos.wantagent'; + // WantAgent object var wantAgent; @@ -750,15 +749,15 @@ var wantAgentInfo = { } } ], - operationType: OperationType.START_ABILITIES, + operationType: WantAgent.OperationType.START_ABILITIES, requestCode: 0, - wantAgentFlags:[WantAgentFlags.UPDATE_PRESENT_FLAG] + wantAgentFlags:[WantAgent.WantAgentFlags.UPDATE_PRESENT_FLAG] } WantAgent.getWantAgent(wantAgentInfo, getWantAgentCallback) -// trigger callback -function triggerCallback(err, data) { +//trigger callback +function triggerCallback(data) { console.info("==========================>triggerCallback=======================>"); } @@ -790,7 +789,7 @@ Checks whether two **WantAgent** objects are equal. This API uses an asynchronou ```js import WantAgent from '@ohos.wantAgent'; -import { OperationType, WantAgentFlags } from '@ohos.wantagent'; + // WantAgent object var wantAgent1; @@ -829,9 +828,9 @@ var wantAgentInfo = { } } ], - operationType: OperationType.START_ABILITIES, + operationType: WantAgent.OperationType.START_ABILITIES, requestCode: 0, - wantAgentFlags:[WantAgentFlags.UPDATE_PRESENT_FLAG] + wantAgentFlags:[WantAgent.WantAgentFlags.UPDATE_PRESENT_FLAG] } WantAgent.getWantAgent(wantAgentInfo, getWantAgentCallback) @@ -870,7 +869,7 @@ Checks whether two **WantAgent** objects are equal. This API uses a promise to r ```js import WantAgent from '@ohos.wantAgent'; -import { OperationType, WantAgentFlags } from '@ohos.wantagent'; + // WantAgent object var wantAgent1; @@ -899,9 +898,9 @@ var wantAgentInfo = { } } ], - operationType: OperationType.START_ABILITIES, + operationType: WantAgent.OperationType.START_ABILITIES, requestCode: 0, - wantAgentFlags:[WantAgentFlags.UPDATE_PRESENT_FLAG] + wantAgentFlags:[WantAgent.WantAgentFlags.UPDATE_PRESENT_FLAG] } WantAgent.getWantAgent(wantAgentInfo).then((data) => { @@ -915,6 +914,135 @@ WantAgent.equal(wantAgent1, wantAgent2).then((data) => { }); ``` +## WantAgent.getOperationType9+ + +getOperationType(agent: WantAgent, callback: AsyncCallback\): void; + +Obtains the operation type of a **WantAgent** object. This API uses an asynchronous callback to return the result. + +**System capability**: SystemCapability.Ability.AbilityRuntime.Core + +**Parameters** + +| Name | Readable | Writable | Type | Mandatory | Description | +| ---------- | --- | ---- | ------------------------ | ---- | --------------------------------------- | +| agent | Yes | No | WantAgent | Yes | Target **WantAgent** object. | +| callback | Yes | No | AsyncCallback\ | Yes | Callback used to return the operation type. | + +**Example** + +```js +import WantAgent from '@ohos.wantAgent'; + +//wantAgent���� +var wantAgent; + +//WantAgentInfo���� +var wantAgentInfo = { + wants: [ + { + deviceId: "deviceId", + bundleName: "com.neu.setResultOnAbilityResultTest1", + abilityName: "com.example.test.MainAbility", + action: "action1", + entities: ["entity1"], + type: "MIMETYPE", + uri: "key={true,true,false}", + parameters: + { + mykey0: 2222, + mykey1: [1, 2, 3], + mykey2: "[1, 2, 3]", + mykey3: "ssssssssssssssssssssssssss", + mykey4: [false, true, false], + mykey5: ["qqqqq", "wwwwww", "aaaaaaaaaaaaaaaaa"], + mykey6: true, + } + } + ], + operationType: WantAgent.OperationType.START_ABILITIES, + requestCode: 0, + wantAgentFlags:[WantAgent.WantAgentFlags.UPDATE_PRESENT_FLAG] +} + +WantAgent.getWantAgent(wantAgentInfo).then((data) => { + console.info("==========================>getWantAgentCallback=======================>"); + wantAgent = data; +}); + +WantAgent.getOperationType(wantAgent, (OperationType) => { + console.log('----------- getOperationType ----------, OperationType: ' + OperationType); +}) +``` + +## WantAgent.getOperationType9+ + +getOperationType(agent: WantAgent): Promise\; + +Obtains the operation type of a **WantAgent** object. This API uses a promise to return the result. + +**System capability**: SystemCapability.Ability.AbilityRuntime.Core + +**Parameters** + +| Name | Readable | Writable | Type | Mandatory | Description | +| ---------- | --- | ---- | --------- | ---- | ------------- | +| agent | Yes | No | WantAgent | Yes | Target **WantAgent** object. | + +**Return value** + +| Type | Description | +| ---------------- | ------------------------------------------ | +| Promise\ | Promise used to return the operation type. | + +**Example** + +```js +import WantAgent from '@ohos.wantAgent'; + +//wantAgent���� +var wantAgent; + +//WantAgentInfo���� +var wantAgentInfo = { + wants: [ + { + deviceId: "deviceId", + bundleName: "com.neu.setResultOnAbilityResultTest1", + abilityName: "com.example.test.MainAbility", + action: "action1", + entities: ["entity1"], + type: "MIMETYPE", + uri: "key={true,true,false}", + parameters: + { + mykey0: 2222, + mykey1: [1, 2, 3], + mykey2: "[1, 2, 3]", + mykey3: "ssssssssssssssssssssssssss", + mykey4: [false, true, false], + mykey5: ["qqqqq", "wwwwww", "aaaaaaaaaaaaaaaaa"], + mykey6: true, + } + } + ], + operationType: WantAgent.OperationType.START_ABILITIES, + requestCode: 0, + wantAgentFlags:[WantAgent.WantAgentFlags.UPDATE_PRESENT_FLAG] +} + +WantAgent.getWantAgent(wantAgentInfo).then((data) => { + console.info("==========================>getWantAgentCallback=======================>"); + wantAgent = data; +}); + +WantAgent.getOperationType(wantAgent).then((OperationType) => { + console.log('getOperationType success, OperationType: ' + OperationType); +}).catch((err) => { + console.log('getOperationType fail, err: ' + err); +}) +``` + ## WantAgentInfo