提交 a515c325 编写于 作者: W wusongqing

updated docs

Signed-off-by: Nwusongqing <wusongqing@huawei.com>
上级 1632d97f
# AbilityStage # AbilityStage
> **NOTE**<br> > **NOTE**<br/>
> 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 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. ...@@ -45,15 +45,15 @@ Called when a specified ability is started.
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | 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. | | want | [Want](js-apis-application-Want.md) | Yes| Information about the ability to start, such as the ability name and bundle name.|
**Return value** **Return value**
| Type | Description | | 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. | | 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** **Example**
...@@ -77,9 +77,9 @@ Called when the global configuration is updated. ...@@ -77,9 +77,9 @@ Called when the global configuration is updated.
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | 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. | | 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** **Example**
...@@ -92,10 +92,12 @@ Called when the global configuration is updated. ...@@ -92,10 +92,12 @@ Called when the global configuration is updated.
``` ```
## AbilityStage.context ## AbilityStage.context
context: AbilityStageContext;
Describes the configuration information about the context. Describes the configuration information about the context.
**System capability**: SystemCapability.Ability.AbilityRuntime.Core **System capability**: SystemCapability.Ability.AbilityRuntime.Core
| Name | Type | Description | | Name | Type | Description |
| ----------- | --------------------------- | ------------------------------------------------------------ | | ----------- | --------------------------- | ------------------------------------------------------------ |
| context | [AbilityStageContext](js-apis-featureAbility.md) | Called when initialization is performed during ability startup. | | context | [AbilityStageContext](js-apis-featureAbility.md) | Called when initialization is performed during ability startup.|
...@@ -6,6 +6,11 @@ ...@@ -6,6 +6,11 @@
Provides application-level context and APIs for registering and deregistering the ability lifecycle listener in an application. 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 ## How to Use
......
...@@ -3,19 +3,18 @@ ...@@ -3,19 +3,18 @@
> **NOTE**<br/> > **NOTE**<br/>
> 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 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**. Implements the extension context. This module is inherited from **Context**.
## Modules to Import
```js
import DataShareExtensionAbility from '@ohos.application.DataShareExtensionAbility';
```
## Attributes ## Attributes
**System capability**: SystemCapability.Ability.AbilityRuntime.Core **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.| | config | Configuration | Yes| No| Module configuration information.|
# FeatureAbility Module (JavaScript) # FeatureAbility Module (JavaScript)
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**<br/> > **NOTE**<br/>
> 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 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 ## Constraints
...@@ -44,7 +44,7 @@ featureAbility.startAbility( ...@@ -44,7 +44,7 @@ featureAbility.startAbility(
deviceId: "", deviceId: "",
bundleName: "com.example.myapplication", bundleName: "com.example.myapplication",
/* In the FA model, abilityName consists of package and ability name. */ /* In the FA model, abilityName consists of package and ability name. */
abilityName: "com.example.entry.secondAbility",, abilityName: "com.example.entry.secondAbility",
uri: "" uri: ""
}, },
}, },
...@@ -139,7 +139,7 @@ Starts an ability. This API uses a callback to return the execution result when ...@@ -139,7 +139,7 @@ Starts an ability. This API uses a callback to return the execution result when
**Example** **Example**
```javascript ```javascript
import featureAbility from '@ohos.ability.featureability'; import featureAbility from '@ohos.ability.featureAbility';
import wantConstant from '@ohos.ability.wantConstant' import wantConstant from '@ohos.ability.wantConstant'
featureAbility.startAbilityForResult( featureAbility.startAbilityForResult(
{ {
...@@ -157,7 +157,7 @@ featureAbility.startAbilityForResult( ...@@ -157,7 +157,7 @@ featureAbility.startAbilityForResult(
}, },
}, },
(err, data) => { (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 ...@@ -185,7 +185,7 @@ Starts an ability. This API uses a promise to return the execution result when t
**Example** **Example**
```javascript ```javascript
import featureAbility from '@ohos.ability.featureability'; import featureAbility from '@ohos.ability.featureAbility';
import wantConstant from '@ohos.ability.wantConstant' import wantConstant from '@ohos.ability.wantConstant'
featureAbility.startAbilityForResult( featureAbility.startAbilityForResult(
{ {
...@@ -291,7 +291,7 @@ Destroys this Page ability, with the result code and data sent to the caller. Th ...@@ -291,7 +291,7 @@ Destroys this Page ability, with the result code and data sent to the caller. Th
**Example** **Example**
```javascript ```javascript
import featureAbility from '@ohos.ability.featureability'; import featureAbility from '@ohos.ability.featureAbility';
import wantConstant from '@ohos.ability.wantConstant' import wantConstant from '@ohos.ability.wantConstant'
featureAbility.terminateSelfWithResult( featureAbility.terminateSelfWithResult(
{ {
...@@ -343,7 +343,7 @@ Checks whether the main window of this ability has the focus. This API uses a ca ...@@ -343,7 +343,7 @@ Checks whether the main window of this ability has the focus. This API uses a ca
**Example** **Example**
```javascript ```javascript
import featureAbility from '@ohos.ability.featureability'; import featureAbility from '@ohos.ability.featureAbility';
featureAbility.hasWindowFocus() featureAbility.hasWindowFocus()
``` ```
...@@ -391,7 +391,7 @@ Obtains the **Want** object sent from this ability. This API uses a callback to ...@@ -391,7 +391,7 @@ Obtains the **Want** object sent from this ability. This API uses a callback to
**Example** **Example**
```javascript ```javascript
import featureAbility from '@ohos.ability.featureability'; import featureAbility from '@ohos.ability.featureAbility';
featureAbility.getWant() featureAbility.getWant()
``` ```
...@@ -414,7 +414,7 @@ Obtains the **Want** object sent from this ability. This API uses a promise to r ...@@ -414,7 +414,7 @@ Obtains the **Want** object sent from this ability. This API uses a promise to r
**Example** **Example**
```javascript ```javascript
import featureAbility from '@ohos.ability.featureability'; import featureAbility from '@ohos.ability.featureAbility';
featureAbility.getWant().then((data) => { featureAbility.getWant().then((data) => {
console.info("==========================>getWantCallBack=======================>"); console.info("==========================>getWantCallBack=======================>");
}); });
...@@ -437,7 +437,7 @@ Obtains the application context. ...@@ -437,7 +437,7 @@ Obtains the application context.
**Example** **Example**
```javascript ```javascript
import featureAbility from '@ohos.ability.featureability'; import featureAbility from '@ohos.ability.featureAbility';
var context = featureAbility.getContext() var context = featureAbility.getContext()
context.getBundleName() context.getBundleName()
``` ```
...@@ -461,7 +461,7 @@ Destroys this Page ability, with the result code and data sent to the caller. Th ...@@ -461,7 +461,7 @@ Destroys this Page ability, with the result code and data sent to the caller. Th
**Example** **Example**
```javascript ```javascript
import featureAbility from '@ohos.ability.featureability'; import featureAbility from '@ohos.ability.featureAbility';
featureAbility.terminateSelf() featureAbility.terminateSelf()
``` ```
...@@ -484,7 +484,7 @@ Destroys this Page ability, with the result code and data sent to the caller. Th ...@@ -484,7 +484,7 @@ Destroys this Page ability, with the result code and data sent to the caller. Th
**Example** **Example**
```javascript ```javascript
import featureAbility from '@ohos.ability.featureability'; import featureAbility from '@ohos.ability.featureAbility';
featureAbility.terminateSelf().then((data) => { featureAbility.terminateSelf().then((data) => {
console.info("==========================>terminateSelfCallBack=======================>"); console.info("==========================>terminateSelfCallBack=======================>");
}); });
...@@ -918,7 +918,6 @@ Enumerates operation types of the Data ability. ...@@ -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. | | 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.| | abilityStartSetting | Read-only | {[key: string]: any} | No | Special attribute of the ability to start. This attribute can be passed in the method call.|
|
## flags ## flags
......
...@@ -3,7 +3,6 @@ ...@@ -3,7 +3,6 @@
> **NOTE**<br> > **NOTE**<br>
> 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 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. Provides the permission request result.
## Modules to Import ## Modules to Import
...@@ -12,6 +11,29 @@ Provides the permission request result. ...@@ -12,6 +11,29 @@ Provides the permission request result.
import Ability from '@ohos.application.Ability' 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 ## Attributes
**System capability**: SystemCapability.Ability.AbilityRuntime.Core **System capability**: SystemCapability.Ability.AbilityRuntime.Core
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册