提交 1f174eb0 编写于 作者: G Gloria

replaced application-dev (en) folder with that in master

Signed-off-by: wusongqing<wusongqing@huawei.com>
上级 a7c7ada2
...@@ -9,9 +9,9 @@ In API references, the earliest versions of APIs and components are specified in ...@@ -9,9 +9,9 @@ In API references, the earliest versions of APIs and components are specified in
- For a new API or component, the version information is provided at the beginning of the reference document. Example: "The initial APIs of this module are supported since API version 7." - For a new API or component, the version information is provided at the beginning of the reference document. Example: "The initial APIs of this module are supported since API version 7."
- For a new feature of an existing API or component, a superscript is added following the feature. For example, "uid<sup>8+</sup>" indicates that the **uid** attribute is supported since API version 8. - For a new feature of an existing API or component, a superscript is added following the feature. For example, "uid<sup>8+</sup>" indicates that the **uid** attribute is supported since API version 8.
## Ability Framework Model Description ## Application Model Description
Ability is the minimum unit for the system to schedule applications. An application can contain one or more `Ability` instances. Ability framework models are classified into the FA model and stage model. For details, see [Ability Framework Overview](../../ability/ability-brief.md). Along its evolution, OpenHarmony has provided two application models: FA model and stage model. For their differences, see [Interpretation of the Application Model](../../application-models/application-model-description.md).
- If all the APIs of a module support only one model, the following description is provided at the beginning of the reference document: "The APIs of this module can be used only in the FA model." or "The APIs of this module can be used only in the stage model." - If all the APIs of a module support only one model, the following description is provided at the beginning of the reference document: "The APIs of this module can be used only in the FA model." or "The APIs of this module can be used only in the stage model."
- If certain APIs of a module support only one model, the following description is provided individually for these APIs: "This API can be used only in the FA model." or "This API can be used only in the stage model." - If certain APIs of a module support only one model, the following description is provided individually for these APIs: "This API can be used only in the FA model." or "This API can be used only in the stage model."
...@@ -19,18 +19,18 @@ Ability is the minimum unit for the system to schedule applications. An applicat ...@@ -19,18 +19,18 @@ Ability is the minimum unit for the system to schedule applications. An applicat
## Available APIs ## Available APIs
Certain APIs provided by OpenHarmony are system APIs, which can be used only by original equipment manufacturers (OEMs) and cannot be used by non-system applications. Certain APIs provided by OpenHarmony are system APIs, which can be used only by original equipment manufacturers (OEMs) and cannot be used by common applications.
A description regarding system APIs will be provided in the document. A description regarding system APIs will be provided in the document.
- If all the APIs of a module are system APIs, the following description is provided at the beginning of the reference document: "All the APIs of this module are system APIs." - If all the APIs of a module are system APIs, the following description is provided at the beginning of the reference document: "All the APIs of this module are system APIs."
- If a specific API of a module is a system API, the following description is provided individually for the API: "This is a system API." - If a specific API of a module is a system API, the following description is provided individually for the API: "This is a system API."
Non-system applications are applications whose Ability Privilege Level (APL) is **normal**. The default application level is **normal**. A common application is an application whose application type is **hos_normal_app** in the HarmonyAppProvision configuration file. **hos_normal_app** is the default value for project creation.
For details about the APL and how to declare the APL of an application higher than **normal**, see [Access Control Overview - App APLs](../../security/accesstoken-overview.md#app-apls). The public SDK, which does not include system APIs, is provided as standard in DevEco Studio. To use the system APIs, you must:
- Switch the public SDK to the full SDK by following the instructions provided in [Guide to Switching to Full SDK] (../../quick-start/full-sdk-switch-guide.md).
The public SDK, which does not include system APIs, is provided as standard in DevEco Studio. To use system APIs, switch to the full SDK. For details on the operation, see [Guide to Switching to Full SDK](../../quick-start/full-sdk-switch-guide.md). - Change the value of **app-feature** in the HarmonyAppProvision configuration file to **hos_system_app**. For details, see [HarmonyAppProvision Configuration File](../../security/app-provision-structure.md).
## Permission Description ## Permission Description
...@@ -41,17 +41,19 @@ To call APIs to access these resources, you must apply for the corresponding per ...@@ -41,17 +41,19 @@ To call APIs to access these resources, you must apply for the corresponding per
- If an application can call an API only after it has obtained a specific permission, the following description is provided for the API: "**Required permissions**: ohos.permission.xxxx" - If an application can call an API only after it has obtained a specific permission, the following description is provided for the API: "**Required permissions**: ohos.permission.xxxx"
- If an application can call an API without any permission, no special description is provided. - If an application can call an API without any permission, no special description is provided.
To determine whether an application can apply for a specific permission, see [Permission List](../../security/permission-list.md). To determine whether an application can request a specific permission, see [Permission Application and Use](../../security/accesstoken-overview.md#permission-application-and-use).
## System Capability Description ## System Capability Description
System capability refers to a relatively independent feature in the operating system. Different devices provide different system capabilities, and multiple APIs implement a system capability. You can determine whether an API can be used based on system capabilities. For details, see [SysCap](../../quick-start/syscap.md). System capability refers to a relatively independent feature in the operating system. Different devices provide different system capabilities, and multiple APIs implement a system capability. You can determine whether an API can be used based on system capabilities. For details, see [SystemCapability](../syscap.md).
The following description is provided for each API in the reference document to describe the system capability of the API: "**System capability**: SystemCapability.xxx.xxx" The following description is provided for each API in the reference document to describe the system capability of the API: "**System capability**: SystemCapability.xxx.xxx"
You can use the [SystemCapability List](../syscap-list.md) to query the devices supported by a specific capability set.
## Sample Code Language Description ## Sample Code Language Description
OpenHarmony supports two development languages: JS and TS. OpenHarmony supports two development languages: JS and TS.
- When a code block is labeled with `js`, the sample code can be used in the JS and ArkTS projects. - When a code block is labeled with **js**, the sample code can be used in the JS and ArkTS projects.
- When a code block is labeled with `ts`, the sample code can be used only in the ArkTS project. - When a code block is labeled with **ts**, the sample code can be used only in the ArkTS project.
# innerBundleManager<sup>(deprecated)</sup> # @ohos.bundle.innerBundleManager
The **innerBundleManager** module provides APIs for the **Home Screen** application. The **innerBundleManager** module provides APIs for the **Home Screen** application.
...@@ -41,7 +41,7 @@ This is a system API and cannot be called by third-party applications. ...@@ -41,7 +41,7 @@ This is a system API and cannot be called by third-party applications.
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| ---------- | ------------------------------------------------------------ | ---- | ----------------------------------------------------- | | ---------- | ------------------------------------------------------------ | ---- | ----------------------------------------------------- |
| bundleName | string | Yes | Bundle name of an application. | | bundleName | string | Yes | Bundle name of an application. |
| userId | number | Yes | User ID. The default value is the user ID of the caller. The value must be greater than or equal to 0.| | userId | number | Yes | User ID. The value must be greater than or equal to 0.|
| callback | AsyncCallback\<Array<[LauncherAbilityInfo](js-apis-bundle-LauncherAbilityInfo.md)>> | Yes | Callback used to return an array of the launcher ability information. | | callback | AsyncCallback\<Array<[LauncherAbilityInfo](js-apis-bundle-LauncherAbilityInfo.md)>> | Yes | Callback used to return an array of the launcher ability information. |
...@@ -69,7 +69,7 @@ This is a system API and cannot be called by third-party applications. ...@@ -69,7 +69,7 @@ This is a system API and cannot be called by third-party applications.
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| ---------- | ------ | ---- | ----------------------------------------------------- | | ---------- | ------ | ---- | ----------------------------------------------------- |
| bundleName | string | Yes | Bundle name of an application. | | bundleName | string | Yes | Bundle name of an application. |
| userId | number | Yes | User ID. The default value is the user ID of the caller. The value must be greater than or equal to 0.| | userId | number | Yes | User ID. The value must be greater than or equal to 0.|
**Return value** **Return value**
...@@ -216,7 +216,7 @@ This is a system API and cannot be called by third-party applications. ...@@ -216,7 +216,7 @@ This is a system API and cannot be called by third-party applications.
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ------------------------------------------------------------ | ---- | ----------------------------------------------------- | | -------- | ------------------------------------------------------------ | ---- | ----------------------------------------------------- |
| userId | number | Yes | User ID. The default value is the user ID of the caller. The value must be greater than or equal to 0.| | userId | number | Yes | User ID. The value must be greater than or equal to 0.|
| callback | AsyncCallback\<Array<[LauncherAbilityInfo](js-apis-bundle-LauncherAbilityInfo.md)>> | Yes | Callback used to return an array of the launcher ability information. | | callback | AsyncCallback\<Array<[LauncherAbilityInfo](js-apis-bundle-LauncherAbilityInfo.md)>> | Yes | Callback used to return an array of the launcher ability information. |
## innerBundleManager.getAllLauncherAbilityInfos<sup>(deprecated)</sup> ## innerBundleManager.getAllLauncherAbilityInfos<sup>(deprecated)</sup>
...@@ -242,7 +242,7 @@ This is a system API and cannot be called by third-party applications. ...@@ -242,7 +242,7 @@ This is a system API and cannot be called by third-party applications.
| Name| Type | Mandatory| Description | | Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ----------------------------------------------------- | | ------ | ------ | ---- | ----------------------------------------------------- |
| userId | number | Yes | User ID. The default value is the user ID of the caller. The value must be greater than or equal to 0.| | userId | number | Yes | User ID. The value must be greater than or equal to 0.|
**Return value** **Return value**
......
...@@ -110,7 +110,7 @@ This is a system API and cannot be called by third-party applications. ...@@ -110,7 +110,7 @@ This is a system API and cannot be called by third-party applications.
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| ------------ | ------------------------------------------------------------ | ---- | -------------------------------------------------- | | ------------ | ------------------------------------------------------------ | ---- | -------------------------------------------------- |
| elementNames | Array<[ElementName](js-apis-bundle-ElementName.md)> | Yes | **ElementName** array, whose maximum length is 10. | | elementNames | Array<[ElementName](js-apis-bundle-ElementName.md)> | Yes | **ElementName** array, whose maximum length is 10. |
| callback | AsyncCallback< Array<[RemoteAbilityInfo](js-apis-bundle-remoteAbilityInfo.md)>> | Yes | Callback used to return the remote ability information.| | callback | AsyncCallback< Array<[RemoteAbilityInfo](js-apis-bundle-remoteAbilityInfo.md)>> | Yes | Callback used to return an array of the remote ability information.|
......
# EnterpriseAdminExtensionAbility # @ohos.enterprise.EnterpriseAdminExtensionAbility (EnterpriseAdminExtensionAbility)
The **EnterpriseAdminExtensionAbility** module provides Extension abilities for enterprise administrators. The **EnterpriseAdminExtensionAbility** module provides Extension abilities for enterprise administrators.
...@@ -13,7 +13,7 @@ To have the capabilities provided by the module, for example, receiving the appl ...@@ -13,7 +13,7 @@ To have the capabilities provided by the module, for example, receiving the appl
## Modules to Import ## Modules to Import
```ts ```ts
import EnterpriseAdminExtensionAbility from '@ohos.EnterpriseAdminExtensionAbility' import EnterpriseAdminExtensionAbility from '@ohos.enterprise.EnterpriseAdminExtensionAbility'
``` ```
## EnterpriseAdminExtensionAbility.onAdminEnabled ## EnterpriseAdminExtensionAbility.onAdminEnabled
...@@ -24,6 +24,8 @@ Called when an enterprise administrator is enabled. ...@@ -24,6 +24,8 @@ Called when an enterprise administrator is enabled.
**System capability**: SystemCapability.Customization.EnterpriseDeviceManager **System capability**: SystemCapability.Customization.EnterpriseDeviceManager
**System API**: This is a system API.
**Example** **Example**
```ts ```ts
...@@ -41,6 +43,8 @@ Called when an enterprise administrator is disabled. ...@@ -41,6 +43,8 @@ Called when an enterprise administrator is disabled.
**System capability**: SystemCapability.Customization.EnterpriseDeviceManager **System capability**: SystemCapability.Customization.EnterpriseDeviceManager
**System API**: This is a system API.
**Example** **Example**
```ts ```ts
...@@ -58,6 +62,8 @@ Called when a bundle is added. ...@@ -58,6 +62,8 @@ Called when a bundle is added.
**System capability**: SystemCapability.Customization.EnterpriseDeviceManager **System capability**: SystemCapability.Customization.EnterpriseDeviceManager
**System API**: This is a system API.
**Parameters** **Parameters**
| Parameter | Type | Mandatory | Description | | Parameter | Type | Mandatory | Description |
...@@ -82,6 +88,8 @@ Called when a bundle is removed. ...@@ -82,6 +88,8 @@ Called when a bundle is removed.
**System capability**: SystemCapability.Customization.EnterpriseDeviceManager **System capability**: SystemCapability.Customization.EnterpriseDeviceManager
**System API**: This is a system API.
**Parameters** **Parameters**
| Parameter | Type | Mandatory | Description | | Parameter | Type | Mandatory | Description |
......
# Work Scheduler Callbacks # @ohos.WorkSchedulerExtensionAbility (Work Scheduler Callbacks)
The **WorkSchedulerExtensionAbility** module provides callbacks for Work Scheduler tasks. The **WorkSchedulerExtensionAbility** module provides callbacks for Work Scheduler tasks.
......
# @ohos.ability.ability (Ability)
The **Ability** module provides all level-2 module APIs for developers to export.
> **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 FA model.
## Modules to Import
```ts
import ability from '@ohos.ability.ability'
```
**System capability**: SystemCapability.Ability.AbilityBase
| Name | Type | Mandatory| Description |
| ----------- | -------------------- | ---- | ------------------------------------------------------------ |
| DataAbilityHelper | [DataAbilityHelper](js-apis-inner-ability-dataAbilityHelper.md) | No | Level-2 module **DataAbilityHelper**. |
| PacMap | [PacMap](js-apis-inner-ability-dataAbilityHelper.md#PacMap) | No | Level-2 module **PacMap**.|
| DataAbilityOperation | [DataAbilityOperation](js-apis-inner-ability-dataAbilityOperation.md) | No | Level-2 module **DataAbilityOperation**.|
| DataAbilityResult | [DataAbilityResult](js-apis-inner-ability-dataAbilityResult.md) | No | Level-2 module **DataAbilityResult**.|
| AbilityResult | [AbilityResult](js-apis-inner-ability-abilityResult.md) | No | Level-2 module **AbilityResult**.|
| ConnectOptions | [ConnectOptions](js-apis-inner-ability-connectOptions.md) | No | Level-2 module **ConnectOptions**.|
| StartAbilityParameter | [StartAbilityParameter](js-apis-inner-ability-startAbilityParameter.md) | No | Level-2 module **StartAbilityParameter**.|
**Example**
```ts
import ability from '@ohos.ability.ability';
let dataAbilityHelper: ability.DataAbilityHelper;
let pacMap: ability.PacMap;
let dataAbilityOperation: ability.DataAbilityOperation;
let dataAbilityResult: ability.DataAbilityResult;
let abilityResult: ability.AbilityResult;
let connectOptions: ability.ConnectOptions;
let startAbilityParameter: ability.StartAbilityParameter;
```
# DataUriUtils # @ohos.ability.dataUriUtils (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. The **DataUriUtils** module provides APIs to process URI objects. 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. This module will be replaced by the **app.ability.dataUriUtils** module in the near future. You are advised to use the **[@ohos.app.ability.dataUriUtils](js-apis-app-ability-dataUriUtils.md)** module.
> **NOTE** > **NOTE**
> >
...@@ -8,7 +8,7 @@ The **DataUriUtils** module provides APIs to handle utility classes for objects ...@@ -8,7 +8,7 @@ The **DataUriUtils** module provides APIs to handle utility classes for objects
## Modules to Import ## Modules to Import
```js ```ts
import dataUriUtils from '@ohos.ability.dataUriUtils'; import dataUriUtils from '@ohos.ability.dataUriUtils';
``` ```
...@@ -24,18 +24,18 @@ Obtains the ID attached to the end of a given URI. ...@@ -24,18 +24,18 @@ Obtains the ID attached to the end of a given URI.
| Name| Type | Mandatory| Description | | Name| Type | Mandatory| Description |
| ---- | ------ | ---- | --------------------------- | | ---- | ------ | ---- | --------------------------- |
| uri | string | Yes | URI object from which the ID is to be obtained.| | uri | string | Yes | Target URI object.|
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------ | ------------------------ | | ------ | ------------------------ |
| number | ID obtained from the URI object.| | number | ID obtained.|
**Example** **Example**
```js ```ts
dataUriUtils.getId("com.example.dataUriUtils/1221") let id = dataUriUtils.getId("com.example.dataUriUtils/1221");
``` ```
...@@ -52,7 +52,7 @@ Attaches an ID to the end of a given URI. ...@@ -52,7 +52,7 @@ Attaches an ID to the end of a given URI.
| Name| Type | Mandatory| Description | | Name| Type | Mandatory| Description |
| ---- | ------ | ---- | --------------------------- | | ---- | ------ | ---- | --------------------------- |
| uri | string | Yes | URI object to which an ID is to be attached.| | uri | string | Yes | Target URI object.|
| id | number | Yes | ID to be attached. | | id | number | Yes | ID to be attached. |
**Return value** **Return value**
...@@ -63,11 +63,11 @@ Attaches an ID to the end of a given URI. ...@@ -63,11 +63,11 @@ Attaches an ID to the end of a given URI.
**Example** **Example**
```js ```ts
var idint = 1122; let id = 1122;
dataUriUtils.attachId( let uri = dataUriUtils.attachId(
"com.example.dataUriUtils", "com.example.dataUriUtils",
idint, id,
) )
``` ```
...@@ -95,8 +95,8 @@ Deletes the ID from the end of a given URI. ...@@ -95,8 +95,8 @@ Deletes the ID from the end of a given URI.
**Example** **Example**
```js ```ts
dataUriUtils.deleteId("com.example.dataUriUtils/1221") let uri = dataUriUtils.deleteId("com.example.dataUriUtils/1221")
``` ```
...@@ -113,7 +113,7 @@ Updates the ID in a given URI. ...@@ -113,7 +113,7 @@ Updates the ID in a given URI.
| Name| Type | Mandatory| Description | | Name| Type | Mandatory| Description |
| ---- | ------ | ---- | ------------------- | | ---- | ------ | ---- | ------------------- |
| uri | string | Yes | URI object to be updated.| | uri | string | Yes | Target URI object.|
| id | number | Yes | New ID. | | id | number | Yes | New ID. |
**Return value** **Return value**
...@@ -124,10 +124,10 @@ Updates the ID in a given URI. ...@@ -124,10 +124,10 @@ Updates the ID in a given URI.
**Example** **Example**
```js ```ts
var idint = 1122; let id = 1122;
dataUriUtils.updateId( let uri = dataUriUtils.updateId(
"com.example.dataUriUtils", "com.example.dataUriUtils/1221",
idint id
) )
``` ```
# ErrorCode # @ohos.ability.errorCode (ErrorCode)
The **ErrorCode** module defines the error codes that can be used when the ability is started. The **ErrorCode** module defines the error codes that may be returned when an ability is started.
> **NOTE** > **NOTE**
> >
...@@ -8,19 +8,19 @@ The **ErrorCode** module defines the error codes that can be used when the abili ...@@ -8,19 +8,19 @@ The **ErrorCode** module defines the error codes that can be used when the abili
## Modules to Import ## Modules to Import
``` ```ts
import errorCode from '@ohos.ability.errorCode' import errorCode from '@ohos.ability.errorCode'
``` ```
## ErrorCode ## ErrorCode
Defines the error codes used when the ability is started. Enumerates the error codes that may be returned when an ability is started.
**System capability**: SystemCapability.Ability.AbilityRuntime.Core **System capability**: SystemCapability.Ability.AbilityRuntime.Core
| Name | Value | Description | | Name | Value | Description |
| ------------------------------ | ---- | ---------------------------------------- | | ------------------------------ | ---- | ---------------------------------------- |
| NO_ERROR | 0 | No error occurs. | | NO_ERROR | 0 | No error. |
| INVALID_PARAMETER | -1 | Invalid parameter.| | INVALID_PARAMETER | -1 | Invalid parameter.|
| ABILITY_NOT_FOUND | -2 | The ability is not found.| | ABILITY_NOT_FOUND | -2 | The ability is not found.|
| PERMISSION_DENY | -3 | Permission denied. | | PERMISSION_DENY | -3 | Permission denied. |
# particleAbility # @ohos.ability.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. The **particleAbility** module provides APIs for operating a ServiceAbility. You can use the APIs to start and terminate a ParticleAbility, obtain a **dataAbilityHelper** object, and connect to or disconnect from a ServiceAbility.
> **NOTE** > **NOTE**
> >
...@@ -13,7 +13,7 @@ The ParticleAbility module is used to perform operations on abilities of the Dat ...@@ -13,7 +13,7 @@ The ParticleAbility module is used to perform operations on abilities of the Dat
## Modules to Import ## Modules to Import
```js ```ts
import particleAbility from '@ohos.ability.particleAbility' import particleAbility from '@ohos.ability.particleAbility'
``` ```
...@@ -21,23 +21,28 @@ import particleAbility from '@ohos.ability.particleAbility' ...@@ -21,23 +21,28 @@ import particleAbility from '@ohos.ability.particleAbility'
startAbility(parameter: StartAbilityParameter, callback: AsyncCallback\<void>): void startAbility(parameter: StartAbilityParameter, callback: AsyncCallback\<void>): void
Starts a Particle ability. This API uses an asynchronous callback to return the result. Starts a ParticleAbility. This API uses an asynchronous callback to return the result.
Observe the following when using this API:
- If an application running in the background needs to call this API to start an ability, it must have the **ohos.permission.START_ABILITIES_FROM_BACKGROUND** permission.
- If **visible** of the target ability is **false** in cross-application scenarios, the caller must have the **ohos.permission.START_INVISIBLE_ABILITY** permission.
- For details about the startup rules for the components in the FA model, see [Component Startup Rules (FA Model)](../../application-models/component-startup-rules-fa.md).
**System capability**: SystemCapability.Ability.AbilityRuntime.FAModel **System capability**: SystemCapability.Ability.AbilityRuntime.FAModel
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| --------- | ----------------------------------------------- | ---- | ----------------- | | --------- | ----------------------------------------------- | ---- | ----------------- |
| parameter | [StartAbilityParameter](js-apis-featureAbility.md#startabilityparameter) | Yes | Ability to start.| | parameter | [StartAbilityParameter](js-apis-inner-ability-startAbilityParameter.md) | Yes | Ability to start.|
| callback | AsyncCallback\<void> | Yes | Callback used to return the result. | | callback | AsyncCallback\<void> | Yes | Callback used to return the result. |
**Example** **Example**
```js ```ts
import particleAbility from '@ohos.ability.particleAbility' import particleAbility from '@ohos.ability.particleAbility'
import wantConstant from '@ohos.ability.wantConstant' import wantConstant from '@ohos.ability.wantConstant'
particleAbility.startAbility( particleAbility.startAbility(
{ {
want: want:
...@@ -48,8 +53,8 @@ particleAbility.startAbility( ...@@ -48,8 +53,8 @@ particleAbility.startAbility(
flags: wantConstant.Flags.FLAG_AUTH_READ_URI_PERMISSION, flags: wantConstant.Flags.FLAG_AUTH_READ_URI_PERMISSION,
deviceId: "", deviceId: "",
bundleName: "com.example.Data", bundleName: "com.example.Data",
abilityName: "com.example.Data.MainAbility", abilityName: "EntryAbility",
uri:"" uri: ""
}, },
}, },
(error, result) => { (error, result) => {
...@@ -58,22 +63,24 @@ particleAbility.startAbility( ...@@ -58,22 +63,24 @@ particleAbility.startAbility(
) )
``` ```
## particleAbility.startAbility ## particleAbility.startAbility
startAbility(parameter: StartAbilityParameter): Promise\<void>; startAbility(parameter: StartAbilityParameter): Promise\<void>;
Starts a Particle ability. This API uses a promise to return the result. Starts a ParticleAbility. This API uses a promise to return the result.
Observe the following when using this API:
- If an application running in the background needs to call this API to start an ability, it must have the **ohos.permission.START_ABILITIES_FROM_BACKGROUND** permission.
- If **visible** of the target ability is **false** in cross-application scenarios, the caller must have the **ohos.permission.START_INVISIBLE_ABILITY** permission.
- For details about the startup rules for the components in the FA model, see [Component Startup Rules (FA Model)](../../application-models/component-startup-rules-fa.md).
**System capability**: SystemCapability.Ability.AbilityRuntime.FAModel **System capability**: SystemCapability.Ability.AbilityRuntime.FAModel
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| --------- | ----------------------------------------------- | ---- | ----------------- | | --------- | ----------------------------------------------- | ---- | ----------------- |
| parameter | [StartAbilityParameter](js-apis-featureAbility.md#startabilityparameter) | Yes | Ability to start.| | parameter | [StartAbilityParameter](js-apis-inner-ability-startAbilityParameter.md) | Yes | Ability to start.|
**Return value** **Return value**
...@@ -83,9 +90,10 @@ Starts a Particle ability. This API uses a promise to return the result. ...@@ -83,9 +90,10 @@ Starts a Particle ability. This API uses a promise to return the result.
**Example** **Example**
```js ```ts
import particleAbility from '@ohos.ability.particleAbility' import particleAbility from '@ohos.ability.particleAbility'
import wantConstant from '@ohos.ability.wantConstant' import wantConstant from '@ohos.ability.wantConstant'
particleAbility.startAbility( particleAbility.startAbility(
{ {
want: want:
...@@ -96,8 +104,8 @@ particleAbility.startAbility( ...@@ -96,8 +104,8 @@ particleAbility.startAbility(
flags: wantConstant.Flags.FLAG_AUTH_READ_URI_PERMISSION, flags: wantConstant.Flags.FLAG_AUTH_READ_URI_PERMISSION,
deviceId: "", deviceId: "",
bundleName: "com.example.Data", bundleName: "com.example.Data",
abilityName: "com.example. Data.MainAbility", abilityName: "EntryAbility",
uri:"" uri: ""
}, },
}, },
).then((data) => { ).then((data) => {
...@@ -105,13 +113,11 @@ particleAbility.startAbility( ...@@ -105,13 +113,11 @@ particleAbility.startAbility(
}); });
``` ```
## particleAbility.terminateSelf ## particleAbility.terminateSelf
terminateSelf(callback: AsyncCallback\<void>): void terminateSelf(callback: AsyncCallback\<void>): void
Terminates this Particle ability. This API uses an asynchronous callback to return the result. Terminates this ParticleAbility. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Ability.AbilityRuntime.FAModel **System capability**: SystemCapability.Ability.AbilityRuntime.FAModel
...@@ -123,8 +129,9 @@ Terminates this Particle ability. This API uses an asynchronous callback to retu ...@@ -123,8 +129,9 @@ Terminates this Particle ability. This API uses an asynchronous callback to retu
**Example** **Example**
```js ```ts
import particleAbility from '@ohos.ability.particleAbility' import particleAbility from '@ohos.ability.particleAbility'
particleAbility.terminateSelf( particleAbility.terminateSelf(
(error, result) => { (error, result) => {
console.log('particleAbility terminateSelf errCode:' + error + 'result:' + result) console.log('particleAbility terminateSelf errCode:' + error + 'result:' + result)
...@@ -132,13 +139,11 @@ particleAbility.terminateSelf( ...@@ -132,13 +139,11 @@ particleAbility.terminateSelf(
) )
``` ```
## particleAbility.terminateSelf ## particleAbility.terminateSelf
terminateSelf(): Promise\<void> terminateSelf(): Promise\<void>
Terminates this Particle ability. This API uses a promise to return the result. Terminates this ParticleAbility. This API uses a promise to return the result.
**System capability**: SystemCapability.Ability.AbilityRuntime.FAModel **System capability**: SystemCapability.Ability.AbilityRuntime.FAModel
...@@ -150,8 +155,9 @@ Terminates this Particle ability. This API uses a promise to return the result. ...@@ -150,8 +155,9 @@ Terminates this Particle ability. This API uses a promise to return the result.
**Example** **Example**
```js ```ts
import particleAbility from '@ohos.ability.particleAbility' import particleAbility from '@ohos.ability.particleAbility'
particleAbility.terminateSelf().then((data) => { particleAbility.terminateSelf().then((data) => {
console.info("particleAbility terminateSelf"); console.info("particleAbility terminateSelf");
}); });
...@@ -165,6 +171,12 @@ acquireDataAbilityHelper(uri: string): DataAbilityHelper ...@@ -165,6 +171,12 @@ acquireDataAbilityHelper(uri: string): DataAbilityHelper
Obtains a **dataAbilityHelper** object. Obtains a **dataAbilityHelper** object.
Observe the following when using this API:
- To access a DataAbility of another application, the target application must be configured with associated startup (**AssociateWakeUp** set to **true**).
- If an application running in the background needs to call this API to access a DataAbility, it must have the **ohos.permission.START_ABILITIES_FROM_BACKGROUND** permission.
- If **visible** of the target ability is **false** in cross-application scenarios, the caller must have the **ohos.permission.START_INVISIBLE_ABILITY** permission.
- For details about the startup rules for the components in the FA model, see [Component Startup Rules (FA Model)](../../application-models/component-startup-rules-fa.md).
**System capability**: SystemCapability.Ability.AbilityRuntime.FAModel **System capability**: SystemCapability.Ability.AbilityRuntime.FAModel
**Parameters** **Parameters**
...@@ -177,12 +189,13 @@ Obtains a **dataAbilityHelper** object. ...@@ -177,12 +189,13 @@ Obtains a **dataAbilityHelper** object.
| Type | Description | | Type | Description |
| ----------------- | -------------------------------------------- | | ----------------- | -------------------------------------------- |
| DataAbilityHelper | A utility class used to help other abilities access a Data ability.| | [DataAbilityHelper](js-apis-inner-ability-dataAbilityHelper.md) | A utility class used to help other abilities access a DataAbility.|
**Example** **Example**
```js ```ts
import particleAbility from '@ohos.ability.particleAbility' import particleAbility from '@ohos.ability.particleAbility'
var uri = ""; var uri = "";
particleAbility.acquireDataAbilityHelper(uri) particleAbility.acquireDataAbilityHelper(uri)
``` ```
...@@ -208,7 +221,7 @@ Requests a continuous task from the system. This API uses an asynchronous callba ...@@ -208,7 +221,7 @@ Requests a continuous task from the system. This API uses an asynchronous callba
**Example** **Example**
```js ```ts
import notification from '@ohos.notification'; import notification from '@ohos.notification';
import particleAbility from '@ohos.ability.particleAbility'; import particleAbility from '@ohos.ability.particleAbility';
import wantAgent from '@ohos.wantAgent'; import wantAgent from '@ohos.wantAgent';
...@@ -225,7 +238,7 @@ let wantAgentInfo = { ...@@ -225,7 +238,7 @@ let wantAgentInfo = {
wants: [ wants: [
{ {
bundleName: "com.example.myapplication", bundleName: "com.example.myapplication",
abilityName: "com.example.myapplication.MainAbility" abilityName: "EntryAbility"
} }
], ],
operationType: wantAgent.OperationType.START_ABILITY, operationType: wantAgent.OperationType.START_ABILITY,
...@@ -277,7 +290,7 @@ Requests a continuous task from the system. This API uses a promise to return th ...@@ -277,7 +290,7 @@ Requests a continuous task from the system. This API uses a promise to return th
**Example** **Example**
```js ```ts
import notification from '@ohos.notification'; import notification from '@ohos.notification';
import particleAbility from '@ohos.ability.particleAbility'; import particleAbility from '@ohos.ability.particleAbility';
import wantAgent from '@ohos.wantAgent'; import wantAgent from '@ohos.wantAgent';
...@@ -286,7 +299,7 @@ let wantAgentInfo = { ...@@ -286,7 +299,7 @@ let wantAgentInfo = {
wants: [ wants: [
{ {
bundleName: "com.example.myapplication", bundleName: "com.example.myapplication",
abilityName: "com.example.myapplication.MainAbility" abilityName: "EntryAbility"
} }
], ],
operationType: wantAgent.OperationType.START_ABILITY, operationType: wantAgent.OperationType.START_ABILITY,
...@@ -333,7 +346,7 @@ Requests to cancel a continuous task from the system. This API uses an asynchron ...@@ -333,7 +346,7 @@ Requests to cancel a continuous task from the system. This API uses an asynchron
**Example** **Example**
```js ```ts
import particleAbility from '@ohos.ability.particleAbility'; import particleAbility from '@ohos.ability.particleAbility';
function callback(err, data) { function callback(err, data) {
...@@ -352,7 +365,7 @@ particleAbility.cancelBackgroundRunning(callback); ...@@ -352,7 +365,7 @@ particleAbility.cancelBackgroundRunning(callback);
cancelBackgroundRunning(): Promise&lt;void&gt;; cancelBackgroundRunning(): Promise&lt;void&gt;;
Requests a continuous task from the system. This API uses a promise to return the result. You are advised to use the new API [backgroundTaskManager.stopBackgroundRunning](js-apis-backgroundTaskManager.md#backgroundtaskmanagerstopbackgroundrunning8-1). Requests to cancel a continuous task from the system. This API uses a promise to return the result. You are advised to use the new API [backgroundTaskManager.stopBackgroundRunning](js-apis-backgroundTaskManager.md#backgroundtaskmanagerstopbackgroundrunning8-1).
**System capability**: SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask **System capability**: SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask
...@@ -364,7 +377,7 @@ Requests a continuous task from the system. This API uses a promise to return th ...@@ -364,7 +377,7 @@ Requests a continuous task from the system. This API uses a promise to return th
**Example** **Example**
```js ```ts
import particleAbility from '@ohos.ability.particleAbility'; import particleAbility from '@ohos.ability.particleAbility';
particleAbility.cancelBackgroundRunning().then(() => { particleAbility.cancelBackgroundRunning().then(() => {
...@@ -375,12 +388,17 @@ particleAbility.cancelBackgroundRunning().then(() => { ...@@ -375,12 +388,17 @@ particleAbility.cancelBackgroundRunning().then(() => {
``` ```
## particleAbility.connectAbility ## particleAbility.connectAbility
connectAbility(request: Want, options:ConnectOptions): number 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 ServiceAbility.
Observe the following when using this API:
- To connect to a ServiceAbility of another application, the target application must be configured with associated startup (**AssociateWakeUp** set to **true**)..
- If an application running in the background needs to call this API to connect to a ServiceAbility, it must have the **ohos.permission.START_ABILITIES_FROM_BACKGROUND** permission.
- If **visible** of the target ability is **false** in cross-application scenarios, the caller must have the **ohos.permission.START_INVISIBLE_ABILITY** permission.
- For details about the startup rules for the components in the FA model, see [Component Startup Rules (FA Model)](../../application-models/component-startup-rules-fa.md).
**System capability**: SystemCapability.Ability.AbilityRuntime.FAModel **System capability**: SystemCapability.Ability.AbilityRuntime.FAModel
...@@ -388,34 +406,29 @@ Connects this ability to a specific Service ability. This API uses a callback to ...@@ -388,34 +406,29 @@ Connects this ability to a specific Service ability. This API uses a callback to
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| ------- | -------------- | ---- | ---------------------------- | | ------- | -------------- | ---- | ---------------------------- |
| request | [Want](js-apis-application-Want.md) | Yes | Service ability to connect.| | request | [Want](js-apis-application-want.md) | Yes | ServiceAbility to connect.|
| options | ConnectOptions | Yes | Callback used to return the result. | | options | [ConnectOptions](js-apis-inner-ability-connectOptions.md) | Yes | Connection options. |
ConnectOptions
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
| 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.|
**Example** **Example**
```js ```ts
import rpc from '@ohos.rpc' import particleAbility from '@ohos.ability.particleAbility'
function onConnectCallback(element, remote){ import rpc from '@ohos.rpc'
function onConnectCallback(element, remote) {
console.log('ConnectAbility onConnect remote is proxy:' + (remote instanceof rpc.RemoteProxy)); console.log('ConnectAbility onConnect remote is proxy:' + (remote instanceof rpc.RemoteProxy));
} }
function onDisconnectCallback(element){
function onDisconnectCallback(element) {
console.log('ConnectAbility onDisconnect element.deviceId : ' + element.deviceId) console.log('ConnectAbility onDisconnect element.deviceId : ' + element.deviceId)
} }
function onFailedCallback(code){
function onFailedCallback(code) {
console.log('particleAbilityTest ConnectAbility onFailed errCode : ' + code) console.log('particleAbilityTest ConnectAbility onFailed errCode : ' + code)
} }
var connId = particleAbility.connectAbility(
var connId = particleAbility.connectAbility(
{ {
bundleName: "com.ix.ServiceAbility", bundleName: "com.ix.ServiceAbility",
abilityName: "ServiceAbilityA", abilityName: "ServiceAbilityA",
...@@ -425,23 +438,21 @@ ConnectOptions ...@@ -425,23 +438,21 @@ ConnectOptions
onDisconnect: onDisconnectCallback, onDisconnect: onDisconnectCallback,
onFailed: onFailedCallback, onFailed: onFailedCallback,
}, },
); );
particleAbility.disconnectAbility(connId).then((data)=>{
console.log( " data: " + data);
}).catch((error)=>{
console.log('particleAbilityTest result errCode : ' + error.code )
});
particleAbility.disconnectAbility(connId).then((data) => {
console.log(" data: " + data);
}).catch((error) => {
console.log('particleAbilityTest result errCode : ' + error.code)
});
``` ```
## particleAbility.disconnectAbility ## particleAbility.disconnectAbility
disconnectAbility(connection: number, callback:AsyncCallback\<void>): void; disconnectAbility(connection: number, callback:AsyncCallback\<void>): void;
Disconnects this ability from the Service ability. This API uses a callback to return the result. Disconnects this ability from a specific ServiceAbility. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Ability.AbilityRuntime.FAModel **System capability**: SystemCapability.Ability.AbilityRuntime.FAModel
...@@ -453,18 +464,23 @@ Disconnects this ability from the Service ability. This API uses a callback to r ...@@ -453,18 +464,23 @@ Disconnects this ability from the Service ability. This API uses a callback to r
**Example** **Example**
```js ```ts
import rpc from '@ohos.rpc' import particleAbility from '@ohos.ability.particleAbility';
function onConnectCallback(element, remote){ import rpc from '@ohos.rpc';
function onConnectCallback(element, remote) {
console.log('ConnectAbility onConnect remote is proxy:' + (remote instanceof rpc.RemoteProxy)); console.log('ConnectAbility onConnect remote is proxy:' + (remote instanceof rpc.RemoteProxy));
} }
function onDisconnectCallback(element){
function onDisconnectCallback(element) {
console.log('ConnectAbility onDisconnect element.deviceId : ' + element.deviceId) console.log('ConnectAbility onDisconnect element.deviceId : ' + element.deviceId)
} }
function onFailedCallback(code){
function onFailedCallback(code) {
console.log('particleAbilityTest ConnectAbility onFailed errCode : ' + code) console.log('particleAbilityTest ConnectAbility onFailed errCode : ' + code)
} }
var connId = particleAbility.connectAbility(
var connId = particleAbility.connectAbility(
{ {
bundleName: "com.ix.ServiceAbility", bundleName: "com.ix.ServiceAbility",
abilityName: "ServiceAbilityA", abilityName: "ServiceAbilityA",
...@@ -474,13 +490,12 @@ import rpc from '@ohos.rpc' ...@@ -474,13 +490,12 @@ import rpc from '@ohos.rpc'
onDisconnect: onDisconnectCallback, onDisconnect: onDisconnectCallback,
onFailed: onFailedCallback, onFailed: onFailedCallback,
}, },
); );
var result = particleAbility.disconnectAbility(connId).then((data)=>{ var result = particleAbility.disconnectAbility(connId).then((data) => {
console.log( " data: " + data); console.log(" data: " + data);
}).catch((error)=>{ }).catch((error) => {
console.log('particleAbilityTest result errCode : ' + error.code ) console.log('particleAbilityTest result errCode : ' + error.code)
}); });
``` ```
...@@ -488,7 +503,7 @@ import rpc from '@ohos.rpc' ...@@ -488,7 +503,7 @@ import rpc from '@ohos.rpc'
disconnectAbility(connection: number): Promise\<void>; disconnectAbility(connection: number): Promise\<void>;
Disconnects this ability from the Service ability. This API uses a promise to return the result. Disconnects this ability from a specific ServiceAbility. This API uses a promise to return the result.
**System capability**: SystemCapability.Ability.AbilityRuntime.FAModel **System capability**: SystemCapability.Ability.AbilityRuntime.FAModel
...@@ -500,18 +515,23 @@ Disconnects this ability from the Service ability. This API uses a promise to re ...@@ -500,18 +515,23 @@ Disconnects this ability from the Service ability. This API uses a promise to re
**Example** **Example**
```js ```ts
import rpc from '@ohos.rpc' import particleAbility from '@ohos.ability.particleAbility';
function onConnectCallback(element, remote){ import rpc from '@ohos.rpc';
function onConnectCallback(element, remote) {
console.log('ConnectAbility onConnect remote is proxy:' + (remote instanceof rpc.RemoteProxy)); console.log('ConnectAbility onConnect remote is proxy:' + (remote instanceof rpc.RemoteProxy));
} }
function onDisconnectCallback(element){
function onDisconnectCallback(element) {
console.log('ConnectAbility onDisconnect element.deviceId : ' + element.deviceId) console.log('ConnectAbility onDisconnect element.deviceId : ' + element.deviceId)
} }
function onFailedCallback(code){
function onFailedCallback(code) {
console.log('particleAbilityTest ConnectAbility onFailed errCode : ' + code) console.log('particleAbilityTest ConnectAbility onFailed errCode : ' + code)
} }
var connId = particleAbility.connectAbility(
var connId = particleAbility.connectAbility(
{ {
bundleName: "com.ix.ServiceAbility", bundleName: "com.ix.ServiceAbility",
abilityName: "ServiceAbilityA", abilityName: "ServiceAbilityA",
...@@ -521,19 +541,19 @@ function onConnectCallback(element, remote){ ...@@ -521,19 +541,19 @@ function onConnectCallback(element, remote){
onDisconnect: onDisconnectCallback, onDisconnect: onDisconnectCallback,
onFailed: onFailedCallback, onFailed: onFailedCallback,
}, },
); );
particleAbility.disconnectAbility(connId).then((data)=>{ particleAbility.disconnectAbility(connId).then((data) => {
console.log( " data: " + data); console.log(" data: " + data);
}).catch((error)=>{ }).catch((error) => {
console.log('particleAbilityTest result errCode : ' + error.code ) console.log('particleAbilityTest result errCode : ' + error.code)
}); });
``` ```
## ErrorCode ## ErrorCode
Enumerates error codes. Enumerates the error codes.
**System capability**: SystemCapability.Ability.AbilityRuntime.FAModel **System capability**: SystemCapability.Ability.AbilityRuntime.FAModel
......
# wantConstant # @ohos.ability.wantConstant (wantConstant)
The **wantConstant** module provides the actions, entities, and flags used in **Want** objects. The **wantConstant** module provides the actions, entities, and flags used in **Want** objects.
> **NOTE** > **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 APIs of this module are supported since API version 6 and deprecated since API version 9. You are advised to use [@ohos.app.ability.wantConstant](js-apis-app-ability-wantConstant.md) instead. Newly added APIs will be marked with a superscript to indicate their earliest API version.
## Modules to Import ## Modules to Import
```js ```ts
import wantConstant from '@ohos.ability.wantConstant'; import wantConstant from '@ohos.ability.wantConstant';
``` ```
## wantConstant.Action ## wantConstant.Action
Enumerates the action constants of the **Want** object. Enumerates the action constants of the **Want** object. **action** specifies the operation to execute.
**System capability**: SystemCapability.Ability.AbilityBase **System capability**: SystemCapability.Ability.AbilityBase
...@@ -46,6 +46,7 @@ Enumerates the action constants of the **Want** object. ...@@ -46,6 +46,7 @@ Enumerates the action constants of the **Want** object.
| ACTION_FILE_SELECT<sup>7+</sup> | ohos.action.fileSelect | Action of selecting a file. | | 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. | | 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_APP_ACCOUNT_OAUTH <sup>8+</sup> | ohos.account.appAccount.action.oauth | Action of providing the OAuth service. |
| ACTION_APP_ACCOUNT_AUTH <sup>9+</sup> | account.appAccount.action.auth | Action of providing the authentication service. |
| ACTION_MARKET_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. | | ACTION_MARKET_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. |
| ACTION_MARKET_CROWDTEST <sup>9+</sup> | ohos.want.action.marketCrowdTest | Action of crowdtesting an application from the application market.<br>**System API**: This is a system API and cannot be called by third-party applications. | | ACTION_MARKET_CROWDTEST <sup>9+</sup> | ohos.want.action.marketCrowdTest | Action of crowdtesting an application from the application market.<br>**System API**: This is a system API and cannot be called by third-party applications. |
| DLP_PARAMS_SANDBOX<sup>9+</sup> |ohos.dlp.params.sandbox | Action of obtaining the sandbox flag.<br>**System API**: This is a system API and cannot be called by third-party applications. | | DLP_PARAMS_SANDBOX<sup>9+</sup> |ohos.dlp.params.sandbox | Action of obtaining the sandbox flag.<br>**System API**: This is a system API and cannot be called by third-party applications. |
...@@ -56,7 +57,7 @@ Enumerates the action constants of the **Want** object. ...@@ -56,7 +57,7 @@ Enumerates the action constants of the **Want** object.
## wantConstant.Entity ## wantConstant.Entity
Enumerates the entity constants of the **Want** object. Enumerates the entity constants of the **Want** object. **entity** specifies additional information of the target ability.
**System capability**: SystemCapability.Ability.AbilityBase **System capability**: SystemCapability.Ability.AbilityBase
...@@ -71,25 +72,25 @@ Enumerates the entity constants of the **Want** object. ...@@ -71,25 +72,25 @@ Enumerates the entity constants of the **Want** object.
## wantConstant.Flags ## wantConstant.Flags
Describes flags. Enumerates the flags that specify how the Want will be handled.
**System capability**: SystemCapability.Ability.AbilityBase **System capability**: SystemCapability.Ability.AbilityBase
| Name | Value | Description | | Name | Value | Description |
| ------------------------------------ | ---------- | ------------------------------------------------------------ | | ------------------------------------ | ---------- | ------------------------------------------------------------ |
| FLAG_AUTH_READ_URI_PERMISSION | 0x00000001 | Indicates the permission to read the URI. | | FLAG_AUTH_READ_URI_PERMISSION | 0x00000001 | Grants the permission to read the URI. |
| FLAG_AUTH_WRITE_URI_PERMISSION | 0x00000002 | Indicates the permission to write data to the URI. | | FLAG_AUTH_WRITE_URI_PERMISSION | 0x00000002 | Grants the permission to write data to the URI. |
| FLAG_ABILITY_FORWARD_RESULT | 0x00000004 | Returns the result to the ability. | | 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_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_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_ABILITY_FORM_ENABLED | 0x00000020 | Indicates that an ability is enabled. |
| 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_PERSISTABLE_URI_PERMISSION | 0x00000040 | Grants 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_AUTH_PREFIX_URI_PERMISSION | 0x00000080 | Grants 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_ABILITYSLICE_MULTI_DEVICE | 0x00000100 | Indicates the support for cross-device startup in the 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 ServiceAbility is started regardless of whether the host application has been started. |
| 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_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_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_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_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_NEW_MISSION | 0x10000000 | Creates 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.| | FLAG_ABILITY_MISSION_TOP | 0x20000000 | Reuses an ability instance if it is on the top of an existing mission stack; creates an ability instance otherwise.|
# @ohos.accessibility.GesturePath
The **GesturePath** module provides APIs for creating gesture path information required for an accessibility application to inject gestures.
> **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
```ts
import GesturePath from '@ohos.accessibility.GesturePath';
```
## GesturePath
Defines a gesture path.
**System capability**: SystemCapability.BarrierFree.Accessibility.Core
### Attributes
| Name | Type | Readable | Writable | Description |
| ------------ | ---------------------------------------- | ---- | ---- | ------ |
| points | Array&lt;[GesturePoint](js-apis-accessibility-GesturePoint.md#gesturepoint)&gt; | Yes | Yes | Gesture touch point. |
| durationTime | number | Yes | Yes | Total gesture duration, in milliseconds.|
### constructor
constructor(durationTime: number);
Constructor used to create a **GesturePath** object.
**System capability**: SystemCapability.BarrierFree.Accessibility.Core
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| durationTime | number | Yes| Total gesture duration, in milliseconds.|
**Example**
```ts
let gesturePath = new GesturePath.GesturePath(20);
```
# @ohos.accessibility.GesturePoint
The **GesturePoint** module provides APIs for creating gesture touch point information required for an accessibility application to inject gestures.
> **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
```ts
import GesturePoint from '@ohos.accessibility.GesturePoint';
```
## GesturePoint
Defines a gesture touch point.
**System capability**: SystemCapability.BarrierFree.Accessibility.Core
### Attributes
| Name | Type | Readable | Writable | Description |
| --------- | ------ | ---- | ---- | ------- |
| positionX | number | Yes | Yes | X coordinate of the touch point.|
| positionY | number | Yes | Yes | Y coordinate of the touch point.|
### constructor
constructor(positionX: number, positionY: number);
Constructor used to create a **GesturePoint** object.
**System capability**: SystemCapability.BarrierFree.Accessibility.Core
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| positionX | number | Yes| X coordinate of the touch point.|
| positionY | number | Yes | Y coordinate of the touch point.|
**Example**
```ts
let gesturePoint = new GesturePoint.GesturePoint(1, 2);
```
# @ohos.app.ability.Ability (Ability Base Class)
This is the base class of [UIAbility](js-apis-app-ability-uiAbility.md) and [ExtensionAbility](js-apis-app-ability-extensionAbility.md). It provides the callbacks for system configuration updates and memory level updates. You cannot inherit from this base class.
> **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.
## Ability.onConfigurationUpdate
onConfigurationUpdate(newConfig: Configuration): void;
Called when the configuration of the environment where the ability is running is updated.
**System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| newConfig | [Configuration](js-apis-app-ability-configuration.md) | Yes| New configuration.|
**Example**
```ts
// You are not allowed to inherit from the top-level base class Ability. Therefore, the derived class UIAbility is used as an example.
import UIAbility from '@ohos.app.ability.UIAbility';
class MyUIAbility extends UIAbility {
onConfigurationUpdate(config) {
console.log('onConfigurationUpdate, config:' + JSON.stringify(config));
}
}
```
## Ability.onMemoryLevel
onMemoryLevel(level: AbilityConstant.MemoryLevel): void;
Called when the system adjusts the memory level.
**System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| level | [AbilityConstant.MemoryLevel](js-apis-app-ability-abilityConstant.md#abilityconstantmemorylevel) | Yes| New memory level.|
**Example**
```ts
// You are not allowed to inherit from the top-level base class Ability. Therefore, the derived class UIAbility is used as an example.
import UIAbility from '@ohos.app.ability.UIAbility';
class MyUIAbility extends UIAbility {
onMemoryLevel(level) {
console.log('onMemoryLevel, level:' + JSON.stringify(level));
}
}
```
# @ohos.app.ability.AbilityConstant (AbilityConstant)
The **AbilityConstant** module defines the ability-related enums, including the initial launch reasons, reasons for the last exit, ability continuation results, and window modes.
> **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.
## Modules to Import
```ts
import AbilityConstant from '@ohos.app.ability.AbilityConstant';
```
## Attributes
## AbilityConstant.LaunchParam
Defines the parameters for starting an ability.
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
| Name| Type| Readable| Writable| Description|
| -------- | -------- | -------- | -------- | -------- |
| launchReason | [LaunchReason](#abilityconstantlaunchreason)| Yes| Yes| Ability launch reason, which is an enumerated type.|
| lastExitReason | [LastExitReason](#abilityconstantlastexitreason) | Yes| Yes| Reason for the last exit, which is an enumerated type.|
## AbilityConstant.LaunchReason
Enumerates the initial ability launch reasons. You can use it together with [onCreate(want, launchParam)](js-apis-app-ability-uiAbility.md#uiabilityoncreate) of [Ability](js-apis-app-ability-uiAbility.md) to complete different operations.
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
| Name | Value | Description |
| ----------------------------- | ---- | ------------------------------------------------------------ |
| UNKNOWN | 0 | Unknown reason.|
| START_ABILITY | 1 | The ability is started by calling [startAbility](js-apis-ability-context.md#abilitycontextstartability).|
| CALL | 2 | The ability is started by calling [startAbilityByCall](js-apis-ability-context.md#abilitycontextstartabilitybycall).|
| CONTINUATION | 3 | The ability is started by means of cross-device migration.|
| APP_RECOVERY | 4 | The ability is automatically started when the application is restored from a fault.|
**Example**
```ts
import UIAbility from '@ohos.app.ability.UIAbility';
class MyAbility extends UIAbility {
onCreate(want, launchParam) {
if (launchParam.launchReason === AbilityConstant.LaunchReason.START_ABILITY) {
console.log("The ability has been started by the way of startAbility.");
}
}
}
```
## AbilityConstant.LastExitReason
Enumerates the reasons for the last exit. You can use it together with [onCreate(want, launchParam)](js-apis-app-ability-uiAbility.md#uiabilityoncreate) of [Ability](js-apis-app-ability-uiAbility.md) to complete different operations.
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
| Name | Value | Description |
| ----------------------------- | ---- | ------------------------------------------------------------ |
| UNKNOWN | 0 | Unknown reason.|
| ABILITY_NOT_RESPONDING | 1 | The ability does not respond.|
| NORMAL | 2 | The ability exits normally.|
**Example**
```ts
import UIAbility from '@ohos.app.ability.UIAbility';
class MyAbility extends UIAbility {
onCreate(want, launchParam) {
if (launchParam.lastExitReason === AbilityConstant.LastExitReason.ABILITY_NOT_RESPONDING) {
console.log("The ability has exit last because the ability was not responding.");
}
}
}
```
## AbilityConstant.OnContinueResult
Enumerates the ability continuation results. You can use it together with [onContinue(wantParam)](js-apis-app-ability-uiAbility.md#uiabilityoncontinue) of [Ability](js-apis-app-ability-uiAbility.md) to complete different operations.
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
| Name | Value | Description |
| ----------------------------- | ---- | ------------------------------------------------------------ |
| AGREE | 0 | Continuation agreed.|
| REJECT | 1 | Continuation denied.|
| MISMATCH | 2 | Mismatch.|
**Example**
```ts
import UIAbility from '@ohos.app.ability.UIAbility';
class MyAbility extends UIAbility {
onContinue(wantParam) {
return AbilityConstant.OnConinueResult.AGREE;
}
}
```
## AbilityConstant.WindowMode
Enumerates the window modes in which an ability can be displayed at startup. It can be used in **startAbility()** to specify the window mode when the ability is started.
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
| Name | Value| Description |
| --- | --- | --- |
| WINDOW_MODE_UNDEFINED | 0 | Undefined window mode. |
| WINDOW_MODE_FULLSCREEN | 1 | The ability is displayed in full screen. |
| WINDOW_MODE_SPLIT_PRIMARY | 100 | The ability is displayed in the primary window in split-screen mode. |
| WINDOW_MODE_SPLIT_SECONDARY | 101 | The ability is displayed in the secondary window in split-screen mode. |
| WINDOW_MODE_FLOATING | 102 | The ability is displayed in a floating window.|
**Example**
```ts
let want = {
bundleName: "com.example.myapplication",
abilityName: "EntryAbility"
};
let option = {
windowMode: AbilityConstant.WindowMode.WINDOW_MODE_FULLSCREEN
};
// Ensure that the context is obtained.
this.context.startAbility(want, option).then(()={
console.log("Succeed to start ability.");
}).catch((error)=>{
console.log("Failed to start ability with error: " + JSON.stringify(error));
});
```
## AbilityConstant.MemoryLevel
Enumerates the memory levels. You can use it in [onMemoryLevel(level)](js-apis-app-ability-ability.md#abilityonmemorylevel) of [Ability](js-apis-app-ability-ability.md) to complete different operations.
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
| Name | Value| Description |
| --- | --- | --- |
| MEMORY_LEVEL_MODERATE | 0 | Moderate memory usage.|
| MEMORY_LEVEL_LOW | 1 | Low memory usage. |
| MEMORY_LEVEL_CRITICAL | 2 | High memory usage. |
**Example**
```ts
import UIAbility from '@ohos.app.ability.UIAbility';
class MyAbility extends UIAbility {
onMemoryLevel(level) {
if (level === AbilityConstant.MemoryLevel.MEMORY_LEVEL_CRITICAL) {
console.log("The memory of device is critical, please release some memory.");
}
}
}
```
## AbilityConstant.OnSaveResult
Enumerates the result types for the operation of saving application data. You can use it in [onSaveState(reason, wantParam)](js-apis-app-ability-uiAbility.md#uiabilityonsavestate) of [Ability](js-apis-app-ability-uiAbility.md) to complete different operations.
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
| Name | Value | Description |
| ----------------------------- | ---- | ------------------------------------------------------------ |
| ALL_AGREE | 0 | Always agreed to save the status.|
| CONTINUATION_REJECT | 1 | Rejected to save the status in continuation.|
| CONTINUATION_MISMATCH | 2 | Continuation mismatch.|
| RECOVERY_AGREE | 3 | Agreed to restore the saved status.|
| RECOVERY_REJECT | 4 | Rejected to restore the saved state.|
| ALL_REJECT | 5 | Always rejected to save the status.|
**Example**
```ts
import UIAbility from '@ohos.app.ability.UIAbility';
class MyAbility extends UIAbility {
onSaveState(reason, wantParam) {
return AbilityConstant.OnSaveResult.ALL_AGREE;
}
}
```
## AbilityConstant.StateType
Enumerates the scenarios for saving application data. You can use it in [onSaveState(reason, wantParam)](js-apis-app-ability-uiAbility.md#uiabilityonsavestate) of [Ability](js-apis-app-ability-uiAbility.md) to complete different operations.
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
| Name | Value | Description |
| ----------------------------- | ---- | ------------------------------------------------------------ |
| CONTINUATION | 0 | Saving the status in continuation.|
| APP_RECOVERY | 1 | Saving the status in application recovery.|
**Example**
```ts
import UIAbility from '@ohos.app.ability.UIAbility';
class MyAbility extends UIAbility {
onSaveState(reason, wantParam) {
if (reason === AbilityConstant.StateType.CONTINUATION) {
console.log("Save the ability data when the ability continuation.");
}
return AbilityConstant.OnSaveResult.ALL_AGREE;
}
}
```
# @ohos.app.ability.contextConstant (ContextConstant)
The **ContextConstant** module defines context-related enums. Currently, it defines only the enum of data encryption levels.
> **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.
## Modules to Import
```ts
import contextConstant from '@ohos.app.ability.contextConstant';
```
## ContextConstant.AreaMode
You can obtain the value of this constant by calling the **ContextConstant.AreaMode** API.
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
| Name| Value| Description|
| -------- | -------- | -------- |
| EL1 | 0 | Device-level encryption area, which is accessible after the device is powered on.|
| EL2 | 1 | User-level encryption area, which is accessible only after the device is powered on and the password is entered (for the first time).|
# @ohos.app.ability.ExtensionAbility (ExtensionAbility Base Class)
**ExtensionAbility** is the base class for scenario-specific ExtensionAbilities. It is inherited from [Ability](js-apis-app-ability-ability.md), with no attribute or method added. You cannot inherit from this base class.
> **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.
**System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册