From 71d56381c4cc309d3cdef35b83767a51715a5d80 Mon Sep 17 00:00:00 2001 From: Gloria Date: Sat, 24 Sep 2022 09:26:57 +0800 Subject: [PATCH] Update docs against 8751+8711+8895 Signed-off-by: wusongqing --- en/application-dev/ability/stage-ability.md | 8 ++- .../reference/apis/js-apis-ability-context.md | 58 +++++++++---------- 2 files changed, 34 insertions(+), 32 deletions(-) diff --git a/en/application-dev/ability/stage-ability.md b/en/application-dev/ability/stage-ability.md index d2b8903083..1f170ebf80 100644 --- a/en/application-dev/ability/stage-ability.md +++ b/en/application-dev/ability/stage-ability.md @@ -108,7 +108,9 @@ To create Page abilities for an application in the stage model, you must impleme } ``` ### Obtaining AbilityStage and Ability Configurations -Both the `AbilityStage` and `Ability` classes have the `context` attribute. An application can obtain the context of an `Ability` instance through `this.context` to obtain the configuration details. The following example shows how an application obtains the bundle code directory, HAP file name, ability name, and system language through the `context` attribute in the `AbilityStage` class. The sample code is as follows: +Both the `AbilityStage` and `Ability` classes have the `context` attribute. An application can obtain the context of an `Ability` instance through `this.context` to obtain the configuration details. + +The following example shows how an application obtains the bundle code directory, HAP file name, ability name, and system language through the `context` attribute in the `AbilityStage` class. The sample code is as follows: ```ts import AbilityStage from "@ohos.application.AbilityStage" @@ -123,7 +125,7 @@ export default class MyAbilityStage extends AbilityStage { console.log("MyAbilityStage hap module mainAbilityName" + currentHapModuleInfo.mainAbilityName) let config = this.context.config - console.log("MainAbility config language" + config.language) + console.log("MyAbilityStage config language" + config.language) } } ``` @@ -142,7 +144,7 @@ export default class MainAbility extends Ability { console.log("MainAbility ability name" + abilityInfo.name) let config = this.context.config - console.log("MainAbility config language" + config.language) + console.log("MyAbilityStage config language" + config.language) } } ``` 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 c378d9e24c..b3aae5254d 100644 --- a/en/application-dev/reference/apis/js-apis-ability-context.md +++ b/en/application-dev/reference/apis/js-apis-ability-context.md @@ -78,7 +78,7 @@ Starts an ability with start options specified. This API uses an asynchronous ca | callback | AsyncCallback<void> | Yes| Callback used to return the result.| **Example** - + ```js var want = { "deviceId": "", @@ -127,7 +127,7 @@ Starts an ability. This API uses a promise to return the result. windowMode: 0, }; this.context.startAbility(want, options) - .then((data) => { + .then(() => { console.log('Operation successful.') }).catch((error) => { console.log('Operation failed.'); @@ -407,8 +407,8 @@ Starts a new Service Extension ability. This API uses a promise to return the re "abilityName": "MainAbility" }; this.context.startServiceExtensionAbility(want) - .then((data) => { - console.log('---------- startServiceExtensionAbility success, data: -----------', data); + .then(() => { + console.log('---------- startServiceExtensionAbility success -----------'); }) .catch((err) => { console.log('---------- startServiceExtensionAbility fail, err: -----------', err); @@ -477,8 +477,8 @@ Starts a new Service Extension ability with the account ID specified. This API u }; var accountId = 100; this.context.startServiceExtensionAbilityWithAccount(want,accountId) - .then((data) => { - console.log('---------- startServiceExtensionAbilityWithAccount success, data: -----------', data); + .then(() => { + console.log('---------- startServiceExtensionAbilityWithAccount success -----------'); }) .catch((err) => { console.log('---------- startServiceExtensionAbilityWithAccount fail, err: -----------', err); @@ -539,8 +539,8 @@ Stops a Service Extension ability in the same application. This API uses a promi "abilityName": "MainAbility" }; this.context.stopServiceExtensionAbility(want) - .then((data) => { - console.log('---------- stopServiceExtensionAbility success, data: -----------', data); + .then(() => { + console.log('---------- stopServiceExtensionAbility success -----------'); }) .catch((err) => { console.log('---------- stopServiceExtensionAbility fail, err: -----------', err); @@ -610,8 +610,8 @@ Stops a Service Extension ability in the same application with the account ID sp }; var accountId = 100; this.context.stopServiceExtensionAbilityWithAccount(want,accountId) - .then((data) => { - console.log('---------- stopServiceExtensionAbilityWithAccount success, data: -----------', data); + .then(() => { + console.log('---------- stopServiceExtensionAbilityWithAccount success -----------'); }) .catch((err) => { console.log('---------- stopServiceExtensionAbilityWithAccount fail, err: -----------', err); @@ -658,8 +658,8 @@ Terminates this ability. This API uses a promise to return the result. **Example** ```js - this.context.terminateSelf().then((data) => { - console.log('success:' + JSON.stringify(data)); + this.context.terminateSelf().then(() => { + console.log('success'); }).catch((error) => { console.log('failed:' + JSON.stringify(error)); }); @@ -836,11 +836,11 @@ Disconnects a connection. This API uses a promise to return the result. | Promise\ | Promise used to return the result.| **Example** - + ```js var connectionNumber = 0; - this.context.disconnectAbility(connectionNumber).then((data) => { - console.log('disconnectAbility success, data: ', data); + this.context.disconnectAbility(connectionNumber).then(() => { + console.log('disconnectAbility success'); }).catch((err) => { console.log('disconnectAbility fail, err: ', err); }); @@ -893,7 +893,7 @@ Obtains the caller interface of the specified ability, and if the specified abil | Promise<Caller> | Promise used to return the caller object to communicate with.| **Example** - + ```js import Ability from '@ohos.application.Ability'; var caller; @@ -1020,8 +1020,8 @@ Starts an ability with the account ID specified. This API uses a promise to retu windowMode: 0, }; this.context.startAbilityWithAccount(want, accountId, options) - .then((data) => { - console.log('---------- startAbilityWithAccount success, data: -----------', data); + .then(() => { + console.log('---------- startAbilityWithAccount success -----------'); }) .catch((err) => { console.log('---------- startAbilityWithAccount fail, err: -----------', err); @@ -1044,13 +1044,13 @@ Requests permissions from the user by displaying a dialog box. This API uses an | callback | AsyncCallback<[PermissionRequestResult](js-apis-permissionrequestresult.md)> | Yes| Callback used to return the result.| **Example** - + ```js var permissions=['com.example.permission'] this.context.requestPermissionsFromUser(permissions,(result) => { console.log('requestPermissionsFromUserresult:' + JSON.stringify(result)); }); - + ``` @@ -1075,7 +1075,7 @@ Requests permissions from the user by displaying a dialog box. This API uses a p | Promise<[PermissionRequestResult](js-apis-permissionrequestresult.md)> | Promise used to return the result.| **Example** - + ```js var permissions=['com.example.permission'] this.context.requestPermissionsFromUser(permissions).then((data) => { @@ -1103,7 +1103,7 @@ Sets a label for this ability in the mission. This API uses an asynchronous call | callback | AsyncCallback<void> | Yes| Callback used to return the result.| **Example** - + ```js this.context.setMissionLabel("test",(result) => { console.log('requestPermissionsFromUserresult:' + JSON.stringify(result)); @@ -1132,10 +1132,10 @@ Sets a label for this ability in the mission. This API uses a promise to return | Promise<void> | Promise used to return the result.| **Example** - + ```js - this.context.setMissionLabel("test").then((data) => { - console.log('success:' + JSON.stringify(data)); + this.context.setMissionLabel("test").then(() => { + console.log('success'); }).catch((error) => { console.log('failed:' + JSON.stringify(error)); }); @@ -1158,7 +1158,7 @@ Sets an icon for this ability in the mission. This API uses an asynchronous call | callback | AsyncCallback\ | Yes| Callback used to return the result.| **Example** - + ```js import image from '@ohos.multimedia.image' var imagePixelMap; @@ -1205,7 +1205,7 @@ Sets an icon for this ability in the mission. This API uses a promise to return | Promise<void> | Promise used to return the result.| **Example** - + ```js import image from '@ohos.multimedia.image' var imagePixelMap; @@ -1224,8 +1224,8 @@ Sets an icon for this ability in the mission. This API uses a promise to return console.log('--------- createPixelMap fail, err: ---------', err) }); this.context.setMissionIcon(imagePixelMap) - .then((data) => { - console.log('-------------- setMissionIcon success, data: -------------', data); + .then(() => { + console.log('-------------- setMissionIcon success -------------'); }) .catch((err) => { console.log('-------------- setMissionIcon fail, err: -------------', err); -- GitLab