未验证 提交 28a99b67 编写于 作者: O openharmony_ci 提交者: Gitee

!4973 翻译完成:4296:Fix document interface question of ability

Merge pull request !4973 from wusongqing/TR4296
...@@ -3,13 +3,10 @@ ...@@ -3,13 +3,10 @@
> **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.
Manages the ability lifecycle and context. Manages the ability lifecycle and context.
## Modules to Import ## Modules to Import
``` ```
import Ability from '@ohos.application.Ability'; import Ability from '@ohos.application.Ability';
``` ```
...@@ -18,11 +15,11 @@ import Ability from '@ohos.application.Ability'; ...@@ -18,11 +15,11 @@ import Ability from '@ohos.application.Ability';
**System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore **System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore
| Name | Type | Readable | Writable | Description | | Name| Type| Readable| Writable| Description|
| -------- | -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- | -------- |
| context | [AbilityContext](js-apis-ability-context.md) | Yes | No | Context of an 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. | | 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. | | lastRequestWant | [Want](js-apis-application-Want.md) | Yes| No| Parameters used when the ability was started last time.|
## Ability.onCreate ## Ability.onCreate
...@@ -35,10 +32,10 @@ Called to initialize the service logic when an ability is created. ...@@ -35,10 +32,10 @@ Called to initialize the service logic when an ability is created.
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| want | [Want](js-apis-application-Want.md) | Yes | Information related to this ability, including the ability name and bundle name. | | want | [Want](js-apis-application-Want.md) | Yes| Information related to this ability, including the ability name and bundle name.|
| param | AbilityConstant.LaunchParam | Yes | Parameters for starting the ability, and the reason for the last abnormal exit. | | param | AbilityConstant.LaunchParam | Yes| Parameters for starting the ability, and the reason for the last abnormal exit.|
**Example** **Example**
...@@ -61,9 +58,9 @@ Called when a **WindowStage** is created for this ability. ...@@ -61,9 +58,9 @@ Called when a **WindowStage** is created for this ability.
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| windowStage | window.WindowStage | Yes | **WindowStage** information. | | windowStage | window.WindowStage | Yes| **WindowStage** information.|
**Example** **Example**
...@@ -105,9 +102,9 @@ Called when the **WindowStage** is restored during the migration of this ability ...@@ -105,9 +102,9 @@ Called when the **WindowStage** is restored during the migration of this ability
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| windowStage | window.WindowStage | Yes | **WindowStage** information. | | windowStage | window.WindowStage | Yes| **WindowStage** information.|
**Example** **Example**
...@@ -143,7 +140,7 @@ Called when this ability is destroyed to clear resources. ...@@ -143,7 +140,7 @@ Called when this ability is destroyed to clear resources.
onForeground(): void; onForeground(): void;
Called when this ability is running in the foreground. Called when this ability is switched from the background to the foreground.
**System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore **System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore
...@@ -162,7 +159,7 @@ Called when this ability is running in the foreground. ...@@ -162,7 +159,7 @@ Called when this ability is running in the foreground.
onBackground(): void; onBackground(): void;
Callback when this ability is switched to the background. Called when this ability is switched from the foreground to the background.
**System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore **System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore
...@@ -187,24 +184,25 @@ Called to save data during the ability migration preparation process. ...@@ -187,24 +184,25 @@ Called to save data during the ability migration preparation process.
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| wantParam | {[key:&nbsp;string]:&nbsp;any} | Yes | **want** parameter. | | wantParam | {[key:&nbsp;string]:&nbsp;any} | Yes| **want** parameter.|
**Return value** **Return value**
| Type | Description | | Type| Description|
| -------- | -------- | | -------- | -------- |
| AbilityConstant.OnContinueResult | Continuation result. | | AbilityConstant.OnContinueResult | Continuation result.|
**Example** **Example**
```js ```js
import AbilityConstant from "@ohos.application.AbilityConstant"
class myAbility extends Ability { class myAbility extends Ability {
onContinue(wantParams) { onContinue(wantParams) {
console.log('onContinue'); console.log('onContinue');
wantParams["myData"] = "my1234567"; wantParams["myData"] = "my1234567";
return true; return AbilityConstant.OnContinueResult.AGREE;
} }
} }
``` ```
...@@ -220,9 +218,9 @@ Called when the ability startup mode is set to singleton. ...@@ -220,9 +218,9 @@ Called when the ability startup mode is set to singleton.
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| want | [Want](js-apis-application-Want.md) | Yes | Want parameters, such as the ability name and bundle name. | | want | [Want](js-apis-application-Want.md) | Yes| Want parameters, such as the ability name and bundle name.|
**Example** **Example**
...@@ -245,9 +243,9 @@ Called when the configuration of the environment where the ability is running is ...@@ -245,9 +243,9 @@ Called when the configuration of the environment where the ability is running is
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| config | [Configuration](js-apis-configuration.md) | Yes | New configuration. | | config | [Configuration](js-apis-configuration.md) | Yes| New configuration.|
**Example** **Example**
...@@ -259,6 +257,32 @@ Called when the configuration of the environment where the ability is running is ...@@ -259,6 +257,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 ## Caller
...@@ -275,22 +299,25 @@ Sends sequenceable data to the target ability. ...@@ -275,22 +299,25 @@ Sends sequenceable data to the target ability.
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| method | string | Yes | Notification message string negotiated between the two abilities. The message is used to instruct the callee to register a function to receive the sequenceable data. | | method | string | Yes| Notification message string negotiated between the two abilities. The message is used to instruct the callee to register a function to receive the sequenceable data.|
| data | rpc.Sequenceable | Yes | Sequenceable data. You need to customize the data. | | data | rpc.Sequenceable | Yes| Sequenceable data. You need to customize the data.|
**Return value** **Return value**
| Type | Description | | Type| Description|
| -------- | -------- | | -------- | -------- |
| Promise&lt;void&gt; | Promise used to return a response. | | Promise&lt;void&gt; | Promise used to return a response.|
**Example** **Example**
```js ```js
import Ability from '@ohos.application.Ability'; import Ability from '@ohos.application.Ability';
class MyMessageAble{ // Custom sequenceable data structure class MyMessageAble{ // Custom sequenceable data structure
name:""
str:""
num: 1
constructor(name, str) { constructor(name, str) {
this.name = name; this.name = name;
this.str = str; this.str = str;
...@@ -345,22 +372,25 @@ Sends sequenceable data to the target ability and obtains the sequenceable data ...@@ -345,22 +372,25 @@ Sends sequenceable data to the target ability and obtains the sequenceable data
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| method | string | Yes | Notification message string negotiated between the two abilities. The message is used to instruct the callee to register a function to receive the sequenceable data. | | method | string | Yes| Notification message string negotiated between the two abilities. The message is used to instruct the callee to register a function to receive the sequenceable data.|
| data | rpc.Sequenceable | Yes | Sequenceable data. You need to customize the data. | | data | rpc.Sequenceable | Yes| Sequenceable data. You need to customize the data.|
**Return value** **Return value**
| Type | Description | | Type| Description|
| -------- | -------- | | -------- | -------- |
| Promise&lt;rpc.MessageParcel&gt; | Promise used to return the sequenceable data from the target ability. | | Promise&lt;rpc.MessageParcel&gt; | Promise used to return the sequenceable data from the target ability.|
**Example** **Example**
```js ```js
import Ability from '@ohos.application.Ability'; import Ability from '@ohos.application.Ability';
class MyMessageAble{ class MyMessageAble{
name:""
str:""
num: 1
constructor(name, str) { constructor(name, str) {
this.name = name; this.name = name;
this.str = str; this.str = str;
...@@ -451,9 +481,9 @@ Registers a callback that is invoked when the Stub on the target ability is disc ...@@ -451,9 +481,9 @@ Registers a callback that is invoked when the Stub on the target ability is disc
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| callback | OnReleaseCallBack | Yes | Callback used for the **onRelease** API. | | callback | OnReleaseCallBack | Yes| Callback used for the **onRelease** API.|
**Example** **Example**
...@@ -486,7 +516,7 @@ Registers a callback that is invoked when the Stub on the target ability is disc ...@@ -486,7 +516,7 @@ Registers a callback that is invoked when the Stub on the target ability is disc
## Callee ## Callee
Implements callbacks for caller notification registration and unregistration. Implements callbacks for caller notification registration and deregistration.
## Callee.on ## Callee.on
...@@ -499,16 +529,19 @@ Registers a caller notification callback, which is invoked when the target abili ...@@ -499,16 +529,19 @@ Registers a caller notification callback, which is invoked when the target abili
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| method | string | Yes | Notification message string negotiated between the two abilities. | | method | string | Yes| Notification message string negotiated between the two abilities.|
| callback | CaleeCallBack | Yes | JS notification synchronization callback of the **rpc.MessageParcel** type. The callback must return at least one empty **rpc.Sequenceable** object. Otherwise, the function execution fails. | | callback | CaleeCallBack | Yes| JS notification synchronization callback of the **rpc.MessageParcel** type. The callback must return at least one empty **rpc.Sequenceable** object. Otherwise, the function execution fails.|
**Example** **Example**
```js ```js
import Ability from '@ohos.application.Ability'; import Ability from '@ohos.application.Ability';
class MyMessageAble{ class MyMessageAble{
name:""
str:""
num: 1
constructor(name, str) { constructor(name, str) {
this.name = name; this.name = name;
this.str = str; this.str = str;
...@@ -546,15 +579,15 @@ Registers a caller notification callback, which is invoked when the target abili ...@@ -546,15 +579,15 @@ Registers a caller notification callback, which is invoked when the target abili
off(method: string): void; off(method: string): void;
Unregisters a caller notification callback, which is invoked when the target ability registers a function. Deregisters a caller notification callback, which is invoked when the target ability registers a function.
**System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore **System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| method | string | Yes | Registered notification message string. | | method | string | Yes| Registered notification message string.|
**Example** **Example**
...@@ -575,9 +608,9 @@ Unregisters a caller notification callback, which is invoked when the target abi ...@@ -575,9 +608,9 @@ Unregisters a caller notification callback, which is invoked when the target abi
**System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore **System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore
| Name | Type | Readable | Writable | Description | | Name| Type| Readable| Writable| Description|
| -------- | -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- | -------- |
| (msg: string) | function | Yes | No | Prototype of the listener function interface registered by the caller. | | (msg: string) | function | Yes| No| Prototype of the listener function interface registered by the caller.|
## CaleeCallBack ## CaleeCallBack
...@@ -586,6 +619,6 @@ Unregisters a caller notification callback, which is invoked when the target abi ...@@ -586,6 +619,6 @@ Unregisters a caller notification callback, which is invoked when the target abi
**System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore **System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore
| Name | Type | Readable | Writable | Description | | Name| Type| Readable| Writable| Description|
| -------- | -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- | -------- |
| (indata: rpc.MessageParcel) | rpc.Sequenceable | Yes | No | Prototype of the message listener function interface registered by the callee. | | (indata: rpc.MessageParcel) | rpc.Sequenceable | Yes| No| Prototype of the message listener function interface registered by the callee.|
# MissionInfo
> **NOTE**<br>
> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version.
## Modules to Import
```js
import MissionInfo from '@ohos.application.missionInfo'
```
## MissionInfo
Provides the mission information.
**System capability**: SystemCapability.Ability.AbilityBase
| Name| Type| Readable| Writable| Description|
| -------- | -------- | -------- | -------- | -------- |
| missionId | number | Yes| Yes| Mission ID.|
| runningState | number | Yes| Yes| Running state of the mission.|
| lockedState | boolean | Yes| Yes| Locked state of the mission.|
| timestamp | string | Yes| Yes| Latest time when the mission was created or updated.|
| want | [Want](js-apis-application-Want.md) | Yes| Yes| **Want** information of the mission.|
| label | string | Yes| Yes| Label of the mission.|
| iconPath | string | Yes| Yes| Path of the mission icon.|
| continuable | boolean | Yes| Yes| Whether the mission is continuable.|
# DataAbilityHelper Module (JavaScript SDK APIs) # DataAbilityHelper Module (JavaScript SDK APIs)
> ![icon-note.gif](public_sys-resources/icon-note.gif)**NOTE** > **NOTE**<br>
> The initial APIs of this module are supported since API version 7. 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 7. Newly added APIs will be marked with a superscript to indicate their earliest API version.
## Modules to Import ## Modules to Import
```js
import featureAbility from "@ohos.ability.featureAbility";
```
## Usage
Import the following modules based on the actual situation before using the current module:
``` ```
import featureAbility from '@ohos.ability.featureAbility' import featureAbility from '@ohos.ability.featureAbility'
import ohos_data_ability from '@ohos.data.dataability' import ohos_data_ability from '@ohos.data.dataAbility'
import ohos_data_rdb from '@ohos.data.rdb' import ohos_data_rdb from '@ohos.data.rdb'
``` ```
...@@ -499,7 +506,7 @@ const valueBucket = { ...@@ -499,7 +506,7 @@ const valueBucket = {
"name": "rose", "name": "rose",
"age": 22, "age": 22,
"salary": 200.5, "salary": 200.5,
"blobType": u8, "blobType": "u8",
} }
DAHelper.insert( DAHelper.insert(
"dataability:///com.example.DataAbility", "dataability:///com.example.DataAbility",
...@@ -541,7 +548,7 @@ const valueBucket = { ...@@ -541,7 +548,7 @@ const valueBucket = {
"name": "rose1", "name": "rose1",
"age": 221, "age": 221,
"salary": 20.5, "salary": 20.5,
"blobType": u8, "blobType": "u8",
} }
DAHelper.insert( DAHelper.insert(
"dataability:///com.example.DataAbility", "dataability:///com.example.DataAbility",
...@@ -574,9 +581,9 @@ import featureAbility from '@ohos.ability.featureAbility' ...@@ -574,9 +581,9 @@ import featureAbility from '@ohos.ability.featureAbility'
var DAHelper = featureAbility.acquireDataAbilityHelper( var DAHelper = featureAbility.acquireDataAbilityHelper(
"dataability:///com.example.DataAbility" "dataability:///com.example.DataAbility"
); );
var cars = new Array({"name": "roe11", "age": 21, "salary": 20.5, "blobType": u8,}, var cars = new Array({"name": "roe11", "age": 21, "salary": 20.5, "blobType": "u8",},
{"name": "roe12", "age": 21, "salary": 20.5, "blobType": u8,}, {"name": "roe12", "age": 21, "salary": 20.5, "blobType": "u8",},
{"name": "roe13", "age": 21, "salary": 20.5, "blobType": u8,}) {"name": "roe13", "age": 21, "salary": 20.5, "blobType": "u8",})
DAHelper.batchInsert( DAHelper.batchInsert(
"dataability:///com.example.DataAbility", "dataability:///com.example.DataAbility",
cars, cars,
...@@ -613,9 +620,9 @@ import featureAbility from '@ohos.ability.featureAbility' ...@@ -613,9 +620,9 @@ import featureAbility from '@ohos.ability.featureAbility'
var DAHelper = featureAbility.acquireDataAbilityHelper( var DAHelper = featureAbility.acquireDataAbilityHelper(
"dataability:///com.example.DataAbility" "dataability:///com.example.DataAbility"
); );
var cars = new Array({"name": "roe11", "age": 21, "salary": 20.5, "blobType": u8,}, var cars = new Array({"name": "roe11", "age": 21, "salary": 20.5, "blobType": "u8",},
{"name": "roe12", "age": 21, "salary": 20.5, "blobType": u8,}, {"name": "roe12", "age": 21, "salary": 20.5, "blobType": "u8",},
{"name": "roe13", "age": 21, "salary": 20.5, "blobType": u8,}) {"name": "roe13", "age": 21, "salary": 20.5, "blobType": "u8",})
DAHelper.batchInsert( DAHelper.batchInsert(
"dataability:///com.example.DataAbility", "dataability:///com.example.DataAbility",
cars cars
...@@ -682,6 +689,7 @@ Deletes one or more data records from the database. This API uses a promise to r ...@@ -682,6 +689,7 @@ Deletes one or more data records from the database. This API uses a promise to r
```js ```js
import featureAbility from '@ohos.ability.featureAbility' import featureAbility from '@ohos.ability.featureAbility'
import ohos_data_ability from '@ohos.data.dataability'
var DAHelper = featureAbility.acquireDataAbilityHelper( var DAHelper = featureAbility.acquireDataAbilityHelper(
"dataability:///com.example.DataAbility" "dataability:///com.example.DataAbility"
); );
...@@ -723,7 +731,7 @@ const va = { ...@@ -723,7 +731,7 @@ const va = {
"name": "roe1", "name": "roe1",
"age": 21, "age": 21,
"salary": 20.5, "salary": 20.5,
"blobType": u8, "blobType": "u8",
} }
let da = new ohos_data_ability.DataAbilityPredicates() let da = new ohos_data_ability.DataAbilityPredicates()
DAHelper.update( DAHelper.update(
...@@ -769,7 +777,7 @@ const va = { ...@@ -769,7 +777,7 @@ const va = {
"name": "roe1", "name": "roe1",
"age": 21, "age": 21,
"salary": 20.5, "salary": 20.5,
"blobType": u8, "blobType": "u8",
} }
let da = new ohos_data_ability.DataAbilityPredicates() let da = new ohos_data_ability.DataAbilityPredicates()
DAHelper.update( DAHelper.update(
......
# FormExtension # FormExtension
> ![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. > 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.
Provides **FormExtension** APIs. Provides **FormExtension** APIs.
...@@ -46,6 +46,7 @@ Called to notify the widget provider that a **Form** instance (widget) has been ...@@ -46,6 +46,7 @@ Called to notify the widget provider that a **Form** instance (widget) has been
**Example** **Example**
```js ```js
import formBindingData from '@ohos.application.formBindingData'
export default class MyFormExtension extends FormExtension { export default class MyFormExtension extends FormExtension {
onCreate(want) { onCreate(want) {
console.log('FormExtension onCreate, want:' + want.abilityName); console.log('FormExtension onCreate, want:' + want.abilityName);
...@@ -100,6 +101,7 @@ Called to notify the widget provider that a widget has been updated. After obtai ...@@ -100,6 +101,7 @@ Called to notify the widget provider that a widget has been updated. After obtai
**Example** **Example**
```js ```js
import formBindingData from '@ohos.application.formBindingData'
export default class MyFormExtension extends FormExtension { export default class MyFormExtension extends FormExtension {
onUpdate(formId) { onUpdate(formId) {
console.log('FormExtension onUpdate, formId:' + formId); console.log('FormExtension onUpdate, formId:' + formId);
...@@ -130,6 +132,7 @@ Called to notify the widget provider of the change of visibility. ...@@ -130,6 +132,7 @@ Called to notify the widget provider of the change of visibility.
**Example** **Example**
```js ```js
import formBindingData from '@ohos.application.formBindingData'
export default class MyFormExtension extends FormExtension { export default class MyFormExtension extends FormExtension {
onVisibilityChange(newStatus) { onVisibilityChange(newStatus) {
console.log('FormExtension onVisibilityChange, newStatus:' + newStatus); console.log('FormExtension onVisibilityChange, newStatus:' + newStatus);
...@@ -213,9 +216,35 @@ Called when the configuration of the environment where the ability is running is ...@@ -213,9 +216,35 @@ Called when the configuration of the environment where the ability is running is
**Example** **Example**
```js ```js
class MyFormExtension extends MyFormExtension { class MyFormExtension extends FormExtension {
onConfigurationUpdated(config) { onConfigurationUpdated(config) {
console.log('onConfigurationUpdated, config:' + JSON.stringify(config)); console.log('onConfigurationUpdated, config:' + JSON.stringify(config));
} }
} }
``` ```
## FormExtension.onAcquireFormState
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.
**System capability**: SystemCapability.Ability.Form
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| want | [Want](js-apis-application-Want.md) | No| Description of the widget state, including the bundle name, ability name, module name, widget name, and widget dimension.|
**Example**
```js
import fromInfo from '@ohos.application.fromInfo'
class MyFormExtension extends FormExtension {
onAcquireFormState(want) {
console.log('FormExtension onAcquireFormState, want:' + want);
return fromInfo.FormState.UNKNOWN;
}
}
```
# FormHost # FormHost
> **NOTE**<br/> > **NOTE**<br>
> The initial APIs of this module are supported since API version 8. 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 8. Newly added APIs will be marked with a superscript to indicate their earliest API version.
Provides APIs related to the widget host. Provides APIs related to the widget host.
...@@ -57,15 +57,15 @@ SystemCapability.Ability.Form ...@@ -57,15 +57,15 @@ SystemCapability.Ability.Form
**Parameters** **Parameters**
| Name| Type | Mandatory| Description | | Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ------- | | ------ | ------ | ---- | ------- |
| formId | string | Yes | ID of a widget.| | formId | string | Yes | ID of a widget.|
**Return value** **Return value**
| Type| Description| | Type| Description|
| -------- | -------- | | -------- | -------- |
| Promise&lt;void&gt; | Promise used to return the result indicating whether the API is successfully called.| | Promise&lt;void&gt; | Promise used to return the result indicating whether the API is successfully called.|
**Parameters** **Parameters**
...@@ -147,16 +147,16 @@ SystemCapability.Ability.Form ...@@ -147,16 +147,16 @@ SystemCapability.Ability.Form
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------------- | ------ | ---- | ----------- | | -------------- | ------ | ---- | ----------- |
| formId | string | Yes | ID of a widget. | | formId | string | Yes | ID of a widget. |
| isReleaseCache | boolean | No | Whether to release the cache.| | isReleaseCache | boolean | No | Whether to release the cache.|
**Return value** **Return value**
| Type| Description| | Type| Description|
| -------- | -------- | | -------- | -------- |
| Promise&lt;void&gt; | Promise used to return the result indicating whether the API is successfully called.| | Promise&lt;void&gt; | Promise used to return the result indicating whether the API is successfully called.|
**Example** **Example**
...@@ -209,15 +209,15 @@ SystemCapability.Ability.Form ...@@ -209,15 +209,15 @@ SystemCapability.Ability.Form
**Parameters** **Parameters**
| Name| Type | Mandatory| Description | | Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ------- | | ------ | ------ | ---- | ------- |
| formId | string | Yes | ID of a widget.| | formId | string | Yes | ID of a widget.|
**Return value** **Return value**
| Type| Description| | Type| Description|
| -------- | -------- | | -------- | -------- |
| Promise&lt;void&gt; | Promise used to return the result indicating whether the API is successfully called.| | Promise&lt;void&gt; | Promise used to return the result indicating whether the API is successfully called.|
**Example** **Example**
...@@ -270,15 +270,15 @@ SystemCapability.Ability.Form ...@@ -270,15 +270,15 @@ SystemCapability.Ability.Form
**Parameters** **Parameters**
| Name| Type | Mandatory| Description | | Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ------- | | ------ | ------ | ---- | ------- |
| formId | string | Yes | ID of a widget.| | formId | string | Yes | ID of a widget.|
**Return value** **Return value**
| Type| Description| | Type| Description|
| -------- | -------- | | -------- | -------- |
| Promise&lt;void&gt; | Promise used to return the result indicating whether the API is successfully called.| | Promise&lt;void&gt; | Promise used to return the result indicating whether the API is successfully called.|
**Example** **Example**
...@@ -311,7 +311,7 @@ SystemCapability.Ability.Form ...@@ -311,7 +311,7 @@ SystemCapability.Ability.Form
**Example** **Example**
```js ```js
var formId = "12400633174999288"; var formId = ["12400633174999288"];
formHost.notifyVisibleForms(formId, (error, data) => { formHost.notifyVisibleForms(formId, (error, data) => {
if (error.code) { if (error.code) {
console.log('formHost notifyVisibleForms, error:' + JSON.stringify(error)); console.log('formHost notifyVisibleForms, error:' + JSON.stringify(error));
...@@ -337,14 +337,14 @@ SystemCapability.Ability.Form ...@@ -337,14 +337,14 @@ SystemCapability.Ability.Form
**Return value** **Return value**
| Type| Description| | Type| Description|
| -------- | -------- | | -------- | -------- |
| Promise&lt;void&gt; | Promise used to return the result indicating whether the API is successfully called.| | Promise&lt;void&gt; | Promise used to return the result indicating whether the API is successfully called.|
**Example** **Example**
```js ```js
var formId = "12400633174999288"; var formId = ["12400633174999288"];
formHost.notifyVisibleForms(formId).then(() => { formHost.notifyVisibleForms(formId).then(() => {
console.log('formHost notifyVisibleForms success'); console.log('formHost notifyVisibleForms success');
}).catch((error) => { }).catch((error) => {
...@@ -372,7 +372,7 @@ SystemCapability.Ability.Form ...@@ -372,7 +372,7 @@ SystemCapability.Ability.Form
**Example** **Example**
```js ```js
var formId = "12400633174999288"; var formId = ["12400633174999288"];
formHost.notifyInvisibleForms(formId, (error, data) => { formHost.notifyInvisibleForms(formId, (error, data) => {
if (error.code) { if (error.code) {
console.log('formHost notifyInvisibleForms, error:' + JSON.stringify(error)); console.log('formHost notifyInvisibleForms, error:' + JSON.stringify(error));
...@@ -398,14 +398,14 @@ SystemCapability.Ability.Form ...@@ -398,14 +398,14 @@ SystemCapability.Ability.Form
**Return value** **Return value**
| Type| Description| | Type| Description|
| -------- | -------- | | -------- | -------- |
| Promise&lt;void&gt; | Promise used to return the result indicating whether the API is successfully called.| | Promise&lt;void&gt; | Promise used to return the result indicating whether the API is successfully called.|
**Example** **Example**
```js ```js
var formId = "12400633174999288"; var formId = ["12400633174999288"];
formHost.notifyInvisibleForms(formId).then(() => { formHost.notifyInvisibleForms(formId).then(() => {
console.log('formHost notifyInvisibleForms success'); console.log('formHost notifyInvisibleForms success');
}).catch((error) => { }).catch((error) => {
...@@ -433,7 +433,7 @@ SystemCapability.Ability.Form ...@@ -433,7 +433,7 @@ SystemCapability.Ability.Form
**Example** **Example**
```js ```js
var formId = "12400633174999288"; var formId = ["12400633174999288"];
formHost.enableFormsUpdate(formId, (error, data) => { formHost.enableFormsUpdate(formId, (error, data) => {
if (error.code) { if (error.code) {
console.log('formHost enableFormsUpdate, error:' + JSON.stringify(error)); console.log('formHost enableFormsUpdate, error:' + JSON.stringify(error));
...@@ -459,14 +459,14 @@ SystemCapability.Ability.Form ...@@ -459,14 +459,14 @@ SystemCapability.Ability.Form
**Return value** **Return value**
| Type| Description| | Type| Description|
| -------- | -------- | | -------- | -------- |
| Promise&lt;void&gt; | Promise used to return the result indicating whether the API is successfully called.| | Promise&lt;void&gt; | Promise used to return the result indicating whether the API is successfully called.|
**Example** **Example**
```js ```js
var formId = "12400633174999288"; var formId = ["12400633174999288"];
formHost.enableFormsUpdate(formId).then(() => { formHost.enableFormsUpdate(formId).then(() => {
console.log('formHost enableFormsUpdate success'); console.log('formHost enableFormsUpdate success');
}).catch((error) => { }).catch((error) => {
...@@ -494,7 +494,7 @@ SystemCapability.Ability.Form ...@@ -494,7 +494,7 @@ SystemCapability.Ability.Form
**Example** **Example**
```js ```js
var formId = "12400633174999288"; var formId = ["12400633174999288"];
formHost.disableFormsUpdate(formId, (error, data) => { formHost.disableFormsUpdate(formId, (error, data) => {
if (error.code) { if (error.code) {
console.log('formHost disableFormsUpdate, error:' + JSON.stringify(error)); console.log('formHost disableFormsUpdate, error:' + JSON.stringify(error));
...@@ -520,14 +520,14 @@ SystemCapability.Ability.Form ...@@ -520,14 +520,14 @@ SystemCapability.Ability.Form
**Return value** **Return value**
| Type| Description| | Type| Description|
| -------- | -------- | | -------- | -------- |
| Promise&lt;void&gt; | Promise used to return the result indicating whether the API is successfully called.| | Promise&lt;void&gt; | Promise used to return the result indicating whether the API is successfully called.|
**Example** **Example**
```js ```js
var formId = "12400633174999288"; var formId = ["12400633174999288"];
formHost.disableFormsUpdate(formId).then(() => { formHost.disableFormsUpdate(formId).then(() => {
console.log('formHost disableFormsUpdate success'); console.log('formHost disableFormsUpdate success');
}).catch((error) => { }).catch((error) => {
...@@ -574,9 +574,9 @@ SystemCapability.Ability.Form ...@@ -574,9 +574,9 @@ SystemCapability.Ability.Form
**Return value** **Return value**
| Type| Description| | Type| Description|
| -------- | -------- | | -------- | -------- |
| Promise&lt;void&gt; | Promise used to return the result indicating whether the API is successfully called.| | Promise&lt;void&gt; | Promise used to return the result indicating whether the API is successfully called.|
**Example** **Example**
...@@ -591,7 +591,7 @@ SystemCapability.Ability.Form ...@@ -591,7 +591,7 @@ SystemCapability.Ability.Form
## getAllFormsInfo ## getAllFormsInfo
getAllFormsInfo(callback: AsyncCallback&lt;Array&lt;FormInfo&gt;&gt;): void; getAllFormsInfo(callback: AsyncCallback&lt;Array&lt;formInfo.FormInfo&gt;&gt;): void;
Obtains the widget information provided by all applications on the device. This API uses an asynchronous callback to return the result. Obtains the widget information provided by all applications on the device. This API uses an asynchronous callback to return the result.
...@@ -601,9 +601,9 @@ SystemCapability.Ability.Form ...@@ -601,9 +601,9 @@ SystemCapability.Ability.Form
**Parameters** **Parameters**
| Name| Type | Mandatory| Description | | Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ------- | | ------ | ------ | ---- | ------- |
| callback | AsyncCallback&lt;Array&lt;[FormInfo](./js-apis-formInfo.md#forminfo-1)&gt;&gt; | Yes| Callback used to return the widget information.| | callback | AsyncCallback&lt;Array&lt;[FormInfo](./js-apis-formInfo.md#forminfo-1)&gt;&gt; | Yes| Callback used to return the widget information.|
**Example** **Example**
...@@ -619,7 +619,8 @@ SystemCapability.Ability.Form ...@@ -619,7 +619,8 @@ SystemCapability.Ability.Form
## getAllFormsInfo ## getAllFormsInfo
getAllFormsInfo(): Promise&lt;Array&lt;FormInfo&gt;&gt;; getAllFormsInfo(): Promise&lt;Array&lt;formInfo.FormInfo&gt;&gt;;
Obtains the widget information provided by all applications on the device. This API uses a promise to return the result. Obtains the widget information provided by all applications on the device. This API uses a promise to return the result.
...@@ -645,7 +646,8 @@ SystemCapability.Ability.Form ...@@ -645,7 +646,8 @@ SystemCapability.Ability.Form
## getFormsInfo ## getFormsInfo
getFormsInfo(bundleName: string, callback: AsyncCallback&lt;Array&lt;FormInfo&gt;&gt;): void; getFormsInfo(bundleName: string, callback: AsyncCallback&lt;Array&lt;formInfo.FormInfo&gt;&gt;): void;
Obtains the widget information provided by a given application on the device. This API uses an asynchronous callback to return the result. Obtains the widget information provided by a given application on the device. This API uses an asynchronous callback to return the result.
...@@ -655,10 +657,10 @@ SystemCapability.Ability.Form ...@@ -655,10 +657,10 @@ SystemCapability.Ability.Form
**Parameters** **Parameters**
| Name| Type | Mandatory| Description | | Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ------- | | ------ | ------ | ---- | ------- |
| bundleName | string | Yes| Bundle name of the target application.| | bundleName | string | Yes| Bundle name of the target application.|
| callback | AsyncCallback&lt;Array&lt;[FormInfo](./js-apis-formInfo.md#forminfo-1)&gt;&gt; | Yes| Callback used to return the widget information.| | callback | AsyncCallback&lt;Array&lt;[FormInfo](./js-apis-formInfo.md#forminfo-1)&gt;&gt; | Yes| Callback used to return the widget information.|
**Example** **Example**
...@@ -674,7 +676,8 @@ SystemCapability.Ability.Form ...@@ -674,7 +676,8 @@ SystemCapability.Ability.Form
## getFormsInfo ## getFormsInfo
getFormsInfo(bundleName: string, moduleName: string, callback: AsyncCallback&lt;Array&lt;FormInfo&gt;&gt;): void; getFormsInfo(bundleName: string, moduleName: string, callback: AsyncCallback&lt;Array&lt;formInfo.FormInfo&gt;&gt;): void;
Obtains the widget information provided by a given application on the device. This API uses an asynchronous callback to return the result. Obtains the widget information provided by a given application on the device. This API uses an asynchronous callback to return the result.
...@@ -684,11 +687,11 @@ SystemCapability.Ability.Form ...@@ -684,11 +687,11 @@ SystemCapability.Ability.Form
**Parameters** **Parameters**
| Name| Type | Mandatory| Description | | Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ------- | | ------ | ------ | ---- | ------- |
| bundleName | string | Yes| Bundle name of the target application.| | bundleName | string | Yes| Bundle name of the target application.|
| moduleName | string | Yes| Module name.| | moduleName | string | Yes| Module name.|
| callback | AsyncCallback&lt;Array&lt;[FormInfo](./js-apis-formInfo.md#forminfo-1)&gt;&gt; | Yes| Callback used to return the widget information.| | callback | AsyncCallback&lt;Array&lt;[FormInfo](./js-apis-formInfo.md#forminfo-1)&gt;&gt; | Yes| Callback used to return the widget information.|
**Example** **Example**
...@@ -704,7 +707,8 @@ SystemCapability.Ability.Form ...@@ -704,7 +707,8 @@ SystemCapability.Ability.Form
## getFormsInfo ## getFormsInfo
getFormsInfo(bundleName: string, moduleName?: string): Promise&lt;Array&lt;FormInfo&gt;&gt;; getFormsInfo(bundleName: string, moduleName?: string): Promise&lt;Array&lt;formInfo.FormInfo&gt;&gt;;
Obtains the widget information provided by a given application on the device. This API uses a promise to return the result. Obtains the widget information provided by a given application on the device. This API uses a promise to return the result.
...@@ -714,10 +718,10 @@ SystemCapability.Ability.Form ...@@ -714,10 +718,10 @@ SystemCapability.Ability.Form
**Parameters** **Parameters**
| Name| Type | Mandatory| Description | | Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ------- | | ------ | ------ | ---- | ------- |
| bundleName | string | Yes| Bundle name of the target application.| | bundleName | string | Yes| Bundle name of the target application.|
| moduleName | string | No| Module name.| | moduleName | string | No| Module name.|
**Return value** **Return value**
...@@ -767,7 +771,7 @@ SystemCapability.Ability.Form ...@@ -767,7 +771,7 @@ SystemCapability.Ability.Form
## deleteInvalidForms ## deleteInvalidForms
function deleteInvalidForms(formIds: Array&lt;string&gt;): Promise&lt;number&gt;; deleteInvalidForms(formIds: Array&lt;string&gt;): Promise&lt;number&gt;;
Deletes invalid widgets from the list. This API uses a promise to return the result. Deletes invalid widgets from the list. This API uses a promise to return the result.
...@@ -800,7 +804,7 @@ SystemCapability.Ability.Form ...@@ -800,7 +804,7 @@ SystemCapability.Ability.Form
## acquireFormState ## acquireFormState
acquireFormState(want: Want, callback: AsyncCallback&lt;FormStateInfo&gt;): void; acquireFormState(want: Want, callback: AsyncCallback&lt;formInfo.FormStateInfo&gt;): void;
Obtains the widget state. This API uses an asynchronous callback to return the result. Obtains the widget state. This API uses an asynchronous callback to return the result.
...@@ -820,8 +824,13 @@ SystemCapability.Ability.Form ...@@ -820,8 +824,13 @@ SystemCapability.Ability.Form
```js ```js
var want = { var want = {
"deviceId": "", "deviceId": "",
"bundleName": "com.extreme.test", "bundleName": "ohos.samples.FormApplication",
"abilityName": "com.extreme.test.MainAbility" "abilityName": "FormAbility",
"parameters": {
"ohos.extra.param.key.module_name": "entry",
"ohos.extra.param.key.form_name": "widget",
"ohos.extra.param.key.form_dimension": 2
}
}; };
formHost.acquireFormState(want, (error, data) => { formHost.acquireFormState(want, (error, data) => {
if (error.code) { if (error.code) {
...@@ -834,7 +843,7 @@ SystemCapability.Ability.Form ...@@ -834,7 +843,7 @@ SystemCapability.Ability.Form
## acquireFormState ## acquireFormState
function acquireFormState(want: Want): Promise&lt;FormStateInfo&gt;; acquireFormState(want: Want): Promise&lt;formInfo.FormStateInfo&gt;;
Obtains the widget state. This API uses a promise to return the result. Obtains the widget state. This API uses a promise to return the result.
...@@ -859,8 +868,13 @@ SystemCapability.Ability.Form ...@@ -859,8 +868,13 @@ SystemCapability.Ability.Form
```js ```js
var want = { var want = {
"deviceId": "", "deviceId": "",
"bundleName": "com.extreme.test", "bundleName": "ohos.samples.FormApplication",
"abilityName": "com.extreme.test.MainAbility" "abilityName": "FormAbility",
"parameters": {
"ohos.extra.param.key.module_name": "entry",
"ohos.extra.param.key.form_name": "widget",
"ohos.extra.param.key.form_dimension": 2
}
}; };
formHost.acquireFormState(want).then((data) => { formHost.acquireFormState(want).then((data) => {
console.log('formHost acquireFormState, data:' + JSON.stringify(data)); console.log('formHost acquireFormState, data:' + JSON.stringify(data));
...@@ -962,16 +976,16 @@ SystemCapability.Ability.Form ...@@ -962,16 +976,16 @@ SystemCapability.Ability.Form
**Parameters** **Parameters**
| Name| Type | Mandatory| Description | | Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ------- | | ------ | ------ | ---- | ------- |
| formIds | Array&lt;string&gt; | Yes | List of widget IDs.| | formIds | Array&lt;string&gt; | Yes | List of widget IDs.|
| isVisible | boolean | Yes | Whether to be visible.| | isVisible | boolean | Yes | Whether to be visible.|
**Return value** **Return value**
| Type| Description| | Type| Description|
| -------- | -------- | | -------- | -------- |
| Promise&lt;void&gt; | Promise used to return the result indicating whether the API is successfully called.| | Promise&lt;void&gt; | Promise used to return the result indicating whether the API is successfully called.|
**Example** **Example**
...@@ -1025,16 +1039,16 @@ SystemCapability.Ability.Form ...@@ -1025,16 +1039,16 @@ SystemCapability.Ability.Form
**Parameters** **Parameters**
| Name| Type | Mandatory| Description | | Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ------- | | ------ | ------ | ---- | ------- |
| formIds | Array&lt;string&gt; | Yes | List of widget IDs.| | formIds | Array&lt;string&gt; | Yes | List of widget IDs.|
| isEnableUpdate | boolean | Yes | Whether to enable update.| | isEnableUpdate | boolean | Yes | Whether to enable update.|
**Return value** **Return value**
| Type| Description| | Type| Description|
| -------- | -------- | | -------- | -------- |
| Promise&lt;void&gt; | Promise used to return the result indicating whether the API is successfully called.| | Promise&lt;void&gt; | Promise used to return the result indicating whether the API is successfully called.|
**Example** **Example**
......
...@@ -80,7 +80,7 @@ SystemCapability.Ability.Form ...@@ -80,7 +80,7 @@ SystemCapability.Ability.Form
## updateForm ## updateForm
updateForm(formId: string, formBindingData: FormBindingData, callback: AsyncCallback&lt;void&gt;): void; updateForm(formId: string, formBindingData: formBindingData.FormBindingData,callback: AsyncCallback&lt;void&gt;): void;
Updates a widget. This API uses an asynchronous callback to return the result. Updates a widget. This API uses an asynchronous callback to return the result.
...@@ -111,7 +111,7 @@ SystemCapability.Ability.Form ...@@ -111,7 +111,7 @@ SystemCapability.Ability.Form
## updateForm ## updateForm
updateForm(formId: string, formBindingData: FormBindingData): Promise&lt;void&gt;; updateForm(formId: string, formBindingData: formBindingData.FormBindingData): Promise&lt;void&gt;;
Updates a widget. This API uses a promise to return the result. Updates a widget. This API uses a promise to return the result.
......
# ProcessRunningInfo # ProcessRunningInfo
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** > **NOTE**<br>
> The initial APIs of this module are supported since API version 8. 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 8. Newly added APIs will be marked with a superscript to indicate their earliest API version.
Provides process running information. Provides process running information.
## Modules to Import
```js
import appManager from '@ohos.application.appManager'
```
## Usage ## Usage
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册