diff --git a/en/application-dev/reference/apis/js-apis-Context.md b/en/application-dev/reference/apis/js-apis-Context.md index 1a4861251195d5cfd17c4c0b2496583b29c212e7..efc0435996bf02ef9e7c5fd046c60a1faaa17f42 100644 --- a/en/application-dev/reference/apis/js-apis-Context.md +++ b/en/application-dev/reference/apis/js-apis-Context.md @@ -1,7 +1,9 @@ # Context Module -> **NOTE**
-> The initial APIs of this module are supported since API version 6. Newly added APIs will be marked with a superscript to indicate their earliest API version. +> **NOTE** +> +> The initial APIs of this module are supported since API version 6. Newly added APIs will be marked with a superscript to indicate their earliest API version. +> The APIs of this module can be used only in the FA model. ## Modules to Import @@ -834,7 +836,7 @@ Obtains information of the current ability. This API uses an asynchronous callba | Name | Type | Mandatory| Description | | -------- | ---------------------- | ---- | ------------------------- | -| callback | AsyncCallback\<[AbilityInfo](#abilityInfo)> | Yes |Callback used to return the ability information.| +| callback | AsyncCallback\<[AbilityInfo](#abilityInfo)> | Yes | Callback used to return the ability information.| **Example** @@ -886,7 +888,7 @@ Obtains the context of the application. | Type | Description | | --------- |------ | -| Context |Application context.| +| Context | Application context.| **Example** @@ -928,14 +930,14 @@ Describes the HAP module information. | labelId | number | Yes | No | Module label ID. | | iconId | number | Yes | No | Module icon ID. | | backgroundImg | string | Yes | No | Module background image. | -| supportedModes | number | Yes | No | Modes supported by the module. | +| supportedModes | number | Yes | No | Running modes supported by the module. | | reqCapabilities | Array | Yes | No | Capabilities required for module running.| -| deviceTypes | Array | Yes | No | An array of supported device types.| -| abilityInfo | Array | Yes | No | Ability information. | +| deviceTypes | Array | Yes | No | Device types supported by the module.| +| abilityInfo | Array | Yes | No | Ability information. | | moduleName | string | Yes | No | Module name. | -| mainAbilityName | string | Yes | No | Name of the entrance ability. | -| installationFree | boolean | Yes | No | When installation-free is supported. | -| mainElementName | string | Yes| No| Information about the entry ability.| +| mainAbilityName | string | Yes | No | Name of the main ability. | +| installationFree | boolean | Yes | No | Whether installation-free is supported. | +| mainElementName | string | Yes| No| Information about the main ability.| ## AppVersionInfo7+ 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 5472f3dff854cb8e97499401954b850ec98e1fcd..88a0908ab11d2b345493aa1e364e48b328d62bd7 100644 --- a/en/application-dev/reference/apis/js-apis-ability-context.md +++ b/en/application-dev/reference/apis/js-apis-ability-context.md @@ -1,7 +1,9 @@ # AbilityContext -> **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. +> **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**. @@ -55,7 +57,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) @@ -85,7 +87,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, @@ -123,7 +125,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, @@ -374,7 +376,7 @@ 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; 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 e892b7c4cded2faa02adcaa2945103a021741be9..bdf719b34ed6e7ba0dcc227ff5866c8ae7b87a87 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,9 @@ # Ability -> **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. +> **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. @@ -347,7 +349,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; @@ -420,7 +422,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; @@ -459,7 +461,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; @@ -500,7 +502,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; diff --git a/en/application-dev/reference/apis/js-apis-featureAbility.md b/en/application-dev/reference/apis/js-apis-featureAbility.md index 578fb21ef40144ad14616abd58e9219dc57e3cbd..9ec94e3742fd02c72880475bb2fc59c34f296a14 100644 --- a/en/application-dev/reference/apis/js-apis-featureAbility.md +++ b/en/application-dev/reference/apis/js-apis-featureAbility.md @@ -923,7 +923,7 @@ Enumerates operation types of the Data ability. **System capability**: SystemCapability.Ability.AbilityBase -| Name | Name | Description | +| Name | Value | Description | | ------------------------------------ | ---------- | ---------------------------------------- | | FLAG_AUTH_READ_URI_PERMISSION | 0x00000001 | Indicates the permission to read the URI. | | FLAG_AUTH_WRITE_URI_PERMISSION | 0x00000002 | Indicates the permission to write the URI. | 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..518167d562ba8801223e206ad5b35ea07ea94936 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,17 @@ # ServiceExtensionContext -> ![icon-note.gif](public_sys-resources/icon-note.gif) **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. - +> **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 @@ -25,13 +31,18 @@ Starts an ability. This API uses a callback to return the result. **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)); + }); + } + } + ``` @@ -58,15 +69,22 @@ Starts an ability. This API uses a promise to return the result. **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)); + }); + } + } + + ``` @@ -87,9 +105,16 @@ Terminates this ability. This API uses a callback to return the result. **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)); + }); + } + } + + ``` @@ -110,11 +135,17 @@ Terminates this ability. This API uses a promise to return the result. **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)); + }); + } +} + ``` @@ -144,7 +175,7 @@ Connects this ability to a Service ability. ```js let want = { "bundleName": "com.example.myapp", - "abilityName": "com.example.myapp.MyAbility" + "abilityName": "MyAbility" }; let options = { onConnect: function(elementName, proxy) {}, @@ -173,9 +204,18 @@ Disconnects this ability from the Service ability. This API uses a callback to r **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)); + }); + } + } + + ``` @@ -202,11 +242,18 @@ Disconnects this ability from the Service ability. This API uses a promise to re **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)); + }); + } + } + ```