提交 d2a0a31d 编写于 作者: W wusongqing

updated docs

Signed-off-by: Nwusongqing <wusongqing@huawei.com>
上级 449ce282
# DataUriUtils Module
> **NOTE**<br>
> **NOTE**<br/>
> 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
......@@ -19,20 +19,20 @@ Obtains the ID attached to the end of a given URI.
**Parameters**
| Name | Type | Mandatory | Description |
| Name| Type | Mandatory| Description |
| ---- | ------ | ---- | --------------------------- |
| uri | 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 value**
| Type | Description |
| Type | Description |
| ------ | ------------------------ |
| number | ID obtained from the URI object. |
| number | ID obtained from the URI object.|
**Example**
```js
dataUriUtils.getIdSync("com.example.dataUriUtils/1221")
dataUriUtils.getId("com.example.dataUriUtils/1221")
```
......@@ -47,16 +47,16 @@ Attaches an ID to the end of a given URI.
**Parameters**
| Name | Type | Mandatory | Description |
| Name| Type | Mandatory| Description |
| ---- | ------ | ---- | --------------------------- |
| uri | string | Yes | URI object to which an ID is to be attached. |
| id | number | Yes | ID to be attached. |
| uri | string | Yes | URI object to which an ID is to be attached.|
| id | number | Yes | ID to be attached. |
**Return value**
| Type | Description |
| Type | Description |
| ------ | --------------------- |
| string | URI object with the ID attached. |
| string | URI object with the ID attached.|
**Example**
......@@ -80,15 +80,15 @@ Deletes the ID from the end of a given URI.
**Parameters**
| Name | Type | Mandatory | Description |
| Name| Type | Mandatory| Description |
| ---- | ------ | ---- | --------------------------- |
| uri | 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 value**
| Type | Description |
| Type | Description |
| ------ | ------------------- |
| string | URI object with the ID deleted. |
| string | URI object with the ID deleted.|
**Example**
......@@ -108,16 +108,16 @@ Updates the ID in a given URI.
**Parameters**
| Name | Type | Mandatory | Description |
| Name| Type | Mandatory| Description |
| ---- | ------ | ---- | ------------------- |
| uri | string | Yes | URI object to be updated. |
| id | number | Yes | New ID. |
| uri | string | Yes | URI object to be updated.|
| id | number | Yes | New ID. |
**Return value**
| Type | Description |
| Type | Description |
| ------ | --------------- |
| string | URI object with the new ID. |
| string | URI object with the new ID.|
**Example**
......
# AbilityContext
> **NOTE**<br>
> **NOTE**<br/>
> The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version.
Implements the ability context. This module is inherited from **Context**.
## Modules to Import
```js
import Ability from '@ohos.application.Ability'
```
## Usage
Before using the **AbilityContext** module, you must define a child class that inherits from **Ability**.
```js
import Ability from '@ohos.application.Ability'
class MainAbility extends Ability {
......@@ -28,7 +28,7 @@ class MainAbility extends Ability {
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
| Name | Type | Readable | Writable | Description |
| Name| Type| Readable| Writable| Description|
| -------- | -------- | -------- | -------- | -------- |
| abilityInfo | AbilityInfo | Yes| No| Ability information.|
| currentHapModuleInfo | HapModuleInfo | Yes| No| Information about the current HAP.|
......@@ -44,7 +44,7 @@ Starts an ability. This API uses a callback to return the result.
**Parameters**
| Name | Type | Mandatory | Description |
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| want | [Want](js-apis-application-Want.md) | Yes| Information about the **Want** used for starting an ability.|
| callback | AsyncCallback&lt;void&gt; | Yes| Callback used to return the result.|
......@@ -73,7 +73,7 @@ Starts an ability. This API uses a callback to return the result.
**Parameters**
| Name | Type | Mandatory | Description |
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| want | [Want](js-apis-application-Want.md) | Yes| Information about the **Want** used for starting an ability.|
| options | StartOptions | Yes| Parameters used for starting the ability.|
......@@ -106,14 +106,14 @@ Starts an ability. This API uses a promise to return the result.
**Parameters**
| Name | Type | Mandatory | Description |
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| want | [Want](js-apis-application-Want.md) | Yes| Information about the **Want** used for starting an ability.|
| options | StartOptions | No| Parameters used for starting the ability.|
**Return value**
| Type | Description |
| Type| Description|
| -------- | -------- |
| Promise&lt;void&gt; | Promise used to return the result.|
......@@ -147,7 +147,7 @@ Starts an ability. This API uses a callback to return the execution result when
**Parameters**
| Name | Type | Mandatory | Description |
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| want |[Want](js-apis-application-Want.md) | Yes| Information about the **Want** used for starting an ability.|
| callback | AsyncCallback&lt;[AbilityResult](js-apis-featureAbility.md#abilityresult)&gt; | Yes| Callback used to return the result.|
......@@ -157,7 +157,7 @@ Starts an ability. This API uses a callback to return the execution result when
```js
this.context.startAbilityForResult(
{bundleName: "com.extreme.myapplication", abilityName: "MainAbilityDemo2"},
{deviceId: "", bundleName: "com.extreme.myapplication", abilityName: "MainAbilityDemo2"},
(error, result) => {
console.log("startAbilityForResult AsyncCallback is called, error.code = " + error.code)
console.log("startAbilityForResult AsyncCallback is called, result.resultCode = " + result.resultCode)
......@@ -175,7 +175,7 @@ Starts an ability. This API uses a callback to return the execution result when
**Parameters**
| Name | Type | Mandatory | Description |
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| want |[Want](js-apis-application-Want.md) | Yes| Information about the **Want** used for starting an ability.|
| options | StartOptions | Yes| Parameters used for starting the ability.|
......@@ -189,7 +189,7 @@ Starts an ability. This API uses a callback to return the execution result when
windowMode: 0,
};
this.context.startAbilityForResult(
{bundleName: "com.extreme.myapplication", abilityName: "MainAbilityDemo2"}, options,
{deviceId: "", bundleName: "com.extreme.myapplication", abilityName: "MainAbilityDemo2"}, options,
(error, result) => {
console.log("startAbilityForResult AsyncCallback is called, error.code = " + error.code)
console.log("startAbilityForResult AsyncCallback is called, result.resultCode = " + result.resultCode)
......@@ -208,7 +208,7 @@ Starts an ability. This API uses a promise to return the execution result when t
**Parameters**
| Name | Type | Mandatory | Description |
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| want | [Want](js-apis-application-Want.md) | Yes| Information about the **Want** used for starting an ability.|
| options | StartOptions | No| Parameters used for starting the ability.|
......@@ -216,7 +216,7 @@ Starts an ability. This API uses a promise to return the execution result when t
**Return value**
| Type | Description |
| Type| Description|
| -------- | -------- |
| Promise&lt;[AbilityResult](js-apis-featureAbility.md#abilityresult)&gt; | Promise used to return the result.|
......@@ -226,7 +226,7 @@ Starts an ability. This API uses a promise to return the execution result when t
var options = {
windowMode: 0,
};
this.context.startAbilityForResult({bundleName: "com.extreme.myapplication", abilityName: "MainAbilityDemo2"}, options).then((result) => {
this.context.startAbilityForResult({deviceId: "", bundleName: "com.extreme.myapplication", abilityName: "MainAbilityDemo2"}, options).then((result) => {
console.log("startAbilityForResult Promise.resolve is called, result.resultCode = " + result.resultCode)
}, (error) => {
console.log("startAbilityForResult Promise.Reject is called, error.code = " + error.code)
......@@ -244,7 +244,7 @@ Terminates this ability. This API uses a callback to return the result.
**Parameters**
| Name | Type | Mandatory | Description |
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| callback | AsyncCallback&lt;void&gt; | Yes| Callback used to return the result indicating whether the API is successfully called.|
......@@ -267,7 +267,7 @@ Terminates this ability. This API uses a promise to return the result.
**Return value**
| Type | Description |
| Type| Description|
| -------- | -------- |
| Promise&lt;void&gt; | Promise used to return the result indicating whether the API is successfully called.|
......@@ -292,7 +292,7 @@ Terminates this ability. This API uses a callback to return the information to t
**Parameters**
| Name | Type | Mandatory | Description |
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| parameter | [AbilityResult](js-apis-featureAbility.md#abilityresult) | Yes| Information returned to the caller.|
| callback | AsyncCallback&lt;void&gt; | Yes| Callback used to return the result.|
......@@ -321,13 +321,13 @@ Terminates this ability. This API uses a promise to return information to the ca
**Parameters**
| Name | Type | Mandatory | Description |
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| parameter | [AbilityResult](js-apis-featureAbility.md#abilityresult) | Yes| Information returned to the caller.|
**Return value**
| Type | Description |
| Type| Description|
| -------- | -------- |
| Promise&lt;void&gt; | Promise used to return the result.|
......@@ -355,13 +355,13 @@ Obtains the caller interface of the specified ability, and if the specified abil
**Parameters**
| Name | Type | Mandatory | Description |
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| want | [Want](js-apis-application-Want.md) | Yes| Information about the ability to start, including the ability name, bundle name, and device ID. If the device ID is left blank or the default value is used, the local ability will be started.|
**Return value**
| Type | Description |
| Type| Description|
| -------- | -------- |
| Promise&lt;Caller&gt; | Promise used to return the caller object to communicate with.|
......@@ -378,7 +378,7 @@ Obtains the caller interface of the specified ability, and if the specified abil
deviceId: ""
}).then((obj) => {
caller = obj;
console.log('Caller GetCaller Get ' + call);
console.log('Caller GetCaller Get ' + caller);
}).catch((e) => {
console.log('Caller GetCaller error ' + e);
});
......@@ -397,17 +397,19 @@ Requests permissions from the user by displaying a pop-up window. This API uses
**Parameters**
| Name | Type | Mandatory | Description |
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| permissions | Array&lt;string&gt; | Yes| Permissions to request.|
| callback | AsyncCallback&lt;[PermissionRequestResult](js-apis-permissionrequestresult.md)&gt; | Yes| Callback used to return the result indicating whether the API is successfully called.|
**Example**
```
this.context.requestPermissionsFromUser(permissions,(result) => {
console.log('requestPermissionsFromUserresult:' + JSON.stringify(result));
```js
var permissions=['com.example.permission']
this.context.requestPermissionsFromUser(permissions,(result) => {
console.log('requestPermissionsFromUserresult:' + JSON.stringify(result));
});
```
......@@ -421,24 +423,26 @@ Requests permissions from the user by displaying a pop-up window. This API uses
**Parameters**
| Name | Type | Mandatory | Description |
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| permissions | Array&lt;string&gt; | Yes| Permissions to request.|
**Return value**
| Type | Description |
| Type| Description|
| -------- | -------- |
| Promise&lt;[PermissionRequestResult](js-apis-permissionrequestresult.md)&gt; | Promise used to return the result indicating whether the API is successfully called.|
**Example**
```
this.context.requestPermissionsFromUser(permissions).then((data) => {
```js
var permissions=['com.example.permission']
this.context.requestPermissionsFromUser(permissions).then((data) => {
console.log('success:' + JSON.stringify(data));
}).catch((error) => {
console.log('failed:' + JSON.stringify(error));
});
```
......@@ -452,7 +456,7 @@ Sets the label of the ability displayed in the task. This API uses a callback to
**Parameters**
| Name | Type | Mandatory | Description |
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| label | string | Yes| Label of the ability to set.|
| callback | AsyncCallback&lt;void&gt; | Yes| Callback used to return the result indicating whether the API is successfully called.|
......@@ -476,13 +480,13 @@ Sets the label of the ability displayed in the task. This API uses a promise to
**Parameters**
| Name | Type | Mandatory | Description |
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| label | string | Yes| Label of the ability to set.|
**Return value**
| Type | Description |
| Type| Description|
| -------- | -------- |
| Promise&lt;void&gt; | Promise used to return the result indicating whether the API is successfully called.|
......
# Ability Access Control
# Ability Access Control
> **NOTE**<br>
> **NOTE**<br/>
> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version.
## Modules to Import
......@@ -20,9 +20,9 @@ Creates an **AtManager** instance, which is used for ability access control.
**Return value**
| Type | Description |
| -------- | -------- |
| [AtManager](#atmanager) | **AtManager** instance obtained. |
| Type| Description|
| -------- | -------- |
| [AtManager](#atmanager) | **AtManager** instance obtained.|
**Example**
......@@ -44,16 +44,16 @@ Checks whether an application has been granted the specified permission. This AP
**Parameters**
| Name | Type | Mandatory | Description |
| -------- | ------------------- | ---- | ------------------------------------------ |
| tokenID | number | Yes | ID of the application. |
| permissionName | string | Yes | Name of the permission to verify. |
| Name | Type | Mandatory| Description |
| -------- | ------------------- | ---- | ------------------------------------------ |
| tokenID | number | Yes | ID of the application. |
| permissionName | string | Yes | Name of the permission to verify.|
**Return value**
| Type | Description |
| :------------ | :---------------------------------- |
| Promise&lt;GrantStatus&gt; | Promise used to return the result. |
| Type | Description |
| :------------ | :---------------------------------- |
| Promise&lt;GrantStatus&gt; | Promise instance used to return the result.|
**Example**
......@@ -78,24 +78,25 @@ Grants a user granted permission to an application. This API uses a promise to r
**Parameters**
| Name | Type | Mandatory | Description |
| --------- | ------------------- | ---- | ------------------------------------------------------------ |
| tokenID | number | Yes | ID of the application. |
| permissionName | string | Yes | Name of the permission to grant. |
| permissionFlag | number | Yes | Permission flag. The value **1** means that a dialog box will still be displayed after the user grants or denies the permission. The value **2** means that no dialog box will be displayed after the user grants or denies the permission. The value **3** means a system permission that cannot be changed. |
| Name | Type | Mandatory| Description |
| --------- | ------------------- | ---- | ------------------------------------------------------------ |
| tokenID | number | Yes | ID of the application. |
| permissionName | string | Yes | Name of the permission to grant.|
| permissionFlag | number | Yes | Permission flag. The value **1** means that a dialog box will still be displayed after the user grants or denies the permission. The value **2** means that no dialog box will be displayed after the user grants or denies the permission. The value **3** means a system permission that cannot be changed. |
**Return value**
| Type | Description |
| :------------ | :---------------------------------- |
| Promise&lt;number&gt; | Promise used to return the result. |
| Type | Description |
| :------------ | :---------------------------------- |
| Promise&lt;number&gt; | Promise instance used to return the result.|
**Example**
```js
var AtManager = abilityAccessCtrl.createAtManager();
let tokenID = 0;
let promise = AtManager.grantUserGrantedPermission(tokenID, "ohos.permission.GRANT_SENSITIVE_PERMISSIONS");
let permissionFlag = 1;
let promise = AtManager.grantUserGrantedPermission(tokenID, "ohos.permission.GRANT_SENSITIVE_PERMISSIONS",permissionFlag);
promise.then(data => {
console.log(`promise: data->${JSON.stringify(data)}`);
});
......@@ -115,12 +116,12 @@ Grants a user granted permission to an application. This API uses an asynchronou
**Parameters**
| Name | Type | Mandatory | Description |
| --------- | ------------------- | ---- | ------------------------------------------------------------ |
| tokenID | number | Yes | ID of the application. |
| permissionName | string | Yes | Name of the permission to grant. |
| permissionFlag | number | Yes | Permission flag. The value **1** means that a dialog box will still be displayed after the user grants or denies the permission. The value **2** means that no dialog box will be displayed after the user grants or denies the permission. The value **3** means a system permission that cannot be changed. |
| callback | AsyncCallback&lt;number&gt; | Yes | Callback used to return the result. |
| Name | Type | Mandatory| Description |
| --------- | ------------------- | ---- | ------------------------------------------------------------ |
| tokenID | number | Yes | ID of the application. |
| permissionName | string | Yes | Name of the permission to grant.|
| permissionFlag | number | Yes | Permission flag. The value **1** means that a dialog box will still be displayed after the user grants or denies the permission. The value **2** means that no dialog box will be displayed after the user grants or denies the permission. The value **3** means a system permission that cannot be changed. |
| callback | AsyncCallback&lt;number&gt; | Yes| Callback used to return the result.|
**Example**
......@@ -145,17 +146,17 @@ Revokes a user granted permission given to an application. This API uses a promi
**Parameters**
| Name | Type | Mandatory | Description |
| --------- | ------------------- | ---- | ------------------------------------------------------------ |
| tokenID | number | Yes | ID of the application. |
| permissionName | string | Yes | Name of the permission to revoke. |
| permissionFlag | number | Yes | Permission flag. The value **1** means that a dialog box will still be displayed after the user grants or denies the permission. The value **2** means that no dialog box will be displayed after the user grants or denies the permission. The value **3** means a system permission that cannot be changed. |
| Name | Type | Mandatory| Description |
| --------- | ------------------- | ---- | ------------------------------------------------------------ |
| tokenID | number | Yes | ID of the application. |
| permissionName | string | Yes | Name of the permission to revoke.|
| permissionFlag | number | Yes | Permission flag. The value **1** means that a dialog box will still be displayed after the user grants or denies the permission. The value **2** means that no dialog box will be displayed after the user grants or denies the permission. The value **3** means a system permission that cannot be changed. |
**Return value**
| Type | Description |
| :------------ | :---------------------------------- |
| Promise&lt;number&gt; | Promise used to return the result. |
| Type | Description |
| :------------ | :---------------------------------- |
| Promise&lt;number&gt; | Promise instance used to return the result.|
**Example**
......@@ -181,18 +182,19 @@ Revokes a user granted permission given to an application. This API uses an asyn
**Parameters**
| Name | Type | Mandatory | Description |
| --------- | ------------------- | ---- | ------------------------------------------------------------ |
| tokenID | number | Yes | ID of the application. |
| permissionName | string | Yes | Name of the permission to revoke. |
| permissionFlag | number | Yes | Permission flag. The value **1** means that a dialog box will still be displayed after the user grants or denies the permission. The value **2** means that no dialog box will be displayed after the user grants or denies the permission. The value **3** means a system permission that cannot be changed. |
| callback | AsyncCallback&lt;number&gt; | Yes | Callback used to return the result. |
| Name | Type | Mandatory| Description |
| --------- | ------------------- | ---- | ------------------------------------------------------------ |
| tokenID | number | Yes | ID of the application. |
| permissionName | string | Yes | Name of the permission to revoke.|
| permissionFlag | number | Yes | Permission flag. The value **1** means that a dialog box will still be displayed after the user grants or denies the permission. The value **2** means that no dialog box will be displayed after the user grants or denies the permission. The value **3** means a system permission that cannot be changed. |
| callback | AsyncCallback&lt;number&gt; | Yes| Callback used to return the result.|
**Example**
```js
var AtManager = abilityAccessCtrl.createAtManager();
let tokenID = 0;
let permissionFlag = 1;
AtManager.revokeUserGrantedPermission(tokenID, "ohos.permission.GRANT_SENSITIVE_PERMISSIONS",permissionFlag, data => {
console.log(`callback: data->${JSON.stringify(data)}`);
});
......@@ -210,16 +212,16 @@ Obtains the flags of the specified permission of a given application. This API u
**Parameters**
| Name | Type | Mandatory | Description |
| --------- | ------------------- | ---- | ------------------------------------------------------------ |
| tokenID | number | Yes | ID of the application. |
| permissionName | string | Yes | Name of the permission to query. |
| Name | Type | Mandatory| Description |
| --------- | ------------------- | ---- | ------------------------------------------------------------ |
| tokenID | number | Yes | ID of the application. |
| permissionName | string | Yes | Name of the permission to query.|
**Return value**
| Type | Description |
| :------------ | :---------------------------------- |
| Promise&lt;number&gt; | Promise used to return the result. |
| Type | Description |
| :------------ | :---------------------------------- |
| Promise&lt;number&gt; | Promise instance used to return the result.|
**Example**
......@@ -238,7 +240,7 @@ Enumerates the permission grant states.
**System capability**: SystemCapability.Security.AccessToken
| Name | Default Value | Description |
| ----------------------------- | ---------------------- | ----------------------- |
| PERMISSION_DENIED | -1 | Permission denied. |
| PERMISSION_GRANTED | 0 | Permission granted. |
| Name | Default Value | Description |
| ----------------------------- | ---------------------- | ----------------------- |
| PERMISSION_DENIED | -1 | Permission denied. |
| PERMISSION_GRANTED | 0 | Permission granted. |
......@@ -6,7 +6,11 @@
Provides ability running information.
## Modules to Import
```js
import abilitymanager from '@ohos.application.abilityManager';
```
## Usage
......@@ -25,14 +29,14 @@ abilitymanager.getAbilityRunningInfos((err,data) => {
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
| Name | Type | Readable | Writable | Description |
| -------- | -------- | -------- | -------- | -------- |
| ability | ElementName | Yes | No | Information that matches an ability. |
| pid | number | Yes | No | Process ID. |
| uid | number | Yes | No | User ID. |
| processName | string | Yes | No | Process name. |
| startTime | number | Yes | No | Ability start time. |
| abilityState | [abilityManager.AbilityState](#abilitymanagerabilitystate) | Yes | No | Ability state. |
| Name| Type| Readable| Writable| Description|
| -------- | -------- | -------- | -------- | -------- |
| ability | ElementName | Yes| No| Information that matches an ability. |
| pid | number | Yes| No| Process ID.|
| uid | number | Yes| No| User ID. |
| processName | string | Yes| No| Process name. |
| startTime | number | Yes| No| Ability start time. |
| abilityState | [abilityManager.AbilityState](#abilitymanagerabilitystate) | Yes| No| Ability state. |
## abilityManager.AbilityState
......@@ -41,10 +45,10 @@ Enumerates the ability states.
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
| Name | Value | Description |
| -------- | -------- | -------- |
| INITIAL | 0 | The ability is in the initial state. |
| FOREGROUND | 9 | The ability is in the foreground state. |
| BACKGROUND | 10 | The ability is in the background state. |
| FOREGROUNDING | 11 | The ability is in the foregrounding state. |
| BACKGROUNDING | 12 | The ability is in the backgrounding state. |
| Name| Value| Description|
| -------- | -------- | -------- |
| INITIAL | 0 | The ability is in the initial state.|
| FOREGROUND | 9 | The ability is in the foreground state. |
| BACKGROUND | 10 | The ability is in the background state. |
| FOREGROUNDING | 11 | The ability is in the foregrounding state. |
| BACKGROUNDING | 12 | The ability is in the backgrounding state. |
......@@ -6,6 +6,11 @@
Implements the context of an ability stage. This module is inherited from [Context](js-apis-application-context.md).
## Modules to Import
```js
import AbilityStage from '@ohos.application.AbilityStage';
```
## Usage
......@@ -28,7 +33,7 @@ class MyAbilityStage extends AbilityStage {
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
| Name| Type | Readable | Writable | Description |
| Name| Type| Readable| Writable| Description|
| -------- | -------- | -------- | -------- | -------- |
| currentHapModuleInfo | HapModuleInfo | Yes | No | **ModuleInfo** object corresponding to the **AbilityStage**. |
| config | [Configuration](js-apis-configuration.md) | Yes| No| Configuration for the environment where the application is running. |
| currentHapModuleInfo | HapModuleInfo | Yes| No| **ModuleInfo** object corresponding to the **AbilityStage**.|
| config | [Configuration](js-apis-configuration.md) | Yes| No| Configuration for the environment where the application is running.|
# MissionSnapshot
> **NOTE**<br>
> **NOTE**
>
> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version.
Provides the snapshot of a mission.
## Modules to Import
```
import { ElementName } from '../bundle/elementName';
import { image } from '../@ohos.multimedia.image';
import abilitymanager from '@ohos.application.abilityManager';
import ElementName from '@ohos.bundle';
import image from '@ohos.multimedia.image';
```
## MissionSnapshot
Describes the mission snapshot.
| Name | Type | Readable | Writable | Description |
| Name| Type| Readable| Writable| Description|
| -------- | -------- | -------- | -------- | -------- |
| ability | ElementName | Yes | Yes | Information that matches an ability. |
| snapshot | [image.PixelMap](js-apis-image.md) | Yes| Yes| Snapshot of the mission. |
| ability | ElementName | Yes| Yes| Information that matches an ability.|
| snapshot | [image.PixelMap](js-apis-image.md) | Yes| Yes| Snapshot of the mission.|
......@@ -185,7 +185,7 @@ Waits for the ability that matches the **AbilityMonitor** instance to reach the
| Name | Type | Mandatory| Description |
| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
| monitor | [AbilityMonitor](js-apis-application-abilityMonitor.md#AbilityMonitor) | Yes | [AbilityMonitor](js-apis-application-abilityMonitor.md#AbilityMonitor) instance.|
| callback | AsyncCallback\<[Ability](js-apis-application-ability.md#Ability)> | Yes | Callback used to return the ability. |
| callback | AsyncCallback\<[Ability](js-apis-application-ability.md#Ability)> | Yes | Callback used to return the result. |
**Example**
......@@ -223,7 +223,7 @@ Waits a period of time for the ability that matches the **AbilityMonitor** insta
| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
| monitor | [AbilityMonitor](js-apis-application-abilityMonitor.md#AbilityMonitor) | Yes | [AbilityMonitor](js-apis-application-abilityMonitor.md#AbilityMonitor) instance.|
| timeout | number | Yes | Maximum waiting time, in milliseconds. |
| callback | AsyncCallback\<[Ability](js-apis-application-ability.md#Ability)> | Yes | Callback used to return the ability. |
| callback | AsyncCallback\<[Ability](js-apis-application-ability.md#Ability)> | Yes | Callback used to return the result. |
**Example**
......@@ -365,7 +365,7 @@ Obtains the top ability of the application. This API uses an asynchronous callba
| Name | Type | Mandatory| Description |
| -------- | ------------------------------------------------------------ | ---- | ------------------ |
| callback | AsyncCallback\<[Ability](js-apis-application-ability.md#Ability)> | Yes | Callback used to return the top ability.|
| callback | AsyncCallback\<[Ability](js-apis-application-ability.md#Ability)> | Yes | Callback used to return the result.|
**Example**
......@@ -747,7 +747,7 @@ abilityDelegator.executeShellCommand(cmd, timeout, (err : any, data : any) => {
### executeShellCommand
executeShellCommand(cmd: string, timeoutSecs: number): Promise\<ShellCmdResult>
executeShellCommand(cmd: string, timeoutSecs?: number): Promise\<ShellCmdResult>
Executes a shell command with the timeout period specified. This API uses a promise to return the result.
......
# AbilityDelegatorArgs
> **NOTE**
> **NOTE**<br/>
>
> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version.
......
# Context
> **NOTE**<br>
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**<br>
> The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version.
Provides the context for running code, including **applicationInfo** and **resourceManager**.
## Modules to Import
```
import AbilityContext from '@ohos.application.Ability';
```
## Usage
You must extend **AbilityContext** to implement this module.
## Attributes
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
| Name | Type | Readable | Writable | Description |
| -------- | -------- | -------- | -------- | -------- |
| resourceManager | ResourceManager | Yes | No | **ResourceManager** object. |
| applicationInfo | ApplicationInfo | Yes | No | Information about the application. |
| cacheDir | string | Yes | No | Cache directory of the application on the internal storage. |
| tempDir | string | Yes | No | Temporary file directory of the application. |
| filesDir | string | Yes | No | File directory of the application on the internal storage. |
| databaseDir | string | Yes | No | Storage directory of local data. |
| storageDir | string | Yes | No | Storage directory of lightweight data. |
| bundleCodeDir | string | Yes | No | Application installation path. |
| distributedFilesDir | string | Yes | No | Storage directory of distributed application data files. |
| eventHub | [EventHub](js-apis-eventhub.md) | Yes | No | Event hub information. |
| Name| Type| Readable| Writable| Description|
| -------- | -------- | -------- | -------- | -------- |
| resourceManager | ResourceManager | Yes| No| **ResourceManager** object.|
| applicationInfo | ApplicationInfo | Yes| No| Information about the application.|
| cacheDir | string | Yes| No| Cache directory of the application on the internal storage.|
| tempDir | string | Yes| No| Temporary file directory of the application.|
| filesDir | string | Yes| No| File directory of the application on the internal storage.|
| databaseDir | string | Yes| No| Storage directory of local data.|
| storageDir | string | Yes| No| Storage directory of lightweight data.|
| bundleCodeDir | string | Yes| No| Application installation path.|
| distributedFilesDir | string | Yes| No| Storage directory of distributed application data files.|
| eventHub | [EventHub](js-apis-eventhub.md) | Yes| No| Event hub information.|
| area | [AreaMode](#areamode) | Yes| Yes| Area in which the file to be access is located.|
## Context.createBundleContext
......@@ -41,27 +44,33 @@ Creates an application context.
**Parameters**
| Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- |
| bundleName | string | Yes | Application bundle name. |
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| bundleName | string | Yes| Application bundle name.|
**Return value**
| Type | Description |
| -------- | -------- |
| Context | Context of the application created. |
| Type| Description|
| -------- | -------- |
| Context | Context of the application created.|
**Example**
```js
let test = "com.example.test";
let context = this.context.createBundleContext(test);
import AbilityContext from '@ohos.application.Ability'
class MainAbility extends AbilityContext {
onWindowStageCreate(windowStage) {
let test = "com.example.test";
let context = this.context.createBundleContext(test);
}
}
```
## Context.getApplicationContext
getApplicationContext(): Context;
getApplicationContext(): ApplicationContext;
Obtains the context of this application.
......@@ -69,13 +78,25 @@ Obtains the context of this application.
**Return value**
| Type | Description |
| -------- | -------- |
| Context | Context obtained. |
| Type| Description|
| -------- | -------- |
| ApplicationContext | Current application context.|
**Example**
```js
// This part is mandatory.
let context = this.context.getApplicationContext();
let applicationContext = this.context.getApplicationContext();
```
## AreaMode
Defines the area where the file to be access is located. Each area has its own content.
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
| Name | Value | Description |
| --------------- | ---- | --------------- |
| EL1 | 0 | Device-level encryption area. |
| EL2 | 1 | User credential encryption area. The default value is **EL2**.|
# ShellCmdResult
> **NOTE**
> **NOTE**<br>
>
> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version.
......
# appManager
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**
> **NOTE**<br>
> 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.
......@@ -34,7 +34,7 @@ Checks whether this application is undergoing a stability test. This API uses an
```js
import app from '@ohos.application.appManager';
app.isRunningInStabilityTest((err, flag) => {
console.log('startAbility result:' + JSON.stringfy(err));
console.log('startAbility result:' + JSON.stringify(err));
})
```
......@@ -58,9 +58,9 @@ Checks whether this application is undergoing a stability test. This API uses a
```js
import app from '@ohos.application.appManager';
app.isRunningInStabilityTest().then((flag) => {
console.log('success:' + JSON.stringfy(flag));
console.log('success:' + JSON.stringify(flag));
}).catch((error) => {
console.log('failed:' + JSON.stringfy(error));
console.log('failed:' + JSON.stringify(error));
});
```
......@@ -82,7 +82,7 @@ Checks whether this application is running on a RAM constrained device. This API
**Example**
```js
app.isRamConstrainedDevicePromise().then((data) => {
app.isRamConstrainedDevice().then((data) => {
console.log('success:' + JSON.stringify(data));
}).catch((error) => {
console.log('failed:' + JSON.stringify(error));
......@@ -106,7 +106,7 @@ Checks whether this application is running on a RAM constrained device. This API
**Example**
```js
app.isRamConstrainedDevicePromise((err, data) => {
app.isRamConstrainedDevice((err, data) => {
console.log('startAbility result failed:' + JSON.stringify(err));
console.log('startAbility result success:' + JSON.stringify(data));
})
......@@ -160,7 +160,7 @@ Obtains the memory size of this application. This API uses an asynchronous callb
```
## appManager.getProcessRunningInfos<sup>8+</sup>
getProcessRunningInfos(): Promise<Array<ProcessRunningInfo>>;
getProcessRunningInfos(): Promise<Array\<ProcessRunningInfo>>;
Obtains information about the running processes. This API uses a promise to return the result.
......@@ -175,7 +175,7 @@ Obtains information about the running processes. This API uses a promise to retu
**Example**
```js
app.GetProcessRunningInfos().then((data) => {
app.getProcessRunningInfos().then((data) => {
console.log('success:' + JSON.stringify(data));
}).catch((error) => {
console.log('failed:' + JSON.stringify(error));
......@@ -184,7 +184,7 @@ Obtains information about the running processes. This API uses a promise to retu
## appManager.getProcessRunningInfos<sup>8+</sup>
getProcessRunningInfos(callback: AsyncCallback<Array<ProcessRunningInfo>>): void;
getProcessRunningInfos(callback: AsyncCallback<Array\<ProcessRunningInfo>>): void;
Obtains information about the running processes. This API uses an asynchronous callback to return the result.
......@@ -199,7 +199,7 @@ Obtains information about the running processes. This API uses an asynchronous c
**Example**
```js
app.GetProcessRunningInfos((err, data) => {
app.getProcessRunningInfos((err, data) => {
console.log('startAbility result failed :' + JSON.stringify(err));
console.log('startAbility result success:' + JSON.stringify(data));
})
......
# EventHub
> **NOTE**<br>
> **NOTE**<br/>
> The initial APIs of this module are supported since API 9. Newly added APIs will be marked with a superscript to indicate their earliest API version.
Implements event subscription, unsubscription, and triggering.
## Modules to Import
```js
import Ability from '@ohos.application.Ability'
```
## Usage
Before using any APIs in the **EventHub**, you must obtain an **EventHub** instance through the member variable **context** of the **Ability** instance.
Before using any APIs in the **EventHub**, you must obtain an **EventHub** instance through the member variable **context** of the **Ability** instance.
```js
import Ability from '@ohos.application.Ability'
export default class MainAbility extends Ability {
func1(){
console.log("func1 is called");
}
onForeground() {
this.context.eventHub.on("123", this.func1);
}
......@@ -34,10 +42,10 @@ Subscribes to an event.
**Parameters**
| Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- |
| event | string | Yes | Event name. |
| callback | Function | Yes | Callback invoked when the event is triggered. |
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| event | string | Yes| Event name.|
| callback | Function | Yes| Callback invoked when the event is triggered.|
**Example**
......@@ -72,10 +80,10 @@ Unsubscribes from an event. If **callback** is specified, this API unsubscribes
**Parameters**
| Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- |
| event | string | Yes | Event name. |
| callback | Function | No | Callback for the event. If **callback** is unspecified, all callbacks of the event are unsubscribed. |
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| event | string | Yes| Event name.|
| callback | Function | No| Callback for the event. If **callback** is unspecified, all callbacks of the event are unsubscribed.|
**Example**
......@@ -110,10 +118,10 @@ Triggers an event.
**Parameters**
| Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- |
| event | string | Yes | Event name. |
| ...args | Object[] | Yes | Variable parameters, which are passed to the callback when the event is triggered. |
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| event | string | Yes| Event name.|
| ...args | Object[] | Yes| Variable parameters, which are passed to the callback when the event is triggered.|
**Example**
......
# ExtensionContext
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**<br/>
> **NOTE**<br/>
> The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version.
```js
import DataShareExtensionAbility from '@ohos.application.DataShareExtensionAbility';
```
Implements the extension context. This module is inherited from **Context**.
......@@ -11,7 +15,7 @@ Implements the extension context. This module is inherited from **Context**.
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
| Name | Type | Readable | Writable | Description |
| Name| Type| Readable| Writable| Description|
| -------- | -------- | -------- | -------- | -------- |
| currentHapModuleInfo | HapModuleInfo | Yes| No | Information about the current HAP. |
| config | Configuration | Yes| No | Module configuration information. |
| currentHapModuleInfo | HapModuleInfo | Yes| No| Information about the current HAP. |
| config | Configuration | Yes| No| Module configuration information.|
# ExtensionRunningInfo
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**<br/>
> **NOTE**<br/>
> The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version.
Provides extension running information.
## Modules to Import
```js
import abilitymanager from '@ohos.application.abilityManager';
```
## Usage
......@@ -14,8 +19,9 @@ The extension running information is obtained through an **abilityManager** inst
```
```js
import abilitymanager from '@ohos.application.abilityManager';
let upperLimit=1
abilitymanager.getExtensionRunningInfos(upperLimit, (err,data) => {
console.log("getExtensionRunningInfos err: " + err + " data: " + JSON.stringify(data));
});
......
# FormExtensionContext
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**<br/>
> **NOTE**<br/>
> The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version.
Implements the context that provides the capabilities and APIs of **FormExtension**. This class is inherited from **ExtensionContext**.
## Modules to Import
```js
import FormExtension from '@ohos.application.FormExtension';
```
## FormExtensionContext.updateForm
updateForm(formId: string, formBindingData: formBindingData.FormBindingData, callback: AsyncCallback\<void>): void
......@@ -24,10 +30,18 @@ Updates a widget. This method uses a callback to return the result.
**Example**
```js
let obj2 = formBindingData.createFormBindingData({temperature:"22c", time:"22:00"});
this.context.updateForm(formId, obj2, (data)=>{
console.log('FormExtension context updateForm, data:' + data);
});
import formBindingData from '@ohos.application.formBindingData'
export default class MyFormExtension extends FormExtension {
onUpdate(formId) {
console.log('FormExtension onUpdate, formId:' + formId);
let obj2 = formBindingData.createFormBindingData({temperature:"22c", time:"22:00"});
this.context.updateForm(formId, obj2, (data)=>{
console.log('FormExtension context updateForm, data:' + data);
});
}
}
```
## FormExtensionContext.updateForm
......@@ -53,11 +67,18 @@ Updates a widget. This method uses a promise to return the result.
**Example**
```
let obj2 = formBindingData.createFormBindingData({temperature:"22c", time:"22:00"});
this.context.updateForm(formId, obj2)
.then((data)=>{
console.log('FormExtension context updateForm, data:' + data);
}).catch((error) => {
console.error('Operation updateForm failed. Cause: ' + error);});
```js
import formBindingData from '@ohos.application.formBindingData'
export default class MyFormExtension extends FormExtension {
onUpdate(formId) {
console.log('FormExtension onUpdate, formId:' + formId);
let obj2 = formBindingData.createFormBindingData({temperature:"22c", time:"22:00"});
this.context.updateForm(formId, obj2)
.then((data)=>{
console.log('FormExtension context updateForm, data:' + data);
}).catch((error) => {
console.error('Operation updateForm failed. Cause: ' + error);});
}
}
```
# missionManager
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**<br>
> **NOTE**<br/>
> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version.
missionManager provides APIs to lock, unlock, and clear missions, and switch a mission to the foreground.
## Modules to Import
```
import missionManager from '@ohos.application.missionManager'
```
## Required Permissions
ohos.permission.MANAGE_MISSIONS
## missionManager.registerMissionListener
......@@ -40,10 +40,11 @@ Registers a listener to observe the mission status.
```js
var listener = {
onMissionCreated: this.onMissionCreatedCallback,
onMissionDestroyed: this.onMissionDestroyedCallback,
onMissionSnapshotChanged: this.onMissionSnapshotChangedCallback,
onMissionMovedToFront: this.onMissionMovedToFrontCallback
onMissionCreated: function(mission){"--------onMissionCreated-------"},
onMissionDestroyed: function(mission){"--------onMissionDestroyed-------"},
onMissionSnapshotChanged: function(mission){"--------onMissionSnapshotChanged-------"},
onMissionMovedToFront: function(mission){"--------onMissionMovedToFront-------"},
onMissionIconUpdated: function(mission,icon){"--------onMissionIconUpdated-------"}
};
console.log("registerMissionListener")
var listenerid = missionManager.registerMissionListener(listener);
......@@ -70,10 +71,11 @@ Deregisters a mission status listener. This API uses an asynchronous callback to
```js
var listener = {
onMissionCreated: this.onMissionCreatedCallback,
onMissionDestroyed: this.onMissionDestroyedCallback,
onMissionSnapshotChanged: this.onMissionSnapshotChangedCallback,
onMissionMovedToFront: this.onMissionMovedToFrontCallback
onMissionCreated: function(mission){"--------onMissionCreated-------"},
onMissionDestroyed: function(mission){"--------onMissionDestroyed-------"},
onMissionSnapshotChanged: function(mission){"--------onMissionSnapshotChanged-------"},
onMissionMovedToFront: function(mission){"--------onMissionMovedToFront-------"},
onMissionIconUpdated: function(mission,icon){"--------onMissionIconUpdated-------"}
};
console.log("registerMissionListener")
var listenerid = missionManager.registerMissionListener(listener);
......@@ -108,17 +110,18 @@ Deregisters a mission status listener. This API uses a promise to return the res
```js
var listener = {
onMissionCreated: this.onMissionCreatedCallback,
onMissionDestroyed: this.onMissionDestroyedCallback,
onMissionSnapshotChanged: this.onMissionSnapshotChangedCallback,
onMissionMovedToFront: this.onMissionMovedToFrontCallback
};
console.log("registerMissionListener")
var listenerid = missionManager.registerMissionListener(listener);
missionManager.unregisterMissionListener(listenerid).catch(function (err){
console.log(err);
});
onMissionCreated: function(mission){"--------onMissionCreated-------"},
onMissionDestroyed: function(mission){"--------onMissionDestroyed-------"},
onMissionSnapshotChanged: function(mission){"--------onMissionSnapshotChanged-------"},
onMissionMovedToFront: function(mission){"--------onMissionMovedToFront-------"},
onMissionIconUpdated: function(mission,icon){"--------onMissionIconUpdated-------"}
};
console.log("registerMissionListener")
var listenerid = missionManager.registerMissionListener(listener);
missionManager.unregisterMissionListener(listenerid).catch(function (err){
console.log(err);
});
```
......@@ -143,15 +146,16 @@ Obtains the information about a given mission. This API uses an asynchronous cal
```js
import missionManager from '@ohos.application.missionManager'
missionManager.getMissionInfo("", allMissions[0].missionId, (error, mission) => {
console.log("getMissionInfo is called, error.code = " + error.code)
console.log("mission.missionId = " + mission.missionId);
console.log("mission.runningState = " + mission.runningState);
console.log("mission.lockedState = " + mission.lockedState);
console.log("mission.timestamp = " + mission.timestamp);
console.log("mission.label = " + mission.label);
console.log("mission.iconPath = " + mission.iconPath);
});
var allMissions=missionManager.getMissionInfos("",10).catch(function(err){console.log(err);});
missionManager.getMissionInfo("", allMissions[0].missionId, (error, mission) => {
console.log("getMissionInfo is called, error.code = " + error.code)
console.log("mission.missionId = " + mission.missionId);
console.log("mission.runningState = " + mission.runningState);
console.log("mission.lockedState = " + mission.lockedState);
console.log("mission.timestamp = " + mission.timestamp);
console.log("mission.label = " + mission.label);
console.log("mission.iconPath = " + mission.iconPath);
});
```
......@@ -181,7 +185,7 @@ Obtains the information about a given mission. This API uses a promise to return
```js
import missionManager from '@ohos.application.missionManager'
var mission = missionManager.getMissionInfo("", id).catch(function (err){
var mission = missionManager.getMissionInfo("", 10).catch(function (err){
console.log(err);
});
```
......@@ -309,15 +313,17 @@ Obtains the snapshot of a given mission. This API uses a promise to return the r
```js
import missionManager from '@ohos.application.missionManager'
var allMissions = missionManager.getMissionInfos("", 10).catch(function (err){
console.log(err);
});
console.log("size = " + allMissions.length);
console.log("missions = " + JSON.stringify(allMissions));
var id = allMissions[0].missionId;
var snapshot = missionManager.getMissionSnapShot("", id).catch(function (err){
console.log(err);
});
var allMissions;
missionManager.getMissionInfos("",10).then(function(res){
allMissions=res;
}).catch(function(err){console.log(err);});
console.log("size = " + allMissions.length);
console.log("missions = " + JSON.stringify(allMissions));
var id = allMissions[0].missionId;
var snapshot = missionManager.getMissionSnapShot("", id).catch(function (err){
console.log(err);
});
```
......@@ -378,10 +384,10 @@ Locks a given mission. This API uses a promise to return the result.
```js
import missionManager from '@ohos.application.missionManager'
var allMissions = missionManager.getMissionInfos("", 10).catch(function (err){
console.log(err);
});
var allMissions;
missionManager.getMissionInfos("",10).then(function(res){
allMissions=res;
}).catch(function(err){console.log(err);});
console.log("size = " + allMissions.length);
console.log("missions = " + JSON.stringify(allMissions));
var id = allMissions[0].missionId;
......@@ -450,9 +456,10 @@ Unlocks a given mission. This API uses a promise to return the result.
```js
import missionManager from '@ohos.application.missionManager'
var allMissions = missionManager.getMissionInfos("", 10).catch(function (err){
console.log(err);
});
var allMissions;
missionManager.getMissionInfos("",10).then(function(res){
allMissions=res;
}).catch(function(err){console.log(err);});
console.log("size = " + allMissions.length);
console.log("missions = " + JSON.stringify(allMissions));
var id = allMissions[0].missionId;
......@@ -524,9 +531,10 @@ Clears a given mission, regardless of whether it is locked. This API uses a prom
```js
import missionManager from '@ohos.application.missionManager'
var allMissions = missionManager.getMissionInfos("", 10).catch(function (err){
console.log(err);
});
var allMissions;
missionManager.getMissionInfos("",10).then(function(res){
allMissions=res;
}).catch(function(err){console.log(err);});
console.log("size = " + allMissions.length);
console.log("missions = " + JSON.stringify(allMissions));
var id = allMissions[0].missionId;
......@@ -673,9 +681,10 @@ Switches a given mission to the foreground, with the startup parameters for the
```js
import missionManager from '@ohos.application.missionManager'
var allMissions = missionManager.getMissionInfos("", 10).catch(function (err){
console.log(err);
});
var allMissions;
missionManager.getMissionInfos("",10).then(function(res){
allMissions=res;
}).catch(function(err){console.log(err);});
console.log("size = " + allMissions.length);
console.log("missions = " + JSON.stringify(allMissions));
var id = allMissions[0].missionId;
......
# ParticleAbility Module
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**<br/>
> **NOTE**<br/>
> 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.
## Constraints
......@@ -226,7 +226,7 @@ let wantAgentInfo = {
],
operationType: wantAgent.OperationType.START_ABILITY,
requestCode: 0,
wantAgentFlags: [wantAgent.WantAgentFlags.UPDATE_PRESET_FLAG]
wantAgentFlags: [wantAgent.WantAgentFlags.UPDATE_PRESENT_FLAG]
};
wantAgent.getWantAgent(wantAgentInfo).then((wantAgentObj) => {
......@@ -235,11 +235,11 @@ wantAgent.getWantAgent(wantAgentInfo).then((wantAgentObj) => {
text: "text"
};
let notificationContent = {
contentType: notification.ContentType.NOTIFICATION_CONTENT_TEXT,
contentType: notification.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT,
normal: basicContent
};
let request = {
content: notificatonContent,
content: notificationContent,
wantAgent: wantAgentObj
};
let id = 1;
......@@ -260,16 +260,16 @@ Requests a continuous task from the system. This API uses a promise to return th
**Parameters**
| Name | Type | Mandatory | Description |
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| id | number | Yes | Notification ID of a continuous task. |
| request | NotificationRequest | Yes | Notification parameter, which is used to display information in the notification bar. |
| id | number | Yes| Notification ID of a continuous task.|
| request | NotificationRequest | Yes| Notification parameter, which is used to display information in the notification bar.|
**Return value**
| Type | Description |
| Type | Description |
| -------------- | ------------------------- |
| Promise\<void> | Promise used to return the result. |
| Promise\<void> | Promise used to return the result.|
**Example**
......@@ -287,7 +287,7 @@ let wantAgentInfo = {
],
operationType: wantAgent.OperationType.START_ABILITY,
requestCode: 0,
wantAgentFlags: [wantAgent.WantAgentFlags.UPDATE_PRESET_FLAG]
wantAgentFlags: [wantAgent.WantAgentFlags.UPDATE_PRESENT_FLAG]
};
wantAgent.getWantAgent(wantAgentInfo).then((wantAgentObj) => {
......@@ -296,11 +296,11 @@ wantAgent.getWantAgent(wantAgentInfo).then((wantAgentObj) => {
text: "text"
};
let notificationContent = {
contentType: notification.ContentType.NOTIFICATION_CONTENT_TEXT,
contentType: notification.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT,
normal: basicContent
};
let request = {
content: notificatonContent,
content: notificationContent,
wantAgent: wantAgentObj
};
let id = 1;
......@@ -323,9 +323,9 @@ Requests to cancel a continuous task from the system. This API uses an asynchron
**Parameters**
| Name | Type | Mandatory | Description |
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result. |
| callback | AsyncCallback&lt;void&gt; | Yes| Callback used to return the result.|
**Example**
......@@ -354,9 +354,9 @@ Requests a continuous task from the system. This API uses a promise to return th
**Return value**
| Type | Description |
| Type | Description |
| -------------- | ------------------------- |
| Promise\<void> | Promise used to return the result. |
| Promise\<void> | Promise used to return the result.|
**Example**
......@@ -382,25 +382,26 @@ Connects this ability to a specific Service ability. This API uses a callback to
**Parameters**
| Name | Type | Mandatory | Description |
| Name | Type | Mandatory| Description |
| ------- | -------------- | ---- | ---------------------------- |
| request | [Want](js-apis-application-Want.md) | Yes | Service ability to connect. |
| options | ConnectOptions | Yes | Callback used to return the result. |
| request | [Want](js-apis-application-Want.md) | Yes | Service ability to connect.|
| options | ConnectOptions | Yes | Callback used to return the result. |
**ConnectOptions**
ConnectOptions
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
| Name | Readable/Writable | Type | Mandatory | Description |
| Name | Readable/Writable| Type | Mandatory | Description |
| ------------ | ---- | -------- | ---- | ------------------------- |
| onConnect | Read only | function | Yes | Callback invoked when the connection is successful. |
| onDisconnect | Read only | function | Yes | Callback invoked when the connection fails. |
| onFailed | Read only | function | Yes | Callback invoked when **connectAbility** fails to be called. |
| onConnect | Read only | function | Yes | Callback invoked when the connection is successful. |
| onDisconnect | Read only | function | Yes | Callback invoked when the connection fails. |
| onFailed | Read only | function | Yes | Callback invoked when **connectAbility** fails to be called.|
**Example**
```js
import rpc from '@ohos.rpc'
function onConnectCallback(element, remote){
console.log('ConnectAbility onConnect remote is proxy:' + (remote instanceof rpc.RemoteProxy));
}
......@@ -422,8 +423,10 @@ Connects this ability to a specific Service ability. This API uses a callback to
},
);
particleAbility.disconnectAbility(connId).then((error,data)=>{
console.log('particleAbilityTest result errCode : ' + error.code + " data: " + data);
particleAbility.disconnectAbility(connId).then((data)=>{
console.log( " data: " + data);
}).catch((error)=>{
console.log('particleAbilityTest result errCode : ' + error.code )
});
......@@ -440,13 +443,14 @@ Disconnects this ability from the Service ability. This API uses a callback to r
**Parameters**
| Name | Type | Mandatory | Description |
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result. |
| callback | AsyncCallback&lt;void&gt; | Yes| Callback used to return the result.|
**Example**
```js
import rpc from '@ohos.rpc'
function onConnectCallback(element, remote){
console.log('ConnectAbility onConnect remote is proxy:' + (remote instanceof rpc.RemoteProxy));
}
......@@ -467,11 +471,11 @@ Disconnects this ability from the Service ability. This API uses a callback to r
onFailed: onFailedCallback,
},
);
var result = particleAbility.disconnectAbility(connId,
(error,data) => {
console.log('particleAbilityTest DisConnectJsSameBundleName result errCode : ' + error.code + " data: " + data)
},
);
var result = particleAbility.disconnectAbility(connId).then((data)=>{
console.log( " data: " + data);
}).catch((error)=>{
console.log('particleAbilityTest result errCode : ' + error.code )
});
```
......@@ -486,13 +490,14 @@ Disconnects this ability from the Service ability. This API uses a promise to re
**Return value**
| Type | Description |
| Type | Description |
| -------------- | ------------------------- |
| Promise\<void> | Promise used to return the result. |
| Promise\<void> | Promise used to return the result.|
**Example**
```js
import rpc from '@ohos.rpc'
function onConnectCallback(element, remote){
console.log('ConnectAbility onConnect remote is proxy:' + (remote instanceof rpc.RemoteProxy));
}
......@@ -514,8 +519,10 @@ function onConnectCallback(element, remote){
},
);
particleAbility.disconnectAbility(connId).then((error,data)=>{
console.log('particleAbilityTest result errCode : ' + error.code + " data: " + data);
particleAbility.disconnectAbility(connId).then((data)=>{
console.log( " data: " + data);
}).catch((error)=>{
console.log('particleAbilityTest result errCode : ' + error.code )
});
```
......
# PermissionRequestResult
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**
> **NOTE**<br>
> The initial APIs of this module are supported since API 9. Newly added APIs will be marked with a superscript to indicate their earliest API version.
Provides the permission request result.
## Modules to Import
```js
import Ability from '@ohos.application.Ability'
```
## Attributes
......
......@@ -11,7 +11,7 @@ Implements URI permission management.
```
import uriPermissionManager from '@ohos.application.uriPermissionManager';
import UriPermissionManager from '@ohos.application.uriPermissionManager';
```
......@@ -27,18 +27,20 @@ SystemCapability.Ability.AbilityRuntime.Core
**Parameters**
| Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- |
| uri | string | Yes | URI of a file, for example, **fileshare:///com.samples.filesharetest.FileShare/person/10**. |
| flag | wantConstant.Flags | Yes | Read or write permission on the file specified by the URI. |
| accessTokenId | number | Yes | Unique ID of an application, which is obtained through the **BundleManager** API. |
| callback | AsyncCallback&lt;number&gt; | Yes | Callback used to return the check result. The value **0** means that the application has the specified permission, and **-1** means the opposite. |
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| uri | string | Yes| URI of a file, for example, **fileshare:///com.samples.filesharetest.FileShare/person/10**.|
| flag | wantConstant.Flags | Yes| Read or write permission on the file specified by the URI.|
| accessTokenId | number | Yes| Unique ID of an application, which is obtained through the **BundleManager** API.|
| callback | AsyncCallback&lt;number&gt; | Yes| Callback used to return the check result. The value **0** means that the application has the specified permission, and **-1** means the opposite.|
**Example**
```
```js
import WantConstant from '@ohos.ability.wantConstant';
let accessTokenId =1
let uri = "fileshare:///com.samples.filesharetest.FileShare/person/10"
UriPermissionManager.verifyUriPermission(uri, wantConstant.Flags.FLAG_AUTH_READ_URI_PERMISSION, accessTokenId, (result) => {
UriPermissionManager.verifyUriPermission(uri, WantConstant.Flags.FLAG_AUTH_READ_URI_PERMISSION, accessTokenId, (result) => {
console.log("result.code = " + result.code)
}) // accessTokenId is obtained through the **BundleManager** API.
```
......@@ -48,7 +50,7 @@ SystemCapability.Ability.AbilityRuntime.Core
verifyUriPermission(uri: string, flag: wantConstant.Flags, accessTokenId: number): Promise&lt;number&gt;
Checks whether an application has the permission specified by **flag** for an URI. This API uses a promise to return the result.
Checks whether an application has the permission specified by **flag** for an URI. This API uses a callback to return the result.
**System capability**:
......@@ -56,21 +58,23 @@ SystemCapability.Ability.AbilityRuntime.Core
**Parameters**
| Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- |
| uri | string | Yes | URI of a file, for example, **fileshare:///com.samples.filesharetest.FileShare/person/10**. |
| flag | wantConstant.Flags | Yes | Read or write permission on the file specified by the URI. |
| accessTokenId | number | Yes | Unique ID of an application, which is obtained through the **BundleManager** API. |
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| uri | string | Yes| URI of a file, for example, **fileshare:///com.samples.filesharetest.FileShare/person/10**.|
| flag | wantConstant.Flags | Yes| Read or write permission on the file specified by the URI.|
| accessTokenId | number | Yes| Unique ID of an application, which is obtained through the **BundleManager** API.|
**Return value**
| Type | Description |
| -------- | -------- |
| Promise&lt;number&gt; | Promise used to return the check result. The value **0** means that the application has the specified permission, and **-1** means the opposite. |
| Type| Description|
| -------- | -------- |
| Promise&lt;number&gt; | Promise used to return the check result. The value **0** means that the application has the specified permission, and **-1** means the opposite.|
**Example**
```
```js
import WantConstant from '@ohos.ability.wantConstant';
let accessTokenId =1
let uri = "fileshare:///com.samples.filesharetest.FileShare/person/10"
UriPermissionManager.verifyUriPermission(uri, wantConstant.Flags.FLAG_AUTH_READ_URI_PERMISSION, accessTokenId)
.then((data) => {
......@@ -78,4 +82,4 @@ SystemCapability.Ability.AbilityRuntime.Core
}).catch((error) => {
console.log('Verification failed.');
})
```
\ No newline at end of file
```
......@@ -29,7 +29,6 @@ Obtains a **WantAgent** object. This API uses an asynchronous callback to return
```js
import WantAgent from '@ohos.wantAgent';
import { OperationType, WantAgentFlags } from '@ohos.wantagent';
// getWantAgent callback
function getWantAgentCallback(err, data) {
......@@ -58,9 +57,9 @@ var wantAgentInfo = {
}
}
],
operationType: OperationType.START_ABILITIES,
operationType: WantAgent.OperationType.START_ABILITIES,
requestCode: 0,
wantAgentFlags:[WantAgentFlags.UPDATE_PRESENT_FLAG]
wantAgentFlags:[WantAgent.WantAgentFlags.UPDATE_PRESENT_FLAG]
}
WantAgent.getWantAgent(wantAgentInfo, getWantAgentCallback)
......@@ -92,7 +91,7 @@ Obtains a **WantAgent** object. This API uses a promise to return the result.
```js
import WantAgent from '@ohos.wantAgent';
import { OperationType, WantAgentFlags } from '@ohos.wantagent';
// WantAgentInfo object
var wantAgentInfo = {
......@@ -117,9 +116,9 @@ var wantAgentInfo = {
}
}
],
operationType: OperationType.START_ABILITIES,
operationType: WantAgent.OperationType.START_ABILITIES,
requestCode: 0,
wantAgentFlags:[WantAgentFlags.UPDATE_PRESENT_FLAG]
wantAgentFlags:[WantAgent.WantAgentFlags.UPDATE_PRESENT_FLAG]
}
WantAgent.getWantAgent(wantAgentInfo).then((data) => {
......@@ -148,7 +147,7 @@ Obtains the bundle name of a **WantAgent** object. This API uses an asynchronous
```js
import WantAgent from '@ohos.wantAgent';
import { OperationType, WantAgentFlags } from '@ohos.wantagent';
// WantAgent object
var wantAgent;
......@@ -185,9 +184,9 @@ var wantAgentInfo = {
}
}
],
operationType: OperationType.START_ABILITIES,
operationType: WantAgent.OperationType.START_ABILITIES,
requestCode: 0,
wantAgentFlags:[WantAgentFlags.UPDATE_PRESENT_FLAG]
wantAgentFlags:[WantAgent.WantAgentFlags.UPDATE_PRESENT_FLAG]
}
WantAgent.getWantAgent(wantAgentInfo, getWantAgentCallback)
......@@ -225,7 +224,7 @@ Obtains the bundle name of a **WantAgent** object. This API uses a promise to re
```js
import WantAgent from '@ohos.wantAgent';
import { OperationType, WantAgentFlags } from '@ohos.wantagent';
// WantAgent object
var wantAgent;
......@@ -253,9 +252,9 @@ var wantAgentInfo = {
}
}
],
operationType: OperationType.START_ABILITIES,
operationType: WantAgent.OperationType.START_ABILITIES,
requestCode: 0,
wantAgentFlags:[WantAgentFlags.UPDATE_PRESENT_FLAG]
wantAgentFlags:[WantAgent.WantAgentFlags.UPDATE_PRESENT_FLAG]
}
WantAgent.getWantAgent(wantAgentInfo).then((data) => {
......@@ -289,7 +288,7 @@ Obtains the user ID of a **WantAgent** object. This API uses an asynchronous cal
```js
import WantAgent from '@ohos.wantAgent';
import { OperationType, WantAgentFlags } from '@ohos.wantagent';
// WantAgent object
var wantAgent;
......@@ -326,9 +325,9 @@ var wantAgentInfo = {
}
}
],
operationType: OperationType.START_ABILITIES,
operationType: WantAgent.OperationType.START_ABILITIES,
requestCode: 0,
wantAgentFlags:[WantAgentFlags.UPDATE_PRESENT_FLAG]
wantAgentFlags:[WantAgent.WantAgentFlags.UPDATE_PRESENT_FLAG]
}
WantAgent.getWantAgent(wantAgentInfo, getWantAgentCallback)
......@@ -366,7 +365,7 @@ Obtains the user ID of a **WantAgent** object. This API uses a promise to return
```js
import WantAgent from '@ohos.wantAgent';
import { OperationType, WantAgentFlags } from '@ohos.wantagent';
// WantAgent object
var wantAgent;
......@@ -394,9 +393,9 @@ var wantAgentInfo = {
}
}
],
operationType: OperationType.START_ABILITIES,
operationType: WantAgent.OperationType.START_ABILITIES,
requestCode: 0,
wantAgentFlags:[WantAgentFlags.UPDATE_PRESENT_FLAG]
wantAgentFlags:[WantAgent.WantAgentFlags.UPDATE_PRESENT_FLAG]
}
WantAgent.getWantAgent(wantAgentInfo).then((data) => {
......@@ -430,7 +429,7 @@ Obtains the want in a **WantAgent** object. This API uses an asynchronous callba
```js
import WantAgent from '@ohos.wantAgent';
import { OperationType, WantAgentFlags } from '@ohos.wantagent';
// WantAgent object
var wantAgent;
......@@ -467,9 +466,9 @@ var wantAgentInfo = {
}
}
],
operationType: OperationType.START_ABILITIES,
operationType: WantAgent.OperationType.START_ABILITIES,
requestCode: 0,
wantAgentFlags:[WantAgentFlags.UPDATE_PRESENT_FLAG]
wantAgentFlags:[WantAgent.WantAgentFlags.UPDATE_PRESENT_FLAG]
}
WantAgent.getWantAgent(wantAgentInfo, getWantAgentCallback)
......@@ -507,7 +506,7 @@ Obtains the want in a **WantAgent** object. This API uses a promise to return th
```js
import WantAgent from '@ohos.wantAgent';
import { OperationType, WantAgentFlags } from '@ohos.wantagent';
// WantAgent object
var wantAgent;
......@@ -535,9 +534,9 @@ var wantAgentInfo = {
}
}
],
operationType: OperationType.START_ABILITIES,
operationType: WantAgent.OperationType.START_ABILITIES,
requestCode: 0,
wantAgentFlags:[WantAgentFlags.UPDATE_PRESENT_FLAG]
wantAgentFlags:[WantAgent.WantAgentFlags.UPDATE_PRESENT_FLAG]
}
WantAgent.getWantAgent(wantAgentInfo).then((data) => {
......@@ -571,7 +570,7 @@ Cancels a **WantAgent** object. This API uses an asynchronous callback to return
```js
import WantAgent from '@ohos.wantAgent';
import { OperationType, WantAgentFlags } from '@ohos.wantagent';
// WantAgent object
var wantAgent;
......@@ -608,9 +607,9 @@ var wantAgentInfo = {
}
}
],
operationType: OperationType.START_ABILITIES,
operationType: WantAgent.OperationType.START_ABILITIES,
requestCode: 0,
wantAgentFlags:[WantAgentFlags.UPDATE_PRESENT_FLAG]
wantAgentFlags:[WantAgent.WantAgentFlags.UPDATE_PRESENT_FLAG]
}
WantAgent.getWantAgent(wantAgentInfo, getWantAgentCallback)
......@@ -648,7 +647,7 @@ Cancels a **WantAgent** object. This API uses a promise to return the result.
```js
import WantAgent from '@ohos.wantAgent';
import { OperationType, WantAgentFlags } from '@ohos.wantagent';
// WantAgent object
var wantAgent;
......@@ -676,9 +675,9 @@ var wantAgentInfo = {
}
}
],
operationType: OperationType.START_ABILITIES,
operationType: WantAgent.OperationType.START_ABILITIES,
requestCode: 0,
wantAgentFlags:[WantAgentFlags.UPDATE_PRESENT_FLAG]
wantAgentFlags:[WantAgent.WantAgentFlags.UPDATE_PRESENT_FLAG]
}
WantAgent.getWantAgent(wantAgentInfo).then((data) => {
......@@ -713,7 +712,7 @@ Triggers a **WantAgent** object. This API uses an asynchronous callback to retur
```js
import WantAgent from '@ohos.wantAgent';
import { OperationType, WantAgentFlags } from '@ohos.wantagent';
// WantAgent object
var wantAgent;
......@@ -750,15 +749,15 @@ var wantAgentInfo = {
}
}
],
operationType: OperationType.START_ABILITIES,
operationType: WantAgent.OperationType.START_ABILITIES,
requestCode: 0,
wantAgentFlags:[WantAgentFlags.UPDATE_PRESENT_FLAG]
wantAgentFlags:[WantAgent.WantAgentFlags.UPDATE_PRESENT_FLAG]
}
WantAgent.getWantAgent(wantAgentInfo, getWantAgentCallback)
// trigger callback
function triggerCallback(err, data) {
function triggerCallback(data) {
console.info("==========================>triggerCallback=======================>");
}
......@@ -783,14 +782,14 @@ Checks whether two **WantAgent** objects are equal. This API uses an asynchronou
| Name | Readable| Writable| Type | Mandatory| Description |
| ---------- | --- | ---- | ------------------------ | ---- | --------------------------------------- |
| agent | Yes | No | WantAgent | Yes | The first **WantAgent** object. |
| otherAgent | Yes | No | WantAgent | Yes | The second **WantAgent** object. |
| otherAgent | Yes | No | WantAgent | Yes | Target **WantAgent** object. |
| callback | Yes | No | AsyncCallback\<boolean\> | Yes | Callback used to return the result.|
**Example**
```js
import WantAgent from '@ohos.wantAgent';
import { OperationType, WantAgentFlags } from '@ohos.wantagent';
// WantAgent object
var wantAgent1;
......@@ -829,9 +828,9 @@ var wantAgentInfo = {
}
}
],
operationType: OperationType.START_ABILITIES,
operationType: WantAgent.OperationType.START_ABILITIES,
requestCode: 0,
wantAgentFlags:[WantAgentFlags.UPDATE_PRESENT_FLAG]
wantAgentFlags:[WantAgent.WantAgentFlags.UPDATE_PRESENT_FLAG]
}
WantAgent.getWantAgent(wantAgentInfo, getWantAgentCallback)
......@@ -858,7 +857,7 @@ Checks whether two **WantAgent** objects are equal. This API uses a promise to r
| Name | Readable| Writable| Type | Mandatory| Description |
| ---------- | --- | ---- | --------- | ---- | ------------- |
| agent | Yes | No | WantAgent | Yes | The first **WantAgent** object.|
| otherAgent | Yes | No | WantAgent | Yes | The second **WantAgent** object.|
| otherAgent | Yes | No | WantAgent | Yes | Target **WantAgent** object.|
**Return value**
......@@ -870,7 +869,7 @@ Checks whether two **WantAgent** objects are equal. This API uses a promise to r
```js
import WantAgent from '@ohos.wantAgent';
import { OperationType, WantAgentFlags } from '@ohos.wantagent';
// WantAgent object
var wantAgent1;
......@@ -899,9 +898,9 @@ var wantAgentInfo = {
}
}
],
operationType: OperationType.START_ABILITIES,
operationType: WantAgent.OperationType.START_ABILITIES,
requestCode: 0,
wantAgentFlags:[WantAgentFlags.UPDATE_PRESENT_FLAG]
wantAgentFlags:[WantAgent.WantAgentFlags.UPDATE_PRESENT_FLAG]
}
WantAgent.getWantAgent(wantAgentInfo).then((data) => {
......@@ -915,6 +914,135 @@ WantAgent.equal(wantAgent1, wantAgent2).then((data) => {
});
```
## WantAgent.getOperationType
getOperationType(agent: WantAgent, callback: AsyncCallback\<number>): void;
Obtains the operation type of a **WantAgent** object. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
**Parameters**
| Name | Readable| Writable| Type | Mandatory| Description |
| ---------- | --- | ---- | ------------------------ | ---- | --------------------------------------- |
| agent | Yes | No | WantAgent | Yes | Target **WantAgent** object. |
| callback | Yes | No | AsyncCallback\<number> | Yes | Callback used to return the operation type.|
**Example**
```js
import WantAgent from '@ohos.wantAgent';
// WantAgent object
var wantAgent;
// WantAgentInfo object
var wantAgentInfo = {
wants: [
{
deviceId: "deviceId",
bundleName: "com.neu.setResultOnAbilityResultTest1",
abilityName: "com.example.test.MainAbility",
action: "action1",
entities: ["entity1"],
type: "MIMETYPE",
uri: "key={true,true,false}",
parameters:
{
mykey0: 2222,
mykey1: [1, 2, 3],
mykey2: "[1, 2, 3]",
mykey3: "ssssssssssssssssssssssssss",
mykey4: [false, true, false],
mykey5: ["qqqqq", "wwwwww", "aaaaaaaaaaaaaaaaa"],
mykey6: true,
}
}
],
operationType: WantAgent.OperationType.START_ABILITIES,
requestCode: 0,
wantAgentFlags:[WantAgent.WantAgentFlags.UPDATE_PRESENT_FLAG]
}
WantAgent.getWantAgent(wantAgentInfo).then((data) => {
console.info("==========================>getWantAgentCallback=======================>");
wantAgent = data;
});
WantAgent.getOperationType(wantAgent, (OperationType) => {
console.log('----------- getOperationType ----------, OperationType: ' + OperationType);
})
```
## WantAgent.getOperationType
getOperationType(agent: WantAgent): Promise\<number>;
Obtains the operation type of a **WantAgent** object. This API uses a promise to return the result.
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
**Parameters**
| Name | Readable| Writable| Type | Mandatory| Description |
| ---------- | --- | ---- | --------- | ---- | ------------- |
| agent | Yes | No | WantAgent | Yes | Target **WantAgent** object.|
**Return value**
| Type | Description |
| ----------------------------------------------------------- | ------------------------------------------------------------ |
| Promise\<number> | Promise used to return the operation type.|
**Example**
```js
import WantAgent from '@ohos.wantAgent';
// WantAgent object
var wantAgent;
// WantAgentInfo object
var wantAgentInfo = {
wants: [
{
deviceId: "deviceId",
bundleName: "com.neu.setResultOnAbilityResultTest1",
abilityName: "com.example.test.MainAbility",
action: "action1",
entities: ["entity1"],
type: "MIMETYPE",
uri: "key={true,true,false}",
parameters:
{
mykey0: 2222,
mykey1: [1, 2, 3],
mykey2: "[1, 2, 3]",
mykey3: "ssssssssssssssssssssssssss",
mykey4: [false, true, false],
mykey5: ["qqqqq", "wwwwww", "aaaaaaaaaaaaaaaaa"],
mykey6: true,
}
}
],
operationType: WantAgent.OperationType.START_ABILITIES,
requestCode: 0,
wantAgentFlags:[WantAgent.WantAgentFlags.UPDATE_PRESENT_FLAG]
}
WantAgent.getWantAgent(wantAgentInfo).then((data) => {
console.info("==========================>getWantAgentCallback=======================>");
wantAgent = data;
});
WantAgent.getOperationType(wantAgent).then((OperationType) => {
console.log('getOperationType success, OperationType: ' + OperationType);
}).catch((err) => {
console.log('getOperationType fail, err: ' + err);
})
```
## WantAgentInfo
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册