提交 45a546e0 编写于 作者: W wusongqing

updated docs against TR5026

Signed-off-by: Nwusongqing <wusongqing@huawei.com>
上级 188c64ed
# Ability
> ![icon-note.gif](public_sys-resources/icon-note.gif) **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.
Manages the ability lifecycle and context.
## Modules to Import
```
import Ability from '@ohos.application.Ability';
```
......@@ -23,6 +20,8 @@ import Ability from '@ohos.application.Ability';
| 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
......@@ -200,11 +199,12 @@ Called to save data during the ability migration preparation process.
**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;
}
}
```
......@@ -212,7 +212,7 @@ Called to save data during the ability migration preparation process.
## Ability.onNewWant
onNewWant(want: Want): void;
onNewWant(want: Want, launchParams: AbilityConstant.LaunchParam): void;
Called when the ability startup mode is set to singleton.
......@@ -223,13 +223,17 @@ Called when the ability startup mode is set to singleton.
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| want | [Want](js-apis-application-Want.md) | Yes| Want parameters, such as the ability name and bundle name.|
| launchParams | AbilityConstant.LaunchParam | Yes| Reason for the ability startup and the last abnormal exit.|
**Example**
```js
class myAbility extends Ability {
onNewWant(want) {
onNewWant(want, launchParams) {
console.log('onNewWant, want:' + want.abilityName);
if (launchParams.launchReason === AbilityConstant.LaunchReason.CONTINUATION) {
console.log('onNewWant, launchReason is continuation');
}
}
}
```
......@@ -259,6 +263,32 @@ Called when the configuration of the environment where the ability is running is
}
```
## Ability.dump
dump(params: Array\<string>): Array\<string>;
Called when the client information is dumped.
**System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| params | Array\<string> | 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
......@@ -291,6 +321,9 @@ Sends sequenceable data to the target ability.
```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;
......@@ -361,6 +394,9 @@ Sends sequenceable data to the target ability and obtains the sequenceable data
```js
import Ability from '@ohos.application.Ability';
class MyMessageAble{
name:""
str:""
num: 1
constructor(name, str) {
this.name = name;
this.str = str;
......@@ -445,7 +481,7 @@ Releases the caller interface of the target ability.
onRelease(callback: OnReleaseCallBack): void;
Registers a callback that is invoked when the Stub on the target ability is disconnected.
Registers a callback that is invoked when the stub on the target ability is disconnected.
**System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore
......@@ -509,6 +545,9 @@ Registers a caller notification callback, which is invoked when the target abili
```js
import Ability from '@ohos.application.Ability';
class MyMessageAble{
name:""
str:""
num: 1
constructor(name, str) {
this.name = name;
this.str = str;
......
......@@ -21,7 +21,7 @@ None
| Name | Type | Readable| Writable| Description |
| ------- | ------------------------------------------------------- | ---- | ---- | --------------------------------------------------- |
| context | [FormExtensionContext](js-apis-formextensioncontext.md) | Yes | No | Context of the **FormExtension**. This class is inherited from **ExtensionContext**.|
| context | [FormExtensionContext](js-apis-formextensioncontext.md) | Yes | No | Context of the **FormExtension**. This context is inherited from **ExtensionContext**.|
## onCreate
......@@ -227,7 +227,7 @@ Called when the configuration of the environment where the ability is running is
onAcquireFormState?(want: Want): formInfo.FormState;
Used by the widget provider to receive the widget state query request. By default, the initial widget state is returned.
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
......
......@@ -914,7 +914,7 @@ WantAgent.equal(wantAgent1, wantAgent2).then((data) => {
});
```
## WantAgent.getOperationType
## WantAgent.getOperationType<sup>9+</sup>
getOperationType(agent: WantAgent, callback: AsyncCallback\<number>): void;
......@@ -975,7 +975,7 @@ WantAgent.getOperationType(wantAgent, (OperationType) => {
})
```
## WantAgent.getOperationType
## WantAgent.getOperationType<sup>9+</sup>
getOperationType(agent: WantAgent): Promise\<number>;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册