From a515c3259bfd4e9423eee4a1ecebba5fad6fe99f Mon Sep 17 00:00:00 2001 From: wusongqing Date: Wed, 8 Jun 2022 15:57:20 +0800 Subject: [PATCH] updated docs Signed-off-by: wusongqing --- .../apis/js-apis-application-abilitystage.md | 28 ++++++++++--------- .../js-apis-application-applicationContext.md | 5 ++++ .../apis/js-apis-extension-context.md | 13 ++++----- .../reference/apis/js-apis-featureAbility.md | 25 ++++++++--------- .../apis/js-apis-permissionrequestresult.md | 24 +++++++++++++++- 5 files changed, 61 insertions(+), 34 deletions(-) diff --git a/en/application-dev/reference/apis/js-apis-application-abilitystage.md b/en/application-dev/reference/apis/js-apis-application-abilitystage.md index 8e501a482e..bb9c758f36 100644 --- a/en/application-dev/reference/apis/js-apis-application-abilitystage.md +++ b/en/application-dev/reference/apis/js-apis-application-abilitystage.md @@ -1,6 +1,6 @@ # AbilityStage -> **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. @@ -45,15 +45,15 @@ Called when a specified ability is started. **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 | - | -------- | -------- | - | string | Returns an ability ID. If this ability has been started, no new instance is created and the ability is placed at the top of the stack. Otherwise, a new instance is created and started. | + | Type| Description| + | -------- | -------- | + | string | Returns an ability ID. If this ability has been started, no new instance is created and the ability is placed at the top of the stack. Otherwise, a new instance is created and started.| **Example** @@ -77,9 +77,9 @@ Called when the global configuration is updated. **Parameters** - | Name | Type | Mandatory | Description | - | -------- | -------- | -------- | -------- | - | config | [Configuration](js-apis-configuration.md) | Yes | Callback invoked when the global configuration is updated. The global configuration indicates the configuration of the environment where the application is running and includes the language and color mode. | + | Name| Type| Mandatory| Description| + | -------- | -------- | -------- | -------- | + | config | [Configuration](js-apis-configuration.md) | Yes| Callback invoked when the global configuration is updated. The global configuration indicates the configuration of the environment where the application is running and includes the language and color mode.| **Example** @@ -92,10 +92,12 @@ Called when the global configuration is updated. ``` ## AbilityStage.context +context: AbilityStageContext; + Describes the configuration information about the context. **System capability**: SystemCapability.Ability.AbilityRuntime.Core - | Name | Type | Description | - | ----------- | --------------------------- | ------------------------------------------------------------ | - | context | [AbilityStageContext](js-apis-featureAbility.md) | Called when initialization is performed during ability startup. | +| Name | Type | Description | +| ----------- | --------------------------- | ------------------------------------------------------------ | +| context | [AbilityStageContext](js-apis-featureAbility.md) | Called when initialization is performed during ability startup.| diff --git a/en/application-dev/reference/apis/js-apis-application-applicationContext.md b/en/application-dev/reference/apis/js-apis-application-applicationContext.md index 0dfc9de068..b34cb68eac 100644 --- a/en/application-dev/reference/apis/js-apis-application-applicationContext.md +++ b/en/application-dev/reference/apis/js-apis-application-applicationContext.md @@ -6,6 +6,11 @@ Provides application-level context and APIs for registering and deregistering the ability lifecycle listener in an application. +## Modules to Import + +``` +import Ability from '@ohos.application.Ability'; +``` ## How to Use 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 630dc3f6a7..afd1cec9cd 100644 --- a/en/application-dev/reference/apis/js-apis-extension-context.md +++ b/en/application-dev/reference/apis/js-apis-extension-context.md @@ -3,19 +3,18 @@ > **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. -```js -import DataShareExtensionAbility from '@ohos.application.DataShareExtensionAbility'; -``` - - 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-featureAbility.md b/en/application-dev/reference/apis/js-apis-featureAbility.md index b57f529219..578fb21ef4 100644 --- a/en/application-dev/reference/apis/js-apis-featureAbility.md +++ b/en/application-dev/reference/apis/js-apis-featureAbility.md @@ -1,6 +1,6 @@ # FeatureAbility Module (JavaScript) -> ![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. ## Constraints @@ -44,7 +44,7 @@ featureAbility.startAbility( deviceId: "", bundleName: "com.example.myapplication", /* In the FA model, abilityName consists of package and ability name. */ - abilityName: "com.example.entry.secondAbility",, + abilityName: "com.example.entry.secondAbility", uri: "" }, }, @@ -139,7 +139,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 +157,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 +185,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 +291,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 +343,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 +391,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 +414,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 +437,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 +461,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 +484,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=======================>"); }); @@ -918,7 +918,6 @@ Enumerates operation types of the Data ability. | ------------------- | ---- | -------------------- | ---- | -------------------------------------- | | want | Read-only | [Want](js-apis-application-Want.md) | Yes | Information about the ability to start. | | abilityStartSetting | Read-only | {[key: string]: any} | No | Special attribute of the ability to start. This attribute can be passed in the method call.| - | ## flags diff --git a/en/application-dev/reference/apis/js-apis-permissionrequestresult.md b/en/application-dev/reference/apis/js-apis-permissionrequestresult.md index 0246c42771..de7be38f0c 100644 --- a/en/application-dev/reference/apis/js-apis-permissionrequestresult.md +++ b/en/application-dev/reference/apis/js-apis-permissionrequestresult.md @@ -3,7 +3,6 @@ > **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. - Provides the permission request result. ## Modules to Import @@ -12,6 +11,29 @@ Provides the permission request result. import Ability from '@ohos.application.Ability' ``` +## How to Use + +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 -- GitLab