未验证 提交 457ae6e7 编写于 作者: O openharmony_ci 提交者: Gitee

!7136 翻译完成:5743 Add module description of ability

Merge pull request !7136 from wusongqing/TR5743
# DataUriUtils Module
# DataUriUtils
The **DataUriUtils** module provides APIs to handle utility classes for objects using the **DataAbilityHelper** schema. You can use the APIs to attach an ID to the end of a given URI and obtain, delete, or update the ID attached to the end of a given URI.
> **NOTE**
>
......
# ErrorCode
The **ErrorCode** module defines the error codes that can be used when the ability is started.
> **NOTE**
>
> The initial APIs of this module are supported since API 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.
## Modules to Import
......@@ -12,7 +14,7 @@ import errorCode from '@ohos.ability.errorCode'
## ErrorCode
Defines the error code used when the ability is started.
Defines the error codes used when the ability is started.
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
......
# wantConstant
The **wantConstant** module provides the action, entity, and flags used in **Want** objects.
> **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.
> The initial APIs of this module are supported since API 6. Newly added APIs will be marked with a superscript to indicate their earliest API version.
## Modules to Import
......@@ -12,73 +14,75 @@ import wantConstant from '@ohos.ability.wantConstant'
## wantConstant.Action
**System capability**: SystemCapability.Ability.AbilityBase
Enumerates the action constants of the **Want** object.
Lists the permissions.
**System capability**: SystemCapability.Ability.AbilityBase
| Common Event Macro | Common Event Name | Subscriber Permission |
| Name | Value | Description |
| ------------ | ------------------ | ---------------------- |
| ACTION_HOME | ohos.want.action.home | None |
| ACTION_DIAL | ohos.want.action.dial | None |
| ACTION_SEARCH | ohos.want.action.search | None |
| ACTION_WIRELESS_SETTINGS | ohos.settings.wireless | None |
| ACTION_MANAGE_APPLICATIONS_SETTINGS | ohos.settings.manage.applications | None |
| ACTION_APPLICATION_DETAILS_SETTINGS | ohos.settings.application.details | None |
| ACTION_SET_ALARM | ohos.want.action.setAlarm | None |
| ACTION_SHOW_ALARMS | ohos.want.action.showAlarms | None |
| ACTION_SNOOZE_ALARM | ohos.want.action.snoozeAlarm | None |
| ACTION_DISMISS_ALARM | ohos.want.action.dismissAlarm | None |
| ACTION_DISMISS_TIMER | ohos.want.action.dismissTimer | None |
| ACTION_SEND_SMS | ohos.want.action.sendSms | None |
| ACTION_CHOOSE | ohos.want.action.choose | None |
| ACTION_IMAGE_CAPTURE<sup>8+</sup> | ohos.want.action.imageCapture | None |
| ACTION_VIDEO_CAPTUR<sup>8+</sup> | ohos.want.action.videoCapture | None |
| ACTION_SELECT | ohos.want.action.select | None |
| ACTION_SEND_DATA | ohos.want.action.sendData | None |
| ACTION_SEND_MULTIPLE_DATA | ohos.want.action.sendMultipleData | None |
| ACTION_SCAN_MEDIA_FILE | ohos.want.action.scanMediaFile | None |
| ACTION_VIEW_DATA | ohos.want.action.viewData | None |
| ACTION_EDIT_DATA | ohos.want.action.editData | None |
| INTENT_PARAMS_INTENT | ability.want.params.INTENT | None |
| INTENT_PARAMS_TITLE | ability.want.params.TITLE | None |
| ACTION_FILE_SELECT<sup>7+</sup> | ohos.action.fileSelect | None |
| PARAMS_STREAM<sup>7+</sup> | ability.params.stream | None |
| ACTION_APP_ACCOUNT_OAUTH <sup>8+</sup> | ohos.account.appAccount.action.oauth | None |
| ACTION_HOME | ohos.want.action.home | Action of returning to the home page. |
| ACTION_DIAL | ohos.want.action.dial | Action of launching the numeric keypad. |
| ACTION_SEARCH | ohos.want.action.search | Action of launching the search function. |
| ACTION_WIRELESS_SETTINGS | ohos.settings.wireless | Action of launching the UI that provides radio network settings, for example, Wi-Fi option. |
| ACTION_MANAGE_APPLICATIONS_SETTINGS | ohos.settings.manage.applications | Action of launching the UI for managing installed applications. |
| ACTION_APPLICATION_DETAILS_SETTINGS | ohos.settings.application.details | Action of launching the UI that displays the details of an application. |
| ACTION_SET_ALARM | ohos.want.action.setAlarm | Action of launching the UI for setting the alarm clock. |
| ACTION_SHOW_ALARMS | ohos.want.action.showAlarms | Action of launching the UI that displays all clock alarms. |
| ACTION_SNOOZE_ALARM | ohos.want.action.snoozeAlarm | Action of launching the UI for snoozing an alarm. |
| ACTION_DISMISS_ALARM | ohos.want.action.dismissAlarm | Action of launching the UI for deleting an alarm. |
| ACTION_DISMISS_TIMER | ohos.want.action.dismissTimer | Action of launching the UI for dismissing a timer. |
| ACTION_SEND_SMS | ohos.want.action.sendSms | Action of launching the UI for sending an SMS. |
| ACTION_CHOOSE | ohos.want.action.choose | Action of launching the UI for openning a contact or picture. |
| ACTION_IMAGE_CAPTURE<sup>8+</sup> | ohos.want.action.imageCapture | Action of launching the UI for photographing. |
| ACTION_VIDEO_CAPTURE<sup>8+</sup> | ohos.want.action.videoCapture | Action of launching the UI for shooting a video. |
| ACTION_SELECT | ohos.want.action.select | Action of launching the UI for application selection. |
| ACTION_SEND_DATA | ohos.want.action.sendData | Action of launching the UI for sending a single data record. |
| ACTION_SEND_MULTIPLE_DATA | ohos.want.action.sendMultipleData | Action of launching the UI for sending multiple data records. |
| ACTION_SCAN_MEDIA_FILE | ohos.want.action.scanMediaFile | Action of requesting a media scanner to scan a file and add the file to the media library. |
| ACTION_VIEW_DATA | ohos.want.action.viewData | Action of viewing data. |
| ACTION_EDIT_DATA | ohos.want.action.editData | Action of editing data. |
| INTENT_PARAMS_INTENT | ability.want.params.INTENT | Action of displaying selection options with an action selector. |
| INTENT_PARAMS_TITLE | ability.want.params.TITLE | Title of the character sequence dialog box used with the action selector. |
| ACTION_FILE_SELECT<sup>7+</sup> | ohos.action.fileSelect | Action of selecting a file. |
| PARAMS_STREAM<sup>7+</sup> | ability.params.stream | URI of the data stream associated with the target when the data is sent. |
| ACTION_APP_ACCOUNT_OAUTH <sup>8+</sup> | ohos.account.appAccount.action.oauth | Action of providing the OAuth service. |
| ACTION_MARKER_DOWNLOAD <sup>9+</sup> | ohos.want.action.marketDownload | Action of downloading an application from the application market.<br>**System API**: This is a system API and cannot be called by third-party applications. |
## wantConstant.Entity
**System capability**: SystemCapability.Ability.AbilityBase
Enumerates the entity constants of the **Want** object.
Lists the permissions.
**System capability**: SystemCapability.Ability.AbilityBase
| Common Event Macro | Common Event Name | Subscriber Permission |
| Name | Value | Description |
| ------------ | ------------------ | ---------------------- |
| ENTITY_DEFAULT | entity.system.default | None |
| ENTITY_HOME | entity.system.homel | None |
| ENTITY_VOICE | ENTITY_VOICE | None |
| ENTITY_BROWSABLE | entity.system.browsable | None |
| ENTITY_VIDEO | entity.system.video | None |
| ACTION_APPLICATION_DETAILS_SETTINGS | ohos.settings.application.details | None |
| ENTITY_DEFAULT | entity.system.default | Default entity. The default entity is used if no entity is specified. |
| ENTITY_HOME | entity.system.home | Home screen entity. |
| ENTITY_VOICE | entity.system.voice | Voice interaction entity. |
| ENTITY_BROWSABLE | entity.system.browsable | Browser type entity. |
| ENTITY_VIDEO | entity.system.video | Video type entity. |
## wantConstant.Flags
## flags
Describes flags.
**System capability**: SystemCapability.Ability.AbilityBase
| Name | Value | Description |
| ------------------------------------ | ---------- | ------------------------------------------------------------ |
| FLAG_AUTH_READ_URI_PERMISSION | 0x00000001 | Indicates the permission to read the URI. |
| FLAG_AUTH_WRITE_URI_PERMISSION | 0x00000002 | Indicates the permission to write the URI. |
| FLAG_AUTH_WRITE_URI_PERMISSION | 0x00000002 | Indicates the permission to write data to the URI. |
| FLAG_ABILITY_FORWARD_RESULT | 0x00000004 | Returns the result to the ability. |
| FLAG_ABILITY_CONTINUATION | 0x00000008 | Indicates whether the ability on the local device can be continued on a remote device. |
| FLAG_NOT_OHOS_COMPONENT | 0x00000010 | Indicates that a component does not belong to OHOS. |
| FLAG_ABILITY_FORM_ENABLED | 0x00000020 | Indicates that an ability is enabled. |
| FLAG_AUTH_PERSISTABLE_URI_PERMISSION | 0x00000040 | Indicates the permission to make the URI persistent. |
| FLAG_AUTH_PREFIX_URI_PERMISSION | 0x00000080 | Indicates the permission to verify URIs by prefix matching. |
| FLAG_AUTH_PERSISTABLE_URI_PERMISSION | 0x00000040 | Indicates the permission to make the URI persistent.<br>**System API**: This is a system API and cannot be called by third-party applications. |
| FLAG_AUTH_PREFIX_URI_PERMISSION | 0x00000080 | Indicates the permission to verify URIs by prefix matching.<br>**System API**: This is a system API and cannot be called by third-party applications.|
| FLAG_ABILITYSLICE_MULTI_DEVICE | 0x00000100 | Supports cross-device startup in a distributed scheduler. |
| FLAG_START_FOREGROUND_ABILITY | 0x00000200 | Indicates that the Service ability is started regardless of whether the host application has been started. |
| FLAG_ABILITY_CONTINUATION_REVERSIBLE | 0x00000400 | Indicates that ability continuation is reversible. |
| FLAG_ABILITY_CONTINUATION_REVERSIBLE | 0x00000400 | Indicates that ability continuation is reversible.<br>**System API**: This is a system API and cannot be called by third-party applications. |
| FLAG_INSTALL_ON_DEMAND | 0x00000800 | Indicates that the specific ability will be installed if it has not been installed. |
| FLAG_INSTALL_WITH_BACKGROUND_MODE | 0x80000000 | Indicates that the specific ability will be installed in the background if it has not been installed. |
| FLAG_ABILITY_CLEAR_MISSION | 0x00008000 | Clears other operation missions. This flag can be set for the **Want** object in the **startAbility** API passed to [ohos.app.Context](js-apis-ability-context.md) and must be used together with **flag_ABILITY_NEW_MISSION**.|
......
# AbilityDelegatorRegistry
The **AbilityDelegatorRegistry** module provides APIs for storing the global registers of the registered **AbilityDelegator** and **AbilityDelegatorArgs** objects. You can use the APIs to obtain the **AbilityDelegator** and **AbilityDelegatorArgs** objects of an application.
> **NOTE**
>
> 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.
......@@ -24,8 +26,6 @@ Enumerates the ability lifecycle states.
| BACKGROUND | 3 | The ability is running in the background. |
| DESTROY | 4 | The ability is destroyed.|
## AbilityDelegatorRegistry.getAbilityDelegator
getAbilityDelegator(): AbilityDelegator
......
# AbilityRunningInfo
The **AbilityRunningInfo** module implements ability running information and ability states.
> **NOTE**
>
> 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 ability running information.
## Modules to Import
```js
import abilitymanager from '@ohos.application.abilityManager';
```
## Usage
The ability running information is obtained by using the **getAbilityRunningInfos** API in **abilityManager**.
......@@ -27,6 +21,8 @@ abilitymanager.getAbilityRunningInfos((err,data) => {
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
**System API**: This is a system API and cannot be called by third-party applications.
| Name| Type| Readable| Writable| Description|
| -------- | -------- | -------- | -------- | -------- |
| ability | ElementName | Yes| No| Information that matches an ability. |
......@@ -34,19 +30,4 @@ abilitymanager.getAbilityRunningInfos((err,data) => {
| uid | number | Yes| No| User ID. |
| processName | string | Yes| No| Process name. |
| startTime | number | Yes| No| Ability start time. |
| abilityState | [abilityManager.AbilityState](#abilitymanagerabilitystate) | Yes| No| Ability state. |
## abilityManager.AbilityState
Enumerates the ability states.
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
| Name| Value| Description|
| -------- | -------- | -------- |
| INITIAL | 0 | The ability is in the initial state.|
| FOREGROUND | 9 | The ability is in the foreground state. |
| BACKGROUND | 10 | The ability is in the background state. |
| FOREGROUNDING | 11 | The ability is in the foregrounding state. |
| BACKGROUNDING | 12 | The ability is in the backgrounding state. |
| abilityState | [abilityManager.AbilityState](js-apis-abilityManager.md#abilityState) | Yes| No| Ability state. |
# AbilityStageContext
The **AbilityStageContext** module, inherited from [Context](js-apis-application-context.md), implements the context of an ability stage.
This module provides APIs for accessing a specific ability stage. You can use the APIs to obtain the **ModuleInfo** object and environment configuration of an ability stage.
> **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.
> The APIs of this module can be used only in the stage model.
Implements the context of an ability stage. This module is inherited from [Context](js-apis-application-context.md).
## Modules to Import
```js
import AbilityStage from '@ohos.application.AbilityStage';
```
## Usage
The ability stage context is obtained through an **AbilityStage** instance.
......
# StartOptions
The **StartOptions** module implements ability startup options.
> **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.
>
> 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 APIs of this module can be used only in the stage model.
**StartOptions** is the basic communication component of the system.
## Modules to Import
```
......@@ -15,10 +15,9 @@ import StartOptions from '@ohos.application.StartOptions';
## Attributes
**System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
| Name| Readable| Writable| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | -------- | -------- |
| [windowMode](js-apis-window.md#windowmode) | Yes| No| number | No| Window mode.|
| windowMode | Yes| No| number | No| Window mode.|
| displayId | Yes| No| number | No| Display ID.|
# Want
The **Want** module provides the basic communication component of the system.
> **NOTE**
>
> 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.
**Want** is the basic communication component of the system.
## Modules to Import
```
......@@ -20,11 +20,26 @@ import Want from '@ohos.application.Want';
| ----------- | -------- | -------------------- | ---- | ------------------------------------------------------------ |
| deviceId | Read only | string | No | ID of the device running the ability. |
| bundleName | Read only | string | No | Bundle name of the ability. If both **bundleName** and **abilityName** are specified in a **Want** object, the **Want** object can match a specific ability.|
| abilityName | Read only | string | No | Name of the ability. If both **package** and **abilityName** are specified in a **Want** object, the **Want** object can match a specific ability.|
| abilityName | Read only | string | No | Name of the ability. If both **package** and **abilityName** are specified in a **Want** object, the **Want** object can match a specific ability. The value of **abilityName** must be unique in an application.|
| uri | Read only | string | No | URI information to match. If **uri** is specified in a **Want** object, the **Want** object will match the specified URI information, including **scheme**, **schemeSpecificPart**, **authority**, and **path**.|
| type | Read only | string | No | MIME type, for example, **text/plain** or **image/***. |
| flags | Read only | number | No | How the **Want** object will be handled. By default, numbers are passed in. For details, see [flags](js-apis-featureAbility.md#flags).|
| action | Read only | string | No | Action option. |
| parameters | Read only | {[key: string]: any} | No | List of parameters in the **Want** object. |
| parameters | Read only | {[key: string]: any} | No | Want parameters in the form of custom key-value (KV) pairs. By default, the following keys are carried:<br>**ohos.aafwk.callerPid**: PID of the caller.<br>**ohos.aafwk.param.callerToken**: token of the caller.<br>**ohos.aafwk.param.callerUid**: UID of the caller. The **userId** parameter in the [Bundle](js-apis-Bundle.js) module can be used to obtain application and bundle information. |
| entities | Read only | Array\<string> | No | List of entities. |
| moduleName<sup>9+</sup> | Read only | string | No | Module to which the ability belongs. Different abilities among HAP files in an application may use the same name. If the abilities cannot be distinguished by the combination of **bundleName** and **abilityName**, you can set **moduleName** for better distinguishing.| |
| moduleName<sup>9+</sup> | Read only | string | No | Module to which the ability belongs.|
**Example**
``` js
var want = {
"deviceId": "", // An empty deviceId indicates the local device.
"bundleName": "com.extreme.test",
"abilityName": "MainAbility",
"moduleName": "entry" // moduleName is optional.
};
this.context.startAbility(want, (error) => {
// Start an ability explicitly. The bundleName, abilityName, and moduleName parameters uniquely identify an ability.
console.log("error.code = " + error.code)
})
```
# Ability
The **Ability** module manages the ability lifecycle and context, such as creating and destroying an ability, and dumping client information.
This module provides the following common ability-related functions:
- [Caller](#caller): implements sending of sequenceable data to the target ability when an ability (caller) invokes the target ability (callee).
- [Callee](#callee): implements callbacks for registration and deregistration of caller notifications.
> **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.
> The APIs of this module can be used only in the stage model.
Manages the ability lifecycle and context.
## Modules to Import
```
......@@ -17,14 +22,12 @@ import Ability from '@ohos.application.Ability';
**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.|
| 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.|
| 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
......@@ -36,13 +39,13 @@ Called to initialize the service logic when an ability is created.
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| 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.|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| 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.|
**Example**
**Example**
```js
class myAbility extends Ability {
onCreate(want, param) {
......@@ -62,12 +65,12 @@ Called when a **WindowStage** is created for this ability.
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| windowStage | window.WindowStage | Yes| **WindowStage** information.|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| windowStage | window.WindowStage | Yes| **WindowStage** information.|
**Example**
**Example**
```js
class myAbility extends Ability {
onWindowStageCreate(windowStage) {
......@@ -85,8 +88,8 @@ Called when the **WindowStage** is destroyed for this ability.
**System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore
**Example**
**Example**
```js
class myAbility extends Ability {
onWindowStageDestroy() {
......@@ -106,12 +109,12 @@ Called when the **WindowStage** is restored during the migration of this ability
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| windowStage | window.WindowStage | Yes| **WindowStage** information.|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| windowStage | window.WindowStage | Yes| **WindowStage** information.|
**Example**
**Example**
```js
class myAbility extends Ability {
onWindowStageRestore(windowStage) {
......@@ -129,8 +132,8 @@ Called when this ability is destroyed to clear resources.
**System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore
**Example**
**Example**
```js
class myAbility extends Ability {
onDestroy() {
......@@ -148,8 +151,8 @@ Called when this ability is switched from the background to the foreground.
**System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore
**Example**
**Example**
```js
class myAbility extends Ability {
onForeground() {
......@@ -167,8 +170,8 @@ Called when this ability is switched from the foreground to the background.
**System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore
**Example**
**Example**
```js
class myAbility extends Ability {
onBackground() {
......@@ -188,18 +191,18 @@ Called to save data during the ability migration preparation process.
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| wantParam | {[key:&nbsp;string]:&nbsp;any} | Yes| **want** parameter.|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| wantParam | {[key:&nbsp;string]:&nbsp;any} | Yes| **want** parameter.|
**Return value**
| Type| Description|
| -------- | -------- |
| AbilityConstant.OnContinueResult | Continuation result.|
| Type| Description|
| -------- | -------- |
| AbilityConstant.OnContinueResult | Continuation result.|
**Example**
**Example**
```js
import AbilityConstant from "@ohos.application.AbilityConstant"
class myAbility extends Ability {
......@@ -222,13 +225,13 @@ Called when the ability startup mode is set to singleton.
**Parameters**
| 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.|
| 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**
**Example**
```js
class myAbility extends Ability {
onNewWant(want, launchParams) {
......@@ -251,12 +254,12 @@ Called when the configuration of the environment where the ability is running is
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| config | [Configuration](js-apis-configuration.md) | Yes| New configuration.|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| config | [Configuration](js-apis-configuration.md) | Yes| New configuration.|
**Example**
**Example**
```js
class myAbility extends Ability {
onConfigurationUpdated(config) {
......@@ -269,18 +272,18 @@ Called when the configuration of the environment where the ability is running is
dump(params: Array\<string>): Array\<string>;
Called when the client information is dumped.
Dumps client information.
**System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| params | Array\<string> | Yes| Parameters in the form of a command.|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| params | Array\<string> | Yes| Parameters in the form of a command.|
**Example**
**Example**
```js
class myAbility extends Ability {
dump(params) {
......@@ -307,19 +310,19 @@ Sends sequenceable data to the target ability.
**Parameters**
| 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.|
| data | rpc.Sequenceable | Yes| Sequenceable data. You need to customize the data.|
| 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.|
| data | rpc.Sequenceable | Yes| Sequenceable data. You need to customize the data.|
**Return value**
| Type| Description|
| -------- | -------- |
| Promise&lt;void&gt; | Promise used to return a response.|
| Type| Description|
| -------- | -------- |
| Promise&lt;void&gt; | Promise used to return a response.|
**Example**
**Example**
```js
import Ability from '@ohos.application.Ability';
class MyMessageAble{ // Custom sequenceable data structure
......@@ -380,19 +383,19 @@ Sends sequenceable data to the target ability and obtains the sequenceable data
**Parameters**
| 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.|
| data | rpc.Sequenceable | Yes| Sequenceable data. You need to customize the data.|
| 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.|
| data | rpc.Sequenceable | Yes| Sequenceable data. You need to customize the data.|
**Return value**
| Type| Description|
| -------- | -------- |
| Promise&lt;rpc.MessageParcel&gt; | Promise used to return the sequenceable data from the target ability.|
| Type| Description|
| -------- | -------- |
| Promise&lt;rpc.MessageParcel&gt; | Promise used to return the sequenceable data from the target ability.|
**Example**
**Example**
```js
import Ability from '@ohos.application.Ability';
class MyMessageAble{
......@@ -452,8 +455,8 @@ Releases the caller interface of the target ability.
**System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore
**Example**
**Example**
```js
import Ability from '@ohos.application.Ability';
var caller;
......@@ -489,12 +492,12 @@ Registers a callback that is invoked when the stub on the target ability is disc
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| callback | OnReleaseCallBack | Yes| Callback used for the **onRelease** API.|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| callback | OnReleaseCallBack | Yes| Callback used for the **onRelease** API.|
**Example**
**Example**
```js
import Ability from '@ohos.application.Ability';
var caller;
......@@ -529,7 +532,7 @@ Implements callbacks for caller notification registration and deregistration.
## Callee.on
on(method: string, callback: CaleeCallBack): void;
on(method: string, callback: CalleeCallBack): void;
Registers a caller notification callback, which is invoked when the target ability registers a function.
......@@ -537,13 +540,12 @@ Registers a caller notification callback, which is invoked when the target abili
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| 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.|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| method | string | Yes| Notification message string negotiated between the two abilities.|
| callback | CalleeCallBack | 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
import Ability from '@ohos.application.Ability';
class MyMessageAble{
......@@ -593,9 +595,9 @@ Deregisters a caller notification callback, which is invoked when the target abi
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| method | string | Yes| Registered notification message string.|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| method | string | Yes| Registered notification message string.|
**Example**
......@@ -616,17 +618,17 @@ Deregisters a caller notification callback, which is invoked when the target abi
**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 registered by the caller.|
## CaleeCallBack
## CalleeCallBack
(indata: rpc.MessageParcel): rpc.Sequenceable;
**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 listener function registered by the callee.|
# AbilityConstant
The **AbilityConstant** module provides ability launch parameters.
The parameters include the initial launch reasons, reasons for the last exit, and ability continuation results.
> **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.
> The APIs of this module can be used only in the stage model.
Provides parameters related to ability launch.
## Modules to Import
```js
......@@ -17,10 +19,10 @@ import AbilityConstant from '@ohos.application.AbilityConstant';
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
| Name| Type| Readable| Writable| Description|
| Name| Type| Readable| Writable| Description|
| -------- | -------- | -------- | -------- | -------- |
| launchReason | LaunchReason| Yes| Yes| Ability launch reason.|
| lastExitReason | LastExitReason | Yes| Yes| Reason for the last exit.|
| launchReason | LaunchReason| Yes| Yes| Ability launch reason.|
| lastExitReason | LastExitReason | Yes| Yes| Reason for the last exit.|
## AbilityConstant.LaunchReason
......
# AbilityDelegator
The **AbilityDelegator** module provides APIs for managing **AbilityMonitor** instances that are used to monitor the lifecycle state changes of a specified ability. You can use the APIs to add and remove **AbilityMonitor** instances, wait for an ability to reach the **OnCreate** lifecycle state, set the waiting time, obtain the lifecycle state of an ability, obtain the top ability of the current application, and start an ability.
> **NOTE**
>
> 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
## Usage
The ability delegator can be obtained by calling **getAbilityDelegator** in **AbilityDelegatorRegistry**.
```js
import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'
var abilityDelegator;
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator();
```
## AbilityDelegator
......@@ -174,7 +182,7 @@ abilityDelegator.removeAbilityMonitor(monitor).then(() => {
waitAbilityMonitor(monitor: AbilityMonitor, callback: AsyncCallback\<Ability>): void
Waits for the ability that matches the **AbilityMonitor** instance to reach the **OnCreate** lifecycle and returns the **Ability** instance. This API uses an asynchronous callback to return the result.
Waits for the **Ability** instance that matches the **AbilityMonitor** instance to reach the **OnCreate** lifecycle state and returns the **Ability** instance. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
......@@ -211,7 +219,7 @@ abilityDelegator.waitAbilityMonitor(monitor, (err : any, data : any) => {
waitAbilityMonitor(monitor: AbilityMonitor, timeout: number, callback: AsyncCallback\<Ability>): void
Waits a period of time for the ability that matches the **AbilityMonitor** instance to reach the **OnCreate** lifecycle and returns the **Ability** instance. This API uses an asynchronous callback to return the result.
Waits a period of time for the **Ability** instance that matches the **AbilityMonitor** instance to reach the **OnCreate** lifecycle state and returns the **Ability** instance. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
......@@ -250,7 +258,7 @@ abilityDelegator.waitAbilityMonitor(monitor, timeout, (err : any, data : any) =>
waitAbilityMonitor(monitor: AbilityMonitor, timeout?: number): Promise\<Ability>
Waits a period of time for the ability that matches the **AbilityMonitor** instance to reach the **OnCreate** lifecycle and returns the **Ability** instance. This API uses a promise to return the result.
Waits a period of time for the **Ability** instance that matches the **AbilityMonitor** instance to reach the **OnCreate** lifecycle state and returns the **Ability** instance. This API uses a promise to return the result.
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
......@@ -355,7 +363,7 @@ abilityDelegator.getCurrentTopAbility((err : any, data : any) => {
getCurrentTopAbility(callback: AsyncCallback\<Ability>): void
Obtains the top ability of the application. This API uses an asynchronous callback to return the result.
Obtains the top ability of this application. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
......@@ -384,7 +392,7 @@ abilityDelegator.getCurrentTopAbility((err : any, data : any) => {
getCurrentTopAbility(): Promise\<Ability>
Obtains the top ability of the application. This API uses a promise to return the result.
Obtains the top ability of this application. This API uses a promise to return the result.
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
......@@ -491,7 +499,7 @@ Schedules the lifecycle state of an ability to **Foreground**. This API uses an
| Name | Type | Mandatory| Description |
| -------- | ----------------------- | ---- | ------------------------------------------------------- |
| ability | Ability | Yes | Target ability. |
| callback | AsyncCallback\<boolean> | Yes | Callback used to return the result.<br>\- **true**: The operation is successful.<br>\- **false**: The operation fails.|
| callback | AsyncCallback\<boolean> | Yes | Callback used to return the result.<br>\- **true**: The operation is successful.<br>\- **false**: The operation failed.|
**Example**
......@@ -529,7 +537,7 @@ Schedules the lifecycle state of an ability to **Foreground**. This API uses a p
| Type | Description |
| ----------------- | ------------------------------------------------------------ |
| Promise\<boolean> | Promise used to return the result.<br>\- **true**: The operation is successful.<br>\- **false**: The operation fails.|
| Promise\<boolean> | Promise used to return the result.<br>\- **true**: The operation is successful.<br>\- **false**: The operation failed.|
**Example**
......@@ -562,7 +570,7 @@ Schedules the lifecycle state of an ability to **Background**. This API uses an
| Name | Type | Mandatory| Description |
| -------- | ----------------------- | ---- | ------------------------------------------------------- |
| ability | Ability | Yes | Target ability. |
| callback | AsyncCallback\<boolean> | Yes | Callback used to return the result.<br>\- **true**: The operation is successful.<br>\- **false**: The operation fails.|
| callback | AsyncCallback\<boolean> | Yes | Callback used to return the result.<br>\- **true**: The operation is successful.<br>\- **false**: The operation failed.|
**Example**
......@@ -600,7 +608,7 @@ Schedules the lifecycle state of an ability to **Background**. This API uses a p
| Type | Description |
| ----------------- | ------------------------------------------------------------ |
| Promise\<boolean> | Promise used to return the result.<br>\- **true**: The operation is successful.<br>\- **false**: The operation fails.|
| Promise\<boolean> | Promise used to return the result.<br>\- **true**: The operation is successful.<br>\- **false**: The operation failed.|
**Example**
......@@ -620,6 +628,32 @@ abilityDelegator.getCurrentTopAbility((err : any, data : any) => {
### printSync<sup>9+</sup>
printSync(msg: string): void
Prints log information to the unit test console.
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
**Parameters**
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ---------- |
| msg | string | Yes | Log string.|
**Example**
```js
var abilityDelegator;
var msg = "msg";
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator();
abilityDelegator.printSync(msg);
```
### print
print(msg: string, callback: AsyncCallback\<void>): void
......
# AbilityDelegatorArgs
The **AbilityDelegatorArgs** module provides a global register to store the registered **AbilityDelegator** and **AbilityDelegatorArgs** instances during application startup.
> **NOTE**
>
> 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
## Usage
The ability delegator arguments are obtained by calling **getArguments** in **AbilityDelegatorRegistry**.
```js
import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'
var args = AbilityDelegatorRegistry.getArguments();
```
## AbilityDelegatorArgs
Describes the test parameters.
Describes the ability delegator arguments.
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
| Name | Type | Readable| Writable| Description |
| ------------------- | ---------------------- | ---- | ---- | ------------------------------------------------------------ |
| bundleName | string | Yes | Yes | Bundle name of the application to test.<br>**System capability**: SystemCapability.Ability.AbilityRuntime.Core|
| parameters | {[key:string]: string} | Yes | Yes | Parameters of the unit test that is started currently.<br>**System capability**: SystemCapability.Ability.AbilityRuntime.Core|
| testCaseNames | string | Yes | Yes | Test case names.<br>**System capability**: SystemCapability.Ability.AbilityRuntime.Core|
| testRunnerClassName | string | Yes | Yes | Names of the test executors that execute the test cases.<br>**System capability**: SystemCapability.Ability.AbilityRuntime.Core|
| bundleName | string | Yes | Yes | Bundle name of the application to test. |
| parameters | {[key:string]: string} | Yes | Yes | Parameters of the unit test that is started currently. |
| testCaseNames | string | Yes | Yes | Test case names. |
| testRunnerClassName | string | Yes | Yes | Names of the test case executors. |
# AbilityLifecycleCallback
The **AbilityLifecycleCallback** module provides callbacks, such as **onAbilityCreate**, **onAbilityWindowStageCreate**, and **onAbilityWindowStageDestroy**, to receive lifecycle state changes in the application context.
> **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.
> The APIs of this module can be used only in the stage model.
A callback class that provides APIs, such as **onAbilityCreate**, **onAbilityWindowStageCreate**, and **onAbilityWindowStageDestroy**, to listen for the lifecycle of the application context.
## Modules to Import
```js
import AbilityLifecycleCallback from "@ohos.application.abilityLifecycleCallback";
import AbilityLifecycleCallback from "@ohos.application.AbilityLifecycleCallback";
```
......
# AbilityMonitor
The **AbilityMonitor** module provides monitors for abilities that meet specified conditions. The latest matched abilities are stored in an **AbilityMonitor** object.
> **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.
## Modules to Import
## Usage
The ability monitor is set by calling **addAbilityMonitor** in **abilityDelegator**.
```js
import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'
var abilityDelegator;
function onAbilityCreateCallback(data) {
console.info("onAbilityCreateCallback");
}
var monitor = {
abilityName: "abilityname",
onAbilityCreate: onAbilityCreateCallback
}
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator();
abilityDelegator.addAbilityMonitor(monitor, (err : any) => {
console.info("addAbilityMonitor callback");
});
```
## AbilityMonitor
Describes an ability monitor.
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
| Name | Type | Readable| Writable| Description |
| ------------------------------------------------------------ | -------- | ---- | ---- | ------------------------------------------------------------ |
| abilityName | string | Yes | Yes | Name of the ability bound to the ability monitor.<br>**System capability**: SystemCapability.Ability.AbilityRuntime.Core|
| onAbilityCreate?:(data: [Ability](js-apis-application-ability.md#Ability)) | function | Yes | Yes | Called when the ability is created.<br>If this attribute is not set, the corresponding lifecycle callback cannot be received.<br>**System capability**: SystemCapability.Ability.AbilityRuntime.Core|
| onAbilityForeground?:(data: [Ability](js-apis-application-ability.md#Ability)) | function | Yes | Yes | Called when the ability starts to run in the foreground.<br>If this attribute is not set, the corresponding lifecycle callback cannot be received.<br>**System capability**: SystemCapability.Ability.AbilityRuntime.Core|
| onAbilityBackground?:(data: [Ability](js-apis-application-ability.md#Ability)) | function | Yes | Yes | Called when the ability starts to run in the background.<br>If this attribute is not set, the corresponding lifecycle callback cannot be received.<br>**System capability**: SystemCapability.Ability.AbilityRuntime.Core|
| onAbilityDestroy?:(data: [Ability](js-apis-application-ability.md#Ability)) | function | Yes | Yes | Called when the ability is destroyed.<br>If this attribute is not set, the corresponding lifecycle callback cannot be received.<br>**System capability**: SystemCapability.Ability.AbilityRuntime.Core|
| onWindowStageCreate?:(data: [Ability](js-apis-application-ability.md#Ability)) | function | Yes | Yes | Called when the window stage is created.<br>If this attribute is not set, the corresponding lifecycle callback cannot be received.<br>**System capability**: SystemCapability.Ability.AbilityRuntime.Core|
| onWindowStageRestore?:(data: [Ability](js-apis-application-ability.md#Ability)) | function | Yes | Yes | Called when the window stage is restored.<br>If this attribute is not set, the corresponding lifecycle callback cannot be received.<br>**System capability**: SystemCapability.Ability.AbilityRuntime.Core|
| onWindowStageDestroy?:(data: [Ability](js-apis-application-ability.md#Ability)) | function | Yes | Yes | Called when the window stage is destroyed.<br>If this attribute is not set, the corresponding lifecycle callback cannot be received.<br>**System capability**: SystemCapability.Ability.AbilityRuntime.Core|
| abilityName | string | Yes | Yes | Name of the ability bound to the ability monitor. |
| onAbilityCreate?:(data: [Ability](js-apis-application-ability.md#Ability)) | function | Yes | Yes | Called when the ability is created.<br>If this attribute is not set, the corresponding lifecycle callback cannot be received. |
| onAbilityForeground?:(data: [Ability](js-apis-application-ability.md#Ability)) | function | Yes | Yes | Called when the ability starts to run in the foreground.<br>If this attribute is not set, the corresponding lifecycle callback cannot be received. |
| onAbilityBackground?:(data: [Ability](js-apis-application-ability.md#Ability)) | function | Yes | Yes | Called when the ability starts to run in the background.<br>If this attribute is not set, the corresponding lifecycle callback cannot be received. |
| onAbilityDestroy?:(data: [Ability](js-apis-application-ability.md#Ability)) | function | Yes | Yes | Called when the ability is destroyed.<br>If this attribute is not set, the corresponding lifecycle callback cannot be received. |
| onWindowStageCreate?:(data: [Ability](js-apis-application-ability.md#Ability)) | function | Yes | Yes | Called when the window stage is created.<br>If this attribute is not set, the corresponding lifecycle callback cannot be received. |
| onWindowStageRestore?:(data: [Ability](js-apis-application-ability.md#Ability)) | function | Yes | Yes | Called when the window stage is restored.<br>If this attribute is not set, the corresponding lifecycle callback cannot be received. |
| onWindowStageDestroy?:(data: [Ability](js-apis-application-ability.md#Ability)) | function | Yes | Yes | Called when the window stage is destroyed.<br>If this attribute is not set, the corresponding lifecycle callback cannot be received. |
# AbilityStage
**AbilityStage** is a runtime class for HAP files.
The **AbilityStage** module notifies you of when you can perform HAP initialization such as resource pre-loading and thread creation during the HAP loading.
> **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.
> 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 APIs of this module can be used only in the stage model.
Runtime class for HAP files. It provides APIs to notify you when a HAP file starts loading. You can then initialize the HAP file, for example, pre-load resources and create threads.
## Modules to Import
```js
......
# ApplicationContext
The **ApplicationContext** module provides application-level context. You can use the APIs of this module to register and deregister the ability lifecycle listener in an application.
> **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.
> The APIs of this module can be used only in the stage model.
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
Before calling any APIs in **ApplicationContext**, obtain an **ApplicationContext** instance through the **context** instance.
......@@ -42,6 +36,54 @@ Registers a listener to monitor the ability lifecycle of the application.
| ------ | ------------------------------ |
| number | ID of the registered listener. The ID is incremented by 1 each time the listener is registered. When the ID exceeds 2^63-1, **-1** is returned.|
**Example**
```js
import AbilityStage from "@ohos.application.AbilityStage";
var lifecycleId;
export default class MyAbilityStage extends AbilityStage {
onCreate() {
console.log("MyAbilityStage onCreate")
let AbilityLifecycleCallback = {
onAbilityCreate(ability){
console.log("AbilityLifecycleCallback onAbilityCreate ability:" + JSON.stringify(ability));
},
onAbilityWindowStageCreate(ability){
console.log("AbilityLifecycleCallback onAbilityWindowStageCreate ability:" + JSON.stringify(ability));
},
onAbilityWindowStageDestroy(ability){
console.log("AbilityLifecycleCallback onAbilityWindowStageDestroy ability:" + JSON.stringify(ability));
},
onAbilityDestroy(ability){
console.log("AbilityLifecycleCallback onAbilityDestroy ability:" + JSON.stringify(ability));
},
onAbilityForeground(ability){
console.log("AbilityLifecycleCallback onAbilityForeground ability:" + JSON.stringify(ability));
},
onAbilityBackground(ability){
console.log("AbilityLifecycleCallback onAbilityBackground ability:" + JSON.stringify(ability));
},
onAbilityContinue(ability){
console.log("AbilityLifecycleCallback onAbilityContinue ability:" + JSON.stringify(ability));
}
}
// 1. Obtain applicationContext through the context attribute.
let applicationContext = this.context.getApplicationContext();
// 2. Use applicationContext to register a listener for the ability lifecycle in the application.
lifecycleId = applicationContext.registerAbilityLifecycleCallback(AbilityLifecycleCallback);
console.log("registerAbilityLifecycleCallback number: " + JSON.stringify(lifecycleId));
}
onDestroy() {
let applicationContext = this.context.getApplicationContext();
applicationContext.unregisterAbilityLifecycleCallback(lifecycleId, (error, data) => {
console.log("unregisterAbilityLifecycleCallback success, err: " + JSON.stringify(error));
});
}
}
```
## ApplicationContext.unregisterAbilityLifecycleCallback
......@@ -61,47 +103,86 @@ Deregisters the listener that monitors the ability lifecycle of the application.
**Example**
```js
import AbilityStage from "@ohos.application.AbilityStage";
var lifecycleid;
export default class MyAbilityStage extends AbilityStage {
onCreate() {
console.log("MyAbilityStage onCreate")
let AbilityLifecycleCallback = {
onAbilityCreate(ability){
console.log("AbilityLifecycleCallback onAbilityCreate ability:" + JSON.stringify(ability));
},
onAbilityWindowStageCreate(ability){
console.log("AbilityLifecycleCallback onAbilityWindowStageCreate ability:" + JSON.stringify(ability));
},
onAbilityWindowStageDestroy(ability){
console.log("AbilityLifecycleCallback onAbilityWindowStageDestroy ability:" + JSON.stringify(ability));
},
onAbilityDestroy(ability){
console.log("AbilityLifecycleCallback onAbilityDestroy ability:" + JSON.stringify(ability));
},
onAbilityForeground(ability){
console.log("AbilityLifecycleCallback onAbilityForeground ability:" + JSON.stringify(ability));
},
onAbilityBackground(ability){
console.log("AbilityLifecycleCallback onAbilityBackground ability:" + JSON.stringify(ability));
},
onAbilityContinue(ability){
console.log("AbilityLifecycleCallback onAbilityContinue ability:" + JSON.stringify(ability));
}
}
// 1. Obtain applicationContext through the context attribute.
let applicationContext = this.context.getApplicationContext();
// 2. Use applicationContext to register a listener for the ability lifecycle in the application.
lifecycleid = applicationContext.registerAbilityLifecycleCallback(AbilityLifecycleCallback);
console.log("registerAbilityLifecycleCallback number: " + JSON.stringify(lifecycleid));
}
onDestroy() {
let applicationContext = this.context.getApplicationContext();
applicationContext.unregisterAbilityLifecycleCallback(lifecycleid, (error, data) => {
console.log("unregisterAbilityLifecycleCallback success, err: " + JSON.stringify(error));
});
}
}
let applicationContext = this.context.getApplicationContext();
let lifecycleId = 1;
console.log("stage applicationContext: " + JSON.stringify(applicationContext));
applicationContext.unregisterAbilityLifecycleCallback(lifecycleId, (error, data) => {
console.log("unregisterAbilityLifecycleCallback success, err: " + JSON.stringify(error));
});
```
## ApplicationContext.registerEnvironmentCallback
registerEnvironmentCallback(callback: EnvironmentCallback): **number**;
Registers a listener for system environment changes. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
**Parameters**
| Name | Type | Mandatory| Description |
| ------------------------ | -------- | ---- | ------------------------------ |
| [EnvironmentCallback](js-apis-application-EnvironmentCallback.md) | callback | Yes | Callback used to return the ID of the registered listener.|
**Return value**
| Type | Description |
| ------ | ------------------------------ |
| number | ID of the registered listener. The ID is incremented by 1 each time the listener is registered. When the ID exceeds 2^63-1, **-1** is returned.|
**Example**
```js
import AbilityStage from "@ohos.application.AbilityStage";
var callbackId;
export default class MyAbilityStage extends AbilityStage {
onCreate() {
console.log("MyAbilityStage onCreate")
globalThis.applicationContext = this.context.getApplicationContext();
let EnvironmentCallback = {
onConfigurationUpdated(config){
console.log("onConfigurationUpdated config:" + JSON.stringify(config));
},
}
// 1. Obtain an applicationContext object.
let applicationContext = globalThis.applicationContext;
// 2. Use applicationContext to register a listener for the ability lifecycle in the application.
callbackId = applicationContext.registerEnvironmentCallback(EnvironmentCallback);
console.log("registerEnvironmentCallback number: " + JSON.stringify(callbackId));
}
onDestroy() {
let applicationContext = globalThis.applicationContext;
applicationContext.unregisterEnvironmentCallback(callbackId, (error, data) => {
console.log("unregisterEnvironmentCallback success, err: " + JSON.stringify(error));
});
}
}
```
## ApplicationContext.unregisterEnvironmentCallback
unregisterEnvironmentCallback(callbackId: **number**, callback: AsyncCallback<**void**>): **void**;
Deregisters the listener for system environment changes. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
**Parameters**
| Name | Type | Mandatory| Description |
| ------------- | -------- | ---- | -------------------------- |
| callbackId | number | Yes | ID of the listener to deregister. |
| AsyncCallback | callback | Yes | Callback used to return the result. |
**Example**
```js
let applicationContext = this.context.getApplicationContext();
let callbackId = 1;
applicationContext.unregisterEnvironmentCallback(callbackId, (error, data) => {
console.log("unregisterEnvironmentCallback success, err: " + JSON.stringify(error));
});
```
# Context
The **Context** module provides the context for running code. You can use the APIs to query and set the application information and resource manager.
> **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.
> The APIs of this module can be used only in the stage model.
Provides the context for running code, including **applicationInfo** and **resourceManager**.
## Modules to Import
```
import AbilityContext from '@ohos.application.Ability';
```
## Usage
You must extend **AbilityContext** to implement this module.
```js
import AbilityContext from '@ohos.application.Ability'
class MainAbility extends AbilityContext {
onWindowStageCreate(windowStage) {
let test = "com.example.test";
let context = this.context.createBundleContext(test);
}
}
```
## Attributes
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
| Name| Type| Readable| Writable| Description|
| Name| Type| Readable| Writable| Description|
| -------- | -------- | -------- | -------- | -------- |
| resourceManager | ResourceManager | Yes| No| **ResourceManager** object.|
| resourceManager | resmgr.ResourceManager; | Yes| No| **ResourceManager** object.|
| applicationInfo | ApplicationInfo | Yes| No| Information about the application.|
| cacheDir | string | Yes| No| Cache directory of the application on the internal storage.|
| tempDir | string | Yes| No| Temporary file directory of the application.|
| filesDir | string | Yes| No| File directory of the application on the internal storage.|
| databaseDir | string | Yes| No| Storage directory of local data.|
| storageDir | string | Yes| No| Storage directory of lightweight data.|
| bundleCodeDir | string | Yes| No| Application installation path.|
| distributedFilesDir | string | Yes| No| Storage directory of distributed application data files.|
| eventHub | [EventHub](js-apis-eventhub.md) | Yes| No| Event hub information.|
| area | [AreaMode](#areamode) | Yes| Yes| Area in which the file to be access is located.|
| preferencesDir | string | Yes| Yes| Preferences directory of the application.|
## Context.createBundleContext
......@@ -41,19 +45,23 @@ createBundleContext(bundleName: string): Context;
Creates a context for a given application.
**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
**System API**: This is a system API and cannot be called by third-party applications.
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| bundleName | string | Yes| Application bundle name.|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| bundleName | string | Yes| Application bundle name.|
**Return value**
| Type| Description|
| -------- | -------- |
| Context | Context created.|
| Type| Description|
| -------- | -------- |
| Context | Context created.|
**Example**
......@@ -79,15 +87,15 @@ Creates a context for a given HAP.
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| moduleName | string | Yes| HAP name in the application.|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| moduleName | string | Yes| HAP name in the application.|
**Return value**
| Type| Description|
| -------- | -------- |
| Context | Context created.|
| Type| Description|
| -------- | -------- |
| Context | Context created.|
**Example**
......@@ -111,18 +119,20 @@ Creates a context for a given HAP in an application.
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
**System API**: This is a system API and cannot be called by third-party applications.
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| bundleName | string | Yes| Application bundle name.|
| moduleName | string | Yes| HAP name in the application.|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| bundleName | string | Yes| Application bundle name.|
| moduleName | string | Yes| HAP name in the application.|
**Return value**
| Type| Description|
| -------- | -------- |
| Context | Context created.|
| Type| Description|
| -------- | -------- |
| Context | Context created.|
**Example**
......
# ShellCmdResult
The **ShellCmdResult** module provides the shell command execution result.
> **NOTE**
>
> 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
## Usage
The result is obtained by calling **executeShellCommand** in **abilityDelegator**.
```js
import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'
var abilityDelegator;
var cmd = "cmd";
var timeout = 100;
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator();
abilityDelegator.executeShellCommand(cmd, timeout).then((data : any) => {
console.info("executeShellCommand promise");
});
```
## ShellCmdResult
Describes the shell command execution result.
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
| Name | Type | Readable| Writable| Description |
| --------- | ------ | ---- | ---- | ------------------------------------------------------------ |
| stdResult | string | Yes | Yes | Standard output content.<br>**System capability**: SystemCapability.Ability.AbilityRuntime.Core|
| exitCode | number | Yes | Yes | Result code.<br>**System capability**: SystemCapability.Ability.AbilityRuntime.Core|
| stdResult | string | Yes | Yes | Standard output content. |
| exitCode | number | Yes | Yes | Result code. |
# StaticSubscriberExtensionAbility
The **StaticSubscriberExtensionAbility** module provides Extension abilities for static subscribers.
> **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.
......@@ -16,13 +18,15 @@ onReceiveEvent(event: CommonEventData): void;
Callback of the common event of a static subscriber.
**System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
**System API**: This is a system API and cannot be called by third-party applications.
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| event | CommonEventData | Yes| Callback of the common event of a static subscriber.|
| event | CommonEventData | Yes| Common event of a static subscriber.|
**Example**
......
# Configuration
The **Configuration** module provides environment configuration information.
> **NOTE**
>
> 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 the configuration for the environment where the ability is running.
## Modules to Import
```js
......@@ -23,3 +23,4 @@ import Configuration from '@ohos.application.Configuration';
| direction<sup>9+</sup> | Direction | Yes| No| Screen orientation, which can be **DIRECTION_HORIZONTAL** or **DIRECTION_VERTICAL**.|
| screenDensity<sup>9+</sup> | ScreenDensity | Yes| No| Screen resolution, which can be **SCREEN_DENSITY_SDPI** (120), **SCREEN_DENSITY_MDPI** (160), **SCREEN_DENSITY_LDPI** (240), **SCREEN_DENSITY_XLDPI** (320), **SCREEN_DENSITY_XXLDPI** (480), or **SCREEN_DENSITY_XXXLDPI** (640).|
| displayId<sup>9+</sup> | number | Yes| No| ID of the display where the application is located.|
| hasPointerDevice<sup>9+</sup> | boolean | Yes| No| Whether the pointer device is connected.|
# ConfigurationConstant
The **ConfigurationConstant** module provides the enumerated values of the environment configuration information.
> **NOTE**
>
> 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.
Defines enumerated values of the configuration for the environment where the ability is running.
## Modules to Import
......@@ -15,7 +13,6 @@ Defines enumerated values of the configuration for the environment where the abi
import ConfigurationConstant from '@ohos.application.ConfigurationConstant';
```
## ConfigurationConstant.ColorMode
You can obtain the value of this constant by calling the **ConfigurationConstant.ColorMode** API.
......
# EventHub
The **EventHub** module provides APIs to subscribe to, unsubscribe from, and trigger events.
> **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.
> 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 APIs of this module can be used only in the stage model.
Implements event subscription, unsubscription, and triggering.
## Modules to Import
```js
import Ability from '@ohos.application.Ability'
```
## Usage
​Before using any APIs in the **EventHub**, you must obtain an **EventHub** instance through the member variable **context** of the **Ability** instance.
......
# ExtensionContext
The **ExtensionContext** module, inherited from **Context**, implements the context for Extension abilities.
This module allows access to Extension abilities.
> **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.
> The APIs of this module can be used only in the stage model.
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.|
| extensionAbilityInfo | [ExtensionAbilityInfo](js-apis-bundle-ExtensionAbilityInfo.md) | Yes| No| Extension ability information.|
# ExtensionRunningInfo
The **ExtensionRunningInfo** module provides running information and states for Extension abilities.
> **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.
Provides extension running information.
## Modules to Import
```js
import abilitymanager from '@ohos.application.abilityManager';
```
> The APIs of this module are system APIs and cannot be called by third-party applications.
## Usage
The extension running information is obtained through an **abilityManager** instance.
The Extension ability running information is obtained through an **abilityManager** instance.
```js
import abilitymanager from '@ohos.application.abilityManager';
......@@ -24,37 +19,16 @@ abilitymanager.getExtensionRunningInfos(upperLimit, (err,data) => {
});
```
### Attributes
## Attributes
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
| Name| Type| Readable| Writable| Description|
| -------- | -------- | -------- | -------- | -------- |
| extension | ElementName | Yes| No| Information that matches an extension.|
| extension | ElementName | Yes| No| Information that matches an Extension ability.|
| pid | number | Yes| No| Process ID.|
| uid | number | Yes| No| User ID.|
| processName | string | Yes| No| Process name.|
| startTime | number | Yes| No| Extension start time.|
| startTime | number | Yes| No| Start time of the Extension ability.|
| clientPackage | Array&lt;String&gt; | Yes| No| Names of all packages in the process.|
| type | [bundle.ExtensionAbilityType](#bundleextensionabilitytype) | Yes| No| Extension type.|
## bundle.ExtensionAbilityType
Enumerates extension types.
**System capability**: SystemCapability.BundleManager.BundleFramework
| Name| Value| Description|
| -------- | -------- | -------- |
| FORM | 0 | Extension information of the form type.< |
| WORK_SCHEDULER | 1 | Extension information of the work scheduler type.< |
| INPUT_METHOD | 2 | Extension information of the input method type.< |
| SERVICE | 3 | Extension information of the service type.< |
| ACCESSIBILITY | 4 | Extension information of the accessibility type.< |
| DATA_SHARE | 5 | Extension information of the data share type.< |
| FILE_SHARE | 6 | Extension information of the file share type.< |
| STATIC_SUBSCRIBER | 7 | Extension information of the static subscriber type.< |
| WALLPAPER | 8 | Extension information of the wallpaper type.< |
| UNSPECIFIED | 9 | Extension information of the unspecified type.< |
| type | [bundle.ExtensionAbilityType](js-apis-Bundle.md#extensionabilitytype9) | Yes| No| Extension ability type.|
# FeatureAbility
The **FeatureAbility** module provides a UI for interacting with users. You can use APIs of this module to start a new ability, obtain the **dataAbilityHelper**, set a Page ability, obtain the window corresponding to this ability, and connecting to a Service ability.
> **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.
......@@ -19,7 +21,7 @@ import featureAbility from '@ohos.ability.featureAbility'
startAbility(parameter: StartAbilityParameter, callback: AsyncCallback\<number>): void
Starts an ability. This API uses a callback to return the result.
Starts an ability. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Ability.AbilityRuntime.FAModel
......@@ -127,7 +129,7 @@ featureAbility.acquireDataAbilityHelper(
startAbilityForResult(parameter: StartAbilityParameter, callback: AsyncCallback\<AbilityResult>): void
Starts an ability. This API uses a callback to return the execution result when the ability is destroyed.
Starts an ability. This API uses an asynchronous callback to return the execution result when the ability is destroyed.
**System capability**: SystemCapability.Ability.AbilityRuntime.FAModel
......@@ -214,7 +216,6 @@ featureAbility.startAbilityForResult(
mykey7: true,
},
},
requestCode: 2,
},
).then((data) => {
console.info("==========================>startAbilityForResult=======================>");
......@@ -225,7 +226,7 @@ featureAbility.startAbilityForResult(
terminateSelfWithResult(parameter: AbilityResult, callback: AsyncCallback\<void>): void
Destroys this Page ability, with the result code and data sent to the caller. This API uses a callback to return the result.
Destroys this Page ability, with the result code and data sent to the caller. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Ability.AbilityRuntime.FAModel
......@@ -326,13 +327,11 @@ featureAbility.terminateSelfWithResult(
});
```
## featureAbility.hasWindowFocus<sup>7+<sup>
hasWindowFocus(callback: AsyncCallback\<boolean>): void
Checks whether the main window of this ability has the focus. This API uses a callback to return the result.
Checks whether the main window of this ability has the focus. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Ability.AbilityRuntime.FAModel
......@@ -349,8 +348,6 @@ import featureAbility from '@ohos.ability.featureAbility';
featureAbility.hasWindowFocus()
```
## featureAbility.hasWindowFocus<sup>7+<sup>
hasWindowFocus(): Promise\<boolean>
......@@ -368,19 +365,17 @@ Checks whether the main window of this ability has the focus. This API uses a pr
**Example**
```javascript
import featureAbility from '@ohos.ability.featureability';
import featureAbility from '@ohos.ability.featureAbility';
featureAbility.hasWindowFocus().then((data) => {
console.info("==========================>hasWindowFocus=======================>");
});
```
## featureAbility.getWant
getWant(callback: AsyncCallback\<Want>): void
Obtains the **Want** object sent from this ability. This API uses a callback to return the result.
Obtains the **Want** object sent from this ability. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Ability.AbilityRuntime.FAModel
......@@ -397,8 +392,6 @@ import featureAbility from '@ohos.ability.featureAbility';
featureAbility.getWant()
```
## featureAbility.getWant
getWant(): Promise\<Want>
......@@ -444,13 +437,11 @@ var context = featureAbility.getContext()
context.getBundleName()
```
## featureAbility.terminateSelf<sup>7+</sup>
terminateSelf(callback: AsyncCallback\<void>): void
Destroys this Page ability, with the result code and data sent to the caller. This API uses a callback to return the result.
Destroys this Page ability, with the result code and data sent to the caller. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Ability.AbilityRuntime.FAModel
......@@ -467,8 +458,6 @@ import featureAbility from '@ohos.ability.featureAbility';
featureAbility.terminateSelf()
```
## featureAbility.terminateSelf<sup>7+</sup>
terminateSelf(): Promise\<void>
......@@ -496,7 +485,7 @@ featureAbility.terminateSelf().then((data) => {
connectAbility(request: Want, options:ConnectOptions): number
Connects this ability to a specific Service ability. This API uses a callback to return the result.
Connects this ability to a specific Service ability. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Ability.AbilityRuntime.FAModel
......@@ -505,17 +494,9 @@ Connects this ability to a specific Service ability. This API uses a callback to
| Name | Type | Mandatory | Description |
| ------- | -------------- | ---- | --------------------- |
| request | [Want](js-apis-application-Want.md) | Yes | Service ability to connect.|
| options | ConnectOptions | Yes | Callback used to return the result. |
| options | [ConnectOptions](#connectoptions) | Yes | Callback used to return the result. |
Want
**System capability**: SystemCapability.Ability.AbilityBase
| Name | Readable/Writable| Type | Mandatory | Description |
| ----------- | ---- | ------ | ---- | ---------------------------------------- |
| deviceId | Read-only | string | No | Device ID of the Service ability to connect. The default value is the local device ID.|
| bundleName | Read-only | string | Yes | Bundle name of the Service ability to connect. |
| abilityName | Read-only | string | Yes | Class name of the Service ability to connect. |
## ConnectOptions
ConnectOptions
......@@ -523,9 +504,9 @@ ConnectOptions
| Name | Readable/Writable| Type | Mandatory | Description |
| ------------ | ---- | -------- | ---- | ------------------------- |
| onConnect | Read-only | function | Yes | Callback invoked when the connection is successful. |
| onDisconnect | Read-only | function | Yes | Callback invoked when the connection fails. |
| onFailed | Read-only | function | Yes | Callback invoked when **connectAbility** fails to be called.|
| onConnect<sup>7+</sup> | Read-only | function | Yes | Callback invoked when the connection is successful. |
| onDisconnect<sup>7+</sup> | Read-only | function | Yes | Callback invoked when the connection fails. |
| onFailed<sup>7+</sup> | Read-only | function | Yes | Callback invoked when **connectAbility** fails to be called.|
**Return value**
......@@ -565,7 +546,7 @@ var connId = featureAbility.connectAbility(
disconnectAbility(connection: number, callback:AsyncCallback\<void>): void
Disconnects this ability from a specific Service ability. This API uses a callback to return the result.
Disconnects this ability from a specific Service ability. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Ability.AbilityRuntime.FAModel
......@@ -654,8 +635,10 @@ var connId = featureAbility.connectAbility(
},
);
featureAbility.disconnectAbility(connId).then((error,data) => {
console.log('featureAbilityTest result errCode : ' + error.code + " data: " + data);
featureAbility.disconnectAbility(connId).then((data) => {
console.log('data : ' + data);
}).catch((error)=>{
console.log('featureAbilityTest result errCode : ' + error.code);
});
```
......@@ -664,7 +647,7 @@ featureAbility.disconnectAbility(connId).then((error,data) => {
getWindow(callback: AsyncCallback\<window.Window>): void
Obtains the window corresponding to this ability. This API uses a callback to return the result.
Obtains the window corresponding to this ability. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Ability.AbilityRuntime.FAModel
......@@ -914,7 +897,7 @@ Enumerates operation types of the Data ability.
## StartAbilityParameter
**System capability**: SystemCapability.AbilityRuntime.FAModel
**System capability**: SystemCapability.Ability.AbilityRuntime.FAModel
| Name | Readable/Writable| Type | Mandatory | Description |
| ------------------- | ---- | -------------------- | ---- | -------------------------------------- |
......@@ -925,7 +908,7 @@ Enumerates operation types of the Data ability.
**System capability**: SystemCapability.Ability.AbilityBase
| Name | Value | Description |
| Name | Name | Description |
| ------------------------------------ | ---------- | ---------------------------------------- |
| FLAG_AUTH_READ_URI_PERMISSION | 0x00000001 | Indicates the permission to read the URI. |
| FLAG_AUTH_WRITE_URI_PERMISSION | 0x00000002 | Indicates the permission to write the URI. |
......@@ -933,10 +916,10 @@ Enumerates operation types of the Data ability.
| FLAG_ABILITY_CONTINUATION | 0x00000008 | Indicates whether the ability on the local device can be migrated to a remote device. |
| FLAG_NOT_OHOS_COMPONENT | 0x00000010 | Indicates that a component does not belong to OHOS. |
| FLAG_ABILITY_FORM_ENABLED | 0x00000020 | Indicates whether to enable an ability. |
| FLAG_AUTH_PERSISTABLE_URI_PERMISSION | 0x00000040 | Indicates the permission to make the URI persistent. |
| FLAG_AUTH_PREFIX_URI_PERMISSION | 0x00000080 | Indicates the permission to verify URIs by prefix matching. |
| FLAG_AUTH_PERSISTABLE_URI_PERMISSION | 0x00000040 | Indicates the permission to make the URI persistent.<br>**System API**: This is a system API and cannot be called by third-party applications. |
| FLAG_AUTH_PREFIX_URI_PERMISSION | 0x00000080 | Indicates the permission to verify URIs by prefix matching.<br>**System API**: This is a system API and cannot be called by third-party applications. |
| FLAG_ABILITYSLICE_MULTI_DEVICE | 0x00000100 | Supports cross-device startup in a distributed scheduler. |
| FLAG_START_FOREGROUND_ABILITY | 0x00000200 | Indicates that the Service ability is started regardless of whether the host application has been started. |
| FLAG_START_FOREGROUND_ABILITY | 0x00000200 | Indicates that the Service ability is started regardless of whether the host application has been started.<br>**System API**: This is a system API and cannot be called by third-party applications. |
| FLAG_ABILITY_CONTINUATION_REVERSIBLE | 0x00000400 | Indicates that the migration is reversible. |
| FLAG_INSTALL_ON_DEMAND | 0x00000800 | Indicates that the specific ability will be installed if it has not been installed. |
| FLAG_INSTALL_WITH_BACKGROUND_MODE | 0x80000000 | Indicates that the specific ability will be installed in the background if it has not been installed. |
......
# FormInfo
The **FormInfo** module provides widget information and state.
> **NOTE**
>
> 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 widget information.
## Modules to Import
```
......@@ -14,15 +14,13 @@ import formInfo from '@ohos.application.formInfo';
## Required Permissions
None.
None
## FormInfo
Describes widget information.
**System capability**
SystemCapability.Ability.Form
**System capability**: SystemCapability.Ability.Form
| Name | Readable/Writable| Type | Description |
| ----------- | -------- | -------------------- | ------------------------------------------------------------ |
......@@ -43,15 +41,13 @@ SystemCapability.Ability.Form
| updateDuration | Read only | string | Widget update period.|
| defaultDimension | Read only | number | Default dimension of the widget. |
| supportDimensions | Read only | Array&lt;number&gt; | Dimensions supported by the widget. |
| customizeData | Read only | {[key: string]: [value: string]} | Custom data of the widget. |
| customizeData | Read only | {[key: string]: [value: string]} | Custom data of the widget. |
## FormType
Enumerates the widget types.
**System capability**
SystemCapability.Ability.Form
**System capability**: SystemCapability.Ability.Form
| Name | Value | Description |
| ----------- | ---- | ------------ |
......@@ -61,13 +57,11 @@ SystemCapability.Ability.Form
Enumerates the color modes supported by the widget.
**System capability**
SystemCapability.Ability.Form
**System capability**: SystemCapability.Ability.Form
| Name | Value | Description |
| ----------- | ---- | ------------ |
| MODE_AUTO | -1 | Automatic mode. |
| MODE_AUTO | -1 | Auto mode. |
| MODE_DARK | 0 | Dark mode. |
| MODE_LIGHT | 1 | Light mode. |
......@@ -75,22 +69,18 @@ SystemCapability.Ability.Form
Describes the widget state information.
**System capability**
SystemCapability.Ability.Form
**System capability**: SystemCapability.Ability.Form
| Name | Readable/Writable| Type | Description |
| ----------- | -------- | -------------------- | ------------------------------------------------------------ |
| formState | Read only | [FormState](#formstate) | Widget state. |
| formState | Read only | [FormState](#formstate) | Widget state. |
| want | Read only | Want | Want text. |
## FormState
Enumerates the widget states.
**System capability**
SystemCapability.Ability.Form
**System capability**: SystemCapability.Ability.Form
| Name | Value | Description |
| ----------- | ---- | ------------ |
......@@ -102,13 +92,11 @@ SystemCapability.Ability.Form
Enumerates the widget parameters.
**System capability**
SystemCapability.Ability.Form
**System capability**: SystemCapability.Ability.Form
| Name | Value | Description |
| ----------- | ---- | ------------ |
| IDENTITY_KEY | "ohos.extra.param.key.form_identity" | ID of a widget. |
| IDENTITY_KEY | "ohos.extra.param.key.form_identity" | ID of a widget.<br>**System API**: This is a system API and cannot be called by third-party applications. |
| DIMENSION_KEY | "ohos.extra.param.key.form_dimension" | Widget dimension. |
| NAME_KEY | "ohos.extra.param.key.form_name" | Widget name. |
| MODULE_NAME_KEY | "ohos.extra.param.key.module_name" | Name of the module to which the widget belongs. |
......
# FormBindingData
The **FormBindingData** module provides APIs for widget data binding. You can use the APIs to create a **FormBindingData** object and obtain related information.
> **NOTE**
>
> 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.
......@@ -26,7 +28,7 @@ Creates a **FormBindingData** object.
| Name| Type | Mandatory| Description |
| ------ | -------------- | ---- | ------------------------------------------------------------ |
| obj | Object or string| No | Data to be displayed on the JS service widget. The value can be an object containing multiple key-value pairs or a string in JSON format. The image data is identified by "formImages", and the content is multiple key-value pairs, each of which consists of an image identifier and image file descriptor. The final format is {"formImages": {"key1": fd1, "key2": fd2}}.|
| obj | Object or string| No | Data to be displayed on the JS widget. The value can be an object containing multiple key-value pairs or a string in JSON format. The image data is identified by "formImages", and the content is multiple key-value pairs, each of which consists of an image identifier and image file descriptor. The final format is {"formImages": {"key1": fd1, "key2": fd2}}.|
**Return value**
......@@ -63,4 +65,4 @@ Describes a **FormBindingData** object.
| Name| Readable| Writable| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | -------- | -------- |
| data | Yes| No| Object | Yes| Data to be displayed on the JS service widget. The value can be an object containing multiple key-value pairs or a string in JSON format.|
| data | Yes| No| Object | Yes| Data to be displayed on the JS widget. The value can be an object containing multiple key-value pairs or a string in JSON format.|
# FormError
The **FormError** module provides error codes for widgets.
> **NOTE**
>
> 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 widget-related error codes.
## Modules to Import
```
......
# FormExtension
The **FormExtension** module provides APIs related to Form Extension abilities.
> **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.
> The APIs of this module can be used only in the stage model.
Provides **FormExtension** APIs.
## Modules to Import
```
......@@ -35,15 +35,15 @@ Called to notify the widget provider that a **Form** instance (widget) has been
**Parameters**
| Name| Type | Mandatory| Description |
| ------ | -------------------------------------- | ---- | ------------------------------------------------------------ |
| want | [Want](js-apis-application-Want.md) | Yes | Information related to the extension, including the widget ID, name, and style. The information must be managed as persistent data to facilitate subsequent widget update and deletion.|
| Name| Type | Mandatory| Description |
| ------ | -------------------------------------- | ---- | ------------------------------------------------------------ |
| want | [Want](js-apis-application-Want.md) | Yes | Information related to the extension, including the widget ID, name, and style. The information must be managed as persistent data to facilitate subsequent widget update and deletion.|
**Return value**
| Type | Description |
| ------------------------------------------------------------ | ----------------------------------------------------------- |
| [formBindingData.FormBindingData](js-apis-formbindingdata.md#formbindingdata) | A **formBindingData.FormBindingData** object containing the data to be displayed on the widget.|
| Type | Description |
| ------------------------------------------------------------ | ----------------------------------------------------------- |
| [formBindingData.FormBindingData](js-apis-formbindingdata.md#formbindingdata) | A **formBindingData.FormBindingData** object containing the data to be displayed on the widget.|
**Example**
......@@ -72,9 +72,9 @@ Called to notify the widget provider that a temporary widget has been converted
**Parameters**
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ------------------------ |
| formId | string | Yes | ID of the widget that requests to be converted to a normal one.|
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ------------------------ |
| formId | string | Yes | ID of the widget that requests to be converted to a normal one.|
**Example**
......@@ -96,9 +96,9 @@ Called to notify the widget provider that a widget has been updated. After obtai
**Parameters**
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ------------------ |
| formId | string | Yes | ID of the widget that requests to be updated.|
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ------------------ |
| formId | string | Yes | ID of the widget that requests to be updated.|
**Example**
......@@ -127,9 +127,9 @@ Called to notify the widget provider of the change of visibility.
**Parameters**
| Name | Type | Mandatory| Description |
| --------- | ------------------------- | ---- | ---------------------------- |
| newStatus | { [key: string]: number } | Yes | ID and visibility status of the widget to be changed.|
| Name | Type | Mandatory| Description |
| --------- | ------------------------- | ---- | ---------------------------- |
| newStatus | { [key: string]: number } | Yes | ID and visibility status of the widget to be changed.|
**Example**
......@@ -162,10 +162,10 @@ Called to instruct the widget provider to receive and process the widget event.
**Parameters**
| Name | Type | Mandatory| Description |
| ------- | ------ | ---- | ---------------------- |
| formId | string | Yes | ID of the widget that requests the event.|
| message | string | Yes | Event message. |
| Name | Type | Mandatory| Description |
| ------- | ------ | ---- | ---------------------- |
| formId | string | Yes | ID of the widget that requests the event.|
| message | string | Yes | Event message. |
**Example**
......@@ -187,9 +187,9 @@ Called to notify the widget provider that a **Form** instance (widget) has been
**Parameters**
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ------------------ |
| formId | string | Yes | ID of the widget to be destroyed.|
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ------------------ |
| formId | string | Yes | ID of the widget to be destroyed.|
**Example**
......@@ -211,9 +211,9 @@ Called when the configuration of the environment where the ability is running is
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| config | [Configuration](js-apis-configuration.md) | Yes| New configuration.|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| config | [Configuration](js-apis-configuration.md) | Yes| New configuration.|
**Example**
......@@ -225,28 +225,28 @@ Called when the configuration of the environment where the ability is running is
}
```
## FormExtension.onAcquireFormState
## FormExtension.onAcquireFormState
onAcquireFormState?(want: Want): formInfo.FormState;
Called when the widget provider receives the status query result of a specified service widget. By default, the initial state is returned.
Called when the widget provider receives the status query result of a widget. By default, the initial 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.|
| 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'
import formInfo from '@ohos.application.formInfo'
class MyFormExtension extends FormExtension {
onAcquireFormState(want) {
console.log('FormExtension onAcquireFormState, want:' + want);
return fromInfo.FormState.UNKNOWN;
return formInfo.FormState.UNKNOWN;
}
}
```
# FormExtensionContext
> **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.
> The APIs of this module can be used only in the stage model.
The **FormExtensionContext** module, inherited from **ExtensionContext**, provides context for Form Extension abilities.
Implements the context that provides the capabilities and APIs of **FormExtension**. This class is inherited from **ExtensionContext**.
You can use the APIs of this module to start abilities.
## Modules to Import
```js
import FormExtension from '@ohos.application.FormExtension';
```
> **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.
> The APIs of this module can be used only in the stage model.
## FormExtensionContext.updateForm
## FormExtensionContext.startAbility
updateForm(formId: string, formBindingData: formBindingData.FormBindingData, callback: AsyncCallback\<void>): void
startAbility(want: Want, callback: AsyncCallback&lt;void&gt;): void
Updates a widget. This method uses a callback to return the result.
Starts an ability. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Ability.Form
**System API**: This is a system API and cannot be called by third-party applications.
**Parameters**
| Name | Type | Mandatory| Description |
| --------------- | ------------------------------------------------------------ | ---- | -------------------------------------- |
| formId | string | Yes | ID of the widget that requests to be updated. |
| formBindingData | [formBindingData.FormBindingData](js-apis-formbindingdata.md#formbindingdata) | Yes | New data of the widget. |
| callback | AsyncCallback\<void> | Yes | Callback used to return the result indicating whether the method is successfully called.|
| 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.|
| callback| AsyncCallback&lt;void&gt; | Yes | Callback used to return the result.|
**Example**
```js
import formBindingData from '@ohos.application.formBindingData'
export default class MyFormExtension extends FormExtension {
onUpdate(formId) {
console.log('FormExtension onUpdate, formId:' + formId);
let obj2 = formBindingData.createFormBindingData({temperature:"22c", time:"22:00"});
this.context.updateForm(formId, obj2, (data)=>{
console.log('FormExtension context updateForm, data:' + data);
});
}
}
```
```js
var want = {
deviceId: "",
bundleName: "com.example.formstartability",
abilityName: "MainAbility",
action: "action1",
entities: ["entity1"],
type: "MIMETYPE",
uri: "key={true,true,false}",
parameters: {}
}
this.context.startAbility(want, function(err) {
console.info(err.code);
})
```
## FormExtensionContext.updateForm
## FormExtensionContext.startAbility
updateForm(formId: string, formBindingData: formBindingData.FormBindingData): Promise\<void>
startAbility(want: Want): Promise&lt;void&gt;
Updates a widget. This method uses a promise to return the result.
Starts an ability. This API uses a promise to return the result.
**System capability**: SystemCapability.Ability.Form
**System API**: This is a system API and cannot be called by third-party applications.
**Parameters**
| Name | Type | Mandatory| Description |
| --------------- | ------------------------------------------------------------ | ---- | ------------------ |
| formId | string | Yes | ID of the widget that requests to be updated.|
| formBindingData | [formBindingData.FormBindingData](js-apis-formbindingdata.md#formbindingdata) | Yes | New data of the widget. |
| 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 |
| -------------- | --------------------------------- |
| Promise\<void> | Promise returned with the result indicating whether the method is successfully called.|
| Type | Description |
| ------------ | ---------------------------------- |
| Promise\<void> | Promise used to return the result.|
**Example**
```js
import formBindingData from '@ohos.application.formBindingData'
export default class MyFormExtension extends FormExtension {
onUpdate(formId) {
console.log('FormExtension onUpdate, formId:' + formId);
let obj2 = formBindingData.createFormBindingData({temperature:"22c", time:"22:00"});
this.context.updateForm(formId, obj2)
.then((data)=>{
console.log('FormExtension context updateForm, data:' + data);
}).catch((error) => {
console.error('Operation updateForm failed. Cause: ' + error);});
}
}
```
```js
var want = {
deviceId: "",
bundleName: "com.example.formstartability",
abilityName: "MainAbility",
action: "action1",
entities: ["entity1"],
type: "MIMETYPE",
uri: "key={true,true,false}",
parameters: {}
}
this.context.startAbility(want).then(() => {
console.info("StartAbility Success");
}).catch((error) => {
console.info("StartAbility failed");
});
```
# FormHost
The **FormHost** module provides APIs related to the widget host, which is an application that displays the widget content and controls the position where the widget is displayed. You can use the APIs to delete, release, and update widgets, send notifications to widgets, and obtain widget information and status.
> **NOTE**
>
> 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.
## Modules to Import
```
......@@ -24,9 +24,11 @@ deleteForm(formId: string, callback: AsyncCallback&lt;void&gt;): void;
Deletes a widget. This API uses an asynchronous callback to return the result. After this API is called, the application can no longer use the widget, and the Widget Manager will not retain the widget information.
**System capability**
**Required permissions**: ohos.permission.REQUIRE_FORM
**System capability**: SystemCapability.Ability.Form
SystemCapability.Ability.Form
**System API**: This is a system API and cannot be called by third-party applications.
**Parameters**
......@@ -52,9 +54,11 @@ deleteForm(formId: string): Promise&lt;void&gt;;
Deletes a widget. This API uses a promise to return the result. After this API is called, the application can no longer use the widget, and the Widget Manager will not retain the widget information.
**System capability**
**Required permissions**: ohos.permission.REQUIRE_FORM
SystemCapability.Ability.Form
**System capability**: SystemCapability.Ability.Form
**System API**: This is a system API and cannot be called by third-party applications.
**Parameters**
......@@ -85,9 +89,11 @@ releaseForm(formId: string, callback: AsyncCallback&lt;void&gt;): void;
Releases a widget. This API uses an asynchronous callback to return the result. After this API is called, the application can no longer use the widget, but the Widget Manager still retains the widget cache and storage information.
**System capability**
**Required permissions**: ohos.permission.REQUIRE_FORM
**System capability**: SystemCapability.Ability.Form
SystemCapability.Ability.Form
**System API**: This is a system API and cannot be called by third-party applications.
**Parameters**
......@@ -113,9 +119,11 @@ releaseForm(formId: string, isReleaseCache: boolean, callback: AsyncCallback&lt;
Releases a widget. This API uses an asynchronous callback to return the result. After this API is called, the application can no longer use the widget, but the Widget Manager retains the storage information about the widget and retains or releases the cache information based on the setting.
**System capability**
**Required permissions**: ohos.permission.REQUIRE_FORM
SystemCapability.Ability.Form
**System capability**: SystemCapability.Ability.Form
**System API**: This is a system API and cannot be called by third-party applications.
**Parameters**
......@@ -142,9 +150,11 @@ releaseForm(formId: string, isReleaseCache?: boolean): Promise&lt;void&gt;;
Releases a widget. This API uses a promise to return the result. After this API is called, the application can no longer use the widget, but the Widget Manager retains the storage information about the widget and retains or releases the cache information based on the setting.
**System capability**
**Required permissions**: ohos.permission.REQUIRE_FORM
**System capability**: SystemCapability.Ability.Form
SystemCapability.Ability.Form
**System API**: This is a system API and cannot be called by third-party applications.
**Parameters**
......@@ -176,9 +186,11 @@ requestForm(formId: string, callback: AsyncCallback&lt;void&gt;): void;
Requests a widget update. This API uses an asynchronous callback to return the result.
**System capability**
**Required permissions**: ohos.permission.REQUIRE_FORM
SystemCapability.Ability.Form
**System capability**: SystemCapability.Ability.Form
**System API**: This is a system API and cannot be called by third-party applications.
**Parameters**
......@@ -204,9 +216,11 @@ requestForm(formId: string): Promise&lt;void&gt;;
Requests a widget update. This API uses a promise to return the result.
**System capability**
**Required permissions**: ohos.permission.REQUIRE_FORM
**System capability**: SystemCapability.Ability.Form
SystemCapability.Ability.Form
**System API**: This is a system API and cannot be called by third-party applications.
**Parameters**
......@@ -237,9 +251,11 @@ castTempForm(formId: string, callback: AsyncCallback&lt;void&gt;): void;
Converts a temporary widget to a normal one. This API uses an asynchronous callback to return the result.
**System capability**
**Required permissions**: ohos.permission.REQUIRE_FORM
SystemCapability.Ability.Form
**System capability**: SystemCapability.Ability.Form
**System API**: This is a system API and cannot be called by third-party applications.
**Parameters**
......@@ -265,9 +281,11 @@ castTempForm(formId: string): Promise&lt;void&gt;;
Converts a temporary widget to a normal one. This API uses a promise to return the result.
**System capability**
**Required permissions**: ohos.permission.REQUIRE_FORM
**System capability**: SystemCapability.Ability.Form
SystemCapability.Ability.Form
**System API**: This is a system API and cannot be called by third-party applications.
**Parameters**
......@@ -298,9 +316,11 @@ notifyVisibleForms(formIds: Array&lt;string&gt;, callback: AsyncCallback&lt;void
Instructs the widget framework to make a widget visible. This API uses an asynchronous callback to return the result. After this API is called, **onVisibilityChange** is invoked to notify the widget provider.
**System capability**
**Required permissions**: ohos.permission.REQUIRE_FORM
**System capability**: SystemCapability.Ability.Form
SystemCapability.Ability.Form
**System API**: This is a system API and cannot be called by third-party applications.
**Parameters**
......@@ -326,9 +346,11 @@ notifyVisibleForms(formIds: Array&lt;string&gt;): Promise&lt;void&gt;;
Instructs the widget framework to make a widget visible. This API uses a promise to return the result. After this API is called, **onVisibilityChange** is invoked to notify the widget provider.
**System capability**
**Required permissions**: ohos.permission.REQUIRE_FORM
SystemCapability.Ability.Form
**System capability**: SystemCapability.Ability.Form
**System API**: This is a system API and cannot be called by third-party applications.
**Parameters**
......@@ -359,9 +381,11 @@ notifyInvisibleForms(formIds: Array&lt;string&gt;, callback: AsyncCallback&lt;vo
Instructs the widget framework to make a widget invisible. This API uses an asynchronous callback to return the result. After this API is called, **onVisibilityChange** is invoked to notify the widget provider.
**System capability**
**Required permissions**: ohos.permission.REQUIRE_FORM
**System capability**: SystemCapability.Ability.Form
SystemCapability.Ability.Form
**System API**: This is a system API and cannot be called by third-party applications.
**Parameters**
......@@ -387,9 +411,11 @@ notifyInvisibleForms(formIds: Array&lt;string&gt;): Promise&lt;void&gt;;
Instructs the widget framework to make a widget invisible. This API uses a promise to return the result. After this API is called, **onVisibilityChange** is invoked to notify the widget provider.
**System capability**
**Required permissions**: ohos.permission.REQUIRE_FORM
SystemCapability.Ability.Form
**System capability**: SystemCapability.Ability.Form
**System API**: This is a system API and cannot be called by third-party applications.
**Parameters**
......@@ -420,9 +446,11 @@ enableFormsUpdate(formIds: Array&lt;string&gt;, callback: AsyncCallback&lt;void&
Instructs the widget framework to make a widget updatable. This API uses an asynchronous callback to return the result. After this API is called, the widget is in the enabled state and can receive updates from the widget provider.
**System capability**
**Required permissions**: ohos.permission.REQUIRE_FORM
**System capability**: SystemCapability.Ability.Form
SystemCapability.Ability.Form
**System API**: This is a system API and cannot be called by third-party applications.
**Parameters**
......@@ -448,9 +476,11 @@ enableFormsUpdate(formIds: Array&lt;string&gt;): Promise&lt;void&gt;;
Instructs the widget framework to make a widget updatable. This API uses a promise to return the result. After this API is called, the widget is in the enabled state and can receive updates from the widget provider.
**System capability**
**Required permissions**: ohos.permission.REQUIRE_FORM
SystemCapability.Ability.Form
**System capability**: SystemCapability.Ability.Form
**System API**: This is a system API and cannot be called by third-party applications.
**Parameters**
......@@ -481,9 +511,11 @@ disableFormsUpdate(formIds: Array&lt;string&gt;, callback: AsyncCallback&lt;void
Instructs the widget framework to make a widget not updatable. This API uses an asynchronous callback to return the result. After this API is called, the widget cannot receive updates from the widget provider.
**System capability**
**Required permissions**: ohos.permission.REQUIRE_FORM
**System capability**: SystemCapability.Ability.Form
SystemCapability.Ability.Form
**System API**: This is a system API and cannot be called by third-party applications.
**Parameters**
......@@ -509,9 +541,11 @@ disableFormsUpdate(formIds: Array&lt;string&gt;): Promise&lt;void&gt;;
Instructs the widget framework to make a widget not updatable. This API uses a promise to return the result. After this API is called, the widget cannot receive updates from the widget provider.
**System capability**
**Required permissions**: ohos.permission.REQUIRE_FORM
SystemCapability.Ability.Form
**System capability**: SystemCapability.Ability.Form
**System API**: This is a system API and cannot be called by third-party applications.
**Parameters**
......@@ -542,9 +576,9 @@ isSystemReady(callback: AsyncCallback&lt;void&gt;): void;
Checks whether the system is ready. This API uses an asynchronous callback to return the result.
**System capability**
**System capability**: SystemCapability.Ability.Form
SystemCapability.Ability.Form
**System API**: This is a system API and cannot be called by third-party applications.
**Parameters**
......@@ -569,9 +603,9 @@ isSystemReady(): Promise&lt;void&gt;;
Checks whether the system is ready. This API uses a promise to return the result.
**System capability**
**System capability**: SystemCapability.Ability.Form
SystemCapability.Ability.Form
**System API**: This is a system API and cannot be called by third-party applications.
**Return value**
......@@ -596,9 +630,11 @@ getAllFormsInfo(callback: AsyncCallback&lt;Array&lt;formInfo.FormInfo&gt;&gt;):
Obtains the widget information provided by all applications on the device. This API uses an asynchronous callback to return the result.
**System capability**
**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED
**System capability**: SystemCapability.Ability.Form
SystemCapability.Ability.Form
**System API**: This is a system API and cannot be called by third-party applications.
**Parameters**
......@@ -625,9 +661,11 @@ 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.
**System capability**
**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED
**System capability**: SystemCapability.Ability.Form
SystemCapability.Ability.Form
**System API**: This is a system API and cannot be called by third-party applications.
**Return value**
......@@ -652,9 +690,11 @@ getFormsInfo(bundleName: string, callback: AsyncCallback&lt;Array&lt;formInfo.Fo
Obtains the widget information provided by a given application on the device. This API uses an asynchronous callback to return the result.
**System capability**
**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED
SystemCapability.Ability.Form
**System capability**: SystemCapability.Ability.Form
**System API**: This is a system API and cannot be called by third-party applications.
**Parameters**
......@@ -682,9 +722,11 @@ getFormsInfo(bundleName: string, moduleName: string, callback: AsyncCallback&lt;
Obtains the widget information provided by a given application on the device. This API uses an asynchronous callback to return the result.
**System capability**
**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED
**System capability**: SystemCapability.Ability.Form
SystemCapability.Ability.Form
**System API**: This is a system API and cannot be called by third-party applications.
**Parameters**
......@@ -713,9 +755,11 @@ getFormsInfo(bundleName: string, moduleName?: string): Promise&lt;Array&lt;formI
Obtains the widget information provided by a given application on the device. This API uses a promise to return the result.
**System capability**
**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED
SystemCapability.Ability.Form
**System capability**: SystemCapability.Ability.Form
**System API**: This is a system API and cannot be called by third-party applications.
**Parameters**
......@@ -746,9 +790,11 @@ deleteInvalidForms(formIds: Array&lt;string&gt;, callback: AsyncCallback&lt;numb
Deletes invalid widgets from the list. This API uses an asynchronous callback to return the result.
**System capability**
**Required permissions**: ohos.permission.REQUIRE_FORM
**System capability**: SystemCapability.Ability.Form
SystemCapability.Ability.Form
**System API**: This is a system API and cannot be called by third-party applications.
**Parameters**
......@@ -776,9 +822,11 @@ 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.
**System capability**
**Required permissions**: ohos.permission.REQUIRE_FORM
SystemCapability.Ability.Form
**System capability**: SystemCapability.Ability.Form
**System API**: This is a system API and cannot be called by third-party applications.
**Parameters**
......@@ -809,9 +857,11 @@ acquireFormState(want: Want, callback: AsyncCallback&lt;formInfo.FormStateInfo&g
Obtains the widget state. This API uses an asynchronous callback to return the result.
**System capability**
**Required permissions**: ohos.permission.REQUIRE_FORM and ohos.permission.GET_BUNDLE_INFO_PRIVILEGED
**System capability**: SystemCapability.Ability.Form
SystemCapability.Ability.Form
**System API**: This is a system API and cannot be called by third-party applications.
**Parameters**
......@@ -848,6 +898,12 @@ acquireFormState(want: Want): Promise&lt;formInfo.FormStateInfo&gt;;
Obtains the widget state. This API uses a promise to return the result.
**Required permissions**: ohos.permission.REQUIRE_FORM and ohos.permission.GET_BUNDLE_INFO_PRIVILEGED
**System capability**: SystemCapability.Ability.Form
**System API**: This is a system API and cannot be called by third-party applications.
**Parameters**
| Name| Type | Mandatory| Description |
......@@ -860,10 +916,6 @@ Obtains the widget state. This API uses a promise to return the result.
| :------------ | :---------------------------------- |
| Promise&lt;[FormStateInfo](js-apis-formInfo.md#formstateinfo)&gt; | Promise used to return the widget state.|
**System capability**
SystemCapability.Ability.Form
**Example**
```js
......@@ -890,9 +942,9 @@ on(type: "formUninstall", callback: Callback&lt;string&gt;): void;
Subscribes to widget uninstall events.
**System capability**
**System capability**: SystemCapability.Ability.Form
SystemCapability.Ability.Form
**System API**: This is a system API and cannot be called by third-party applications.
**Parameters**
......@@ -916,9 +968,9 @@ off(type: "formUninstall", callback?: Callback&lt;string&gt;): void;
Unsubscribes from widget uninstall events.
**System capability**
**System capability**: SystemCapability.Ability.Form
SystemCapability.Ability.Form
**System API**: This is a system API and cannot be called by third-party applications.
**Parameters**
......@@ -942,9 +994,11 @@ notifyFormsVisible(formIds: Array&lt;string&gt;, isVisible: boolean, callback: A
Instructs the widgets to make themselves visible. This API uses an asynchronous callback to return the result.
**System capability**
**Required permissions**: ohos.permission.REQUIRE_FORM
SystemCapability.Ability.Form
**System capability**: SystemCapability.Ability.Form
**System API**: This is a system API and cannot be called by third-party applications.
**Parameters**
......@@ -971,9 +1025,11 @@ notifyFormsVisible(formIds: Array&lt;string&gt;, isVisible: boolean): Promise&lt
Instructs the widgets to make themselves visible. This API uses a promise to return the result.
**System capability**
**Required permissions**: ohos.permission.REQUIRE_FORM
**System capability**: SystemCapability.Ability.Form
SystemCapability.Ability.Form
**System API**: This is a system API and cannot be called by third-party applications.
**Parameters**
......@@ -1005,9 +1061,11 @@ notifyFormsEnableUpdate(formIds: Array&lt;string&gt;, isEnableUpdate: boolean, c
Instructs the widgets to enable or disable updates. This API uses an asynchronous callback to return the result.
**System capability**
**Required permissions**: ohos.permission.REQUIRE_FORM
SystemCapability.Ability.Form
**System capability**: SystemCapability.Ability.Form
**System API**: This is a system API and cannot be called by third-party applications.
**Parameters**
......@@ -1034,9 +1092,11 @@ notifyFormsEnableUpdate(formIds: Array&lt;string&gt;, isEnableUpdate: boolean):
Instructs the widgets to enable or disable updates. This API uses a promise to return the result.
**System capability**
**Required permissions**: ohos.permission.REQUIRE_FORM
**System capability**: SystemCapability.Ability.Form
SystemCapability.Ability.Form
**System API**: This is a system API and cannot be called by third-party applications.
**Parameters**
......
# FormProvider
The **FormProvider** module provides APIs related to the widget provider. You can use the APIs to update a widget, set the next refresh time for a widget, obtain widget information, and release a widget release.
The **FormProvider** module provides APIs related to the widget provider. You can use the APIs to update a widget, set the next refresh time for a widget, obtain widget information, and request a widget release.
> **NOTE**
>
......@@ -28,11 +28,11 @@ SystemCapability.Ability.Form
**Parameters**
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ------------------------------------- |
| formId | string | Yes | ID of a widget. |
| minute | number | Yes | Refresh interval, in minutes. The value must be greater than or equal to 5. |
| callback | AsyncCallback&lt;void&gt; | Yes| Callback used to return the result.|
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ------------------------------------- |
| formId | string | Yes | ID of a widget. |
| minute | number | Yes | Refresh interval, in minutes. The value must be greater than or equal to 5. |
| callback | AsyncCallback&lt;void&gt; | Yes| Callback used to return the result.|
**Example**
......@@ -57,16 +57,16 @@ SystemCapability.Ability.Form
**Parameters**
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ------------------------------------- |
| formId | string | Yes | ID of a widget. |
| minute | number | Yes | Refresh interval, in minutes. The value must be greater than or equal to 5. |
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ------------------------------------- |
| formId | string | Yes | ID of a widget. |
| minute | number | Yes | Refresh interval, in minutes. The value must be greater than or equal to 5. |
**Return value**
| Type | Description |
| ------------- | ---------------------------------- |
| Promise\<void> |Promise used to return the result. |
| Type | Description |
| ------------- | ---------------------------------- |
| Promise\<void> |Promise used to return the result. |
**Example**
......@@ -91,11 +91,11 @@ SystemCapability.Ability.Form
**Parameters**
| Name| Type | Mandatory| Description |
| ------ | ---------------------------------------------------------------------- | ---- | ---------------- |
| formId | string | Yes | ID of the widget to update.|
| formBindingData | [FormBindingData](js-apis-formbindingdata.md#formbindingdata) | Yes | Data to be used for the update. |
| callback | AsyncCallback&lt;void&gt; | Yes| Callback used to return the result.|
| Name| Type | Mandatory| Description |
| ------ | ---------------------------------------------------------------------- | ---- | ---------------- |
| formId | string | Yes | ID of the widget to update.|
| formBindingData | [FormBindingData](js-apis-formbindingdata.md#formbindingdata) | Yes | Data to be used for the update. |
| callback | AsyncCallback&lt;void&gt; | Yes| Callback used to return the result.|
**Example**
......@@ -122,10 +122,10 @@ SystemCapability.Ability.Form
**Parameters**
| Name| Type | Mandatory| Description |
| ------ | ---------------------------------------------------------------------- | ---- | ---------------- |
| formId | string | Yes | ID of the widget to update.|
| formBindingData | [FormBindingData](js-apis-formbindingdata.md#formbindingdata) | Yes | Data to be used for the update. |
| Name| Type | Mandatory| Description |
| ------ | ---------------------------------------------------------------------- | ---- | ---------------- |
| formId | string | Yes | ID of the widget to update.|
| formBindingData | [FormBindingData](js-apis-formbindingdata.md#formbindingdata) | Yes | Data to be used for the update. |
**Return value**
......
# missionManager
The **missionManager** module provides APIs to lock, unlock, and clear missions, and switch a mission to the foreground.
> **NOTE**
>
> 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.
missionManager provides APIs to lock, unlock, and clear missions, and switch a mission to the foreground.
## Modules to Import
```
......@@ -23,8 +22,12 @@ registerMissionListener(listener: MissionListener): number;
Registers a listener to observe the mission status.
**Required permission**: ohos.permission.MANAGE_MISSIONS
**System capability**: SystemCapability.Ability.AbilityRuntime.Mission
**System API**: This is a system API and cannot be called by third-party applications.
**Parameters**
| Name| Type| Mandatory| Description|
......@@ -59,8 +62,12 @@ unregisterMissionListener(listenerId: number, callback: AsyncCallback&lt;void&gt
Deregisters a mission status listener. This API uses an asynchronous callback to return the result.
**Required permission**: ohos.permission.MANAGE_MISSIONS
**System capability**: SystemCapability.Ability.AbilityRuntime.Mission
**System API**: This is a system API and cannot be called by third-party applications.
**Parameters**
| Name| Type| Mandatory| Description|
......@@ -93,8 +100,12 @@ unregisterMissionListener(listenerId: number): Promise&lt;void&gt;;
Deregisters a mission status listener. This API uses a promise to return the result.
**Required permission**: ohos.permission.MANAGE_MISSIONS
**System capability**: SystemCapability.Ability.AbilityRuntime.Mission
**System API**: This is a system API and cannot be called by third-party applications.
**Parameters**
| Name| Type| Mandatory| Description|
......@@ -132,8 +143,12 @@ getMissionInfo(deviceId: string, missionId: number, callback: AsyncCallback&lt;M
Obtains the information about a given mission. This API uses an asynchronous callback to return the result.
**Required permission**: ohos.permission.MANAGE_MISSIONS
**System capability**: SystemCapability.Ability.AbilityRuntime.Mission
**System API**: This is a system API and cannot be called by third-party applications.
**Parameters**
| Name| Type| Mandatory| Description|
......@@ -166,8 +181,12 @@ getMissionInfo(deviceId: string, missionId: number): Promise&lt;MissionInfo&gt;;
Obtains the information about a given mission. This API uses a promise to return the result.
**Required permission**: ohos.permission.MANAGE_MISSIONS
**System capability**: SystemCapability.Ability.AbilityRuntime.Mission
**System API**: This is a system API and cannot be called by third-party applications.
**Parameters**
| Name| Type| Mandatory| Description|
......@@ -198,8 +217,12 @@ getMissionInfos(deviceId: string, numMax: number, callback: AsyncCallback&lt;Arr
Obtains information about all missions. This API uses an asynchronous callback to return the result.
**Required permission**: ohos.permission.MANAGE_MISSIONS
**System capability**: SystemCapability.Ability.AbilityRuntime.Mission
**System API**: This is a system API and cannot be called by third-party applications.
**Parameters**
| Name| Type| Mandatory| Description|
......@@ -227,8 +250,12 @@ getMissionInfos(deviceId: string, numMax: number): Promise&lt;Array&lt;MissionIn
Obtains information about all missions. This API uses a promise to return the result.
**Required permission**: ohos.permission.MANAGE_MISSIONS
**System capability**: SystemCapability.Ability.AbilityRuntime.Mission
**System API**: This is a system API and cannot be called by third-party applications.
**Parameters**
| Name| Type| Mandatory| Description|
......@@ -259,8 +286,12 @@ getMissionSnapShot(deviceId: string, missionId: number, callback: AsyncCallback&
Obtains the snapshot of a given mission. This API uses an asynchronous callback to return the result.
**Required permission**: ohos.permission.MANAGE_MISSIONS
**System capability**: SystemCapability.Ability.AbilityRuntime.Mission
**System API**: This is a system API and cannot be called by third-party applications.
**Parameters**
| Name| Type| Mandatory| Description|
......@@ -294,8 +325,12 @@ getMissionSnapShot(deviceId: string, missionId: number): Promise&lt;MissionSnaps
Obtains the snapshot of a given mission. This API uses a promise to return the result.
**Required permission**: ohos.permission.MANAGE_MISSIONS
**System capability**: SystemCapability.Ability.AbilityRuntime.Mission
**System API**: This is a system API and cannot be called by third-party applications.
**Parameters**
| Name| Type| Mandatory| Description|
......@@ -334,8 +369,12 @@ lockMission(missionId: number, callback: AsyncCallback&lt;void&gt;): void;
Locks a given mission. This API uses an asynchronous callback to return the result.
**Required permission**: ohos.permission.MANAGE_MISSIONS
**System capability**: SystemCapability.Ability.AbilityRuntime.Mission
**System API**: This is a system API and cannot be called by third-party applications.
**Parameters**
| Name| Type| Mandatory| Description|
......@@ -367,8 +406,12 @@ lockMission(missionId: number): Promise&lt;void&gt;;
Locks a given mission. This API uses a promise to return the result.
**Required permission**: ohos.permission.MANAGE_MISSIONS
**System capability**: SystemCapability.Ability.AbilityRuntime.Mission
**System API**: This is a system API and cannot be called by third-party applications.
**Parameters**
| Name| Type| Mandatory| Description|
......@@ -405,8 +448,12 @@ unlockMission(missionId: number, callback: AsyncCallback&lt;void&gt;): void;
Unlocks a given mission. This API uses an asynchronous callback to return the result.
**Required permission**: ohos.permission.MANAGE_MISSIONS
**System capability**: SystemCapability.Ability.AbilityRuntime.Mission
**System API**: This is a system API and cannot be called by third-party applications.
**Parameters**
| Name| Type| Mandatory| Description|
......@@ -438,8 +485,12 @@ unlockMission(missionId: number): Promise&lt;void&gt;;
Unlocks a given mission. This API uses a promise to return the result.
**Required permission**: ohos.permission.MANAGE_MISSIONS
**System capability**: SystemCapability.Ability.AbilityRuntime.Mission
**System API**: This is a system API and cannot be called by third-party applications.
**Parameters**
| Name| Type| Mandatory| Description|
......@@ -480,8 +531,12 @@ clearMission(missionId: number, callback: AsyncCallback&lt;void&gt;): void;
Clears a given mission, regardless of whether it is locked. This API uses an asynchronous callback to return the result.
**Required permission**: ohos.permission.MANAGE_MISSIONS
**System capability**: SystemCapability.Ability.AbilityRuntime.Mission
**System API**: This is a system API and cannot be called by third-party applications.
**Parameters**
| Name| Type| Mandatory| Description|
......@@ -513,8 +568,12 @@ clearMission(missionId: number): Promise&lt;void&gt;;
Clears a given mission, regardless of whether it is locked. This API uses a promise to return the result.
**Required permission**: ohos.permission.MANAGE_MISSIONS
**System capability**: SystemCapability.Ability.AbilityRuntime.Mission
**System API**: This is a system API and cannot be called by third-party applications.
**Parameters**
| Name| Type| Mandatory| Description|
......@@ -552,8 +611,12 @@ clearAllMissions(callback: AsyncCallback&lt;void&gt;): void;
Clears all unlocked missions. This API uses an asynchronous callback to return the result.
**Required permission**: ohos.permission.MANAGE_MISSIONS
**System capability**: SystemCapability.Ability.AbilityRuntime.Mission
**System API**: This is a system API and cannot be called by third-party applications.
**Example**
```js
......@@ -571,8 +634,12 @@ clearAllMissions(): Promise&lt;void&gt;;
Clears all unlocked missions. This API uses a promise to return the result.
**Required permission**: ohos.permission.MANAGE_MISSIONS
**System capability**: SystemCapability.Ability.AbilityRuntime.Mission
**System API**: This is a system API and cannot be called by third-party applications.
**Return value**
| Type| Description|
......@@ -595,8 +662,12 @@ moveMissionToFront(missionId: number, callback: AsyncCallback&lt;void&gt;): void
Switches a given mission to the foreground. This API uses an asynchronous callback to return the result.
**Required permission**: ohos.permission.MANAGE_MISSIONS
**System capability**: SystemCapability.Ability.AbilityRuntime.Mission
**System API**: This is a system API and cannot be called by third-party applications.
**Parameters**
| Name| Type| Mandatory| Description|
......@@ -628,8 +699,12 @@ moveMissionToFront(missionId: number, options: StartOptions, callback: AsyncCall
Switches a given mission to the foreground, with the startup parameters for the switching specified. This API uses an asynchronous callback to return the result.
**Required permission**: ohos.permission.MANAGE_MISSIONS
**System capability**: SystemCapability.Ability.AbilityRuntime.Mission
**System API**: This is a system API and cannot be called by third-party applications.
**Parameters**
| Name| Type| Mandatory| Description|
......@@ -662,8 +737,12 @@ moveMissionToFront(missionId: number, options?: StartOptions): Promise&lt;void&g
Switches a given mission to the foreground, with the startup parameters for the switching specified. This API uses a promise to return the result.
**Required permission**: ohos.permission.MANAGE_MISSIONS
**System capability**: SystemCapability.Ability.AbilityRuntime.Mission
**System API**: This is a system API and cannot be called by third-party applications.
**Parameters**
| Name| Type| Mandatory| Description|
......@@ -699,7 +778,9 @@ Switches a given mission to the foreground, with the startup parameters for the
Describes the mission information.
**System capability**: SystemCapability.Ability.AbilityBase
**System capability**: SystemCapability.Ability.AbilityRuntime.Mission
**System API**: This is a system API and cannot be called by third-party applications.
| Name| Type| Readable| Writable| Description|
| -------- | -------- | -------- | -------- | -------- |
......@@ -710,4 +791,4 @@ Describes the mission information.
| 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 can be continued on another device. |
| continuable | boolean | Yes| Yes| Whether the mission can be continued on another device.|
# ParticleAbility
# particleAbility
The **particleAbility** module provides APIs for Service abilities. You can use the APIs to start and terminate a Particle ability, obtain a **dataAbilityHelper** object, connect the current ability to a specific Service ability, and disconnect the current ability from a specific Service ability.
> **NOTE**
>
......
# PermissionRequestResult
The **PermissionRequestResult** module provides the result of a permission request.
> **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.
> 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 APIs of this module can be used only in the stage model.
Provides the permission request result.
## Modules to Import
```js
import Ability from '@ohos.application.Ability'
```
## How to Use
## Usage
The permission request result is obtained through an **AbilityStage** instance.
......
# ProcessRunningInfo
The **ProcessRunningInfo** module provides process running information.
> **NOTE**
>
> 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.
## Modules to Import
```js
import appManager from '@ohos.application.appManager'
```
> 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.
## Usage
......@@ -23,7 +17,6 @@ appManager.getProcessRunningInfos((error,data) => {
});
```
## Attributes
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
......
# TestRunner
The **TestRunner** module provides a test framework. You can use the APIs of this module to prepare the unit test environment and run test cases.
To implement your own unit test framework, extend this class and override its APIs.
> **NOTE**
>
> 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.
......@@ -10,8 +14,6 @@
import TestRunner from '@ohos.application.testRunner'
```
## TestRunner.onPrepare
onPrepare(): void
......@@ -23,10 +25,11 @@ Prepares the unit test environment to run test cases.
**Example**
```js
export default class UserTestRunner extends TestRunner {
export default class UserTestRunner implements TestRunner {
onPrepare() {
console.log("Trigger onPrepare")
}
onRun(){}
};
```
......@@ -43,9 +46,10 @@ Runs test cases.
**Example**
```js
export default class UserTestRunner extends TestRunner {
onRun() {
console.log("Trigger onRun")
export default class UserTestRunner implements TestRunner {
onPrepare() {
console.log("Trigger onRun")
}
onRun(){}
};
```
# WantAgent
The **WantAgent** module provides APIs for triggering, canceling, and comparing **WantAgent** objects. You can use the APIs to create a **WantAgent** object, and obtain the user ID, bundle name, and want information of the object.
> **NOTE**
>
> 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.
......@@ -418,6 +420,8 @@ Obtains the want in a **WantAgent** object. This API uses an asynchronous callba
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
**System API**: This is a system API and cannot be called by third-party applications.
**Parameters**
| Name | Readable| Writable| Type | Mandatory| Description |
......@@ -490,6 +494,8 @@ Obtains the want in a **WantAgent** object. This API uses a promise to return th
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
**System API**: This is a system API and cannot be called by third-party applications.
**Parameters**
| Name | Readable| Writable| Type | Mandatory| Description |
......@@ -704,7 +710,7 @@ Triggers a **WantAgent** object. This API uses an asynchronous callback to retur
| Name | Readable| Writable| Type | Mandatory| Description |
| ----------- | --- | ---- | ----------------------------- | ---- | ------------------------------- |
| agent | Yes | No | WantAgent | Yes | **WantAgent** object to trigger. |
| agent | Yes | No | WantAgent | Yes | Target **WantAgent** object. |
| triggerInfo | Yes | No | TriggerInfo | Yes | **TriggerInfo** object. |
| callback | Yes | No | AsyncCallback\<CompleteData\> | Yes | Callback used to return the result.|
......@@ -1052,7 +1058,7 @@ WantAgent.getOperationType(wantAgent).then((OperationType) => {
| Name | Readable| Writable| Type | Mandatory| Description |
| -------------- | --- | ---- | ------------------------------- | ---- | ---------------------- |
| wants | Yes | Yes | Array\<Want\> | Yes | Array of all **Want** objects. |
| operationType | Yes | Yes | wantAgent.OperationType | Yes | Action type. |
| operationType | Yes | Yes | wantAgent.OperationType | Yes | Operation type. |
| requestCode | Yes | Yes | number | Yes | Request code defined by the user.|
| wantAgentFlags | Yes | Yes | Array<wantAgent.WantAgentFlags> | No | Array of flags for using the **WantAgent** object. |
| extraInfo | Yes | Yes | {[key: string]: any} | No | Extra information. |
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册