> 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.
Implements the ability context. This module is inherited from **Context**.
...
...
@@ -13,7 +13,7 @@ Implements the ability context. This module is inherited from **Context**.
Before using the **AbilityContext** module, you must define a child class that inherits from **Ability**.
```js
importAbilityfrom'@ohos.application.Ability'
classMainAbilityextendsAbility{
...
...
@@ -26,10 +26,12 @@ class MainAbility extends Ability {
| currentHapModuleInfo | HapModuleInfo | Yes| No| Information about the current HAP.<br>**System capability**: SystemCapability.Ability.AbilityRuntime.Core|
> 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
```
import errorCode from '@ohos.ability.errorCode'
```
## ErrorCode
Defines the error code used when the ability is started.
> 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
```
import wantConstant from '@ohos.ability.wantConstant'
| 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_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_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_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**.|
| FLAG_ABILITY_NEW_MISSION | 0x10000000 | Indicates the operation of creating a mission on the history mission stack. |
| FLAG_ABILITY_MISSION_TOP | 0x20000000 | Starts the mission on the top of the existing mission stack; creates an ability instance if no mission exists.|
> The 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 the Extension ability for data sharing.
## Modules to Import
```
import DataShareExtensionAbility from '@ohos.application.DataShareExtensionAbility';
| callback | AsyncCallback\<string> | Yes | Callback used to return the normalized URI object if the Data ability supports URI normalization. If the Data ability does not support URI normalization, **null** is returned.|
> 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 snapshot of a mission.
...
...
@@ -10,8 +10,6 @@ Provides snapshot of a mission.
## Modules to Import
Import ElementName and image before use.
```
import { ElementName } from '../bundle/elementName';
> 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.
**StartOptions** is the basic communication component of the system.
## Modules to Import
```
import StartOptions from '@ohos.application.StartOptions';
> The APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version.
> The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version.
Manages the ability lifecycle and context.
...
...
@@ -16,11 +16,13 @@ import Ability from '@ohos.application.Ability';
| context | [AbilityContext](js-apis-ability-context.md) | Yes| No| Context of an ability.<br>**System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore|
| launchWant | [Want](js-apis-featureAbility.md#Want)| Yes| No| Parameters for starting the ability.<br>**System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore|
| lastRequestWant | [Want](js-apis-featureAbility.md#Want)| Yes| No| Parameters used when the ability was started last time.<br>**System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore|
| context | [AbilityContext](js-apis-ability-context.md) | Yes| No| Context of an ability.|
| launchWant | [Want](js-apis-featureAbility.md#Want)| Yes| No| Parameters for starting the ability.|
| lastRequestWant | [Want](js-apis-featureAbility.md#Want)| Yes| No| Parameters used when the ability was started last time.|
## Ability.onCreate
...
...
@@ -245,7 +247,7 @@ Called when the configuration of the environment where the ability is running is
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| config | [Configuration](#section188911144124715) | Yes| New configuration.|
| config | [Configuration](js-apis-configuration.md) | Yes| New configuration.|
**Example**
...
...
@@ -363,7 +365,6 @@ Sends sequenceable data to the target ability and obtains the sequenceable data
this.name=name;
this.str=str;
}
constructor(){}
marshalling(messageParcel){
messageParcel.writeInt(this.num);
messageParcel.writeString(this.str);
...
...
@@ -380,7 +381,6 @@ Sends sequenceable data to the target ability and obtains the sequenceable data
varmethod='call_Function';
varcaller;
exportdefaultclassMainAbilityextendsAbility{
onWindowStageCreate(windowStage){
onWindowStageCreate(windowStage){
this.context.startAbilityByCall({
bundleName:"com.example.myservice",
...
...
@@ -573,15 +573,19 @@ Unregisters a caller notification callback, which is invoked when the target abi
| (msg: string) | function | Yes| No| Prototype of the listener function interface registered by the caller.<br>**System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore |
| (msg: string) | function | Yes| No| Prototype of the listener function interface registered by the caller.|
| (indata: rpc.MessageParcel) | rpc.Sequenceable | Yes| No| Prototype of the message listener function interface registered by the callee.<br>**System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore |
| (indata: rpc.MessageParcel) | rpc.Sequenceable | Yes| No| Prototype of the message listener function interface registered by the callee.|
> The initial APIs of this module are supported since API version 9.
> 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 parameters related to ability launch.
...
...
@@ -9,7 +9,7 @@ Provides parameters related to ability launch.
| context | [AbilityStageContext](js-apis-featureAbility.md) | Called when initialization is performed during ability startup.<br>**System capability**: SystemCapability.Ability.AbilityRuntime.Core|
| context | [AbilityStageContext](js-apis-featureAbility.md) | Called when initialization is performed during ability startup.|
> 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
```
import StaticSubscriberExtensionAbility from '@ohos.application.StaticSubscriberExtensionAbility'
> 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 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 extension context. This module is inherited from **Context**.
...
...
@@ -9,6 +9,8 @@ Implements the extension context. This module is inherited from **Context**.
| currentHapModuleInfo | HapModuleInfo | Yes| No| Information about the current HAP.<br>**System capability**: SystemCapability.Ability.AbilityRuntime.Core |
| currentHapModuleInfo | HapModuleInfo | Yes| No| Information about the current HAP. |
> The initial APIs of this module are supported since API 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.
| context | [FormExtensionContext](js-apis-formextensioncontext.md) | Yes | No | Context of the **FormExtension**. This class is inherited from **ExtensionContext**.<br>**System capability**: SystemCapability.Ability.Form|
| context | [FormExtensionContext](js-apis-formextensioncontext.md) | Yes | No | Context of the **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.
Provides mission management. You can use the APIs to lock, unlock, and clear missions, and switch a mission to the foreground.
...
...
@@ -18,7 +18,7 @@ import missionManager from '@ohos.application.missionManager'
## missionManager.registerMissionListener
function registerMissionListener(listener: MissionListener): number;
Unregisters a mission status listener. This API uses a promise to return the result.
...
...
@@ -98,6 +98,12 @@ Unregisters a mission status listener. This API uses a promise to return the res
| -------- | -------- | -------- | -------- |
| listenerId | number | Yes| Index of the mission status listener to unregister. Each listener has a unique index, which is returned by **registerMissionListener**.|
**Return value**
| Type| Description|
| -------- | -------- |
| Promise<void> | Promise used to return the result.|
**Example**
```js
...
...
@@ -110,7 +116,7 @@ Unregisters a mission status listener. This API uses a promise to return the res
Obtains information of all missions. This API uses an asynchronous callback to return the result.
...
...
@@ -195,7 +201,7 @@ Obtains information of all missions. This API uses an asynchronous callback to r
| -------- | -------- | -------- | -------- |
| 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.|
| callback | AsyncCallback<Array<[MissionInfo](js-apis-application-MissionInfo.md)>> | Yes| Callback used to return the array of mission information obtained.|
| callback | AsyncCallback<Array<[MissionInfo](#missioninfo)>> | Yes| Callback used to return the array of mission information obtained.|
**Example**
...
...
@@ -212,7 +218,7 @@ Obtains information of all missions. This API uses an asynchronous callback to r
## missionManager.getMissionInfos
function getMissionInfos(deviceId: string, numMax: number): Promise<Array<MissionInfo>>;
Switches a given mission to the foreground, with the startup parameters for the switch specified, such as the window mode and device ID. This API uses an asynchronous callback to return the result.
...
...
@@ -618,9 +649,9 @@ Switches a given mission to the foreground, with the startup parameters for the
## missionManager.moveMissionToFront
function moveMissionToFront(missionId: number, options?: StartOptions): Promise<void>;
Switches a given mission to the foreground. This API uses a promise to return the result.
Switches a given mission to the foreground, with the startup parameters for the switch specified, such as the window mode and device ID. This API uses a promise to return the result.
@@ -631,19 +662,42 @@ Switches a given mission to the foreground. This API uses a promise to return th
| 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.|
> The initial APIs of this module are supported since API 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.
| context | [ServiceExtensionContext](js-apis-service-extension-context.md) | Yes| No| Service extension context, which is inherited from **ExtensionContext**.<br>**System capability**: SystemCapability.Ability.AbilityRuntime.Core|
| context | [ServiceExtensionContext](js-apis-service-extension-context.md) | Yes| No| Service extension context, which is inherited from **ExtensionContext**.|
> The initial APIs of this module are supported since API 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 **ServiceExtension**. This class is inherited from **ExtensionContext**.