> 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.
>
...
...
@@ -18,13 +18,13 @@ Enumerates the ability states.
> 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.
Implements the context of an ability stage. This module is inherited from [Context](js-apis-application-context.md).
> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version.
> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version.
> 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.
...
...
@@ -25,9 +26,9 @@ Checks whether this application is undergoing a stability test. This API uses an
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| callback | AsyncCallback<boolean> | No| Callback used to return the result. If the application is undergoing a stability test, **true** will be returned; otherwise, **false** will be returned.|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| callback | AsyncCallback<boolean> | No| Callback used to return the result. If the application is undergoing a stability test, **true** will be returned; otherwise, **false** will be returned.|
**Example**
...
...
@@ -49,9 +50,9 @@ Checks whether this application is undergoing a stability test. This API uses a
**Return value**
| Type| Description|
| -------- | -------- |
| Promise<boolean> | Promise used to return the result. If the application is undergoing a stability test, **true** will be returned; otherwise, **false** will be returned.|
| Type| Description|
| -------- | -------- |
| Promise<boolean> | Promise used to return the result. If the application is undergoing a stability test, **true** will be returned; otherwise, **false** will be returned.|
**Example**
...
...
@@ -75,9 +76,9 @@ Checks whether this application is running on a RAM constrained device. This API
**Return value**
| Type| Description|
| -------- | -------- |
| Promise<boolean> | Promise used to return whether the application is running on a RAM constrained device. If the application is running on a RAM constrained device, **true** will be returned; otherwise, **false** will be returned.|
| Type| Description|
| -------- | -------- |
| Promise<boolean> | Promise used to return whether the application is running on a RAM constrained device. If the application is running on a RAM constrained device, **true** will be returned; otherwise, **false** will be returned.|
**Example**
...
...
@@ -99,9 +100,9 @@ Checks whether this application is running on a RAM constrained device. This API
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| callback | AsyncCallback<boolean> | No| Callback used to return whether the application is running on a RAM constrained device. If the application is running on a RAM constrained device, **true** will be returned; otherwise, **false** will be returned.|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| callback | AsyncCallback<boolean> | No| Callback used to return whether the application is running on a RAM constrained device. If the application is running on a RAM constrained device, **true** will be returned; otherwise, **false** will be returned.|
**Example**
...
...
@@ -122,9 +123,9 @@ Obtains the memory size of this application. This API uses a promise to return t
**Return value**
| Type| Description|
| -------- | -------- |
| Promise<number> | Size of the application memory.|
| Type| Description|
| -------- | -------- |
| Promise<number> | Size of the application memory.|
**Example**
...
...
@@ -146,9 +147,9 @@ Obtains the memory size of this application. This API uses an asynchronous callb
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| callback | AsyncCallback<number> | No| Size of the application memory.|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| callback | AsyncCallback<number> | No| Size of the application memory.|
**Example**
...
...
@@ -160,7 +161,7 @@ Obtains the memory size of this application. This API uses an asynchronous callb
> The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version.
> The initial APIs of this module are supported since API 9. Newly added APIs will be marked with a superscript to indicate their earliest API version.
Implements event subscription, unsubscription, and triggering.
## Modules to Import
```js
importAbilityfrom'@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.
```js
importAbilityfrom'@ohos.application.Ability'
exportdefaultclassMainAbilityextendsAbility{
...
...
@@ -34,10 +38,10 @@ Subscribes to an event.
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| event | string | Yes| Event name.|
| callback | Function | Yes| Callback invoked when the event is triggered.|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| event | string | Yes| Event name.|
| callback | Function | Yes| Callback invoked when the event is triggered.|
**Example**
...
...
@@ -72,10 +76,10 @@ Unsubscribes from an event. If **callback** is specified, this API unsubscribes
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| event | string | Yes| Event name.|
| callback | Function | No| Callback for the event. If **callback** is unspecified, all callbacks of the event are unsubscribed.|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| event | string | Yes| Event name.|
| callback | Function | No| Callback for the event. If **callback** is unspecified, all callbacks of the event are unsubscribed.|
**Example**
...
...
@@ -110,10 +114,10 @@ Triggers an event.
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| event | string | Yes| Event name.|
| ...args | Object[] | Yes| Variable parameters, which are passed to the callback when the event is triggered.|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| event | string | Yes| Event name.|
| ...args | Object[] | Yes| Variable parameters, which are passed to the callback when the event is triggered.|
> The initial APIs of this module are supported since API version 9. API version 9 is a canary version for trial use. The APIs of this version may be unstable.
> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version.
> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version.
Implements the context that provides the capabilities and APIs of **FormExtension**. This class is inherited from **ExtensionContext**.
> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version.
> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version.
> 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,15 +27,15 @@ Registers a listener to observe the mission status.
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| listener | MissionListener | Yes| Listener to register.|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| listener | MissionListener | Yes| Listener to register.|
**Return value**
| Type| Description|
| -------- | -------- |
| number | Returns the index of the listener, which is created by the system and allocated when the mission status listener is registered. Each listener has a unique index.|
| Type| Description|
| -------- | -------- |
| number | Returns the unique index of the mission status listener, which is created by the system and allocated when the listener is registered.|
**Example**
...
...
@@ -55,16 +56,16 @@ Registers a listener to observe the mission status.
| listenerId | number | Yes| Index of the mission status listener to unregister. Each listener has a unique index, which is returned by **registerMissionListener**.|
| callback | AsyncCallback<void> | Yes| Callback used to return the result.|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| listenerId | number | Yes| Unique index of the mission status listener to unregister. It is returned by **registerMissionListener**.|
| callback | AsyncCallback<void> | Yes| Callback used to return the result.|
**Example**
...
...
@@ -88,21 +89,21 @@ Unregisters a mission status listener. This API uses an asynchronous callback to
| listenerId | number | Yes| Index of the mission status listener to unregister. Each listener has a unique index, which is returned by **registerMissionListener**.|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| listenerId | number | Yes| Unique index of the mission status listener to unregister. It is returned by **registerMissionListener**.|
**Return value**
| Type| Description|
| -------- | -------- |
| Promise<void> | Promise used to return the result.|
| Type| Description|
| -------- | -------- |
| Promise<void> | Promise used to return the result.|
**Example**
...
...
@@ -126,17 +127,17 @@ Unregisters a mission status listener. This API uses a promise to return the res
| deviceId | string | Yes| Device ID. It is a null string by default for the local device.|
| numMax | number | Yes| Maximum number of missions whose information can be obtained.|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| deviceId | string | Yes| Device ID. It is a null string by default for the local device.|
| numMax | number | Yes| Maximum number of missions whose information can be obtained.|
**Return value**
| Type| Description|
| -------- | -------- |
| Promise<Array<[MissionInfo](#missioninfo)>> | Promise used to return the array of mission information obtained.|
| Type| Description|
| -------- | -------- |
| Promise<Array<[MissionInfo](#missioninfo)>> | Promise used to return the array of mission information obtained.|
**Example**
...
...
@@ -258,11 +259,11 @@ Obtains the snapshot of a given mission. This API uses an asynchronous callback
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| deviceId | string | Yes| Device ID. It is a null string by default for the local device.|
| missionId | number | Yes| Mission ID.|
| callback | AsyncCallback<[MissionSnapshot](js-apis-application-MissionSnapshot.md)> | Yes| Callback used to return the snapshot information obtained.|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| deviceId | string | Yes| Device ID. It is a null string by default for the local device.|
| missionId | number | Yes| Mission ID.|
| callback | AsyncCallback<[MissionSnapshot](js-apis-application-MissionSnapshot.md)> | Yes| Callback used to return the snapshot information obtained.|
**Example**
...
...
@@ -293,16 +294,16 @@ Obtains the snapshot of a given mission. This API uses a promise to return the r
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| deviceId | string | Yes| Device ID. It is a null string by default for the local device.|
| missionId | number | Yes| Mission ID.|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| deviceId | string | Yes| Device ID. It is a null string by default for the local device.|
| missionId | number | Yes| Mission ID.|
**Return value**
| Type| Description|
| -------- | -------- |
| Promise<[MissionSnapshot](js-apis-application-MissionSnapshot.md)> | Promise used to return the snapshot information obtained.|
| Type| Description|
| -------- | -------- |
| Promise<[MissionSnapshot](js-apis-application-MissionSnapshot.md)> | Promise used to return the snapshot information obtained.|
**Example**
...
...
@@ -331,10 +332,10 @@ Locks a given mission. This API uses an asynchronous callback to return the resu
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| missionId | number | Yes| Mission ID.|
| callback | AsyncCallback<void> | Yes| Callback used to return the result.|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| missionId | number | Yes| Mission ID.|
| callback | AsyncCallback<void> | Yes| Callback used to return the result.|
**Example**
...
...
@@ -364,15 +365,15 @@ Locks a given mission. This API uses a promise to return the result.
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| missionId | number | Yes| Mission ID.|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| missionId | number | Yes| Mission ID.|
**Return value**
| Type| Description|
| -------- | -------- |
| Promise<void> | Promise used to return the result.|
| Type| Description|
| -------- | -------- |
| Promise<void> | Promise used to return the result.|
**Example**
...
...
@@ -435,15 +436,15 @@ Unlocks a given mission. This API uses a promise to return the result.
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| missionId | number | Yes| Mission ID.|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| missionId | number | Yes| Mission ID.|
**Return value**
| Type| Description|
| -------- | -------- |
| Promise<void> | Promise used to return the result.|
| Type| Description|
| -------- | -------- |
| Promise<void> | Promise used to return the result.|
**Example**
...
...
@@ -476,10 +477,10 @@ Clears a given mission, regardless of whether it is locked. This API uses an asy
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| missionId | number | Yes| Mission ID.|
| callback | AsyncCallback<void> | Yes| Callback used to return the result.|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| missionId | number | Yes| Mission ID.|
| callback | AsyncCallback<void> | Yes| Callback used to return the result.|
**Example**
...
...
@@ -509,15 +510,15 @@ Clears a given mission, regardless of whether it is locked. This API uses a prom
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| missionId | number | Yes| Mission ID.|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| missionId | number | Yes| Mission ID.|
**Return value**
| Type| Description|
| -------- | -------- |
| Promise<void> | Promise used to return the result.|
| Type| Description|
| -------- | -------- |
| Promise<void> | Promise used to return the result.|
**Example**
...
...
@@ -566,9 +567,9 @@ Clears all unlocked missions. This API uses a promise to return the result.
**Return value**
| Type| Description|
| -------- | -------- |
| Promise<void> | Promise used to return the result.|
| Type| Description|
| -------- | -------- |
| Promise<void> | Promise used to return the result.|
**Example**
...
...
@@ -590,10 +591,10 @@ Switches a given mission to the foreground. This API uses an asynchronous callba
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| missionId | number | Yes| Mission ID.|
| callback | AsyncCallback<void> | Yes| Callback used to return the result.|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| missionId | number | Yes| Mission ID.|
| callback | AsyncCallback<void> | Yes| Callback used to return the result.|
**Example**
...
...
@@ -623,11 +624,11 @@ Switches a given mission to the foreground, with the startup parameters for the
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| missionId | number | Yes| Mission ID.|
| options | StartOptions | Yes| Startup parameters, which are used to specify the window mode and device ID for switching the mission to the foreground.|
| callback | AsyncCallback<void> | Yes| Callback used to return the result.|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| missionId | number | Yes| Mission ID.|
| options | StartOptions | Yes| Startup parameters, which are used to specify the window mode and device ID for switching the mission to the foreground.|
| callback | AsyncCallback<void> | Yes| Callback used to return the result.|
**Example**
...
...
@@ -657,16 +658,16 @@ Switches a given mission to the foreground, with the startup parameters for the
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| missionId | number | Yes| Mission ID.|
| options | StartOptions | No| Startup parameters, which are used to specify the window mode and device ID for switching the mission to the foreground.|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| missionId | number | Yes| Mission ID.|
| options | StartOptions | No| Startup parameters, which are used to specify the window mode and device ID for switching the mission to the foreground.|
**Return value**
| Type| Description|
| -------- | -------- |
| Promise<void> | Promise used to return the result.|
| Type| Description|
| -------- | -------- |
| Promise<void> | Promise used to return the result.|
**Example**
...
...
@@ -684,20 +685,3 @@ Switches a given mission to the foreground, with the startup parameters for the
> 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.
| authResults | Array<number> | Yes| No| Whether the requested permissions are granted or denied. The value **0** means that the requests permissions are granted, and **-1** means the opposite. |
| authResults | Array<number> | Yes| No| Whether the requested permissions are granted or denied. The value **0** means that the requests permissions are granted, and **-1** means the opposite. |
> 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.