提交 ea72980d 编写于 作者: W wusongqing

updated docs

Signed-off-by: Nwusongqing <wusongqing@huawei.com>
上级 8d874f4b
...@@ -15,24 +15,24 @@ var context = featureAbility.getContext(); ...@@ -15,24 +15,24 @@ var context = featureAbility.getContext();
context.getOrCreateLocalDir() context.getOrCreateLocalDir()
``` ```
## Context.getOrCreateLocalDir(callback: AsyncCallback<string>) ## Context
- Functionality ### getOrCreateLocalDir
Obtains the local root directory of the application. If this method is called for the first time, a root directory is created. This method uses a callback to return the result. getOrCreateLocalDir(callback: AsyncCallback\<string>): void
- Parameters Obtains the local root directory of the application. This method uses a callback to return the result.
If this method is called for the first time, a root directory is created.
| Name| Readable/Writable| Type| Mandatory| Description| **Parameters**
| -------- | -------- | ---------------------- | ---- | ------------------------ |
| callback | Read-only| AsyncCallback\<string> | Yes| Callback used to return the local root directory of the application.|
- Return values
void | Name| Type| Mandatory| Description|
| -------- | ---------------------- | ---- | -------------------------- |
| callback | AsyncCallback\<string> | Yes| Callback used to return the local root directory of the application.|
- Example **Example**
```js ```js
import featureAbility from '@ohos.ability.featureAbility' import featureAbility from '@ohos.ability.featureAbility'
...@@ -44,23 +44,21 @@ context.getOrCreateLocalDir((err, data)=>{ ...@@ -44,23 +44,21 @@ context.getOrCreateLocalDir((err, data)=>{
## Context.getOrCreateLocalDir() ### getOrCreateLocalDir
- Functionality
Obtains the local root directory of the application. If this method is called for the first time, a root directory is created. This method uses a promise to return the result. getOrCreateLocalDir(): Promise\<string>
- Parameters Obtains the local root directory of the application. This method uses a promise to return the result.
None If this method is called for the first time, a root directory is created.
- Return values **Return value**
| Type| Description| | Type| Description|
| --------------- | -------------------- | | ---------------- | ---------------------- |
| Promise<string> | Promise used to return the local root directory of the application.| | Promise\<string> | Promise returned with the local root directory of the application.|
- Example **Example**
```js ```js
import featureAbility from '@ohos.ability.featureAbility' import featureAbility from '@ohos.ability.featureAbility'
...@@ -70,33 +68,24 @@ context.getOrCreateLocalDir().then((void) => { ...@@ -70,33 +68,24 @@ context.getOrCreateLocalDir().then((void) => {
}); });
``` ```
## PermissionOptions
| Name| Readable/Writable| Type| Mandatory| Description|
| ---- | -------- | ------ | ---- | ------ |
| pid | Read-only| number | No| PID.|
| uid | Read-only| number | No| UID.|
## Context.verifyPermission(permission: string, options: PermissionOptions, callback: AsyncCallback<number>) ### verifyPermission
- Functionality verifyPermission(permission: string, options: PermissionOptions, callback: AsyncCallback\<number>): void
Verifies whether a specific PID and UID have the given permission. This method uses a callback to return the result. Verifies whether a specific PID and UID have the given permission. This method uses a callback to return the result.
- Parameters **Parameters**
| Name| Readable/Writable| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| ---------- | -------- | ----------------------------------------------- | ---- | ----------------------------------- | | ---------- | --------------------------------------- | ---- | ------------------------------------- |
| permission | Read-only| string | Yes| Name of the permission to verify.| | permission | string | Yes| Name of the permission to verify.|
| options | Read-only| [PermissionOptions](#PermissionOptions)| Yes| Permission options.| | options | [PermissionOptions](#permissionoptions) | Yes| Permission options.|
| callback | Read-only| AsyncCallback\<number> | Yes| Callback used to return the permission verification result. The value **0** indicates that the PID and UID have the given permission, and the value **-1** indicates that the PID and UID do not have the given permission.| | callback | AsyncCallback\<number> | Yes| Callback used to return the permission verification result. The value **0** indicates that the PID and UID have the given permission, and the value **-1** indicates that the PID and UID do not have the given permission.|
- Return values
void **Example**
- Example
```js ```js
import featureAbility from '@ohos.ability.featureAbility' import featureAbility from '@ohos.ability.featureAbility'
...@@ -109,25 +98,21 @@ context.verifyPermission("com.example.permission",datainfo.uid) ...@@ -109,25 +98,21 @@ context.verifyPermission("com.example.permission",datainfo.uid)
## Context.verifyPermission(permission: string, callback: AsyncCallback<number>) ### verifyPermission
- Functionality
Verifies whether the current PID and UID have the given permission. This method uses a callback to return the result. verifyPermission(permission: string, callback: AsyncCallback\<number>): void
- Parameters Verifies whether the current PID and UID have the given permission. This method uses a callback to return the result.
**Parameters**
| Name| Readable/Writable| Type| Mandatory| Description|
| ---------- | -------- | ---------------------- | ---- | ----------------------------------- |
| permission | Read-only| string | Yes| Name of the permission to verify.|
| callback | Read-only| AsyncCallback\<number> | Yes| Callback used to return the permission verification result. The value **0** indicates that the PID and UID have the given permission, and the value **-1** indicates that the PID and UID do not have the given permission.|
- Return values
void | Name| Type| Mandatory| Description|
| ---------- | ---------------------- | ---- | ------------------------------------- |
| permission | string | Yes| Name of the permission to verify.|
| callback | AsyncCallback\<number> | Yes| Callback used to return the permission verification result. The value **0** indicates that the PID and UID have the given permission, and the value **-1** indicates that the PID and UID do not have the given permission.|
- Example **Example**
```js ```js
import featureAbility from '@ohos.ability.featureAbility' import featureAbility from '@ohos.ability.featureAbility'
...@@ -135,29 +120,27 @@ var context = featureAbility.getContext(); ...@@ -135,29 +120,27 @@ var context = featureAbility.getContext();
context.verifyPermission("com.example.permission") context.verifyPermission("com.example.permission")
``` ```
### verifyPermission
verifyPermission(permission: string, options?: PermissionOptions): Promise\<number>
## Context.verifyPermission(permission: string, options?: PermissionOptions) Verifies whether a specific PID and UID have the given permission. This method uses a promise to return the result.
- Functionality **Parameters**
Verifies whether a specific PID and UID have the given permission. This method uses a promise to return the result.
- Parameters | Name| Type| Mandatory| Description|
| ---------- | --------------------------------------- | ---- | ---------------- |
| permission | string | Yes| Name of the permission to verify.|
| options | [PermissionOptions](#permissionoptions) | No| Permission options.|
**Return value**
| Name| Readable/Writable| Type| Mandatory| Description| | Type| Description|
| ---------- | -------- | ----------------------------------------------- | ---- | -------------- | | ---------------- | ----------------------------------------------------------- |
| permission | Read-only| string | Yes| Name of the permission to verify.| | Promise\<number> | Promise used to return the permission verification result. The value **0** indicates that the PID and UID have the given permission, and the value **-1** indicates that the PID and UID do not have the given permission.|
| options | Read-only| [PermissionOptions](#PermissionOptions)| No| Permission options.|
- Return values
| Type| Description| **Example**
| --------------- | ------------------------------------------------------------ |
| Promise<number> | Promise used to return the permission verification result. The value **0** indicates that the PID and UID have the given permission, and the value **-1** indicates that the PID and UID do not have the given permission.|
- Example
```js ```js
import featureAbility from '@ohos.ability.featureAbility' import featureAbility from '@ohos.ability.featureAbility'
...@@ -168,35 +151,23 @@ context.getOrCreateLocalDir('com.context.permission',Permission).then((void) => ...@@ -168,35 +151,23 @@ context.getOrCreateLocalDir('com.context.permission',Permission).then((void) =>
}); });
``` ```
## PermissionRequestResult
| Name| Readable/Writable| Type| Mandatory| Description|
| ----------- | -------- | -------------- | ---- | ------------------ |
| requestCode | Read-only| number | Yes| Request code passed.|
| permissions | Read-only| Array\<string> | Yes| Permissions passed.|
| authResults | Read-only| Array\<number> | Yes| Permission request result.|
## Context.requestPermissionsFromUser(permissions: Array<string>, requestCode: number, resultCallback: AsyncCallback<[PermissionRequestResult](#PermissionRequestResult)>) ### requestPermissionsFromUser
- Functionality requestPermissionsFromUser(permissions: Array\<string>, requestCode: number, resultCallback: AsyncCallback<[PermissionRequestResult](#permissionrequestresult)>)
Requests certain permissions from the system. This method uses a callback to return the result. Requests certain permissions from the system. This method uses a callback to return the result.
- Parameters **Parameters**
| Name| Readable/Writable| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------------- | -------- | ------------------------------------------------------------ | ---- | --------------------------------------------- | | -------------- | ------------------------------------------------------------ | ---- | ----------------------------------------------- |
| permissions | Read-only| Array\<string> | Yes| Permissions to request. This parameter cannot be **null**.| | permissions | Array\<string> | Yes| Permissions to request. This parameter cannot be **null**.|
| requestCode | Read-only| number | Yes| Request code to be passed to **PermissionRequestResult**.| | requestCode | number | Yes| Request code to be passed to **PermissionRequestResult**.|
| resultCallback | Read-only| AsyncCallback\<[PermissionRequestResult](#PermissionRequestResult)> | Yes| Permission request result.| | resultCallback | AsyncCallback<[PermissionRequestResult](#permissionrequestresult)> | Yes| Permission request result.|
- Return values **Example**
void
- Example
```js ```js
import featureAbility from '@ohos.ability.featureAbility' import featureAbility from '@ohos.ability.featureAbility'
...@@ -213,23 +184,19 @@ context.getOrCreateLocalDir( ...@@ -213,23 +184,19 @@ context.getOrCreateLocalDir(
## Context.getApplicationInfo(callback: AsyncCallback<ApplicationInfo>) ### getApplicationInfo
- Functionality
Obtains information about the current application. This method uses a callback to return the result. getApplicationInfo(callback: AsyncCallback\<ApplicationInfo>)
- Parameters Obtains information about the current application. This method uses a callback to return the result.
| Name| Readable/Writable| Type| Mandatory| Description| **Parameters**
| -------- | -------- | ------------------------------- | ---- | ---------------------- |
| callback | Read-only| AsyncCallback\<ApplicationInfo> | Yes| Callback used to return the application information.|
- Return values | Name| Type| Mandatory| Description|
| -------- | ------------------------------- | ---- | ------------------------ |
| callback | AsyncCallback\<ApplicationInfo> | Yes| Callback used to return the application information.|
void **Example**
- Example
```js ```js
import featureAbility from '@ohos.ability.featureAbility' import featureAbility from '@ohos.ability.featureAbility'
...@@ -239,23 +206,19 @@ context.getApplicationInfo() ...@@ -239,23 +206,19 @@ context.getApplicationInfo()
## Context.getApplicationInfo ### getApplicationInfo
- Functionality
Obtains information about the current application. This method uses a promise to return the result. getApplicationInfo(): Promise\<ApplicationInfo>
- Parameters Obtains information about the current application. This method uses a promise to return the result.
None **Return value**
- Return values | Type| Description|
| ------------------------- | ------------------ |
| Promise\<ApplicationInfo> | Promise used to return the application information.|
| Type| Description| **Example**
| ------------------------ | ------------------ |
| Promise<ApplicationInfo> | Promise used to return the application information.|
- Example
```js ```js
import featureAbility from '@ohos.ability.featureAbility' import featureAbility from '@ohos.ability.featureAbility'
...@@ -267,23 +230,19 @@ context.getApplicationInfo().then((void) => { ...@@ -267,23 +230,19 @@ context.getApplicationInfo().then((void) => {
## Context.getBundleName(callback: AsyncCallback<string>) ### getBundleName
- Functionality
Obtains the bundle name of the current ability. This method uses a callback to return the result. getBundleName(callback: AsyncCallback\<string>): void
- Parameters Obtains the bundle name of the current ability. This method uses a callback to return the result.
| Name| Readable/Writable| Type| Mandatory| Description| **Parameters**
| -------- | -------- | ---------------------- | ---- | --------------------------- |
| callback | Read-only| AsyncCallback\<string> | Yes| Callback used to return the bundle name.|
- Return values | Name| Type| Mandatory| Description|
| -------- | ---------------------- | ---- | ----------------------------- |
| callback | AsyncCallback\<string> | Yes| Callback used to return the bundle name.|
void **Example**
- Example
```js ```js
import featureAbility from '@ohos.ability.featureAbility' import featureAbility from '@ohos.ability.featureAbility'
...@@ -293,23 +252,19 @@ context.getBundleName() ...@@ -293,23 +252,19 @@ context.getBundleName()
## Context.getBundleName ### getBundleName
- Functionality
Obtains the bundle name of the current ability. This method uses a promise to return the result. getBundleName(): Promise\<string>
- Parameters Obtains the bundle name of the current ability. This method uses a promise to return the result.
None **Return value**
- Return values | Type| Description|
| ---------------- | ------------------------- |
| Promise\<string> | Promise used to return the bundle name.|
| Type| Description| **Example**
| --------------- | ----------------------- |
| Promise<string> | Promise used to return the bundle name.|
- Example
```js ```js
import featureAbility from '@ohos.ability.featureAbility' import featureAbility from '@ohos.ability.featureAbility'
...@@ -321,23 +276,19 @@ context.getBundleName().then((void) => { ...@@ -321,23 +276,19 @@ context.getBundleName().then((void) => {
## Context.getProcessInfo(callback: AsyncCallback<ProcessInfo>) ### getProcessInfo
- Functionality
Obtains information about the current process, including the PID and process name. This method uses a callback to return the result.
- Parameters getProcessInfo(callback: AsyncCallback\<ProcessInfo>)
| Name| Readable/Writable| Type| Mandatory| Description| Obtains information about the current process, including the PID and process name. This method uses a callback to return the result.
| -------- | -------- | --------------------------- | ---- | ------------------ |
| callback | Read-only| AsyncCallback\<ProcessInfo> | Yes| Callback used to return the process information.|
- Return values **Parameters**
void | Name| Type| Mandatory| Description|
| -------- | --------------------------- | ---- | -------------------- |
| callback | AsyncCallback\<ProcessInfo> | Yes| Callback used to return the process information.|
- Example **Example**
```js ```js
import featureAbility from '@ohos.ability.featureAbility' import featureAbility from '@ohos.ability.featureAbility'
...@@ -347,23 +298,19 @@ context.getProcessInfo() ...@@ -347,23 +298,19 @@ context.getProcessInfo()
## Context.getProcessInfo ### getProcessInfo
- Functionality
Obtains information about the current process, including the PID and process name. This method uses a promise to return the result.
- Parameters getProcessInfo(): Promise\<ProcessInfo>
None Obtains information about the current process, including the PID and process name. This method uses a promise to return the result.
- Return values **Return value**
| Type| Description| | Type| Description|
| -------------------- | -------------- | | --------------------- | -------------- |
| Promise<ProcessInfo> | Promise used to return the process information.| | Promise\<ProcessInfo> | Promise used to return the process information.|
- Example **Example**
```js ```js
import featureAbility from '@ohos.ability.featureAbility' import featureAbility from '@ohos.ability.featureAbility'
...@@ -375,23 +322,21 @@ context.getProcessInfo().then((void) => { ...@@ -375,23 +322,21 @@ context.getProcessInfo().then((void) => {
## Context.getElementName(callback: AsyncCallback<ElementName>) ### getElementName
- Functionality getElementName(callback: AsyncCallback\<ElementName>): void
Obtains the **ohos.bundle.ElementName** object of the current ability. This method is available only to Page abilities. It uses a callback to return the result. Obtains the **ohos.bundle.ElementName** object of the current ability. This method uses a callback to return the result.
- Parameters This method is available only to Page abilities.
| Name| Readable/Writable| Type| Mandatory| Description| **Parameters**
| -------- | -------- | --------------------------- | ---- | -------------------------------------------- |
| callback | Read-only| AsyncCallback\<ElementName> | Yes| Callback used to return the **ohos.bundle.ElementName** object.|
- Return values | Name| Type| Mandatory| Description|
| -------- | --------------------------- | ---- | ---------------------------------------------- |
| callback | AsyncCallback\<ElementName> | Yes| Callback used to return the **ohos.bundle.ElementName** object.|
void **Example**
- Example
```js ```js
import featureAbility from '@ohos.ability.featureAbility' import featureAbility from '@ohos.ability.featureAbility'
...@@ -401,23 +346,21 @@ context.getElementName() ...@@ -401,23 +346,21 @@ context.getElementName()
## Context.getElementName ### getElementName
- Functionality
Obtains the **ohos.bundle.ElementName** object of the current ability. This method is available only to Page abilities. It uses a promise to return the result. getElementName(): Promise\<ElementName>
- Parameters Obtains the **ohos.bundle.ElementName** object of the current ability. This method uses a promise to return the result.
None This method is available only to Page abilities.
- Return values **Return value**
| Type| Description| | Type| Description|
| -------------------- | ---------------------------------------- | | --------------------- | ------------------------------------------ |
| Promise<ElementName> | Promise used to return the **ohos.bundle.ElementName** object.| | Promise\<ElementName> | Promise returned with the **ohos.bundle.ElementName** object.|
- Example **Example**
```js ```js
import featureAbility from '@ohos.ability.featureAbility' import featureAbility from '@ohos.ability.featureAbility'
...@@ -427,23 +370,17 @@ context.getElementName().then((void) => { ...@@ -427,23 +370,17 @@ context.getElementName().then((void) => {
}); });
``` ```
## **Context.getProcessName(callback: AsyncCallback<string>)** ### getProcessName
- Functionality
Obtains the name of the current process. This method uses a callback to return the result.
- Parameters getProcessName(callback: AsyncCallback\<string>): void
| Name| Readable/Writable| Type| Mandatory| Description| Obtains the name of the current process. This method uses a callback to return the result.
| -------- | -------- | ---------------------- | ---- | ------------------ |
| callback | Read-only| AsyncCallback\<string> | Yes| Callback used to return the process name.|
- Return values | Name| Type| Mandatory| Description|
| -------- | ---------------------- | ---- | -------------------- |
| callback | AsyncCallback\<string> | Yes| Callback used to return the process name.|
void **Example**
- Example
```js ```js
import featureAbility from '@ohos.ability.featureAbility' import featureAbility from '@ohos.ability.featureAbility'
...@@ -453,23 +390,19 @@ context.getProcessName() ...@@ -453,23 +390,19 @@ context.getProcessName()
## Context.getProcessName ### getProcessName
- Functionality
Obtains the name of the current process. This method uses a promise to return the result. getProcessName(): Promise\<string>
- Parameters Obtains the name of the current process. This method uses a promise to return the result.
None **Return value**
- Return values | Type| Description|
| ---------------- | -------------------- |
| Promise\<string> | Promise returned with the process name.|
| Type| Description| **Example**
| --------------- | -------------- |
| Promise<string> | Promise used to return the process name.|
- Example
```js ```js
import featureAbility from '@ohos.ability.featureAbility' import featureAbility from '@ohos.ability.featureAbility'
...@@ -481,23 +414,19 @@ context.getProcessName().then((void) => { ...@@ -481,23 +414,19 @@ context.getProcessName().then((void) => {
## Context.getCallingBundle(callback: AsyncCallback<string>) ### getCallingBundle
- Functionality
Obtains the bundle name of the calling ability. This method uses a callback to return the result. getCallingBundle(callback: AsyncCallback\<string>): void
- Parameters Obtains the bundle name of the calling ability. This method uses a callback to return the result.
| Name| Readable/Writable| Type| Mandatory| Description| **Parameters**
| -------- | -------- | ---------------------- | ---- | ------------------------- |
| callback | Read-only| AsyncCallback\<string> | Yes| Callback used to return the bundle name.|
- Return values | Name| Type| Mandatory| Description|
| -------- | ---------------------- | ---- | ------------------------- |
| callback | AsyncCallback\<string> | Yes| Callback used to return the bundle name.|
void **Example**
- Example
```js ```js
import featureAbility from '@ohos.ability.featureAbility' import featureAbility from '@ohos.ability.featureAbility'
...@@ -507,25 +436,19 @@ context.getCallingBundle() ...@@ -507,25 +436,19 @@ context.getCallingBundle()
## Context.getCallingBundle ### getCallingBundle
- Functionality
Obtains the bundle name of the calling ability. This method uses a promise to return the result.
- Parameters
None getCallingBundle(): Promise\<string>
- Return values Obtains the bundle name of the calling ability. This method uses a promise to return the result.
| Type| Description| **Return value**
| --------------- | ------------------------- |
| Promise<string> | Promise used to return the bundle name.|
| Type| Description|
| --------------- | ------------------------- |
| Promise\<string> | Promise used to return the bundle name.|
**Example**
- Example
```js ```js
import featureAbility from '@ohos.ability.featureAbility' import featureAbility from '@ohos.ability.featureAbility'
...@@ -534,3 +457,18 @@ context.getCallingBundle().then((void) => { ...@@ -534,3 +457,18 @@ context.getCallingBundle().then((void) => {
console.info("==========================>getCallingBundleCallback=======================>"); console.info("==========================>getCallingBundleCallback=======================>");
}); });
``` ```
## PermissionOptions
| Name| Readable/Writable| Type| Mandatory| Description|
| ---- | -------- | ------ | ---- | ------ |
| pid | Read-only| number | No| PID.|
| uid | Read-only| number | No| UID.|
## PermissionRequestResult
| Name| Readable/Writable| Type| Mandatory| Description|
| ----------- | -------- | -------------- | ---- | ------------------ |
| requestCode | Read-only| number | Yes| Request code passed.|
| permissions | Read-only| Array\<string> | Yes| Permissions passed.|
| authResults | Read-only| Array\<number> | Yes| Permission request result.|
...@@ -6,24 +6,25 @@ ...@@ -6,24 +6,25 @@
import dataUriUtils from '@ohos.ability.dataUriUtils'; import dataUriUtils from '@ohos.ability.dataUriUtils';
``` ```
## DataUriUtils.getId ## dataUriUtils.getId
- Functionality getId(uri: string): number
Obtains the ID attached to the end of a given URI. Obtains the ID attached to the end of a given URI.
- Parameters **Parameters**
| Name| Readable/Writable| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| ---- | -------- | ------ | ---- | ------------------------- | | ---- | ------ | ---- | --------------------------- |
| uri | Read-only| string | Yes| URI object from which the ID is to be obtained.| | uri | string | Yes| URI object from which the ID is to be obtained.|
- Return values **Return value**
| Type| Description|
| ------ | ------------------------ |
| number | ID obtained from the URI object.|
Returns the ID obtained from the URI object. **Example**
- Example
```js ```js
import dataUriUtils from '@ohos.ability.datauriutils' import dataUriUtils from '@ohos.ability.datauriutils'
...@@ -32,25 +33,26 @@ dataUriUtils.getIdSync("com.example.dataUriUtils/1221") ...@@ -32,25 +33,26 @@ dataUriUtils.getIdSync("com.example.dataUriUtils/1221")
## DataUriUtils.attachId ## dataUriUtils.attachId
- Functionality
Attaches an ID to the end of a given URI. attachId(uri: string, id: number): string
- Parameters Attaches an ID to the end of a given URI.
**Parameters**
| Name| Readable/Writable| Type| Mandatory| Description|
| ---- | -------- | ------ | ---- | ------------------------- |
| uri | Read-only| string | Yes| URI object to which an ID is to be attached.|
| id | Read-only| number | Yes| ID to be attached.|
- Return values | Name| Type| Mandatory| Description|
| ---- | ------ | ---- | --------------------------- |
| uri | string | Yes| URI object to which an ID is to be attached.|
| id | number | Yes| ID to be attached.|
Returns the URI object with the ID attached. **Return value**
| Type| Description|
| ------ | --------------------- |
| string | URI object with the ID attached.|
- Example **Example**
```js ```js
import dataUriUtils from '@ohos.ability.datauriutils' import dataUriUtils from '@ohos.ability.datauriutils'
...@@ -63,23 +65,24 @@ dataUriUtils.attachId( ...@@ -63,23 +65,24 @@ dataUriUtils.attachId(
## DataUriUtils.deleteId ## dataUriUtils.deleteId
- Functionality deleteId(uri: string): string
Deletes the ID from the end of a given URI. Deletes the ID from the end of a given URI.
- Parameters **Parameters**
| Name| Readable/Writable| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| ---- | -------- | ------ | ---- | ------------------------- | | ---- | ------ | ---- | --------------------------- |
| uri | Read-only| string | Yes| URI object from which the ID is to be deleted.| | uri | string | Yes| URI object from which the ID is to be deleted.|
- Return values **Return value**
| Type| Description|
| ------ | ------------------- |
| string | URI object with the ID deleted.|
Returns the URI object with the ID deleted. **Example**
- Example
```js ```js
import dataUriUtils from '@ohos.ability.datauriutils' import dataUriUtils from '@ohos.ability.datauriutils'
...@@ -88,24 +91,25 @@ dataUriUtils.deleteId("com.example.dataUriUtils/1221") ...@@ -88,24 +91,25 @@ dataUriUtils.deleteId("com.example.dataUriUtils/1221")
## DataUriUtils.updateId ## dataUriUtils.updateId
- Functionality
Updates the ID in a given URI. updateId(uri: string, id: number): string
- Parameters Updates the ID in a given URI.
| Name| Readable/Writable| Type| Mandatory| Description| **Parameters**
| ---- | -------- | ------ | ---- | ------------------- |
| uri | Read-only| string | Yes| URI object to be updated.|
| id | Read-only| number | Yes| New ID.|
- Return values | Name| Type| Mandatory| Description|
| ---- | ------ | ---- | ------------------- |
| uri | string | Yes| URI object to be updated.|
| id | number | Yes| New ID.|
Returns the URI object with the new ID. **Return value**
| Type| Description|
| ------ | --------------- |
| string | URI object with the new ID.|
- Example **Example**
```js ```js
import dataUriUtils from '@ohos.ability.datauriutils' import dataUriUtils from '@ohos.ability.datauriutils'
......
# CommonEvent Module # CommonEvent Module
**Note:** > **Note:**
The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version. > 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.
## Required Permissions ## Required Permissions
| Common Event Macro| Common Event Name| Subscriber Permissions| | Common Event Macro| Common Event Name| Subscriber Permissions|
| ------------------------------------------------------------ | ----------------------------------------------------------- | ------------------------------------------------------------ | | ------------ | ------------------ | ---------------------- |
| COMMON_EVENT_BOOT_COMPLETED | usual.event.BOOT_COMPLETED | ohos.permission.RECEIVER_STARTUP_COMPLETED | | COMMON_EVENT_BOOT_COMPLETED | usual.event.BOOT_COMPLETED | ohos.permission.RECEIVER_STARTUP_COMPLETED |
| COMMON_EVENT_SHUTDOWN | usual.event.SHUTDOWN | N/A| | COMMON_EVENT_SHUTDOWN | usual.event.SHUTDOWN | N/A|
| COMMON_EVENT_BATTERY_CHANGED | usual.event.BATTERY_CHANGED | N/A| | COMMON_EVENT_BATTERY_CHANGED | usual.event.BATTERY_CHANGED | N/A|
...@@ -103,11 +103,11 @@ The initial APIs of this module are supported since API version 7. Newly added A ...@@ -103,11 +103,11 @@ The initial APIs of this module are supported since API version 7. Newly added A
| COMMON_EVENT_USB_DEVICE_DETACHED | usual.event.hardware.usb.action.USB_DEVICE_DETACHED | N/A| | COMMON_EVENT_USB_DEVICE_DETACHED | usual.event.hardware.usb.action.USB_DEVICE_DETACHED | N/A|
| COMMON_EVENT_USB_ACCESSORY_ATTACHED | usual.event.hardware.usb.action.USB_ACCESSORY_ATTACHED | N/A| | COMMON_EVENT_USB_ACCESSORY_ATTACHED | usual.event.hardware.usb.action.USB_ACCESSORY_ATTACHED | N/A|
| COMMON_EVENT_USB_ACCESSORY_DETACHED | usual.event.hardware.usb.action.USB_ACCESSORY_DETACHED | N/A| | COMMON_EVENT_USB_ACCESSORY_DETACHED | usual.event.hardware.usb.action.USB_ACCESSORY_DETACHED | N/A|
| COMMON_EVENT_DISK_REMOVED | usual.event.data.DISK_REMOVED | ohos.permission.WRITE_USER_STORAGE or ohos.permission.READ_USER_STORAGE | | COMMON_EVENT_DISK_REMOVED | usual.event.data.DISK_REMOVED | ohos.permission.WRITE_USER_STORAGE or ohos.permission.READ_USER_STORAGE|
| COMMON_EVENT_DISK_UNMOUNTED | usual.event.data.DISK_UNMOUNTED | ohos.permission.WRITE_USER_STORAGEor ohos.permission.READ_USER_STORAGE | | COMMON_EVENT_DISK_UNMOUNTED | usual.event.data.DISK_UNMOUNTED | ohos.permission.WRITE_USER_STORAGE or ohos.permission.READ_USER_STORAGE|
| COMMON_EVENT_DISK_MOUNTED | usual.event.data.DISK_MOUNTED | ohos.permission.WRITE_USER_STORAGEor ohos.permission.READ_USER_STORAGE | | COMMON_EVENT_DISK_MOUNTED | usual.event.data.DISK_MOUNTED | ohos.permission.WRITE_USER_STORAGE or ohos.permission.READ_USER_STORAGE|
| COMMON_EVENT_DISK_BAD_REMOVAL | usual.event.data.DISK_BAD_REMOVAL | ohos.permission.WRITE_USER_STORAGEor ohos.permission.READ_USER_STORAGE | | COMMON_EVENT_DISK_BAD_REMOVAL | usual.event.data.DISK_BAD_REMOVAL | ohos.permission.WRITE_USER_STORAGE or ohos.permission.READ_USER_STORAGE|
| COMMON_EVENT_DISK_EJECT | usual.event.data.DISK_EJECT | ohos.permission.WRITE_USER_STORAGEor ohos.permission.READ_USER_STORAGE | | COMMON_EVENT_DISK_EJECT | usual.event.data.DISK_EJECT | ohos.permission.WRITE_USER_STORAGE or ohos.permission.READ_USER_STORAGE|
| COMMON_EVENT_AIRPLANE_MODE_CHANGED | usual.event.AIRPLANE_MODE | N/A| | COMMON_EVENT_AIRPLANE_MODE_CHANGED | usual.event.AIRPLANE_MODE | N/A|
## Modules to Import ## Modules to Import
...@@ -118,20 +118,20 @@ import CommonEvent from '@ohos.commonevent'; ...@@ -118,20 +118,20 @@ import CommonEvent from '@ohos.commonevent';
## CommonEvent.publish(event: string, callback: AsyncCallback\<void>): void ## CommonEvent.publish
- Functionality publish(event: string, callback: AsyncCallback\<void>): void
Publishes a common event. This method uses a callback to return the result. Publishes a common event. This method uses a callback to return the result.
* Parameters **Parameters**
| Name| Readable/Writable| Type| Mandatory| Description| | Name| Readable/Writable| Type| Mandatory| Description|
| -------- | -------- | -------------------- | ---- | -------------------- | | -------- | -------- | -------------------- | ---- | ---------------------- |
| event | Read-only| string | Yes| Name of the common event to publish.| | event | Read-only| string | Yes| Name of the common event to publish.|
| callback | Read-only| AsyncCallback\<void> | Yes| Callback used to return the result.| | callback | Read-only| AsyncCallback\<void> | Yes| Callback used to return the result.|
* Example **Example**
```js ```js
// Callback for common event publication // Callback for common event publication
...@@ -145,21 +145,21 @@ CommonEvent.publish("publish_event", PublishCallBack); ...@@ -145,21 +145,21 @@ CommonEvent.publish("publish_event", PublishCallBack);
## CommonEvent.publish(event: string, options: CommonEventPublishData, callback: AsyncCallback\<void>): void ## CommonEvent.publish
- Functionality publish(event: string, options: CommonEventPublishData, callback: AsyncCallback\<void>): void
Publishes a common event with given attributes. This method uses a callback to return the result. Publishes a common event with given attributes. This method uses a callback to return the result.
- Parameters **Parameters**
| Name| Readable/Writable| Type| Mandatory| Description| | Name| Readable/Writable| Type| Mandatory| Description|
| -------- | -------- | ---------------------- | ---- | ---------------------- | | -------- | -------- | ---------------------- | ---- | ---------------------- |
| event | Read-only| string | Yes| Name of the common event to publish.| | event | Read-only| string | Yes| Name of the common event to publish.|
| options | Read-only| [CommonEventPublishData](#publishData) | Yes| Attributes of the common event to publish.| | options | Read-only| [CommonEventPublishData](#commoneventpublishdata) | Yes| Attributes of the common event to publish.|
| callback | Read-only| AsyncCallback\<void> | Yes| Callback used to return the result.| | callback | Read-only| AsyncCallback\<void> | Yes| Callback used to return the result.|
- Example **Example**
```js ```js
...@@ -179,20 +179,20 @@ CommonEvent.publish("publish_event", options, PublishCallBack); ...@@ -179,20 +179,20 @@ CommonEvent.publish("publish_event", options, PublishCallBack);
## CommonEvent.createSubscriber(subscribeInfo: CommonEventSubscribeInfo, callback: AsyncCallback\<CommonEventSubscriber>): void ## CommonEvent.createSubscriber
- Functionality createSubscriber(subscribeInfo: CommonEventSubscribeInfo, callback: AsyncCallback\<CommonEventSubscriber>): void
Creates a subscriber. This method uses a callback to return the result. Creates a subscriber. This method uses a callback to return the result.
- Parameters **Parameters**
| Name| Readable/Writable| Type| Mandatory| Description| | Name| Readable/Writable| Type| Mandatory| Description|
| ------------- | -------- | ---------------------------------------------------- | ---- | ------------------------ | | ------------- | -------- | ------------------------------------------------------------ | ---- | -------------------------- |
| subscribeInfo | Read-only| [CommonEventSubscribeInfo](#SubscribeInfo) | Yes| Subscriber information.| | subscribeInfo | Read-only| [CommonEventSubscribeInfo](#commoneventsubscribeinfo) | Yes| Subscriber information.|
| callback | Read-only| AsyncCallback\<[CommonEventSubscriber](#Subscriber)> | Yes| Callback used to return the result.| | callback | Read-only| AsyncCallback\<[CommonEventSubscriber](#commoneventsubscriber)> | Yes| Callback used to return the result.|
- Example **Example**
```js ```js
...@@ -212,25 +212,24 @@ CommonEvent.createSubscriber(subscribeInfo, CreateSubscriberCallBack); ...@@ -212,25 +212,24 @@ CommonEvent.createSubscriber(subscribeInfo, CreateSubscriberCallBack);
## CommonEvent.createSubscriber(subscribeInfo: CommonEventSubscribeInfo): Promise\<CommonEventSubscriber> ## CommonEvent.createSubscriber
- Functionality
Creates a subscriber. This method uses a promise to return the result. createSubscriber(subscribeInfo: CommonEventSubscribeInfo): Promise\<CommonEventSubscriber>
- Parameters Creates a subscriber. This method uses a promise to return the result.
| Name| Readable/Writable| Type| Mandatory| Description| **Parameters**
| ------------- | -------- | ------------------------------------------ | ---- | ------------ |
| subscribeInfo | Read-only| [CommonEventSubscribeInfo](#SubscribeInfo) | Yes| Subscriber information.|
- Return values | Name| Readable/Writable| Type| Mandatory| Description|
| ------------- | -------- | ----------------------------------------------------- | ---- | -------------- |
Promise\<[CommonEventSubscriber](#Subscriber)> | subscribeInfo | Read-only| [CommonEventSubscribeInfo](#commoneventsubscribeinfo) | Yes| Subscriber information.|
Returns a subscriber object. **Return value**
| Type| Description|
| --------------------------------------------------------- | ---------------- |
| Promise\<[CommonEventSubscriber](#commoneventsubscriber)> | Promise returned with the subscriber object.|
- Example **Example**
```js ```js
var subscriber; // Used to save the created subscriber object for subsequent subscription and unsubscription. var subscriber; // Used to save the created subscriber object for subsequent subscription and unsubscription.
...@@ -247,23 +246,22 @@ CommonEvent.createSubscriber(subscribeInfo).then((data) => { ...@@ -247,23 +246,22 @@ CommonEvent.createSubscriber(subscribeInfo).then((data) => {
## CommonEvent.subscribe(subscriber: CommonEventSubscriber, callback: AsyncCallback\<CommonEventData>): void ## CommonEvent.subscribe
- Functionality
Subscribes to common events. This method uses a callback to return the result. subscribe(subscriber: CommonEventSubscriber, callback: AsyncCallback\<CommonEventData>): void
- Parameters Subscribes to common events. This method uses a callback to return the result.
| Name| Readable/Writable| Type| Mandatory| Description| **Parameters**
| ---------- | -------- | --------------------------------------------------- | ---- | ------------------------------ |
| subscriber | Read-only| [CommonEventSubscriber](#Subscriber) | Yes| Subscriber object.|
| callback | Read-only| AsyncCallback\<[CommonEventData](#CommonEventData)> | Yes| Callback used to return the result.|
- Example | Name| Readable/Writable| Type| Mandatory| Description|
| ---------- | -------- | --------------------------------------------------- | ---- | -------------------------------- |
| subscriber | Read-only| [CommonEventSubscriber](#commoneventsubscriber) | Yes| Subscriber object.|
| callback | Read-only| AsyncCallback\<[CommonEventData](#commoneventdata)> | Yes| Callback used to return the result.|
Unordered common event: **Example**
Unordered common event:
```js ```js
var subscriber; // Used to save the created subscriber object for subsequent subscription and unsubscription. var subscriber; // Used to save the created subscriber object for subsequent subscription and unsubscription.
...@@ -286,7 +284,7 @@ function CreateSubscriberCallBack(err, data) { ...@@ -286,7 +284,7 @@ function CreateSubscriberCallBack(err, data) {
CommonEvent.createSubscriber(subscribeInfo, CreateSubscriberCallBack); CommonEvent.createSubscriber(subscribeInfo, CreateSubscriberCallBack);
``` ```
Ordered common event: Ordered common event:
```js ```js
var subscriber; // Used to save the created subscriber object for subsequent subscription and unsubscription. var subscriber; // Used to save the created subscriber object for subsequent subscription and unsubscription.
...@@ -330,22 +328,22 @@ function CreateSubscriberCallBack(err, data) { ...@@ -330,22 +328,22 @@ function CreateSubscriberCallBack(err, data) {
CommonEvent.createSubscriber(subscribeInfo, CreateSubscriberCallBack); CommonEvent.createSubscriber(subscribeInfo, CreateSubscriberCallBack);
``` ```
## CommonEvent.unsubscribe(subscriber: CommonEventSubscriber, callback?: AsyncCallback\<void>): void
- Functionality ## CommonEvent.unsubscribe
unsubscribe(subscriber: CommonEventSubscriber, callback?: AsyncCallback\<void>): void
Unsubscribes from common events. This method uses a callback to return the result. Unsubscribes from common events. This method uses a callback to return the result.
- Parameters **Parameters**
| Name| Readable/Writable| Type| Mandatory| Description| | Name| Readable/Writable| Type| Mandatory| Description|
| ---------- | -------- | --------------------- | ---- | ---------------------- | | ---------- | -------- | --------------------- | ---- | ------------------------ |
| subscriber | Read-only| CommonEventSubscriber | Yes| Subscriber object.| | subscriber | Read-only| CommonEventSubscriber | Yes| Subscriber object.|
| callback | Read-only| AsyncCallback\<void> | Yes| Callback used to return the result.| | callback | Read-only| AsyncCallback\<void> | Yes| Callback used to return the result.|
- Example **Example**
```js ```js
var subscriber; // Used to save the created subscriber object for subsequent subscription and unsubscription. var subscriber; // Used to save the created subscriber object for subsequent subscription and unsubscription.
...@@ -374,7 +372,7 @@ CommonEvent.createSubscriber(subscribeInfo, CreateSubscriberCallBack); ...@@ -374,7 +372,7 @@ CommonEvent.createSubscriber(subscribeInfo, CreateSubscriberCallBack);
CommonEvent.unsubscribe(subscriber, UnsubscribeCallBack); CommonEvent.unsubscribe(subscriber, UnsubscribeCallBack);
``` ```
## <span id = "publishData">CommonEventPublishData</span> ## CommonEventPublishData
| Name| Readable/Writable| Type| Mandatory| Description| | Name| Readable/Writable| Type| Mandatory| Description|
| --------------------- | -------- | -------------------- | ---- | ---------------------------- | | --------------------- | -------- | -------------------- | ---- | ---------------------------- |
...@@ -385,7 +383,7 @@ CommonEvent.unsubscribe(subscriber, UnsubscribeCallBack); ...@@ -385,7 +383,7 @@ CommonEvent.unsubscribe(subscriber, UnsubscribeCallBack);
| isOrdered | Read-only| boolean | No| Whether the common event is an ordered one.| | isOrdered | Read-only| boolean | No| Whether the common event is an ordered one.|
| parameters | Read-only| {[key: string]: any} | No| Additional information about the common event.| | parameters | Read-only| {[key: string]: any} | No| Additional information about the common event.|
## <span id = "SubscribeInfo">CommonEventSubscribeInfo</span> ## CommonEventSubscribeInfo
| Name| Readable/Writable| Type| Mandatory| Description| | Name| Readable/Writable| Type| Mandatory| Description|
| ------------------- | -------- | -------------- | ---- | ------------------------------------------------------------ | | ------------------- | -------- | -------------- | ---- | ------------------------------------------------------------ |
...@@ -395,7 +393,7 @@ CommonEvent.unsubscribe(subscriber, UnsubscribeCallBack); ...@@ -395,7 +393,7 @@ CommonEvent.unsubscribe(subscriber, UnsubscribeCallBack);
| userId | Read-only| number | No| User ID. The default value is the ID of the current user. If this parameter is specified, the value must be an existing user ID in the system.| | userId | Read-only| number | No| User ID. The default value is the ID of the current user. If this parameter is specified, the value must be an existing user ID in the system.|
| priority | Read-only| number | No| Subscriber priority. The value ranges from -100 to 1000.| | priority | Read-only| number | No| Subscriber priority. The value ranges from -100 to 1000.|
## <span id = "CommonEventData">CommonEventData</span> ## CommonEventData
| Name| Readable/Writable| Type| Mandatory| Description| | Name| Readable/Writable| Type| Mandatory| Description|
| ---------- | -------- | -------------------- | ---- | ------------------------------------------------------ | | ---------- | -------- | -------------------- | ---- | ------------------------------------------------------ |
...@@ -405,456 +403,456 @@ CommonEvent.unsubscribe(subscriber, UnsubscribeCallBack); ...@@ -405,456 +403,456 @@ CommonEvent.unsubscribe(subscriber, UnsubscribeCallBack);
| data | Read-only| string | No| Custom result data of the common event, which is used to transfer data of the string type.| | data | Read-only| string | No| Custom result data of the common event, which is used to transfer data of the string type.|
| parameters | Read-only| {[key: string]: any} | No| Additional information about the common event.| | parameters | Read-only| {[key: string]: any} | No| Additional information about the common event.|
## <span id = "Subscriber">CommonEventSubscriber</span> ## CommonEventSubscriber
### getCode (callback) ### getCode
- Functionality getCode(callback: AsyncCallback\<number>): void
Obtains the result code of this common event. This method uses a callback to return the result. Obtains the result code of this common event. This method uses a callback to return the result.
- Parameters **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | ---------------------- | ---- | ------------------ | | -------- | ---------------------- | ---- | ------------------ |
| callback | AsyncCallback\<number> | Yes| Callback used to return the result code.| | callback | AsyncCallback\<number> | Yes| Callback used to return the result code.|
- Example **Example**
```js ```js
var subscriber; // Used to save the created subscriber object for subsequent subscription and unsubscription. var subscriber; // Used to save the created subscriber object for subsequent subscription and unsubscription.
// Callback for result data setting of an ordered common event // Callback for result data setting of an ordered common event
function getCodeCallback(err, data) { function getCodeCallback(err, data) {
console.info("==========================>getCodeCallback=======================>"); console.info("==========================>getCodeCallback=======================>");
console.info("==========================>err:=======================>", err.code); console.info("==========================>err:=======================>", err.code);
console.info("==========================>code:=======================>", data); console.info("==========================>code:=======================>", data);
} }
subscriber.getCode(getCodeCallback); subscriber.getCode(getCodeCallback);
``` ```
### getCode (promise) ### getCode
- Functionality getCode(): Promise\<number>
Obtains the result code of this common event. This method uses a promise to return the result. Obtains the result code of this common event. This method uses a promise to return the result.
- Return values **Return value**
| Type| Description| | Type| Description|
| ---------------- | ------------------ | | ---------------- | -------------------- |
| Promise\<number> | A promise used to return the result code.| | Promise\<number> | Promise returned with the result code.|
- Example **Example**
```js ```js
var subscriber; // Used to save the created subscriber object for subsequent subscription and unsubscription. var subscriber; // Used to save the created subscriber object for subsequent subscription and unsubscription.
subscriber.getCode().then((data) => { subscriber.getCode().then((data) => {
console.info("==========================>getCodePromise=======================>"); console.info("==========================>getCodePromise=======================>");
console.info("==========================>code:=======================>", data); console.info("==========================>code:=======================>", data);
}); });
``` ```
### setCode (callback) ### setCode
- Functionality setCode(code: number, callback: AsyncCallback\<void>): void
Sets the result code for this common event. This method uses a callback to return the result. Sets the result code for this common event. This method uses a callback to return the result.
- Parameters **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------------------- | ---- | -------------------- | | -------- | -------------------- | ---- | ---------------------- |
| code | number | Yes| Result code of the common event.| | code | number | Yes| Result code of the common event.|
| callback | AsyncCallback\<void> | Yes| Callback used to return the result.| | callback | AsyncCallback\<void> | Yes| Callback used to return the result.|
- Example **Example**
```js ```js
var subscriber; // Used to save the created subscriber object for subsequent subscription and unsubscription. var subscriber; // Used to save the created subscriber object for subsequent subscription and unsubscription.
// Callback for result data setting of an ordered common event // Callback for result data setting of an ordered common event
function setCodeCallback(err) { function setCodeCallback(err) {
console.info("==========================>setCodeCallback=======================>"); console.info("==========================>setCodeCallback=======================>");
console.info("==========================>err:=======================>", err.code); console.info("==========================>err:=======================>", err.code);
} }
subscriber.setCode(1, setCodeCallback); subscriber.setCode(1, setCodeCallback);
``` ```
### setCode (promise) ### setCode
- Functionality setCode(code: number): Promise\<void>
Sets the result code for this common event. This method uses a promise to return the result. Sets the result code for this common event. This method uses a promise to return the result.
- Parameters **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| ------ | ------ | ---- | ------------------ | | ------ | ------ | ---- | ------------------ |
| code | number | Yes| Result code of the common event.| | code | number | Yes| Result code of the common event.|
- Example **Example**
```js ```js
var subscriber; // Used to save the created subscriber object for subsequent subscription and unsubscription. var subscriber; // Used to save the created subscriber object for subsequent subscription and unsubscription.
subscriber.setCode(1).then(() => { subscriber.setCode(1).then(() => {
console.info("==========================>setCodePromise=======================>"); console.info("==========================>setCodePromise=======================>");
}); });
``` ```
### getData (callback) ### getData
- Functionality getData(callback: AsyncCallback\<string>): void
Obtains the result data of this common event. This method uses a callback to return the result. Obtains the result data of this common event. This method uses a callback to return the result.
- Parameters **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | ---------------------- | ---- | ------------------ | | -------- | ---------------------- | ---- | -------------------- |
| callback | AsyncCallback\<string> | Yes| Callback used to return the result data.| | callback | AsyncCallback\<string> | Yes| Callback used to return the result data.|
- Example **Example**
```js ```js
var subscriber; // Used to save the created subscriber object for subsequent subscription and unsubscription. var subscriber; // Used to save the created subscriber object for subsequent subscription and unsubscription.
// Callback for result data setting of an ordered common event // Callback for result data setting of an ordered common event
function getDataCallback(err, data) { function getDataCallback(err, data) {
console.info("==========================>getDataCallback=======================>"); console.info("==========================>getDataCallback=======================>");
console.info("==========================>err:=======================>", err.code); console.info("==========================>err:=======================>", err.code);
console.info("==========================>data:=======================>", data); console.info("==========================>data:=======================>", data);
} }
subscriber.getData(getDataCallback); subscriber.getData(getDataCallback);
``` ```
### getData (promise) ### getData
- Functionality getData(): Promise\<string>
Obtains the result data of this common event. This method uses a promise to return the result. Obtains the result data of this common event. This method uses a promise to return the result.
- Return values **Return value**
| Type| Description| | Type| Description|
| ---------------- | ------------------ | | ---------------- | ------------------ |
| Promise\<string> | A promise used to return the result data.| | Promise\<string> | Promise returned with the result data.|
- Example **Example**
```js ```js
var subscriber; // Used to save the created subscriber object for subsequent subscription and unsubscription. var subscriber; // Used to save the created subscriber object for subsequent subscription and unsubscription.
subscriber.getData().then((data) => { subscriber.getData().then((data) => {
console.info("==========================>getDataPromise=======================>"); console.info("==========================>getDataPromise=======================>");
console.info("==========================>data:=======================>", data); console.info("==========================>data:=======================>", data);
}); });
``` ```
### setData (callback) ### setData
- Functionality setData(data: string, callback: AsyncCallback\<void>): void
Sets the result data for this common event. This method uses a callback to return the result. Sets the result data for this common event. This method uses a callback to return the result.
- Parameters **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------------------- | ---- | -------------------- | | -------- | -------------------- | ---- | -------------------- |
| data | string | Yes| Result data of the common event.| | data | string | Yes| Result data of the common event.|
| callback | AsyncCallback\<void> | Yes| Callback used to return the result.| | callback | AsyncCallback\<void> | Yes| Callback used to return the result.|
- Example **Example**
```js ```js
var subscriber; // Used to save the created subscriber object for subsequent subscription and unsubscription. var subscriber; // Used to save the created subscriber object for subsequent subscription and unsubscription.
// Callback for result data setting of an ordered common event // Callback for result data setting of an ordered common event
function setDataCallback(err) { function setDataCallback(err) {
console.info("==========================>setDataCallback=======================>"); console.info("==========================>setDataCallback=======================>");
console.info("==========================>err:=======================>", err.code); console.info("==========================>err:=======================>", err.code);
} }
subscriber.setData("publish_data_changed", setDataCallback); subscriber.setData("publish_data_changed", setDataCallback);
``` ```
### setData (promise) ### setData
- Functionality setData(data: string): Promise\<void>
Sets the result data for this common event. This method uses a promise to return the result. Sets the result data for this common event. This method uses a promise to return the result.
- Parameters **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| ------ | ------ | ---- | ------------------ | | ------ | ------ | ---- | -------------------- |
| data | string | Yes| Result data of the common event.| | data | string | Yes| Result data of the common event.|
- Example **Example**
```js ```js
var subscriber; // Used to save the created subscriber object for subsequent subscription and unsubscription. var subscriber; // Used to save the created subscriber object for subsequent subscription and unsubscription.
subscriber.setData("publish_data_changed").then(() => { subscriber.setData("publish_data_changed").then(() => {
console.info("==========================>setDataPromise=======================>"); console.info("==========================>setDataPromise=======================>");
}); });
``` ```
### setCodeAndData (callback) ### setCodeAndData
- Functionality setCodeAndData(code: number, data: string, callback:AsyncCallback\<void>): void
Sets the result code and result data for this common event. This method uses a callback to return the result. Sets the result code and result data for this common event. This method uses a callback to return the result.
- Parameters **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------------------- | ---- | -------------------- | | -------- | -------------------- | ---- | ---------------------- |
| code | number | Yes| Result code of the common event.| | code | number | Yes| Result code of the common event.|
| data | string | Yes| Result data of the common event.| | data | string | Yes| Result data of the common event.|
| callback | AsyncCallback\<void> | Yes| Callback used to return the result.| | callback | AsyncCallback\<void> | Yes| Callback used to return the result.|
- Example **Example**
```js ```js
var subscriber; // Used to save the created subscriber object for subsequent subscription and unsubscription. var subscriber; // Used to save the created subscriber object for subsequent subscription and unsubscription.
// Callback for result data setting of an ordered common event // Callback for result data setting of an ordered common event
function setCodeDataCallback(err) { function setCodeDataCallback(err) {
console.info("==========================>setCodeDataCallback=======================>"); console.info("==========================>setCodeDataCallback=======================>");
console.info("==========================>err:=======================>", err.code); console.info("==========================>err:=======================>", err.code);
} }
subscriber.setCodeAndData(1, "publish_data_changed", setCodeDataCallback); subscriber.setCodeAndData(1, "publish_data_changed", setCodeDataCallback);
``` ```
### setCodeAndData (promise) ### setCodeAndData
- Functionality setCodeAndData(code: number, data: string): Promise\<void>
Sets the result code and result data for this common event. This method uses a promise to return the result. Sets the result code and result data for this common event. This method uses a promise to return the result.
- Parameters **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| ------ | ------ | ---- | ------------------ | | ------ | ------ | ---- | -------------------- |
| code | number | Yes| Result code of the common event.| | code | number | Yes| Result code of the common event.|
| data | string | Yes| Result data of the common event.| | data | string | Yes| Result data of the common event.|
- Example **Example**
```js ```js
var subscriber; // Used to save the created subscriber object for subsequent subscription and unsubscription. var subscriber; // Used to save the created subscriber object for subsequent subscription and unsubscription.
subscriber.setCodeAndData(1, "publish_data_changed").then(() => { subscriber.setCodeAndData(1, "publish_data_changed").then(() => {
console.info("==========================>setCodeAndData=======================>"); console.info("==========================>setCodeAndData=======================>");
}); });
``` ```
### isOrderedCommonEvent (callback) ### isOrderedCommonEvent
- Functionality isOrderedCommonEvent(callback: AsyncCallback\<boolean>): void
Checks whether this common event is an ordered one. This method uses a callback to return the result. Checks whether this common event is an ordered one. This method uses a callback to return the result.
- Parameters **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | ----------------------- | ---- | -------------------------------- | | -------- | ----------------------- | ---- | ---------------------------------- |
| callback | AsyncCallback\<boolean> | Yes| Returns **true** if the common event is an ordered one; returns **false** otherwise.| | callback | AsyncCallback\<boolean> | Yes| Returns **true** if the common event is an ordered one; returns **false** otherwise.|
- Example **Example**
```js ```js
var subscriber; // Used to save the created subscriber object for subsequent subscription and unsubscription. var subscriber; // Used to save the created subscriber object for subsequent subscription and unsubscription.
// Callback for result data setting of an ordered common event // Callback for result data setting of an ordered common event
function isOrderedCallback(err, data) { function isOrderedCallback(err, data) {
console.info("==========================>isOrderedCallback=======================>"); console.info("==========================>isOrderedCallback=======================>");
console.info("==========================>err:=======================>", err.code); console.info("==========================>err:=======================>", err.code);
console.info("==========================>isOrdered:=======================>", data); console.info("==========================>isOrdered:=======================>", data);
} }
subscriber.isOrderedCommonEvent(isOrderedCallback); subscriber.isOrderedCommonEvent(isOrderedCallback);
``` ```
### isOrderedCommonEvent (promise) ### isOrderedCommonEvent
- Functionality isOrderedCommonEvent(): Promise\<boolean>
Checks whether this common event is an ordered one. This method uses a promise to return the result. Checks whether this common event is an ordered one. This method uses a promise to return the result.
- Return values **Return value**
| Type| Description| | Type| Description|
| ----------------- | -------------------------------- | | ----------------- | -------------------------------- |
| Promise\<boolean> | Returns **true** if the common event is an ordered one; returns **false** otherwise.| | Promise\<boolean> | Returns **true** if the common event is an ordered one; returns **false** otherwise.|
- Example **Example**
```js ```js
var subscriber; // Used to save the created subscriber object for subsequent subscription and unsubscription. var subscriber; // Used to save the created subscriber object for subsequent subscription and unsubscription.
subscriber.isOrderedCommonEvent().then((data) => { subscriber.isOrderedCommonEvent().then((data) => {
console.info("==========================>isOrdered:=======================>", data); console.info("==========================>isOrdered:=======================>", data);
}); });
``` ```
### abortCommonEvent (callback) ### abortCommonEvent
- Functionality abortCommonEvent(callback: AsyncCallback\<void>): void
Aborts this common event. After the abort, the common event is not sent to the next subscriber. This method takes effect only for ordered common events. It uses a callback to return the result. Aborts this common event. After the abort, the common event is not sent to the next subscriber. This method takes effect only for ordered common events. It uses a callback to return the result.
- Parameters **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | ----------------------- | ---- | ------------------ | | -------- | -------------------- | ---- | -------------------- |
| callback | AsyncCallback\<boolean> | Yes| Callback used to return the result.| | callback | AsyncCallback\<void> | Yes| Callback used to return the result.|
- Example **Example**
```js ```js
var subscriber; // Used to save the created subscriber object for subsequent subscription and unsubscription. var subscriber; // Used to save the created subscriber object for subsequent subscription and unsubscription.
// Callback for result data setting of an ordered common event // Callback for result data setting of an ordered common event
function abortCallback(err) { function abortCallback(err) {
console.info("==========================>abortCallback=======================>"); console.info("==========================>abortCallback=======================>");
console.info("==========================>err:=======================>", err.code); console.info("==========================>err:=======================>", err.code);
} }
subscriber.abortCommonEvent(abortCallback); subscriber.abortCommonEvent(abortCallback);
``` ```
### abortCommonEvent (promise) ### abortCommonEvent
- Functionality abortCommonEvent(): Promise\<void>
Aborts this common event. After the abort, the common event is not sent to the next subscriber. This method takes effect only for ordered common events. It uses a promise to return the result. Aborts this common event. After the abort, the common event is not sent to the next subscriber. This method takes effect only for ordered common events. It uses a promise to return the result.
- Example **Example**
```js ```js
var subscriber; // Used to save the created subscriber object for subsequent subscription and unsubscription. var subscriber; // Used to save the created subscriber object for subsequent subscription and unsubscription.
subscriber.abortCommonEvent().then(() => { subscriber.abortCommonEvent().then(() => {
console.info("==========================>abortCommonEvent:=======================>"); console.info("==========================>abortCommonEvent:=======================>");
}); });
``` ```
### clearAbortCommonEvent (callback) ### clearAbortCommonEvent
- Functionality clearAbortCommonEvent(callback: AsyncCallback\<void>): void
Clears the aborted state of this common event. This method takes effect only for ordered common events. It uses a callback to return the result. Clears the aborted state of this common event. This method takes effect only for ordered common events. It uses a callback to return the result.
- Parameters **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------------------- | ---- | -------------------- | | -------- | -------------------- | ---- | -------------------- |
| callback | AsyncCallback\<void> | Yes| Callback used to return the result.| | callback | AsyncCallback\<void> | Yes| Callback used to return the result.|
- Example **Example**
```js ```js
var subscriber; // Used to save the created subscriber object for subsequent subscription and unsubscription. var subscriber; // Used to save the created subscriber object for subsequent subscription and unsubscription.
// Callback for result data setting of an ordered common event // Callback for result data setting of an ordered common event
function clearAbortCallback(err) { function clearAbortCallback(err) {
console.info("==========================>clearAbortCallback=======================>"); console.info("==========================>clearAbortCallback=======================>");
console.info("==========================>err:=======================>", err.code); console.info("==========================>err:=======================>", err.code);
} }
subscriber.clearAbortCommonEvent(clearAbortCallback); subscriber.clearAbortCommonEvent(clearAbortCallback);
``` ```
### clearAbortCommonEvent (promise) ### clearAbortCommonEvent
- Functionality clearAbortCommonEvent(): Promise\<void>
Clears the aborted state of this common event. This method takes effect only for ordered common events. It uses a promise to return the result. Clears the aborted state of this common event. This method takes effect only for ordered common events. It uses a promise to return the result.
- Example **Example**
```js ```js
var subscriber; // Used to save the created subscriber object for subsequent subscription and unsubscription. var subscriber; // Used to save the created subscriber object for subsequent subscription and unsubscription.
subscriber.clearAbortCommonEvent().then(() => { subscriber.clearAbortCommonEvent().then(() => {
console.info("==========================>clearAbortCommonEvent:=======================>"); console.info("==========================>clearAbortCommonEvent:=======================>");
}); });
``` ```
### getAbortCommonEvent (callback) ### getAbortCommonEvent
- Functionality getAbortCommonEvent(callback: AsyncCallback\<boolean>): void
Checks whether this common event is in the aborted state. This method takes effect only for ordered common events. It uses a callback to return the result. Checks whether this common event is in the aborted state. This method takes effect only for ordered common events. It uses a callback to return the result.
- Parameters **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | ----------------------- | ---- | ---------------------------------- | | -------- | ----------------------- | ---- | ---------------------------------- |
| callback | AsyncCallback\<boolean> | Yes| Returns **true** if the ordered common event is in the aborted state; returns **false** otherwise.| | callback | AsyncCallback\<boolean> | Yes| Returns **true** if the ordered common event is in the aborted state; returns **false** otherwise.|
- Example **Example**
```js ```js
var subscriber; // Used to save the created subscriber object for subsequent subscription and unsubscription. var subscriber; // Used to save the created subscriber object for subsequent subscription and unsubscription.
// Callback for result data setting of an ordered common event // Callback for result data setting of an ordered common event
function getAbortCallback(err, data) { function getAbortCallback(err, data) {
console.info("==========================>getAbortCallback=======================>"); console.info("==========================>getAbortCallback=======================>");
console.info("==========================>err:=======================>", err.code); console.info("==========================>err:=======================>", err.code);
console.info("==========================>abort:=======================>", data); console.info("==========================>abort:=======================>", data);
} }
subscriber.getAbortCommonEvent(getAbortCallback); subscriber.getAbortCommonEvent(getAbortCallback);
``` ```
### getAbortCommonEvent (promise) ### getAbortCommonEvent
- Functionality getAbortCommonEvent(): Promise\<void>
Checks whether this common event is in the aborted state. This method takes effect only for ordered common events. It uses a promise to return the result. Checks whether this common event is in the aborted state. This method takes effect only for ordered common events. It uses a promise to return the result.
- Return values **Return value**
| Type| Description| | Type| Description|
| ----------------- | ---------------------------------- | | ----------------- | ---------------------------------- |
| Promise\<boolean> | Returns **true** if the ordered common event is in the aborted state; returns **false** otherwise.| | Promise\<boolean> | Returns **true** if the ordered common event is in the aborted state; returns **false** otherwise.|
- Example **Example**
```js ```js
var subscriber; // Used to save the created subscriber object for subsequent subscription and unsubscription. var subscriber; // Used to save the created subscriber object for subsequent subscription and unsubscription.
subscriber.getAbortCommonEvent().then((data) => { subscriber.getAbortCommonEvent().then((data) => {
console.info("==========================>getAbortCommonEvent:=======================>"); console.info("==========================>getAbortCommonEvent:=======================>");
console.info("==========================>abort:=======================>", data); console.info("==========================>abort:=======================>", data);
}); });
``` ```
### getSubscribeInfo (callback) ### getSubscribeInfo
- Functionality getSubscribeInfo(callback: AsyncCallback\<CommonEventSubscribeInfo>): void
Obtains the subscriber information. This method uses a callback to return the result. Obtains the subscriber information. This method uses a callback to return the result.
- Parameters **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | ---------------------------------------- | ---- | -------------------- | | -------- | ------------------------------------------------------------ | ---- | ---------------------- |
| callback | AsyncCallback\<CommonEventSubscribeInfo> | Yes| Callback used to return the subscriber information.| | callback | AsyncCallback\<[CommonEventSubscribeInfo](#commoneventsubscribeinfo)> | Yes| Callback used to return the subscriber information.|
- Example **Example**
```js ```js
var subscriber; // Used to save the created subscriber object for subsequent subscription and unsubscription. var subscriber; // Used to save the created subscriber object for subsequent subscription and unsubscription.
// Callback for result data setting of an ordered common event // Callback for result data setting of an ordered common event
function getSubscribeInfoCallback(err, data) { function getSubscribeInfoCallback(err, data) {
console.info("==========================>getSubscribeInfoCallback=======================>"); console.info("==========================>getSubscribeInfoCallback=======================>");
console.info("==========================>err:=======================>", err.code); console.info("==========================>err:=======================>", err.code);
console.info("==========================>priority:=======================>", data.priority); console.info("==========================>priority:=======================>", data.priority);
} }
subscriber.getSubscribeInfo(getSubscribeInfoCallback); subscriber.getSubscribeInfo(getSubscribeInfoCallback);
``` ```
### getSubscribeInfo (promise) ### getSubscribeInfo
- Functionality getSubscribeInfo(): Promise\<CommonEventSubscribeInfo>
Obtains the subscriber information. This method uses a promise to return the result. Obtains the subscriber information. This method uses a promise to return the result.
- Return values **Return value**
| Type| Description| | Type| Description|
| ---------------------------------- | -------------------- | | ------------------------------------------------------------ | ---------------------- |
| Promise\<CommonEventSubscribeInfo> | A promise used to return the subscriber information.| | Promise\<[CommonEventSubscribeInfo](#commoneventsubscribeinfo)> | Promise returned with the subscriber information.|
- Example **Example**
```js ```js
var subscriber; // Used to save the created subscriber object for subsequent subscription and unsubscription. var subscriber; // Used to save the created subscriber object for subsequent subscription and unsubscription.
subscriber.getSubscribeInfo().then((data) => { subscriber.getSubscribeInfo().then((data) => {
console.info("==========================>getSubscribeInfo:=======================>"); console.info("==========================>getSubscribeInfo:=======================>");
console.info("==========================>priority:=======================>", data.priority); console.info("==========================>priority:=======================>", data.priority);
}); });
``` ```
# Display<a name="EN-US_TOPIC_0000001163727614"></a> # Display
>![](../../public_sys-resources/icon-note.gif) **NOTE:** > ![icon-note.gif](public_sys-resources/icon-note.gif) **Note:**
>The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version. > The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version.
## Modules to Import<a name="s56d19203690d4782bfc74069abb6bd71"></a>
## Modules to Import
``` ```
import display from '@ohos.display'; import display from '@ohos.display';
``` ```
## Required Permissions<a name="section11257113618419"></a>
## Required Permissions
None None
## DisplayState<a name="section099619567453"></a>
## DisplayState
Provides the state of a display. Provides the state of a display.
<a name="table20633101642315"></a> | Name| Default Value| Description|
<table><thead align="left"><tr id="row663331618238"><th class="cellrowborder" valign="top" width="27.900000000000002%" id="mcps1.1.4.1.1"><p id="a3d0fc780cc904c1cbab7991251622f65"><a name="a3d0fc780cc904c1cbab7991251622f65"></a><a name="a3d0fc780cc904c1cbab7991251622f65"></a>Name</p> | -------- | -------- | -------- |
</th> | STATE_UNKNOWN | 0 | Unknown.|
<th class="cellrowborder" valign="top" width="12.43%" id="mcps1.1.4.1.2"><p id="aace9cae4ba0d4939bfa048460f61c3c7"><a name="aace9cae4ba0d4939bfa048460f61c3c7"></a><a name="aace9cae4ba0d4939bfa048460f61c3c7"></a>Default Value</p> | STATE_OFF | 1 | The display is shut down.|
</th> | STATE_ON | 2 | The display is powered on.|
<th class="cellrowborder" valign="top" width="59.67%" id="mcps1.1.4.1.3"><p id="afec895de33f94e3c87ee7acc20190a17"><a name="afec895de33f94e3c87ee7acc20190a17"></a><a name="afec895de33f94e3c87ee7acc20190a17"></a>Description</p> | STATE_DOZE | 3 | The display is in sleep mode.|
</th> | STATE_DOZE_SUSPEND | 4 | The display is in sleep mode, and the CPU is suspended.|
</tr> | STATE_VR | 5 | The display is in VR mode.|
</thead> | STATE_ON_SUSPEND | 6 | The display is powered on, and the CPU is suspended.|
<tbody><tr id="row188481425182510"><td class="cellrowborder" valign="top" width="27.900000000000002%" headers="mcps1.1.4.1.1 "><p id="p52851329122117"><a name="p52851329122117"></a><a name="p52851329122117"></a>STATE_UNKNOWN</p>
</td>
<td class="cellrowborder" valign="top" width="12.43%" headers="mcps1.1.4.1.2 "><p id="p2282152962115"><a name="p2282152962115"></a><a name="p2282152962115"></a>0</p> ## Display
</td>
<td class="cellrowborder" valign="top" width="59.67%" headers="mcps1.1.4.1.3 "><p id="p328012293211"><a name="p328012293211"></a><a name="p328012293211"></a>Unknown.</p>
</td>
</tr>
<tr id="row9573466526"><td class="cellrowborder" valign="top" width="27.900000000000002%" headers="mcps1.1.4.1.1 "><p id="p1657317665219"><a name="p1657317665219"></a><a name="p1657317665219"></a>STATE_OFF</p>
</td>
<td class="cellrowborder" valign="top" width="12.43%" headers="mcps1.1.4.1.2 "><p id="p457396175219"><a name="p457396175219"></a><a name="p457396175219"></a>1</p>
</td>
<td class="cellrowborder" valign="top" width="59.67%" headers="mcps1.1.4.1.3 "><p id="p195734655215"><a name="p195734655215"></a><a name="p195734655215"></a>The display is shut down.</p>
</td>
</tr>
<tr id="row594210615212"><td class="cellrowborder" valign="top" width="27.900000000000002%" headers="mcps1.1.4.1.1 "><p id="p1194218685216"><a name="p1194218685216"></a><a name="p1194218685216"></a>STATE_ON</p>
</td>
<td class="cellrowborder" valign="top" width="12.43%" headers="mcps1.1.4.1.2 "><p id="p99429655216"><a name="p99429655216"></a><a name="p99429655216"></a>2</p>
</td>
<td class="cellrowborder" valign="top" width="59.67%" headers="mcps1.1.4.1.3 "><p id="p994212610529"><a name="p994212610529"></a><a name="p994212610529"></a>The display is powered on.</p>
</td>
</tr>
<tr id="row1126914795219"><td class="cellrowborder" valign="top" width="27.900000000000002%" headers="mcps1.1.4.1.1 "><p id="p526907135217"><a name="p526907135217"></a><a name="p526907135217"></a>STATE_DOZE</p>
</td>
<td class="cellrowborder" valign="top" width="12.43%" headers="mcps1.1.4.1.2 "><p id="p172697710521"><a name="p172697710521"></a><a name="p172697710521"></a>3</p>
</td>
<td class="cellrowborder" valign="top" width="59.67%" headers="mcps1.1.4.1.3 "><p id="p2269207135212"><a name="p2269207135212"></a><a name="p2269207135212"></a>The display is in sleep mode.</p>
</td>
</tr>
<tr id="row9269113311527"><td class="cellrowborder" valign="top" width="27.900000000000002%" headers="mcps1.1.4.1.1 "><p id="p13269133315527"><a name="p13269133315527"></a><a name="p13269133315527"></a>STATE_DOZE_SUSPEND</p>
</td>
<td class="cellrowborder" valign="top" width="12.43%" headers="mcps1.1.4.1.2 "><p id="p3269133315527"><a name="p3269133315527"></a><a name="p3269133315527"></a>4</p>
</td>
<td class="cellrowborder" valign="top" width="59.67%" headers="mcps1.1.4.1.3 "><p id="p18269153355217"><a name="p18269153355217"></a><a name="p18269153355217"></a>The display is in sleep mode, and the CPU is suspended.</p>
</td>
</tr>
<tr id="row0461622112513"><td class="cellrowborder" valign="top" width="27.900000000000002%" headers="mcps1.1.4.1.1 "><p id="p12106173918219"><a name="p12106173918219"></a><a name="p12106173918219"></a>STATE_VR</p>
</td>
<td class="cellrowborder" valign="top" width="12.43%" headers="mcps1.1.4.1.2 "><p id="p1310553911218"><a name="p1310553911218"></a><a name="p1310553911218"></a>5</p>
</td>
<td class="cellrowborder" valign="top" width="59.67%" headers="mcps1.1.4.1.3 "><p id="p15865395215"><a name="p15865395215"></a><a name="p15865395215"></a>The display is in VR mode.</p>
</td>
</tr>
<tr id="row119663437528"><td class="cellrowborder" valign="top" width="27.900000000000002%" headers="mcps1.1.4.1.1 "><p id="p119671435520"><a name="p119671435520"></a><a name="p119671435520"></a>STATE_ON_SUSPEND</p>
</td>
<td class="cellrowborder" valign="top" width="12.43%" headers="mcps1.1.4.1.2 "><p id="p0967144325219"><a name="p0967144325219"></a><a name="p0967144325219"></a>6</p>
</td>
<td class="cellrowborder" valign="top" width="59.67%" headers="mcps1.1.4.1.3 "><p id="p396720433521"><a name="p396720433521"></a><a name="p396720433521"></a>The display is powered on, and the CPU is suspended.</p>
</td>
</tr>
</tbody>
</table>
## Display<a name="section12882825611"></a>
Describes the attributes of a display. Describes the attributes of a display.
### Attributes<a name="section1059684317312"></a> | Name| Type| Readable| Writable| Description|
| -------- | -------- | -------- | -------- | -------- |
<a name="table1459620431636"></a> | id | number | Yes| No| ID of the display.|
<table><thead align="left"><tr id="row25971143435"><th class="cellrowborder" valign="top" width="17.73%" id="mcps1.1.6.1.1"><p id="p1559716434320"><a name="p1559716434320"></a><a name="p1559716434320"></a>Name</p> | name | string | Yes| No| Name of the display.|
</th> | alive | boolean | Yes| No| Whether the display is alive.|
<th class="cellrowborder" valign="top" width="24.6%" id="mcps1.1.6.1.2"><p id="p3597743539"><a name="p3597743539"></a><a name="p3597743539"></a>Type</p> | state | [DisplayState](#displaystate) | Yes| No| State of the display.|
</th> | refreshRate | number | Yes| No| Refresh rate of the display.|
<th class="cellrowborder" valign="top" width="10.549999999999999%" id="mcps1.1.6.1.3"><p id="p15971343131"><a name="p15971343131"></a><a name="p15971343131"></a>Readable</p> | rotation | number | Yes| No| Screen rotation angle of the display.|
</th> | width | number | Yes| No| Width of the display, in pixels.|
<th class="cellrowborder" valign="top" width="9.34%" id="mcps1.1.6.1.4"><p id="p1459715436311"><a name="p1459715436311"></a><a name="p1459715436311"></a>Writable</p> | height | number | Yes| No| Height of the display, in pixels.|
</th> | densityDPI | number | Yes| No| Screen density of the display, in DPI.|
<th class="cellrowborder" valign="top" width="37.78%" id="mcps1.1.6.1.5"><p id="p75975439316"><a name="p75975439316"></a><a name="p75975439316"></a>Description</p> | densityPixels | number | Yes| No| Screen density of the display, in pixels.|
</th> | scaledDensity | number | Yes| No| Scaling factor for fonts displayed on the display.|
</tr> | xDPI | number | Yes| No| Exact physical dots per inch of the screen in the horizontal direction.|
</thead> | yDPI | number | Yes| No| Exact physical dots per inch of the screen in the vertical direction.|
<tbody><tr id="row95971943839"><td class="cellrowborder" valign="top" width="17.73%" headers="mcps1.1.6.1.1 "><p id="p85976431431"><a name="p85976431431"></a><a name="p85976431431"></a>id</p>
</td>
<td class="cellrowborder" valign="top" width="24.6%" headers="mcps1.1.6.1.2 "><p id="p2059710431030"><a name="p2059710431030"></a><a name="p2059710431030"></a>number</p> ## display.getDefaultDisplay
</td>
<td class="cellrowborder" valign="top" width="10.549999999999999%" headers="mcps1.1.6.1.3 "><p id="p1059711439317"><a name="p1059711439317"></a><a name="p1059711439317"></a>Yes</p> getDefaultDisplay(callback: AsyncCallback&lt;Display&gt;): void;
</td>
<td class="cellrowborder" valign="top" width="9.34%" headers="mcps1.1.6.1.4 "><p id="p659715430317"><a name="p659715430317"></a><a name="p659715430317"></a>No</p>
</td>
<td class="cellrowborder" valign="top" width="37.78%" headers="mcps1.1.6.1.5 "><p id="p2059719436313"><a name="p2059719436313"></a><a name="p2059719436313"></a>ID of the display.</p>
</td>
</tr>
<tr id="row457515412419"><td class="cellrowborder" valign="top" width="17.73%" headers="mcps1.1.6.1.1 "><p id="p185751494115"><a name="p185751494115"></a><a name="p185751494115"></a>name</p>
</td>
<td class="cellrowborder" valign="top" width="24.6%" headers="mcps1.1.6.1.2 "><p id="p1575174134114"><a name="p1575174134114"></a><a name="p1575174134114"></a>string</p>
</td>
<td class="cellrowborder" valign="top" width="10.549999999999999%" headers="mcps1.1.6.1.3 "><p id="p85757417416"><a name="p85757417416"></a><a name="p85757417416"></a>Yes</p>
</td>
<td class="cellrowborder" valign="top" width="9.34%" headers="mcps1.1.6.1.4 "><p id="p115751144412"><a name="p115751144412"></a><a name="p115751144412"></a>No</p>
</td>
<td class="cellrowborder" valign="top" width="37.78%" headers="mcps1.1.6.1.5 "><p id="p165751447416"><a name="p165751447416"></a><a name="p165751447416"></a>Name of the display.</p>
</td>
</tr>
<tr id="row179143454114"><td class="cellrowborder" valign="top" width="17.73%" headers="mcps1.1.6.1.1 "><p id="p19144416411"><a name="p19144416411"></a><a name="p19144416411"></a>alive</p>
</td>
<td class="cellrowborder" valign="top" width="24.6%" headers="mcps1.1.6.1.2 "><p id="p7914541418"><a name="p7914541418"></a><a name="p7914541418"></a>boolean</p>
</td>
<td class="cellrowborder" valign="top" width="10.549999999999999%" headers="mcps1.1.6.1.3 "><p id="p1991420434110"><a name="p1991420434110"></a><a name="p1991420434110"></a>Yes</p>
</td>
<td class="cellrowborder" valign="top" width="9.34%" headers="mcps1.1.6.1.4 "><p id="p791411411418"><a name="p791411411418"></a><a name="p791411411418"></a>No</p>
</td>
<td class="cellrowborder" valign="top" width="37.78%" headers="mcps1.1.6.1.5 "><p id="p99144412415"><a name="p99144412415"></a><a name="p99144412415"></a>Whether the display is alive.</p>
</td>
</tr>
<tr id="row102142520415"><td class="cellrowborder" valign="top" width="17.73%" headers="mcps1.1.6.1.1 "><p id="p52142514414"><a name="p52142514414"></a><a name="p52142514414"></a>state</p>
</td>
<td class="cellrowborder" valign="top" width="24.6%" headers="mcps1.1.6.1.2 "><p id="p142142564116"><a name="p142142564116"></a><a name="p142142564116"></a><a href="#section099619567453">DisplayState</a></p>
</td>
<td class="cellrowborder" valign="top" width="10.549999999999999%" headers="mcps1.1.6.1.3 "><p id="p7215195164110"><a name="p7215195164110"></a><a name="p7215195164110"></a>Yes</p>
</td>
<td class="cellrowborder" valign="top" width="9.34%" headers="mcps1.1.6.1.4 "><p id="p821510515418"><a name="p821510515418"></a><a name="p821510515418"></a>No</p>
</td>
<td class="cellrowborder" valign="top" width="37.78%" headers="mcps1.1.6.1.5 "><p id="p102153564110"><a name="p102153564110"></a><a name="p102153564110"></a>State of the display.</p>
</td>
</tr>
<tr id="row5472125204114"><td class="cellrowborder" valign="top" width="17.73%" headers="mcps1.1.6.1.1 "><p id="p184722514117"><a name="p184722514117"></a><a name="p184722514117"></a>refreshRate</p>
</td>
<td class="cellrowborder" valign="top" width="24.6%" headers="mcps1.1.6.1.2 "><p id="p1547215544112"><a name="p1547215544112"></a><a name="p1547215544112"></a>number</p>
</td>
<td class="cellrowborder" valign="top" width="10.549999999999999%" headers="mcps1.1.6.1.3 "><p id="p74726515410"><a name="p74726515410"></a><a name="p74726515410"></a>Yes</p>
</td>
<td class="cellrowborder" valign="top" width="9.34%" headers="mcps1.1.6.1.4 "><p id="p1947355194112"><a name="p1947355194112"></a><a name="p1947355194112"></a>No</p>
</td>
<td class="cellrowborder" valign="top" width="37.78%" headers="mcps1.1.6.1.5 "><p id="p647315520412"><a name="p647315520412"></a><a name="p647315520412"></a>Refresh rate of the display.</p>
</td>
</tr>
<tr id="row1968020524118"><td class="cellrowborder" valign="top" width="17.73%" headers="mcps1.1.6.1.1 "><p id="p1968005184118"><a name="p1968005184118"></a><a name="p1968005184118"></a>rotation</p>
</td>
<td class="cellrowborder" valign="top" width="24.6%" headers="mcps1.1.6.1.2 "><p id="p116804584113"><a name="p116804584113"></a><a name="p116804584113"></a>number</p>
</td>
<td class="cellrowborder" valign="top" width="10.549999999999999%" headers="mcps1.1.6.1.3 "><p id="p668013504119"><a name="p668013504119"></a><a name="p668013504119"></a>Yes</p>
</td>
<td class="cellrowborder" valign="top" width="9.34%" headers="mcps1.1.6.1.4 "><p id="p10680156412"><a name="p10680156412"></a><a name="p10680156412"></a>No</p>
</td>
<td class="cellrowborder" valign="top" width="37.78%" headers="mcps1.1.6.1.5 "><p id="p16808514113"><a name="p16808514113"></a><a name="p16808514113"></a>Screen rotation angle of the display.</p>
</td>
</tr>
<tr id="row164425664116"><td class="cellrowborder" valign="top" width="17.73%" headers="mcps1.1.6.1.1 "><p id="p1744216134115"><a name="p1744216134115"></a><a name="p1744216134115"></a>width</p>
</td>
<td class="cellrowborder" valign="top" width="24.6%" headers="mcps1.1.6.1.2 "><p id="p0442126194115"><a name="p0442126194115"></a><a name="p0442126194115"></a>number</p>
</td>
<td class="cellrowborder" valign="top" width="10.549999999999999%" headers="mcps1.1.6.1.3 "><p id="p1444212614110"><a name="p1444212614110"></a><a name="p1444212614110"></a>Yes</p>
</td>
<td class="cellrowborder" valign="top" width="9.34%" headers="mcps1.1.6.1.4 "><p id="p2044286124115"><a name="p2044286124115"></a><a name="p2044286124115"></a>No</p>
</td>
<td class="cellrowborder" valign="top" width="37.78%" headers="mcps1.1.6.1.5 "><p id="p1544266184119"><a name="p1544266184119"></a><a name="p1544266184119"></a>Width of the display, in pixels.</p>
</td>
</tr>
<tr id="row1764911684115"><td class="cellrowborder" valign="top" width="17.73%" headers="mcps1.1.6.1.1 "><p id="p164916610417"><a name="p164916610417"></a><a name="p164916610417"></a>height</p>
</td>
<td class="cellrowborder" valign="top" width="24.6%" headers="mcps1.1.6.1.2 "><p id="p164906174116"><a name="p164906174116"></a><a name="p164906174116"></a>number</p>
</td>
<td class="cellrowborder" valign="top" width="10.549999999999999%" headers="mcps1.1.6.1.3 "><p id="p136492624113"><a name="p136492624113"></a><a name="p136492624113"></a>Yes</p>
</td>
<td class="cellrowborder" valign="top" width="9.34%" headers="mcps1.1.6.1.4 "><p id="p12649660417"><a name="p12649660417"></a><a name="p12649660417"></a>No</p>
</td>
<td class="cellrowborder" valign="top" width="37.78%" headers="mcps1.1.6.1.5 "><p id="p126490694117"><a name="p126490694117"></a><a name="p126490694117"></a>Height of the display, in pixels.</p>
</td>
</tr>
<tr id="row0814166164118"><td class="cellrowborder" valign="top" width="17.73%" headers="mcps1.1.6.1.1 "><p id="p1081413694118"><a name="p1081413694118"></a><a name="p1081413694118"></a>densityDPI</p>
</td>
<td class="cellrowborder" valign="top" width="24.6%" headers="mcps1.1.6.1.2 "><p id="p88142654116"><a name="p88142654116"></a><a name="p88142654116"></a>number</p>
</td>
<td class="cellrowborder" valign="top" width="10.549999999999999%" headers="mcps1.1.6.1.3 "><p id="p1081415654114"><a name="p1081415654114"></a><a name="p1081415654114"></a>Yes</p>
</td>
<td class="cellrowborder" valign="top" width="9.34%" headers="mcps1.1.6.1.4 "><p id="p481466164119"><a name="p481466164119"></a><a name="p481466164119"></a>No</p>
</td>
<td class="cellrowborder" valign="top" width="37.78%" headers="mcps1.1.6.1.5 "><p id="p29318812312"><a name="p29318812312"></a><a name="p29318812312"></a>Screen density of the display, in DPI.</p>
</td>
</tr>
<tr id="row1022157124119"><td class="cellrowborder" valign="top" width="17.73%" headers="mcps1.1.6.1.1 "><p id="p422576414"><a name="p422576414"></a><a name="p422576414"></a>densityPixels</p>
</td>
<td class="cellrowborder" valign="top" width="24.6%" headers="mcps1.1.6.1.2 "><p id="p72220724116"><a name="p72220724116"></a><a name="p72220724116"></a>number</p>
</td>
<td class="cellrowborder" valign="top" width="10.549999999999999%" headers="mcps1.1.6.1.3 "><p id="p1822677418"><a name="p1822677418"></a><a name="p1822677418"></a>Yes</p>
</td>
<td class="cellrowborder" valign="top" width="9.34%" headers="mcps1.1.6.1.4 "><p id="p13221371412"><a name="p13221371412"></a><a name="p13221371412"></a>No</p>
</td>
<td class="cellrowborder" valign="top" width="37.78%" headers="mcps1.1.6.1.5 "><p id="p422127164110"><a name="p422127164110"></a><a name="p422127164110"></a>Screen density of the display, in pixels.</p>
</td>
</tr>
<tr id="row420113911425"><td class="cellrowborder" valign="top" width="17.73%" headers="mcps1.1.6.1.1 "><p id="p220117954217"><a name="p220117954217"></a><a name="p220117954217"></a>scaledDensity</p>
</td>
<td class="cellrowborder" valign="top" width="24.6%" headers="mcps1.1.6.1.2 "><p id="p15201994420"><a name="p15201994420"></a><a name="p15201994420"></a>number</p>
</td>
<td class="cellrowborder" valign="top" width="10.549999999999999%" headers="mcps1.1.6.1.3 "><p id="p162025915423"><a name="p162025915423"></a><a name="p162025915423"></a>Yes</p>
</td>
<td class="cellrowborder" valign="top" width="9.34%" headers="mcps1.1.6.1.4 "><p id="p182027916423"><a name="p182027916423"></a><a name="p182027916423"></a>No</p>
</td>
<td class="cellrowborder" valign="top" width="37.78%" headers="mcps1.1.6.1.5 "><p id="p132021793429"><a name="p132021793429"></a><a name="p132021793429"></a>Scaling factor for fonts displayed on the display.</p>
</td>
</tr>
<tr id="row185973435316"><td class="cellrowborder" valign="top" width="17.73%" headers="mcps1.1.6.1.1 "><p id="p1559710432310"><a name="p1559710432310"></a><a name="p1559710432310"></a>xDPI</p>
</td>
<td class="cellrowborder" valign="top" width="24.6%" headers="mcps1.1.6.1.2 "><p id="p16597144318312"><a name="p16597144318312"></a><a name="p16597144318312"></a>number</p>
</td>
<td class="cellrowborder" valign="top" width="10.549999999999999%" headers="mcps1.1.6.1.3 "><p id="p12597194313317"><a name="p12597194313317"></a><a name="p12597194313317"></a>Yes</p>
</td>
<td class="cellrowborder" valign="top" width="9.34%" headers="mcps1.1.6.1.4 "><p id="p1259710431236"><a name="p1259710431236"></a><a name="p1259710431236"></a>No</p>
</td>
<td class="cellrowborder" valign="top" width="37.78%" headers="mcps1.1.6.1.5 "><p id="p10597843034"><a name="p10597843034"></a><a name="p10597843034"></a>Exact physical dots per inch of the screen in the horizontal direction.</p>
</td>
</tr>
<tr id="row138296171429"><td class="cellrowborder" valign="top" width="17.73%" headers="mcps1.1.6.1.1 "><p id="p183016179421"><a name="p183016179421"></a><a name="p183016179421"></a>yDPI</p>
</td>
<td class="cellrowborder" valign="top" width="24.6%" headers="mcps1.1.6.1.2 "><p id="p15830101715429"><a name="p15830101715429"></a><a name="p15830101715429"></a>number</p>
</td>
<td class="cellrowborder" valign="top" width="10.549999999999999%" headers="mcps1.1.6.1.3 "><p id="p198301917164219"><a name="p198301917164219"></a><a name="p198301917164219"></a>Yes</p>
</td>
<td class="cellrowborder" valign="top" width="9.34%" headers="mcps1.1.6.1.4 "><p id="p18301174421"><a name="p18301174421"></a><a name="p18301174421"></a>No</p>
</td>
<td class="cellrowborder" valign="top" width="37.78%" headers="mcps1.1.6.1.5 "><p id="p2083001718427"><a name="p2083001718427"></a><a name="p2083001718427"></a>Exact physical dots per inch of the screen in the vertical direction.</p>
</td>
</tr>
</tbody>
</table>
## display.getDefaultDisplay<a name="section39061940191"></a>
getDefaultDisplay\(callback: AsyncCallback<Display\>\): void;
Obtains the default display object. Obtains the default display object.
- Parameters - Parameters
| Name| Type| Mandatory| Description|
<a name="table1889910298214"></a> | -------- | -------- | -------- | -------- |
<table><thead align="left"><tr id="row38991829162119"><th class="cellrowborder" valign="top" width="14.95%" id="mcps1.1.5.1.1"><p id="p17899192918217"><a name="p17899192918217"></a><a name="p17899192918217"></a>Name</p> | callback | AsyncCallback&lt;[Display](#display)&gt; | Yes| Callback used to return the attributes of the default display.|
</th>
<th class="cellrowborder" valign="top" width="41.839999999999996%" id="mcps1.1.5.1.2"><p id="p1389972922116"><a name="p1389972922116"></a><a name="p1389972922116"></a>Type</p>
</th>
<th class="cellrowborder" valign="top" width="7.829999999999999%" id="mcps1.1.5.1.3"><p id="p089952919215"><a name="p089952919215"></a><a name="p089952919215"></a>Mandatory</p>
</th>
<th class="cellrowborder" valign="top" width="35.38%" id="mcps1.1.5.1.4"><p id="p178998291215"><a name="p178998291215"></a><a name="p178998291215"></a>Description</p>
</th>
</tr>
</thead>
<tbody><tr id="row18900102982117"><td class="cellrowborder" valign="top" width="14.95%" headers="mcps1.1.5.1.1 "><p id="p1590019292215"><a name="p1590019292215"></a><a name="p1590019292215"></a>callback</p>
</td>
<td class="cellrowborder" valign="top" width="41.839999999999996%" headers="mcps1.1.5.1.2 "><p id="p1290017293214"><a name="p1290017293214"></a><a name="p1290017293214"></a>AsyncCallback&lt;<a href="#section12882825611">Display</a>&gt;</p>
</td>
<td class="cellrowborder" valign="top" width="7.829999999999999%" headers="mcps1.1.5.1.3 "><p id="p990042932115"><a name="p990042932115"></a><a name="p990042932115"></a>Yes</p>
</td>
<td class="cellrowborder" valign="top" width="35.38%" headers="mcps1.1.5.1.4 "><p id="p1790072917218"><a name="p1790072917218"></a><a name="p1790072917218"></a>Callback used to return the attributes of the default display.</p>
</td>
</tr>
</tbody>
</table>
- Example - Example
``` ```
var displayClass = null; var displayClass = null;
display.getDefaultDisplay((err, data) => { display.getDefaultDisplay((err, data) => {
...@@ -289,39 +77,18 @@ Obtains the default display object. ...@@ -289,39 +77,18 @@ Obtains the default display object.
``` ```
## display.getAllDisplay<a name="section129251146697"></a> ## display.getAllDisplay
getAllDisplay\(callback: AsyncCallback<Array<Display\>\>\): void; getAllDisplay(callback: AsyncCallback&lt;Array&lt;Display&gt;&gt;): void;
Obtains all the display objects. Obtains all the display objects.
- Parameters - Parameters
| Name| Type| Mandatory| Description|
<a name="table1098161318234"></a> | -------- | -------- | -------- | -------- |
<table><thead align="left"><tr id="row18981913132317"><th class="cellrowborder" valign="top" width="14.95%" id="mcps1.1.5.1.1"><p id="p898201322314"><a name="p898201322314"></a><a name="p898201322314"></a>Name</p> | callback | AsyncCallback&lt;Array&lt;[Display](#display)&gt;&gt; | Yes| Callback used to return the attributes of all displays.|
</th>
<th class="cellrowborder" valign="top" width="35.949999999999996%" id="mcps1.1.5.1.2"><p id="p8981013162319"><a name="p8981013162319"></a><a name="p8981013162319"></a>Type</p>
</th>
<th class="cellrowborder" valign="top" width="7.920000000000001%" id="mcps1.1.5.1.3"><p id="p298161362320"><a name="p298161362320"></a><a name="p298161362320"></a>Mandatory</p>
</th>
<th class="cellrowborder" valign="top" width="41.18%" id="mcps1.1.5.1.4"><p id="p398101318235"><a name="p398101318235"></a><a name="p398101318235"></a>Description</p>
</th>
</tr>
</thead>
<tbody><tr id="row1798413152317"><td class="cellrowborder" valign="top" width="14.95%" headers="mcps1.1.5.1.1 "><p id="p1798161319239"><a name="p1798161319239"></a><a name="p1798161319239"></a>callback</p>
</td>
<td class="cellrowborder" valign="top" width="35.949999999999996%" headers="mcps1.1.5.1.2 "><p id="p7981213122317"><a name="p7981213122317"></a><a name="p7981213122317"></a>AsyncCallback&lt;Array&lt;<a href="#section12882825611">Display</a>&gt;&gt;</p>
</td>
<td class="cellrowborder" valign="top" width="7.920000000000001%" headers="mcps1.1.5.1.3 "><p id="p189861392314"><a name="p189861392314"></a><a name="p189861392314"></a>Yes</p>
</td>
<td class="cellrowborder" valign="top" width="41.18%" headers="mcps1.1.5.1.4 "><p id="p29812131235"><a name="p29812131235"></a><a name="p29812131235"></a>Callback used to return the attributes of all displays.</p>
</td>
</tr>
</tbody>
</table>
- Example - Example
``` ```
display.getAllDisplay((err, data) => { display.getAllDisplay((err, data) => {
if (err) { if (err) {
...@@ -333,49 +100,19 @@ Obtains all the display objects. ...@@ -333,49 +100,19 @@ Obtains all the display objects.
``` ```
## display.on\('add'|'remove'|'change'\)<a name="section5851341125"></a> ## display.on('add'|'remove'|'change')
on\(type: 'add'|'remove'|'change', callback: Callback<number\>\): void; on(type: 'add'|'remove'|'change', callback: Callback&lt;number&gt;): void;
Enables listening. Enables listening.
- Parameters - Parameters
| Name| Type| Mandatory| Description|
<a name="table1185133418121"></a> | -------- | -------- | -------- | -------- |
<table><thead align="left"><tr id="row10857341125"><th class="cellrowborder" valign="top" width="12.97%" id="mcps1.1.5.1.1"><p id="p88503412128"><a name="p88503412128"></a><a name="p88503412128"></a>Name</p> | type | string | Yes| Listening type. The available values are as follows: <br/>-&nbsp;**add**: listening for whether a display is added <br/>-&nbsp;**remove**: listening for whether a display is removed <br/>-&nbsp;**change**: listening for whether a display is changed|
</th> | callback | Callback&lt;number&gt; | Yes| Callback used to return the ID of the display.|
<th class="cellrowborder" valign="top" width="31.130000000000003%" id="mcps1.1.5.1.2"><p id="p98513411125"><a name="p98513411125"></a><a name="p98513411125"></a>Type</p>
</th>
<th class="cellrowborder" valign="top" width="7.91%" id="mcps1.1.5.1.3"><p id="p585163481213"><a name="p585163481213"></a><a name="p585163481213"></a>Mandatory</p>
</th>
<th class="cellrowborder" valign="top" width="47.99%" id="mcps1.1.5.1.4"><p id="p086183411124"><a name="p086183411124"></a><a name="p086183411124"></a>Description</p>
</th>
</tr>
</thead>
<tbody><tr id="row286153419127"><td class="cellrowborder" valign="top" width="12.97%" headers="mcps1.1.5.1.1 "><p id="p108693415126"><a name="p108693415126"></a><a name="p108693415126"></a>type</p>
</td>
<td class="cellrowborder" valign="top" width="31.130000000000003%" headers="mcps1.1.5.1.2 "><p id="p18867344125"><a name="p18867344125"></a><a name="p18867344125"></a>string</p>
</td>
<td class="cellrowborder" valign="top" width="7.91%" headers="mcps1.1.5.1.3 "><p id="p7863341127"><a name="p7863341127"></a><a name="p7863341127"></a>Yes</p>
</td>
<td class="cellrowborder" valign="top" width="47.99%" headers="mcps1.1.5.1.4 "><p id="p12576162873620"><a name="p12576162873620"></a><a name="p12576162873620"></a>Listening type.</p>
<a name="ul5610203018367"></a><a name="ul5610203018367"></a><ul id="ul5610203018367"><li><strong id="b1574838195610"><a name="b1574838195610"></a><a name="b1574838195610"></a>add</strong>: listening for whether a display is added</li><li><strong id="b51261741175616"><a name="b51261741175616"></a><a name="b51261741175616"></a>remove</strong>: listening for whether a display is removed</li><li><strong id="b18418142145615"><a name="b18418142145615"></a><a name="b18418142145615"></a>change</strong>: listening for whether a display is changed</li></ul>
</td>
</tr>
<tr id="row926414772311"><td class="cellrowborder" valign="top" width="12.97%" headers="mcps1.1.5.1.1 "><p id="p8654354112313"><a name="p8654354112313"></a><a name="p8654354112313"></a>callback</p>
</td>
<td class="cellrowborder" valign="top" width="31.130000000000003%" headers="mcps1.1.5.1.2 "><p id="p2654854112310"><a name="p2654854112310"></a><a name="p2654854112310"></a>Callback&lt;number&gt;</p>
</td>
<td class="cellrowborder" valign="top" width="7.91%" headers="mcps1.1.5.1.3 "><p id="p15654185417236"><a name="p15654185417236"></a><a name="p15654185417236"></a>Yes</p>
</td>
<td class="cellrowborder" valign="top" width="47.99%" headers="mcps1.1.5.1.4 "><p id="p965485411233"><a name="p965485411233"></a><a name="p965485411233"></a>Callback used to return the ID of the display.</p>
</td>
</tr>
</tbody>
</table>
- Example - Example
``` ```
var type = "add"; var type = "add";
var callback = (data) => { var callback = (data) => {
...@@ -385,52 +122,20 @@ Enables listening. ...@@ -385,52 +122,20 @@ Enables listening.
``` ```
## display.off\('add'|'remove'|'change'\)<a name="section13178205443512"></a> ## display.off('add'|'remove'|'change')
off\(type: 'add'|'remove'|'change', callback?: Callback<number\>\): void; off(type: 'add'|'remove'|'change', callback?: Callback&lt;number&gt;): void;
Disables listening. Disables listening.
- Parameters - Parameters
| Name| Type| Mandatory| Description|
<a name="table1717865483515"></a> | -------- | -------- | -------- | -------- |
<table><thead align="left"><tr id="row91789548359"><th class="cellrowborder" valign="top" width="12.479999999999999%" id="mcps1.1.5.1.1"><p id="p19178185413352"><a name="p19178185413352"></a><a name="p19178185413352"></a>Name</p> | type | string | Yes| Listening type. The available values are as follows: <br/>-&nbsp;**add**: listening for whether a display is added <br/>-&nbsp;**remove**: listening for whether a display is removed <br/>-&nbsp;**change**: listening for whether a display is changed|
</th> | callback | Callback&lt;number&gt; | No| Callback used to return the ID of the display.|
<th class="cellrowborder" valign="top" width="26.32%" id="mcps1.1.5.1.2"><p id="p41780541354"><a name="p41780541354"></a><a name="p41780541354"></a>Type</p>
</th>
<th class="cellrowborder" valign="top" width="9.3%" id="mcps1.1.5.1.3"><p id="p917895443512"><a name="p917895443512"></a><a name="p917895443512"></a>Mandatory</p>
</th>
<th class="cellrowborder" valign="top" width="51.9%" id="mcps1.1.5.1.4"><p id="p17178205410352"><a name="p17178205410352"></a><a name="p17178205410352"></a>Description</p>
</th>
</tr>
</thead>
<tbody><tr id="row151787544353"><td class="cellrowborder" valign="top" width="12.479999999999999%" headers="mcps1.1.5.1.1 "><p id="p1217819543355"><a name="p1217819543355"></a><a name="p1217819543355"></a>type</p>
</td>
<td class="cellrowborder" valign="top" width="26.32%" headers="mcps1.1.5.1.2 "><p id="p417915453516"><a name="p417915453516"></a><a name="p417915453516"></a>string</p>
</td>
<td class="cellrowborder" valign="top" width="9.3%" headers="mcps1.1.5.1.3 "><p id="p81791954203516"><a name="p81791954203516"></a><a name="p81791954203516"></a>Yes</p>
</td>
<td class="cellrowborder" valign="top" width="51.9%" headers="mcps1.1.5.1.4 "><p id="p11366379368"><a name="p11366379368"></a><a name="p11366379368"></a>Listening type.</p>
<a name="ul20308203893611"></a><a name="ul20308203893611"></a><ul id="ul20308203893611"><li><strong id="b78701755195618"><a name="b78701755195618"></a><a name="b78701755195618"></a>add</strong>: listening for whether a display is added</li><li><strong id="b10430956195611"><a name="b10430956195611"></a><a name="b10430956195611"></a>remove</strong>: listening for whether a display is removed</li><li><strong id="b113699578561"><a name="b113699578561"></a><a name="b113699578561"></a>change</strong>: listening for whether a display is changed</li></ul>
</td>
</tr>
<tr id="row152711425132514"><td class="cellrowborder" valign="top" width="12.479999999999999%" headers="mcps1.1.5.1.1 "><p id="p0986172612510"><a name="p0986172612510"></a><a name="p0986172612510"></a>callback</p>
</td>
<td class="cellrowborder" valign="top" width="26.32%" headers="mcps1.1.5.1.2 "><p id="p9987102617255"><a name="p9987102617255"></a><a name="p9987102617255"></a>Callback&lt;number&gt;</p>
</td>
<td class="cellrowborder" valign="top" width="9.3%" headers="mcps1.1.5.1.3 "><p id="p1798742617259"><a name="p1798742617259"></a><a name="p1798742617259"></a>No</p>
</td>
<td class="cellrowborder" valign="top" width="51.9%" headers="mcps1.1.5.1.4 "><p id="p1698722611251"><a name="p1698722611251"></a><a name="p1698722611251"></a>Callback used to return the ID of the display.</p>
</td>
</tr>
</tbody>
</table>
- Example - Example
``` ```
var type = "remove"; var type = "remove";
display.off(type); display.off(type);
``` ```
...@@ -12,7 +12,7 @@ import faultLogger from '@ohos.faultLogger' ...@@ -12,7 +12,7 @@ import faultLogger from '@ohos.faultLogger'
None None
## faultLogger.FaultType ## FaultType
Enumerates the fault types. Enumerates the fault types.
...@@ -23,7 +23,7 @@ Enumerates the fault types. ...@@ -23,7 +23,7 @@ Enumerates the fault types.
| JS_CRASH | 3 | JS program crash.| | JS_CRASH | 3 | JS program crash.|
| APP_FREEZE | 4 | Application freezing.| | APP_FREEZE | 4 | Application freezing.|
## faultLogger.FaultLogInfo ## FaultLogInfo
Defines the data structure of the fault log information. Defines the data structure of the fault log information.
...@@ -31,7 +31,7 @@ Defines the data structure of the fault log information. ...@@ -31,7 +31,7 @@ Defines the data structure of the fault log information.
| -------- | -------- | -------- | | -------- | -------- | -------- |
| pid | number | Process ID of the faulty process.| | pid | number | Process ID of the faulty process.|
| uid | number | User ID of the faulty process.| | uid | number | User ID of the faulty process.|
| type | [FaultType](#faultloggerfaulttype) | Fault type.| | type | [FaultType](#faulttype) | Fault type.|
| timestamp | number | Second-level timestamp when the log was generated.| | timestamp | number | Second-level timestamp when the log was generated.|
| reason | string | Reason for the fault.| | reason | string | Reason for the fault.|
| module | string | Module on which the fault occurred.| | module | string | Module on which the fault occurred.|
...@@ -47,8 +47,8 @@ Obtains the fault information about the current process. This method uses a call ...@@ -47,8 +47,8 @@ Obtains the fault information about the current process. This method uses a call
- Parameters - Parameters
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| faultType | [FaultType](#faultloggerfaulttype) | Yes| Fault type.| | faultType | [FaultType](#faulttype) | Yes| Fault type.|
| callback | AsyncCallbackArray&lt;Array&lt;[FaultLogInfo](#faultloggerfaultloginfo)&gt;&gt; | Yes| Callback used to return the fault information array. <br/>The value is the fault information array obtained. If the value is **undefined**, an exception occurs during the information retrieval. In this case, an error string will be returned. | callback | AsyncCallbackArray&lt;Array&lt;[FaultLogInfo](#faultloginfo)&gt;&gt; | Yes| Callback used to return the fault information array. <br/>The value is the fault information array obtained. If the value is **undefined**, an exception occurs during the information retrieval. In this case, an error string will be returned.
- Example - Example
``` ```
...@@ -83,12 +83,12 @@ Obtains the fault information about the current process. This method uses a prom ...@@ -83,12 +83,12 @@ Obtains the fault information about the current process. This method uses a prom
- Parameters - Parameters
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| faultType | [FaultType](#faultloggerfaulttype) | Yes| Fault type.| | faultType | [FaultType](#faulttype) | Yes| Fault type.|
- Return values - Return value
| Type| Description| | Type| Description|
| -------- | -------- | | -------- | -------- |
| Promise&lt;Array&lt;[FaultLogInfo](#faultloggerfaultloginfo)&gt;&gt; | Promise used to return the fault information array. You can obtain the fault information instance in its **then()** method or use **await**. <br/>The value is the fault information array obtained. If the value is **undefined**, an exception occurs during the information retrieval.| | Promise&lt;Array&lt;[FaultLogInfo](#faultloginfo)&gt;&gt; | Promise used to return the fault information array. You can obtain the fault information instance in its **then()** method or use **await**. <br/>The value is the fault information array obtained. If the value is **undefined**, an exception occurs during the information retrieval.|
- Example - Example
``` ```
......
# FeatureAbility Module (JavaScript) # FeatureAbility Module (JavaScript)
#### Constraints ## Constraints
APIs of the **FeatureAbility** module can be called only by Page abilities. APIs of the **FeatureAbility** module can be called only by Page abilities.
#### Modules to Import ## Modules to Import
``` ```
import featureAbility from '@ohos.ability.featureAbility' import featureAbility from '@ohos.ability.featureAbility'
``` ```
#### FeatureAbility.startAbility(parameter: StartAbilityParameter, callback: AsyncCallback\<number>): void ## featureAbility.startAbility
* Functionality startAbility(parameter: StartAbilityParameter, callback: AsyncCallback\<number>): void
Starts an ability. This method uses a callback to return the result. Starts an ability. This method uses a callback to return the result.
* Parameters **Parameters**
| Name| Readable/Writable| Type| Mandatory| Description|
| --------- | -------- | --------------------- | ---- | ------------------- |
| parameter | Read-only| [StartAbilityParameter](#StartAbilityParameter)| Yes| Ability to start.|
| callback | Read-only| AsyncCallback\<number> | Yes| Callback used to return the result.|
| Name| Type| Mandatory| Description|
| --------- | --------------------- | ---- | ------------------- |
| parameter | [StartAbilityParameter](#startabilityparameter) | Yes| Ability to start.|
| callback | AsyncCallback\<number> | Yes| Callback used to return the result.|
- Example **Example**
```javascript ```javascript
import featureAbility from '@ohos.ability.featureAbility' import featureAbility from '@ohos.ability.featureAbility'
...@@ -48,20 +47,19 @@ featureAbility.startAbility( ...@@ -48,20 +47,19 @@ featureAbility.startAbility(
#### FeatureAbility.startAbility(parameter: StartAbilityParameter): Promise\<number> ## featureAbility.startAbility
* Functionality startAbility(parameter: StartAbilityParameter): Promise\<number>
Starts an ability. This method uses a promise to return the result. Starts an ability. This method uses a promise to return the result.
* Parameters **Parameters**
| Name| Readable/Writable| Type| Mandatory| Description|
| --------- | -------- | ------------------------------------------------------- | ---- | ------------------- |
| parameter | Read-only| [StartAbilityParameter](#StartAbilityParameter)| Yes| Ability to start.|
| Name| Type| Mandatory| Description|
| --------- | ----------------------------------------------- | ---- | --------------------- |
| parameter | [StartAbilityParameter](#startabilityparameter) | Yes| Ability to start.|
- Example **Example**
```javascript ```javascript
import featureAbility from '@ohos.ability.featureAbility' import featureAbility from '@ohos.ability.featureAbility'
...@@ -84,27 +82,25 @@ featureAbility.startAbility( ...@@ -84,27 +82,25 @@ featureAbility.startAbility(
}); });
``` ```
## featureAbility.acquireDataAbilityHelper
acquireDataAbilityHelper(uri: string): DataAbilityHelper
#### FeatureAbility.acquireDataAbilityHelper(uri: string): DataAbilityHelper Obtains a **dataAbilityHelper** object.
* Functionality **Parameters**
Obtains a **dataAbilityHelper**. | Name| Type| Mandatory| Description|
| ---- | ------ | ---- | ------------------------ |
* Parameters | uri | string | Yes| URI of the file to open.|
| Name| Readable/Writable| Type| Mandatory| Description|
| ---- | -------- | ------ | ---- | ---------------------- |
| uri | Read-only| string | Yes| URI of the file to open.|
* Return values **Return value**
| Type| Description| | Type| Description|
| ----------------- | ------------------------------------------ | | ----------------- | -------------------------------------------- |
| DataAbilityHelper | A utility class used to help other abilities access the Data ability.| | DataAbilityHelper | A utility class used to help other abilities access the Data ability.|
* Example **Example**
```javascript ```javascript
import featureAbility from '@ohos.ability.featureAbility' import featureAbility from '@ohos.ability.featureAbility'
...@@ -113,26 +109,20 @@ featureAbility.acquireDataAbilityHelper( ...@@ -113,26 +109,20 @@ featureAbility.acquireDataAbilityHelper(
) )
``` ```
## featureAbility.startAbilityForResult
startAbilityForResult(parameter: StartAbilityParameter, callback: AsyncCallback\<AbilityResult>): void
#### FeatureAbility.startAbilityForResult(parameter: StartAbilityParameter, callback: AsyncCallback\<AbilityResult>): void Starts an ability. This method uses a callback to return the execution result when the ability is destroyed.
* Functionality **Parameters**
Starts an ability. This method uses a callback to return the execution result when the ability is destroyed. | Name| Type| Mandatory| Description|
| --------- | ----------------------------------------------- | ---- | --------------------- |
| parameter | [StartAbilityParameter](#startabilityparameter) | Yes| Ability to start.|
| callback | AsyncCallback\<[AbilityResult](#abilityresult)> | Yes| Callback used to return the result.|
* Parameters **Example**
| Name| Readable/Writable| Type| Mandatory| Description|
| --------- | -------- | ---------------------- | ---- | ------------------- |
| parameter | Read-only| [StartAbilityParameter](#StartAbilityParameter)| Yes| Ability to start.|
| callback | Read-only| AsyncCallback\<[AbilityResult](#AbilityResult)>| Yes| Callback used to return the result.|
* Return values
Returns [AbilityResult](#AbilityResult).
* Example
```javascript ```javascript
import featureAbility from '@ohos.ability.featureability'; import featureAbility from '@ohos.ability.featureability';
...@@ -153,25 +143,24 @@ featureAbility.startAbilityForResult( ...@@ -153,25 +143,24 @@ featureAbility.startAbilityForResult(
) )
``` ```
## featureAbility.startAbilityForResult
startAbilityForResult(parameter: StartAbilityParameter): Promise\<AbilityResult>
#### FeatureAbility.startAbilityForResult(parameter: StartAbilityParameter): Promise\<AbilityResult> Starts an ability. This method uses a promise to return the execution result when the ability is destroyed.
* Functionality
Starts an ability. This method uses a promise to return the execution result when the ability is destroyed. **Parameters**
* Parameters | Name| Type| Mandatory| Description|
| --------- | ----------------------------------------------- | ---- | ------------------- |
| parameter | [StartAbilityParameter](#startabilityparameter) | Yes| Ability to start.|
| Name| Readable/Writable| Type| Mandatory| Description| **Return value**
| --------- | -------- | ------------------------------------------------------- | ---- | ------------------- | | Type| Description|
| parameter | Read-only| [StartAbilityParameter](#StartAbilityParameter)| Yes| Ability to start.| | ----------------------------------------- | -------------- |
| Promise\<[AbilityResult](#abilityresult)> | Promised returned with the execution result.|
* Return values
Returns [AbilityResult](#AbilityResult).
* Example **Example**
```javascript ```javascript
import featureAbility from '@ohos.ability.featureability'; import featureAbility from '@ohos.ability.featureability';
...@@ -206,24 +195,20 @@ featureAbility.startAbilityForResult( ...@@ -206,24 +195,20 @@ featureAbility.startAbilityForResult(
}); });
``` ```
## featureAbility.terminateSelfWithResult
terminateSelfWithResult(parameter: AbilityResult, callback: AsyncCallback\<void>): void
#### FeatureAbility.terminateSelfWithResult(parameter: AbilityResult, callback: AsyncCallback\<void>): void Destroys this Page ability, with the result code and data sent to the caller. This method uses a callback to return the result.
* Functionality **Parameters**
Destroys this Page ability, with the result code and data sent to the caller. This method uses a callback to return the result. | Name| Type| Mandatory| Description|
| --------- | ------------- | ---- | ------------------- |
| parameter | [AbilityResult](#abilityresult) | Yes| Ability to start.|
| callback | AsyncCallback\<void> | Yes| Callback used to return the result.|
**Example**
* Parameters
| Name| Readable/Writable| Type| Mandatory| Description|
| --------- | -------- | ------------- | ---- | ------------------- |
| parameter | Read-only| [AbilityResult](#AbilityResult)| Yes| Ability to start.|
| callback | Read-only| AsyncCallback\<void> | Yes| Callback used to return the result.|
* Example
```javascript ```javascript
import featureAbility from '@ohos.ability.featureAbility' import featureAbility from '@ohos.ability.featureAbility'
...@@ -255,22 +240,24 @@ featureAbility.terminateSelfWithResult( ...@@ -255,22 +240,24 @@ featureAbility.terminateSelfWithResult(
); );
``` ```
## featureAbility.terminateSelfWithResult
terminateSelfWithResult(parameter: AbilityResult): Promise\<void>
#### FeatureAbility.terminateSelfWithResult(parameter: AbilityResult): Promise\<void> Destroys this Page ability, with the result code and data sent to the caller. This method uses a promise to return the result.
* Functionality
Destroys this Page ability, with the result code and data sent to the caller. This method uses a promise to return the result. **Parameters**
* Parameters | Name| Type| Mandatory| Description|
| --------- | ------------------------------- | ---- | ------------------- |
| Name| Readable/Writable| Type| Mandatory| Description| | parameter | [AbilityResult](#abilityresult) | Yes| Ability to start.|
| --------- | -------- | --------------------------------------- | ---- | ------------------- |
| parameter | Read-only| [AbilityResult](#AbilityResult)| Yes| Ability to start.|
**Return value**
| Type| Description|
| -------------- | ----------------------- |
| Promise\<void> | Promise returned with the result.|
* Example **Example**
```javascript ```javascript
import featureAbility from '@ohos.ability.featureability'; import featureAbility from '@ohos.ability.featureability';
...@@ -306,23 +293,19 @@ featureAbility.terminateSelfWithResult( ...@@ -306,23 +293,19 @@ featureAbility.terminateSelfWithResult(
#### FeatureAbility.hasWindowFocus(callback: AsyncCallback\<boolean>): void ## featureAbility.hasWindowFocus
* Functionality hasWindowFocus(callback: AsyncCallback\<boolean>): void
Checks whether the main window of this ability has the focus. This method uses a callback to return the result. Checks whether the main window of this ability has the focus. This method uses a callback to return the result.
* Parameters **Parameters**
| Name| Readable/Writable| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | ----------------------- | ---- | ---------------- | | -------- | ----------------------- | ---- | ------------------------------------------------------------ |
| callback | Read-only| AsyncCallback\<boolean> | Yes| Callback used to return the result.| | callback | AsyncCallback\<boolean> | Yes| Callback used to return the result. <br>Returns **true** if the main window of this ability has the focus; returns **false** otherwise.|
* Return values
Returns **true** if the main window of this ability has the focus; returns **false** otherwise. **Example**
* Example
```javascript ```javascript
import featureAbility from '@ohos.ability.featureability'; import featureAbility from '@ohos.ability.featureability';
...@@ -331,21 +314,19 @@ featureAbility.hasWindowFocus() ...@@ -331,21 +314,19 @@ featureAbility.hasWindowFocus()
#### FeatureAbility.hasWindowFocus(): Promise\<boolean> ## featureAbility.hasWindowFocus
* Functionality
Checks whether the main window of this ability has the focus. This method uses a promise to return the result. hasWindowFocus(): Promise\<boolean>
* Parameters Checks whether the main window of this ability has the focus. This method uses a promise to return the result.
None **Return value**
* Return values | Type| Description|
| ----------------- | ---------------------------------------------------------- |
Returns **true** if the main window of this ability has the focus; returns **false** otherwise. | Promise\<boolean> | Returns **true** if the main window of this ability has the focus; returns **false** otherwise.|
* Example **Example**
```javascript ```javascript
import featureAbility from '@ohos.ability.featureability'; import featureAbility from '@ohos.ability.featureability';
...@@ -356,20 +337,19 @@ featureAbility.hasWindowFocus().then((void) => { ...@@ -356,20 +337,19 @@ featureAbility.hasWindowFocus().then((void) => {
#### FeatureAbility.getWant(callback: AsyncCallback\<Want>) ## featureAbility.getWant
* Functionality getWant(callback: AsyncCallback\<Want>): void
Obtains the **Want** object sent from this ability. This method uses a callback to return the result. Obtains the **Want** object sent from this ability. This method uses a callback to return the result.
* Parameters **Parameters**
| Name| Readable/Writable| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------------------- | ---- | ---------------- | | -------- | ----------------------------- | ---- | ------------------ |
| callback | Read-only| AsyncCallback\<Want> | Yes| Callback used to return the result.| | callback | AsyncCallback\<[Want](#want)> | Yes| Callback used to return the result.|
**Example**
* Example
```javascript ```javascript
import featureAbility from '@ohos.ability.featureability'; import featureAbility from '@ohos.ability.featureability';
...@@ -378,17 +358,18 @@ featureAbility.getWant() ...@@ -378,17 +358,18 @@ featureAbility.getWant()
#### FeatureAbility.getWant(): void ## featureAbility.getWant
* Functionality
Obtains the **Want** object sent from this ability. This method uses a promise to return the result. getWant(): Promise\<Want>
* Parameters Obtains the **Want** object sent from this ability. This method uses a promise to return the result.
None **Return value**
| Type| Description|
| ----------------------- | ------------------------- |
| Promise\<[Want](#want)> | Promise returned with the result.|
* Example **Example**
```javascript ```javascript
import featureAbility from '@ohos.ability.featureability'; import featureAbility from '@ohos.ability.featureability';
...@@ -397,19 +378,18 @@ featureAbility.getWant().then((void) => { ...@@ -397,19 +378,18 @@ featureAbility.getWant().then((void) => {
}); });
``` ```
## featureAbility.getContext
getContext(): Context
#### FeatureAbility.getContext(): Context Obtains the application context.
* Functionality
Obtains the application context.
* Return values
Returns the application context. **Return value**
| Type| Description|
| ------- | -------------------- |
| Context | Application context returned.|
* Example **Example**
```javascript ```javascript
import featureAbility from '@ohos.ability.featureability'; import featureAbility from '@ohos.ability.featureability';
...@@ -419,19 +399,19 @@ context.getBundleName() ...@@ -419,19 +399,19 @@ context.getBundleName()
#### FeatureAbility.terminateSelf(callback: AsyncCallback\<void>): void ## featureAbility.terminateSelf
* Functionality terminateSelf(callback: AsyncCallback\<void>): void
Destroys this Page ability, with the result code and data sent to the caller. This method uses a callback to return the result. Destroys this Page ability, with the result code and data sent to the caller. This method uses a callback to return the result.
* Parameters **Parameters**
| Name| Readable/Writable| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------------------- | ---- | ---------------- | | -------- | -------------------- | ---- | ---------------- |
| callback | Read-only| AsyncCallback\<void> | Yes| Callback used to return the result.| | callback | AsyncCallback\<void> | Yes| Callback used to return the result.|
* Example **Example**
```javascript ```javascript
import featureAbility from '@ohos.ability.featureability'; import featureAbility from '@ohos.ability.featureability';
...@@ -440,17 +420,18 @@ featureAbility.terminateSelf() ...@@ -440,17 +420,18 @@ featureAbility.terminateSelf()
#### FeatureAbility.terminateSelf(): Promise\<void> ## featureAbility.terminateSelf
* Functionality terminateSelf(): Promise\<void>
Destroys this Page ability, with the result code and data sent to the caller. This method uses a promise to return the result. Destroys this Page ability, with the result code and data sent to the caller. This method uses a promise to return the result.
* Parameters **Return value**
| Type| Description|
None | -------------- | ------------------------- |
| Promise\<void> | Promise returned with the result.|
* Example **Example**
```javascript ```javascript
import featureAbility from '@ohos.ability.featureability'; import featureAbility from '@ohos.ability.featureability';
...@@ -458,20 +439,20 @@ featureAbility.terminateSelf().then((void) => { console.info("============= ...@@ -458,20 +439,20 @@ featureAbility.terminateSelf().then((void) => { console.info("=============
}); });
``` ```
#### FeatureAbility.connectAbility(request: Want, options:ConnectOptions): number ## featureAbility.connectAbility
* Functionality connectAbility(request: Want, options:ConnectOptions): number
Connects this ability to a specific Service ability. This method uses a callback to return the result. Connects this ability to a specific Service ability. This method uses a callback to return the result.
* Parameters **Parameters**
| Name| Readable/Writable| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| ------- | -------- | -------------- | ---- | -------------------------- | | ------- | -------------- | ---- | ---------------------------- |
| request | Read-only| Want | Yes| Service ability to connect.| | request | [Want](#want) | Yes| Service ability to connect.|
| options | Read-only| ConnectOptions | Yes| Callback used to return the result.| | options | ConnectOptions | Yes| Callback used to return the result.|
* Want parameters Want
| Name| Readable/Writable| Type| Mandatory| Description| | Name| Readable/Writable| Type| Mandatory| Description|
| ------------ | -------- | -------- | ---- | ---------------------------------- | | ------------ | -------- | -------- | ---- | ---------------------------------- |
...@@ -479,7 +460,7 @@ featureAbility.terminateSelf().then((void) => { console.info("============= ...@@ -479,7 +460,7 @@ featureAbility.terminateSelf().then((void) => { console.info("=============
| bundleName | Read-only| string | Yes| Bundle name of the Service ability to connect.| | bundleName | Read-only| string | Yes| Bundle name of the Service ability to connect.|
| abilityName | Read-only| string | Yes| Class name of the Service ability to connect.| | abilityName | Read-only| string | Yes| Class name of the Service ability to connect.|
- ConnectOptions ConnectOptions
| Name| Readable/Writable| Type| Mandatory| Description| | Name| Readable/Writable| Type| Mandatory| Description|
| ------------ | -------- | -------- | ---- | ---------------------------------- | | ------------ | -------- | -------- | ---- | ---------------------------------- |
...@@ -487,11 +468,12 @@ featureAbility.terminateSelf().then((void) => { console.info("============= ...@@ -487,11 +468,12 @@ featureAbility.terminateSelf().then((void) => { console.info("=============
| onDisconnect | Read-only| function | Yes| Callback invoked when the connection fails.| | onDisconnect | Read-only| function | Yes| Callback invoked when the connection fails.|
| onFailed | Read-only| function | Yes| Callback invoked when **connectAbility** fails to be called.| | onFailed | Read-only| function | Yes| Callback invoked when **connectAbility** fails to be called.|
* Return values **Return value**
| Type| Description|
Returns the ID of the Service ability connected. | ------ | ------------------------ |
| number | Returns the ID of the Service ability connected.|
* Example **Example**
```javascript ```javascript
import featureAbility from '@ohos.ability.featureAbility' import featureAbility from '@ohos.ability.featureAbility'
...@@ -518,20 +500,20 @@ var connId = featureAbility.connectAbility( ...@@ -518,20 +500,20 @@ var connId = featureAbility.connectAbility(
); );
``` ```
#### FeatureAbility.disconnectAbility(connection: number, callback:AsyncCallback\<void>): void ## featureAbility.disconnectAbility
* Functionality disconnectAbility(connection: number, callback:AsyncCallback\<void>): void
Disconnects this ability from a specific Service ability. This method uses a callback to return the result. Disconnects this ability from a specific Service ability. This method uses a callback to return the result.
* Parameters **Parameters**
| Name| Readable/Writable| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| ---------- | -------- | ------------- | ---- | ------------------------------ | | ---------- | ------------- | ---- | ------------------------------ |
| connection | Read-only| number | Yes| ID of the Service ability to disconnect.| | connection | number | Yes| ID of the Service ability to disconnect.|
| callback | Read-only| AsyncCallback\<void> | Yes| Callback used to return the result.| | callback | AsyncCallback\<void> | Yes| Callback used to return the result.|
* Example **Example**
```javascript ```javascript
import featureAbility from '@ohos.ability.featureAbility' import featureAbility from '@ohos.ability.featureAbility'
...@@ -562,19 +544,24 @@ var result = featureAbility.disconnectAbility(connId, ...@@ -562,19 +544,24 @@ var result = featureAbility.disconnectAbility(connId,
); );
``` ```
#### FeatureAbility.disconnectAbility(connection: number): Promise\<void> ## featureAbility.disconnectAbility
* Functionality disconnectAbility(connection: number): Promise\<void>
Disconnects this ability from a specific Service ability. This method uses a promise to return the result. Disconnects this ability from a specific Service ability. This method uses a promise to return the result.
* Parameters **Parameters**
| Name| Readable/Writable| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| ---------- | -------- | ------ | ---- | ------------------------------ | | ---------- | ------ | ---- | ------------------------------ |
| connection | Read-only| number | Yes| ID of the Service ability to disconnect.| | connection | number | Yes| ID of the Service ability to disconnect.|
**Return value**
| Type| Description|
| -------------- | ----------------------- |
| Promise\<void> | Promise returned with the result.|
* Example **Example**
```javascript ```javascript
import featureAbility from '@ohos.ability.featureAbility' import featureAbility from '@ohos.ability.featureAbility'
...@@ -601,28 +588,27 @@ var connId = featureAbility.connectAbility( ...@@ -601,28 +588,27 @@ var connId = featureAbility.connectAbility(
var result = await featureAbility.disconnectAbility(connId); var result = await featureAbility.disconnectAbility(connId);
``` ```
## featureAbility.continueAbility
#### FeatureAbility.continueAbility(options: ContinueAbilityOptions, callback: AsyncCallback\<void>): void; continueAbility(options: ContinueAbilityOptions, callback: AsyncCallback\<void>): void
* Functionality
Migrates an ability to another device. This method uses a callback to return the execution result. Migrates an ability to another device. This method uses a callback to return the execution result.
* Parameters **Parameters**
| Name| Readable/Writable| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | ---------------------- | ---- | ------------------- | | -------- | ---------------------- | ---- | ------------------- |
| options | Read-only| ContinueAbilityOptions | Yes| Ability to migrate.| | options | ContinueAbilityOptions | Yes| Ability to migrate.|
| callback | Read-only| AsyncCallback\<void> | Yes| Callback used to return the result.| | callback | AsyncCallback\<void> | Yes| Callback used to return the result.|
- ContinueAbilityOptions ContinueAbilityOptions
| Name| Readable/Writable| Type| Mandatory| Description| | Name| Readable/Writable| Type| Mandatory| Description|
| ---------- | -------- | ------- | ---- | ----------------------------------------------------------- | | ---------- | -------- | ------- | ---- | ------------------------------------------------------------ |
| deviceId | Read-only| string | Yes| Information about the ability to migrate.| | deviceId | Read-only| string | Yes| Information about the ability to migrate.|
| reversible | Read-only| boolean | Yes| Whether migration back is supported. Currently, this feature is not supported. This parameter is reserved and can be set to **false**.| | reversible | Read-only| boolean | Yes| Whether migration back is supported. Currently, this feature is not supported. This parameter is reserved and can be set to **false**.|
* Example **Example**
```javascript ```javascript
import featureAbility from '@ohos.ability.featureAbility' import featureAbility from '@ohos.ability.featureAbility'
...@@ -642,21 +628,21 @@ async StartContinueAbility(deviceId) { ...@@ -642,21 +628,21 @@ async StartContinueAbility(deviceId) {
this.StartContinueAbility(remoteDeviceId); //remoteDeviceId is acquired from DeviceManager this.StartContinueAbility(remoteDeviceId); //remoteDeviceId is acquired from DeviceManager
``` ```
#### AbilityResult ## AbilityResult
| Name| Readable/Writable| Type| Mandatory| Description| | Name| Readable/Writable| Type| Mandatory| Description|
| ---------- | -------- | --------------------- | ---- | ------------------------------------------------------------ | | ---------- | -------- | --------------------- | ---- | ------------------------------------------------------------ |
| resultCode | Read-only| number | Yes| Result code returned after the ability is destroyed. The feature for defining error-specific result codes is coming soon.| | resultCode | Read-only| number | Yes| Result code returned after the ability is destroyed. The feature for defining error-specific result codes is coming soon.|
| want | Read-only| [Want](#Want)| No| Data returned after the ability is destroyed. You can define the data to be returned. This parameter can be **null**.| | want | Read-only| [Want](#want) | No| Data returned after the ability is destroyed. You can define the data to be returned. This parameter can be **null**.|
#### StartAbilityParameter ## StartAbilityParameter
| Name| Readable/Writable| Type| Mandatory| Description| | Name| Readable/Writable| Type| Mandatory| Description|
| ------------------- | -------- | --------------------- | ---- | ------------------------------------------------------------ | | ------------------- | -------- | -------------------- | ---- | ------------------------------------------------------------ |
| want | Read-only| [Want](#Want)| Yes| Information about the ability to start.| | want | Read-only| [Want](#want) | Yes| Information about the ability to start.|
| abilityStartSetting | Read-only| {[key: string]: any} | No| Special attribute of the ability to start. This attribute can be passed in the method call.| | abilityStartSetting | Read-only| {[key: string]: any} | No| Special attribute of the ability to start. This attribute can be passed in the method call.|
#### Want ## Want
| Name| Readable/Writable| Type| Mandatory| Description| | Name| Readable/Writable| Type| Mandatory| Description|
| ----------- | -------- | -------------------- | ---- | ------------------------------------------------------------ | | ----------- | -------- | -------------------- | ---- | ------------------------------------------------------------ |
......
...@@ -10,25 +10,21 @@ The ParticleAbility module is used to perform operations on abilities of the Dat ...@@ -10,25 +10,21 @@ The ParticleAbility module is used to perform operations on abilities of the Dat
import particleAbility from '@ohos.ability.particleAbility' import particleAbility from '@ohos.ability.particleAbility'
``` ```
## particleAbility.startAbility(parameter: StartAbilityParameter, callback: AsyncCallback\<void>: void ## particleAbility.startAbility
- Functionality startAbility(parameter: StartAbilityParameter, callback: AsyncCallback\<void>: void
Starts a Service ability. This method uses a callback to return the result. Starts a Service ability. This method uses a callback to return the result.
- Parameters **Parameters**
| Name| Readable/Writable| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| --------- | -------- | ------------------------------------------------------- | ---- | ----------------- | | --------- | ----------------------------------------------- | ---- | ----------------- |
| parameter | Read-only| [StartAbilityParameter](#StartAbilityParameter)| Yes| Ability to start.| | parameter | [StartAbilityParameter](#startabilityparameter) | Yes| Ability to start.|
| callback | Read-only| AsyncCallback\<void> | Yes| Callback used to return the result.| | callback | AsyncCallback\<void> | Yes| Callback used to return the result.|
- Return values
void **Example**
- Example
```js ```js
import particleAbility from '@ohos.ability.particleAbility' import particleAbility from '@ohos.ability.particleAbility'
...@@ -54,22 +50,23 @@ particleAbility.startAbility( ...@@ -54,22 +50,23 @@ particleAbility.startAbility(
## particleAbility.startAbility(parameter: StartAbilityParameter): Promise\<number> ## particleAbility.startAbility
- Functionality startAbility(parameter: StartAbilityParameter): Promise\<number>
Starts a Service ability. This method uses a promise to return the result. Starts a Service ability. This method uses a promise to return the result.
- Parameters **Parameters**
| Name| Readable/Writable| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| --------- | -------- | ------------------------------------------------------- | ---- | ----------------- | | --------- | ----------------------------------------------- | ---- | ----------------- |
| parameter | Read-only| [StartAbilityParameter](#StartAbilityParameter)| Yes| Ability to start.| | parameter | [StartAbilityParameter](#startabilityparameter) | Yes| Ability to start.|
- Return values **Return value**
| Type| Description|
Promise\<void> | -------------- | ------------------------- |
| Promise\<void> | Promise returned with the result.|
- Example **Example**
```js ```js
import particleAbility from '@ohos.ability.particleAbility' import particleAbility from '@ohos.ability.particleAbility'
...@@ -94,23 +91,19 @@ particleAbility.startAbility( ...@@ -94,23 +91,19 @@ particleAbility.startAbility(
## particleAbility.terminateSelf(callback: AsyncCallback\<void>): void ## particleAbility.terminateSelf
- Functionality terminateSelf(callback: AsyncCallback\<void>): void
Terminates this Service ability. This method uses a callback to return the result. Terminates this Service ability. This method uses a callback to return the result.
- Parameters **Parameters**
| Name| Readable/Writable| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------------------- | ---- | -------------------- | | -------- | -------------------- | ---- | -------------------- |
| callback | Read-only| AsyncCallback\<void> | Yes| Callback used to return the result.| | callback | AsyncCallback\<void> | Yes| Callback used to return the result.|
- Return values **Example**
void
- Example
```js ```js
import particleAbility from '@ohos.ability.particleAbility' import particleAbility from '@ohos.ability.particleAbility'
...@@ -123,17 +116,18 @@ particleAbility.terminateSelf( ...@@ -123,17 +116,18 @@ particleAbility.terminateSelf(
## particleAbility.terminateSelf(): Promise\<void> ## particleAbility.terminateSelf
- Functionality
Terminates this Service ability. This method uses a promise to return the result. terminateSelf(): Promise\<void>
- Return values Terminates this Service ability. This method uses a promise to return the result.
Promise\<void> **Return value**
| Type| Description|
| -------------- | ------------------------- |
| Promise\<void> | Promise returned with the result.|
- Example **Example**
```js ```js
import particleAbility from '@ohos.ability.particleAbility' import particleAbility from '@ohos.ability.particleAbility'
...@@ -144,25 +138,25 @@ particleAbility.terminateSelf().then((void) => { ...@@ -144,25 +138,25 @@ particleAbility.terminateSelf().then((void) => {
## particleAbility.acquireDataAbilityHelper(uri: string): DataAbilityHelper ## particleAbility.acquireDataAbilityHelper
- Functionality acquireDataAbilityHelper(uri: string): DataAbilityHelper
Obtains a **dataAbilityHelper** object. Obtains a **dataAbilityHelper** object.
- Parameters **Parameters**
| Name| Readable/Writable| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| :--- | -------- | ------ | ---- | ---------------------- | | :--- | ------ | ---- | ------------------------ |
| uri | Read-only| string | Yes| URI of the file to open.| | uri | string | Yes| URI of the file to open.|
- Return values **Return value**
| Type| Description| | Type| Description|
| ----------------- | ------------------------------------------ | | ----------------- | -------------------------------------------- |
| DataAbilityHelper | A utility class used to help other abilities access a Data ability.| | DataAbilityHelper | A utility class used to help other abilities access a Data ability.|
- Example **Example**
```js ```js
import particleAbility from '@ohos.ability.particleAbility' import particleAbility from '@ohos.ability.particleAbility'
...@@ -170,20 +164,20 @@ var uri = ""; ...@@ -170,20 +164,20 @@ var uri = "";
particleAbility.acquireDataAbilityHelper(uri) particleAbility.acquireDataAbilityHelper(uri)
``` ```
## particleAbility.connectAbility(request: Want, options:ConnectOptions): number ## particleAbility.connectAbility
* Functionality connectAbility(request: Want, options:ConnectOptions): number
Connects this ability to a specific Service ability. This method uses a callback to return the result. Connects this ability to a specific Service ability. This method uses a callback to return the result.
* Parameters **Parameters**
| Name| Readable/Writable| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| ------- | -------- | -------------- | ---- | -------------------------- | | ------- | -------------- | ---- | -------------------------- |
| request | Read-only| Want | Yes| Service ability to connect.| | request | [Want](#want) | Yes| Service ability to connect.|
| options | Read-only| ConnectOptions | Yes| Callback used to return the result.| | options | ConnectOptions | Yes| Callback used to return the result.|
- ConnectOptions ConnectOptions
| Name| Readable/Writable| Type| Mandatory| Description| | Name| Readable/Writable| Type| Mandatory| Description|
| ------------ | -------- | -------- | ---- | ---------------------------------- | | ------------ | -------- | -------- | ---- | ---------------------------------- |
...@@ -191,11 +185,12 @@ particleAbility.acquireDataAbilityHelper(uri) ...@@ -191,11 +185,12 @@ particleAbility.acquireDataAbilityHelper(uri)
| onDisconnect | Read-only| function | Yes| Callback invoked when the connection is interrupted.| | onDisconnect | Read-only| function | Yes| Callback invoked when the connection is interrupted.|
| onFailed | Read-only| function | Yes| Callback invoked when the connection fails.| | onFailed | Read-only| function | Yes| Callback invoked when the connection fails.|
* Return values **Return value**
| Type| Description|
Returns the unique identifier of the connection. | ------ | -------------------------- |
| number | Unique identifier of the connection between the client and the service side.|
* Example **Example**
```javascript ```javascript
import particleAbility from '@ohos.ability.particleAbility' import particleAbility from '@ohos.ability.particleAbility'
...@@ -221,24 +216,20 @@ var connId = particleAbility.connectAbility( ...@@ -221,24 +216,20 @@ var connId = particleAbility.connectAbility(
); );
``` ```
## particleAbility.disconnectAbility(connection: number, callback:AsyncCallback\<void>): void ## particleAbility.disconnectAbility
* Functionality
Disconnects this ability from a specific Service ability. This method uses a callback to return the result. disconnectAbility(connection: number, callback:AsyncCallback\<void>): void
* Parameters Disconnects this ability from a specific Service ability. This method uses a callback to return the result.
| Name| Readable/Writable| Type| Mandatory| Description| **Parameters**
| ---------- | -------- | ------------- | ---- | ------------------------------ |
| connection | Read-only| number | Yes| ID of the Service ability to disconnect.|
| callback | Read-only| AsyncCallback\<void> | Yes| Callback used to return the result.|
* Return values
void | Name| Type| Mandatory| Description|
| ---------- | ------------- | ---- | ------------------------------ |
| connection | number | Yes| ID of the Service ability to disconnect.|
| callback | AsyncCallback\<void> | Yes| Callback used to return the result.|
* Example **Example**
```javascript ```javascript
import particleAbility from '@ohos.ability.particleAbility' import particleAbility from '@ohos.ability.particleAbility'
...@@ -269,23 +260,24 @@ var result = particleAbility.disconnectAbility(connId, ...@@ -269,23 +260,24 @@ var result = particleAbility.disconnectAbility(connId,
); );
``` ```
## particleAbility.disconnectAbility(connection: number): Promise\<void> ## particleAbility.disconnectAbility
* Functionality
Disconnects this ability from a specific Service ability. This method uses a promise to return the result. disconnectAbility(connection: number): Promise\<void>
* Parameters Disconnects this ability from a specific Service ability. This method uses a promise to return the result.
| Name| Readable/Writable| Type| Mandatory| Description| **Parameters**
| ---------- | -------- | ------ | ---- | ------------------------------ |
| connection | Read-only| number | Yes| ID of the Service ability to disconnect.|
* Return values | Name| Type| Mandatory| Description|
| ---------- | ------ | ---- | ------------------------------ |
| connection | number | Yes| ID of the Service ability to disconnect.|
Promise\<void> **Return value**
| Type| Description|
| -------------- | ------------------------- |
| Promise\<void> | Promise returned with the result.|
* Example **Example**
```javascript ```javascript
import particleAbility from '@ohos.ability.particleAbility' import particleAbility from '@ohos.ability.particleAbility'
...@@ -318,7 +310,7 @@ var result = particleAbility.disconnectAbility(connId).then((void) => { ...@@ -318,7 +310,7 @@ var result = particleAbility.disconnectAbility(connId).then((void) => {
| Name| Readable/Writable| Type| Mandatory| Description| | Name| Readable/Writable| Type| Mandatory| Description|
| ------------------- | -------- | --------------------- | ---- | ------------------------------------------------------------ | | ------------------- | -------- | --------------------- | ---- | ------------------------------------------------------------ |
| want | Read-only| [Want](#Want)| Yes| Information about the ability to start.| | want | Read-only| [Want](#want) | Yes| Information about the ability to start.|
| abilityStartSetting | Read-only| {[key: string]: any} | No| Special attribute of the ability to start. This attribute can be passed in the method call.| | abilityStartSetting | Read-only| {[key: string]: any} | No| Special attribute of the ability to start. This attribute can be passed in the method call.|
## Want ## Want
...@@ -358,10 +350,10 @@ var result = particleAbility.disconnectAbility(connId).then((void) => { ...@@ -358,10 +350,10 @@ var result = particleAbility.disconnectAbility(connId).then((void) => {
## AbilityStartSetting ## AbilityStartSetting
Defines special attributes of an ability, for example, **featureAbility.AbilityStartSetting.BOUNDS_KEY**.
The **AbilityStartSetting** attribute is an object defined as [key: string]: any. The key is a type of **AbilityStartSetting**, and the value is a type of **AbilityWindowConfiguration**. The **AbilityStartSetting** attribute is an object defined as [key: string]: any. The key is a type of **AbilityStartSetting**, and the value is a type of **AbilityWindowConfiguration**.
Defines special attributes of an ability, for example, **featureAbility.AbilityStartSetting.BOUNDS_KEY**.
| Name| Value| Description| | Name| Value| Description|
| --------------- | --------------- | -------------------------- | | --------------- | --------------- | -------------------------- |
| BOUNDS_KEY | "abilityBounds" | Ability window size.| | BOUNDS_KEY | "abilityBounds" | Ability window size.|
......
...@@ -662,18 +662,18 @@ this.StartContinueAbility(remoteDeviceId); //remoteDeviceId is acquired from Dev ...@@ -662,18 +662,18 @@ this.StartContinueAbility(remoteDeviceId); //remoteDeviceId is acquired from Dev
| ------------------------------------ | ---------- | ------------------------------------------------------------ | | ------------------------------------ | ---------- | ------------------------------------------------------------ |
| FLAG_AUTH_READ_URI_PERMISSION | 0x00000001 | 指示对URI执行读取操作的授权 | | FLAG_AUTH_READ_URI_PERMISSION | 0x00000001 | 指示对URI执行读取操作的授权 |
| FLAG_AUTH_WRITE_URI_PERMISSION | 0x00000002 | 指示对URI执行写入操作的授权 | | FLAG_AUTH_WRITE_URI_PERMISSION | 0x00000002 | 指示对URI执行写入操作的授权 |
| FLAG_ABILITY_FORWARD_RESULT | 0x00000004 | 将结果返回给能力 | | FLAG_ABILITY_FORWARD_RESULT | 0x00000004 | 将结果返回给能力 |
| FLAG_ABILITY_CONTINUATION | 0x00000008 | 确定是否可以将本地设备上的功能迁移到远程设备 | | FLAG_ABILITY_CONTINUATION | 0x00000008 | 确定是否可以将本地设备上的功能迁移到远程设备 |
| FLAG_NOT_OHOS_COMPONENT | 0x00000010 | 指定组件是否属于OHOS | | FLAG_NOT_OHOS_COMPONENT | 0x00000010 | 指定组件是否属于OHOS |
| FLAG_ABILITY_FORM_ENABLED | 0x00000020 | 指定是否启动某个能力 | | FLAG_ABILITY_FORM_ENABLED | 0x00000020 | 指定是否启动某个能力 |
| FLAG_AUTH_PERSISTABLE_URI_PERMISSION | 0x00000040 | 指示URI上可能持久化的授权 | | FLAG_AUTH_PERSISTABLE_URI_PERMISSION | 0x00000040 | 指示URI上可能持久化的授权 |
| FLAG_AUTH_PREFIX_URI_PERMISSION | 0x00000080 | 指示对URI前缀进行授权的权限 | | FLAG_AUTH_PREFIX_URI_PERMISSION | 0x00000080 | 按照前缀匹配的方式验证URI权限 |
| FLAG_ABILITYSLICE_MULTI_DEVICE | 0x00000100 | 支持分布式调度系统中的多设备启动 | | FLAG_ABILITYSLICE_MULTI_DEVICE | 0x00000100 | 支持分布式调度系统中的多设备启动 |
| FLAG_START_FOREGROUND_ABILITY | 0x00000200 | 指示无论主机应用程序是否已启动,都将启动使用服务模板的功能 | | FLAG_START_FOREGROUND_ABILITY | 0x00000200 | 指示无论主机应用程序是否已启动,都将启动使用服务模板的功能 |
| FLAG_ABILITY_CONTINUATION_REVERSIBLE | 0x00000400 | 表示迁移是可拉回的。 | | FLAG_ABILITY_CONTINUATION_REVERSIBLE | 0x00000400 | 表示迁移是可拉回的。 |
| FLAG_INSTALL_ON_DEMAND | 0x00000800 | 如果未安装指定的功能,请安装该功能 | | FLAG_INSTALL_ON_DEMAND | 0x00000800 | 如果未安装指定的功能,请安装该功能 |
| FLAG_INSTALL_WITH_BACKGROUND_MODE | 0x80000000 | 如果未安装,使用后台模式安装该功能。 | | FLAG_INSTALL_WITH_BACKGROUND_MODE | 0x80000000 | 如果未安装,使用后台模式安装该功能。 |
| FLAG_ABILITY_CLEAR_MISSION | 0x00008000 | 指示清除其他任务的操作。可以为传递给{@link ohos.app.Context#startAbility}的{@code Want}设置此标志,并且必须与{@link flag_ABILITY_NEW_MISSION}一起使用 | | FLAG_ABILITY_CLEAR_MISSION | 0x00008000 | 指示清除其他任务的操作。可以为传递给**ohos.app.Context#startAbility****Want**设置此标志,并且必须与**flag_ABILITY_NEW_MISSION**一起使用 |
| FLAG_ABILITY_NEW_MISSION | 0x10000000 | 指示在历史任务堆栈上创建任务的操作。 | | FLAG_ABILITY_NEW_MISSION | 0x10000000 | 指示在历史任务堆栈上创建任务的操作。 |
| FLAG_ABILITY_MISSION_TOP | 0x20000000 | 指示如果启动能力的现有实例已位于任务堆栈的顶部,则将重用该实例。否则,将创建一个新的能力实例。 | | FLAG_ABILITY_MISSION_TOP | 0x20000000 | 指示如果启动能力的现有实例已位于任务堆栈的顶部,则将重用该实例。否则,将创建一个新的能力实例。 |
...@@ -333,12 +333,12 @@ var result = particleAbility.disconnectAbility(connId).then((void) => { ...@@ -333,12 +333,12 @@ var result = particleAbility.disconnectAbility(connId).then((void) => {
| ------------------------------------ | ---------- | ------------------------------------------------------------ | | ------------------------------------ | ---------- | ------------------------------------------------------------ |
| FLAG_AUTH_READ_URI_PERMISSION | 0x00000001 | 指示对URI执行读取操作的授权 | | FLAG_AUTH_READ_URI_PERMISSION | 0x00000001 | 指示对URI执行读取操作的授权 |
| FLAG_AUTH_WRITE_URI_PERMISSION | 0x00000002 | 指示对URI执行写入操作的授权 | | FLAG_AUTH_WRITE_URI_PERMISSION | 0x00000002 | 指示对URI执行写入操作的授权 |
| FLAG_ABILITY_FORWARD_RESULT | 0x00000004 | 将结果返回给能力 | | FLAG_ABILITY_FORWARD_RESULT | 0x00000004 | 将结果返回给能力 |
| FLAG_ABILITY_CONTINUATION | 0x00000008 | 确定是否可以将本地设备上的功能迁移到远程设备 | | FLAG_ABILITY_CONTINUATION | 0x00000008 | 确定是否可以将本地设备上的功能迁移到远程设备 |
| FLAG_NOT_OHOS_COMPONENT | 0x00000010 | 指定组件是否属于OHOS | | FLAG_NOT_OHOS_COMPONENT | 0x00000010 | 指定组件是否属于OHOS |
| FLAG_ABILITY_FORM_ENABLED | 0x00000020 | 指定是否启动某个能力 | | FLAG_ABILITY_FORM_ENABLED | 0x00000020 | 指定是否启动某个能力 |
| FLAG_AUTH_PERSISTABLE_URI_PERMISSION | 0x00000040 | 指示URI上可能持久化的授权 | | FLAG_AUTH_PERSISTABLE_URI_PERMISSION | 0x00000040 | 指示URI上可能持久化的授权 |
| FLAG_AUTH_PREFIX_URI_PERMISSION | 0x00000080 | 将结果返回到源能力 | | FLAG_AUTH_PREFIX_URI_PERMISSION | 0x00000080 | 按照前缀匹配的方式验证URI权限 |
| FLAG_ABILITYSLICE_MULTI_DEVICE | 0x00000100 | 支持分布式调度系统中的多设备启动 | | FLAG_ABILITYSLICE_MULTI_DEVICE | 0x00000100 | 支持分布式调度系统中的多设备启动 |
| FLAG_START_FOREGROUND_ABILITY | 0x00000200 | 指示无论主机应用程序是否已启动,都将启动使用服务模板的功能 | | FLAG_START_FOREGROUND_ABILITY | 0x00000200 | 指示无论主机应用程序是否已启动,都将启动使用服务模板的功能 |
| FLAG_ABILITY_CONTINUATION_REVERSIBLE | 0x00000400 | 表示迁移是可拉回的。 | | FLAG_ABILITY_CONTINUATION_REVERSIBLE | 0x00000400 | 表示迁移是可拉回的。 |
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册