> The initial APIs of this module are supported since API version 6. Newly added APIs will be marked with a superscript to indicate their earliest API version.
> The initial APIs of this module are supported since API version 6. Newly added APIs will be marked with a superscript to indicate their earliest API version.
>
> The APIs of this module can be used only in the FA module.
## Modules to Import
## Modules to Import
...
@@ -96,8 +99,8 @@ Verifies whether a specific PID and UID have the given permission. This API uses
...
@@ -96,8 +99,8 @@ Verifies whether a specific PID and UID have the given permission. This API uses
> 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
## Modules to Import
...
@@ -32,7 +33,7 @@ Obtains the ID attached to the end of a given URI.
...
@@ -32,7 +33,7 @@ Obtains the ID attached to the end of a given URI.
> The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version.
> The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version.
>
> The APIs of this module can be used only in the stage model.
Implements the ability context. This module is inherited from **Context**.
Implements the ability context. This module is inherited from **Context**.
## Modules to Import
```js
importAbilityfrom'@ohos.application.Ability'
```
## Usage
## Usage
Before using the **AbilityContext** module, you must define a child class that inherits from **Ability**.
Before using the **AbilityContext** module, you must define a child class that inherits from **Ability**.
```js
```js
importAbilityfrom'@ohos.application.Ability'
importAbilityfrom'@ohos.application.Ability'
classMainAbilityextendsAbility{
classMainAbilityextendsAbility{
...
@@ -28,10 +34,10 @@ class MainAbility extends Ability {
...
@@ -28,10 +34,10 @@ class MainAbility extends Ability {
| currentHapModuleInfo | HapModuleInfo | Yes| No| Information about the current HAP.|
| currentHapModuleInfo | HapModuleInfo | Yes| No| Information about the current HAP.|
## AbilityContext.startAbility
## AbilityContext.startAbility
...
@@ -44,10 +50,10 @@ Starts an ability. This API uses a callback to return the result.
...
@@ -44,10 +50,10 @@ Starts an ability. This API uses a callback to return the result.
**Parameters**
**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.|
| want | [Want](js-apis-application-Want.md) | Yes| Information about the **Want** used for starting an ability.|
| callback | AsyncCallback<void> | Yes| Callback used to return the result.|
| callback | AsyncCallback<void> | Yes| Callback used to return the result.|
**Example**
**Example**
...
@@ -55,7 +61,7 @@ Starts an ability. This API uses a callback to return the result.
...
@@ -55,7 +61,7 @@ Starts an ability. This API uses a callback to return the result.
varwant={
varwant={
"deviceId":"",
"deviceId":"",
"bundleName":"com.extreme.test",
"bundleName":"com.extreme.test",
"abilityName":"com.extreme.test.MainAbility"
"abilityName":"MainAbility"
};
};
this.context.startAbility(want,(error)=>{
this.context.startAbility(want,(error)=>{
console.log("error.code = "+error.code)
console.log("error.code = "+error.code)
...
@@ -73,11 +79,11 @@ Starts an ability. This API uses a callback to return the result.
...
@@ -73,11 +79,11 @@ Starts an ability. This API uses a callback to return the result.
**Parameters**
**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.|
| 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.|
| options | StartOptions | Yes| Parameters used for starting the ability.|
| callback | AsyncCallback<void> | Yes| Callback used to return the result.|
| callback | AsyncCallback<void> | Yes| Callback used to return the result.|
**Example**
**Example**
...
@@ -85,7 +91,7 @@ Starts an ability. This API uses a callback to return the result.
...
@@ -85,7 +91,7 @@ Starts an ability. This API uses a callback to return the result.
varwant={
varwant={
"deviceId":"",
"deviceId":"",
"bundleName":"com.extreme.test",
"bundleName":"com.extreme.test",
"abilityName":"com.extreme.test.MainAbility"
"abilityName":"MainAbility"
};
};
varoptions={
varoptions={
windowMode:0,
windowMode:0,
...
@@ -106,16 +112,16 @@ Starts an ability. This API uses a promise to return the result.
...
@@ -106,16 +112,16 @@ Starts an ability. This API uses a promise to return the result.
**Parameters**
**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.|
| 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.|
| options | StartOptions | No| Parameters used for starting the ability.|
**Return value**
**Return value**
| Type | Description |
| Type | Description |
| -------- | -------- |
| -------- | -------- |
| Promise<void> | Promise used to return the result.|
| Promise<void> | Promise used to return the result.|
**Example**
**Example**
...
@@ -123,7 +129,7 @@ Starts an ability. This API uses a promise to return the result.
...
@@ -123,7 +129,7 @@ Starts an ability. This API uses a promise to return the result.
varwant={
varwant={
"deviceId":"",
"deviceId":"",
"bundleName":"com.extreme.test",
"bundleName":"com.extreme.test",
"abilityName":"com.extreme.test.MainAbility"
"abilityName":"MainAbility"
};
};
varoptions={
varoptions={
windowMode:0,
windowMode:0,
...
@@ -147,10 +153,10 @@ Starts an ability. This API uses a callback to return the execution result when
...
@@ -147,10 +153,10 @@ Starts an ability. This API uses a callback to return the execution result when
**Parameters**
**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.|
| want |[Want](js-apis-application-Want.md) | Yes| Information about the **Want** used for starting an ability.|
| callback | AsyncCallback<[AbilityResult](js-apis-featureAbility.md#abilityresult)> | Yes| Callback used to return the result.|
| callback | AsyncCallback<[AbilityResult](js-apis-featureAbility.md#abilityresult)> | Yes| Callback used to return the result.|
**Example**
**Example**
...
@@ -175,11 +181,11 @@ Starts an ability. This API uses a callback to return the execution result when
...
@@ -175,11 +181,11 @@ Starts an ability. This API uses a callback to return the execution result when
**Parameters**
**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.|
| 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.|
| options | StartOptions | Yes| Parameters used for starting the ability.|
| callback | AsyncCallback<[AbilityResult](js-apis-featureAbility.md#abilityresult)> | Yes| Callback used to return the result.|
| callback | AsyncCallback<[AbilityResult](js-apis-featureAbility.md#abilityresult)> | Yes| Callback used to return the result.|
**Example**
**Example**
...
@@ -208,17 +214,17 @@ Starts an ability. This API uses a promise to return the execution result when t
...
@@ -208,17 +214,17 @@ Starts an ability. This API uses a promise to return the execution result when t
**Parameters**
**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.|
| 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.|
| options | StartOptions | No| Parameters used for starting the ability.|
**Return value**
**Return value**
| Type | Description |
| Type | Description |
| -------- | -------- |
| -------- | -------- |
| Promise<[AbilityResult](js-apis-featureAbility.md#abilityresult)> | Promise used to return the result.|
| Promise<[AbilityResult](js-apis-featureAbility.md#abilityresult)> | Promise used to return the result.|
**Example**
**Example**
...
@@ -244,9 +250,9 @@ Terminates this ability. This API uses a callback to return the result.
...
@@ -244,9 +250,9 @@ Terminates this ability. This API 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 indicating whether the API is successfully called.|
| callback | AsyncCallback<void> | Yes| Callback used to return the result indicating whether the API is successfully called.|
**Example**
**Example**
...
@@ -267,9 +273,9 @@ Terminates this ability. This API uses a promise to return the result.
...
@@ -267,9 +273,9 @@ Terminates this ability. This API uses a promise to return the result.
**Return value**
**Return value**
| Type | Description |
| Type | Description |
| -------- | -------- |
| -------- | -------- |
| Promise<void> | Promise used to return the result indicating whether the API is successfully called.|
| Promise<void> | Promise used to return the result indicating whether the API is successfully called.|
**Example**
**Example**
...
@@ -292,10 +298,10 @@ Terminates this ability. This API uses a callback to return the information to t
...
@@ -292,10 +298,10 @@ Terminates this ability. This API uses a callback to return the information to t
**Parameters**
**Parameters**
| Name | Type | Mandatory | Description |
| Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- |
| -------- | -------- | -------- | -------- |
| parameter | [AbilityResult](js-apis-featureAbility.md#abilityresult) | Yes| Information returned to the caller.|
| parameter | [AbilityResult](js-apis-featureAbility.md#abilityresult) | Yes| Information returned to the caller.|
| callback | AsyncCallback<void> | Yes| Callback used to return the result.|
| callback | AsyncCallback<void> | Yes| Callback used to return the result.|
**Example**
**Example**
...
@@ -321,15 +327,15 @@ Terminates this ability. This API uses a promise to return information to the ca
...
@@ -321,15 +327,15 @@ Terminates this ability. This API uses a promise to return information to the ca
**Parameters**
**Parameters**
| Name | Type | Mandatory | Description |
| Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- |
| -------- | -------- | -------- | -------- |
| parameter | [AbilityResult](js-apis-featureAbility.md#abilityresult) | Yes| Information returned to the caller.|
| parameter | [AbilityResult](js-apis-featureAbility.md#abilityresult) | Yes| Information returned to the caller.|
**Return value**
**Return value**
| Type | Description |
| Type | Description |
| -------- | -------- |
| -------- | -------- |
| Promise<void> | Promise used to return the result.|
| Promise<void> | Promise used to return the result.|
**Example**
**Example**
...
@@ -355,18 +361,18 @@ Obtains the caller interface of the specified ability, and if the specified abil
...
@@ -355,18 +361,18 @@ Obtains the caller interface of the specified ability, and if the specified abil
**Parameters**
**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.|
| 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**
**Return value**
| Type | Description |
| Type | Description |
| -------- | -------- |
| -------- | -------- |
| Promise<Caller> | Promise used to return the caller object to communicate with.|
| Promise<Caller> | Promise used to return the caller object to communicate with.|
**Example**
**Example**
```js
```js
importAbilityfrom'@ohos.application.Ability';
importAbilityfrom'@ohos.application.Ability';
varcaller;
varcaller;
...
@@ -374,11 +380,11 @@ Obtains the caller interface of the specified ability, and if the specified abil
...
@@ -374,11 +380,11 @@ Obtains the caller interface of the specified ability, and if the specified abil
onWindowStageCreate(windowStage){
onWindowStageCreate(windowStage){
this.context.startAbilityByCall({
this.context.startAbilityByCall({
bundleName:"com.example.myservice",
bundleName:"com.example.myservice",
abilityName:"com.example.myservice.MainAbility",
abilityName:"MainAbility",
deviceId:""
deviceId:""
}).then((obj)=>{
}).then((obj)=>{
caller=obj;
caller=obj;
console.log('Caller GetCaller Get '+call);
console.log('Caller GetCaller Get '+caller);
}).catch((e)=>{
}).catch((e)=>{
console.log('Caller GetCaller error '+e);
console.log('Caller GetCaller error '+e);
});
});
...
@@ -397,17 +403,19 @@ Requests permissions from the user by displaying a pop-up window. This API uses
...
@@ -397,17 +403,19 @@ Requests permissions from the user by displaying a pop-up window. This API uses
**Parameters**
**Parameters**
| Name | Type | Mandatory | Description |
| Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- |
| -------- | -------- | -------- | -------- |
| permissions | Array<string> | Yes| Permissions to request.|
| permissions | Array<string> | Yes| Permissions to request.|
| callback | AsyncCallback<[PermissionRequestResult](js-apis-permissionrequestresult.md)> | Yes| Callback used to return the result indicating whether the API is successfully called.|
| callback | AsyncCallback<[PermissionRequestResult](js-apis-permissionrequestresult.md)> | Yes| Callback used to return the result indicating whether the API is successfully called.|
@@ -421,24 +429,26 @@ Requests permissions from the user by displaying a pop-up window. This API uses
...
@@ -421,24 +429,26 @@ Requests permissions from the user by displaying a pop-up window. This API uses
**Parameters**
**Parameters**
| Name | Type | Mandatory | Description |
| Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- |
| -------- | -------- | -------- | -------- |
| permissions | Array<string> | Yes| Permissions to request.|
| permissions | Array<string> | Yes| Permissions to request.|
**Return value**
**Return value**
| Type | Description |
| Type | Description |
| -------- | -------- |
| -------- | -------- |
| Promise<[PermissionRequestResult](js-apis-permissionrequestresult.md)> | Promise used to return the result indicating whether the API is successfully called.|
| Promise<[PermissionRequestResult](js-apis-permissionrequestresult.md)> | Promise used to return the result indicating whether the API is successfully called.|
> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version.
> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version.
## Modules to Import
## Modules to Import
...
@@ -20,9 +21,9 @@ Creates an **AtManager** instance, which is used for ability access control.
...
@@ -20,9 +21,9 @@ Creates an **AtManager** instance, which is used for ability access control.
| tokenID | number | Yes | ID of the application. |
| tokenID | number | Yes | ID of the application. |
| permissionName | string | Yes | Name of the permission to grant. |
| 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. |
| 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. |
| tokenID | number | Yes | ID of the application. |
| tokenID | number | Yes | ID of the application. |
| permissionName | string | Yes | Name of the permission to grant. |
| 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. |
| 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<number> | Yes | Callback used to return the result. |
| callback | AsyncCallback<number> | Yes | Callback used to return the result. |
**Example**
**Example**
...
@@ -145,17 +147,17 @@ Revokes a user granted permission given to an application. This API uses a promi
...
@@ -145,17 +147,17 @@ Revokes a user granted permission given to an application. This API uses a promi
| tokenID | number | Yes | ID of the application. |
| tokenID | number | Yes | ID of the application. |
| permissionName | string | Yes | Name of the permission to revoke. |
| 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. |
| 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. |
| tokenID | number | Yes | ID of the application. |
| tokenID | number | Yes | ID of the application. |
| permissionName | string | Yes | Name of the permission to revoke. |
| 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. |
| 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<number> | Yes | Callback used to return the result. |
| callback | AsyncCallback<number> | Yes | Callback used to return the result. |
> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version.
> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version.
Provides ability running information.
Provides ability running information.
## Modules to Import
## Usage
The ability running information is obtained by using the **getAbilityRunningInfos** API in **abilityManager**.
> The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version.
> The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version.
Implements the context of an ability stage. This module is inherited from [Context](js-apis-application-context.md).
Implements the context of an ability stage. This module is inherited from [Context](js-apis-application-context.md).
> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version.
> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version.
...
@@ -12,8 +13,9 @@ Provides the snapshot of a mission.
...
@@ -12,8 +13,9 @@ Provides the snapshot of a mission.
```
```
import { ElementName } from '../bundle/elementName';
import missionManager from '@ohos.application.missionManager'
import { image } from '../@ohos.multimedia.image';
> The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version.
> The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version.
>
> The APIs of this module can be used only in the stage model.
Manages the ability lifecycle and context.
Manages the ability lifecycle and context.
...
@@ -9,7 +12,7 @@ Manages the ability lifecycle and context.
...
@@ -9,7 +12,7 @@ Manages the ability lifecycle and context.
## Modules to Import
## Modules to Import
```
```
import Ability from '@ohos.application.Ability';
import Ability from '@ohos.application.Ability';
```
```
...
@@ -18,11 +21,12 @@ import Ability from '@ohos.application.Ability';
...
@@ -18,11 +21,12 @@ import Ability from '@ohos.application.Ability';
@@ -275,22 +306,25 @@ Sends sequenceable data to the target ability.
...
@@ -275,22 +306,25 @@ Sends sequenceable data to the target ability.
**Parameters**
**Parameters**
| Name | Type | Mandatory | Description |
| Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- |
| -------- | -------- | -------- | -------- |
| method | string | Yes | Notification message string negotiated between the two abilities. The message is used to instruct the callee to register a function to receive the sequenceable data. |
| method | string | Yes | Notification message string negotiated between the two abilities. The message is used to instruct the callee to register a function to receive the sequenceable data. |
| data | rpc.Sequenceable | Yes | Sequenceable data. You need to customize the data. |
| data | rpc.Sequenceable | Yes | Sequenceable data. You need to customize the data. |
**Return value**
**Return value**
| Type | Description |
| Type | Description |
| -------- | -------- |
| -------- | -------- |
| Promise<void> | Promise used to return a response. |
| Promise<void> | Promise used to return a response. |
**Example**
**Example**
```js
```js
importAbilityfrom'@ohos.application.Ability';
importAbilityfrom'@ohos.application.Ability';
classMyMessageAble{// Custom sequenceable data structure
classMyMessageAble{// Custom sequenceable data structure
name:""
str:""
num:1
constructor(name,str){
constructor(name,str){
this.name=name;
this.name=name;
this.str=str;
this.str=str;
...
@@ -314,7 +348,7 @@ Sends sequenceable data to the target ability.
...
@@ -314,7 +348,7 @@ Sends sequenceable data to the target ability.
onWindowStageCreate(windowStage){
onWindowStageCreate(windowStage){
this.context.startAbilityByCall({
this.context.startAbilityByCall({
bundleName:"com.example.myservice",
bundleName:"com.example.myservice",
abilityName:"com.example.myservice.MainAbility",
abilityName:"MainAbility",
deviceId:""
deviceId:""
}).then((obj)=>{
}).then((obj)=>{
caller=obj;
caller=obj;
...
@@ -345,22 +379,25 @@ Sends sequenceable data to the target ability and obtains the sequenceable data
...
@@ -345,22 +379,25 @@ Sends sequenceable data to the target ability and obtains the sequenceable data
**Parameters**
**Parameters**
| Name | Type | Mandatory | Description |
| Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- |
| -------- | -------- | -------- | -------- |
| method | string | Yes | Notification message string negotiated between the two abilities. The message is used to instruct the callee to register a function to receive the sequenceable data. |
| method | string | Yes | Notification message string negotiated between the two abilities. The message is used to instruct the callee to register a function to receive the sequenceable data. |
| data | rpc.Sequenceable | Yes | Sequenceable data. You need to customize the data. |
| data | rpc.Sequenceable | Yes | Sequenceable data. You need to customize the data. |
**Return value**
**Return value**
| Type | Description |
| Type | Description |
| -------- | -------- |
| -------- | -------- |
| Promise<rpc.MessageParcel> | Promise used to return the sequenceable data from the target ability. |
| Promise<rpc.MessageParcel> | Promise used to return the sequenceable data from the target ability. |
**Example**
**Example**
```js
```js
importAbilityfrom'@ohos.application.Ability';
importAbilityfrom'@ohos.application.Ability';
classMyMessageAble{
classMyMessageAble{
name:""
str:""
num:1
constructor(name,str){
constructor(name,str){
this.name=name;
this.name=name;
this.str=str;
this.str=str;
...
@@ -384,7 +421,7 @@ Sends sequenceable data to the target ability and obtains the sequenceable data
...
@@ -384,7 +421,7 @@ Sends sequenceable data to the target ability and obtains the sequenceable data
onWindowStageCreate(windowStage){
onWindowStageCreate(windowStage){
this.context.startAbilityByCall({
this.context.startAbilityByCall({
bundleName:"com.example.myservice",
bundleName:"com.example.myservice",
abilityName:"com.example.myservice.MainAbility",
abilityName:"MainAbility",
deviceId:""
deviceId:""
}).then((obj)=>{
}).then((obj)=>{
caller=obj;
caller=obj;
...
@@ -423,7 +460,7 @@ Releases the caller interface of the target ability.
...
@@ -423,7 +460,7 @@ Releases the caller interface of the target ability.
onWindowStageCreate(windowStage){
onWindowStageCreate(windowStage){
this.context.startAbilityByCall({
this.context.startAbilityByCall({
bundleName:"com.example.myservice",
bundleName:"com.example.myservice",
abilityName:"com.example.myservice.MainAbility",
abilityName:"MainAbility",
deviceId:""
deviceId:""
}).then((obj)=>{
}).then((obj)=>{
caller=obj;
caller=obj;
...
@@ -451,9 +488,9 @@ Registers a callback that is invoked when the Stub on the target ability is disc
...
@@ -451,9 +488,9 @@ Registers a callback that is invoked when the Stub on the target ability is disc
**Parameters**
**Parameters**
| Name | Type | Mandatory | Description |
| Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- |
| -------- | -------- | -------- | -------- |
| callback | OnReleaseCallBack | Yes | Callback used for the **onRelease** API. |
| callback | OnReleaseCallBack | Yes | Callback used for the **onRelease** API. |
**Example**
**Example**
...
@@ -464,7 +501,7 @@ Registers a callback that is invoked when the Stub on the target ability is disc
...
@@ -464,7 +501,7 @@ Registers a callback that is invoked when the Stub on the target ability is disc
onWindowStageCreate(windowStage){
onWindowStageCreate(windowStage){
this.context.startAbilityByCall({
this.context.startAbilityByCall({
bundleName:"com.example.myservice",
bundleName:"com.example.myservice",
abilityName:"com.example.myservice.MainAbility",
abilityName:"MainAbility",
deviceId:""
deviceId:""
}).then((obj)=>{
}).then((obj)=>{
caller=obj;
caller=obj;
...
@@ -499,16 +536,19 @@ Registers a caller notification callback, which is invoked when the target abili
...
@@ -499,16 +536,19 @@ Registers a caller notification callback, which is invoked when the target abili
**Parameters**
**Parameters**
| Name | Type | Mandatory | Description |
| Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- |
| -------- | -------- | -------- | -------- |
| method | string | Yes | Notification message string negotiated between the two abilities. |
| method | string | Yes | Notification message string negotiated between the two abilities. |
| callback | CaleeCallBack | Yes | JS notification synchronization callback of the **rpc.MessageParcel** type. The callback must return at least one empty **rpc.Sequenceable** object. Otherwise, the function execution fails. |
| callback | CaleeCallBack | Yes | JS notification synchronization callback of the **rpc.MessageParcel** type. The callback must return at least one empty **rpc.Sequenceable** object. Otherwise, the function execution fails. |
**Example**
**Example**
```js
```js
importAbilityfrom'@ohos.application.Ability';
importAbilityfrom'@ohos.application.Ability';
classMyMessageAble{
classMyMessageAble{
name:""
str:""
num:1
constructor(name,str){
constructor(name,str){
this.name=name;
this.name=name;
this.str=str;
this.str=str;
...
@@ -552,9 +592,9 @@ Unregisters a caller notification callback, which is invoked when the target abi
...
@@ -552,9 +592,9 @@ Unregisters a caller notification callback, which is invoked when the target abi
> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version.
> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version.
> The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version.
> The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version.
Provides the context for running code, including **applicationInfo** and **resourceManager**.
Provides the context for running code, including **applicationInfo** and **resourceManager**.
## Modules to Import
```
import AbilityContext from '@ohos.application.Ability';
```
## Usage
## Usage
...
@@ -17,18 +23,19 @@ You must extend **AbilityContext** to implement this module.
...
@@ -17,18 +23,19 @@ You must extend **AbilityContext** to implement this module.
> 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.
...
@@ -25,16 +26,16 @@ Checks whether this application is undergoing a stability test. This API uses an
...
@@ -25,16 +26,16 @@ Checks whether this application is undergoing a stability test. This API uses an
**Parameters**
**Parameters**
| Name| Type| Mandatory| Description|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| -------- | -------- | -------- | -------- |
| callback | AsyncCallback<boolean> | No| Callback used to return the result. If the application is undergoing a stability test, **true** will be returned; otherwise, **false** will be returned.|
| callback | AsyncCallback<boolean> | No| Callback used to return the result. If the application is undergoing a stability test, **true** will be returned; otherwise, **false** will be returned.|
@@ -49,18 +50,18 @@ Checks whether this application is undergoing a stability test. This API uses a
...
@@ -49,18 +50,18 @@ Checks whether this application is undergoing a stability test. This API uses a
**Return value**
**Return value**
| Type| Description|
| Type| Description|
| -------- | -------- |
| -------- | -------- |
| Promise<boolean> | Promise used to return the result. If the application is undergoing a stability test, **true** will be returned; otherwise, **false** will be returned.|
| Promise<boolean> | Promise used to return the result. If the application is undergoing a stability test, **true** will be returned; otherwise, **false** will be returned.|
**Example**
**Example**
```js
```js
importappfrom'@ohos.application.appManager';
importappfrom'@ohos.application.appManager';
app.isRunningInStabilityTest().then((flag)=>{
app.isRunningInStabilityTest().then((flag)=>{
console.log('success:'+JSON.stringfy(flag));
console.log('success:'+JSON.stringify(flag));
}).catch((error)=>{
}).catch((error)=>{
console.log('failed:'+JSON.stringfy(error));
console.log('failed:'+JSON.stringify(error));
});
});
```
```
...
@@ -75,14 +76,14 @@ Checks whether this application is running on a RAM constrained device. This API
...
@@ -75,14 +76,14 @@ Checks whether this application is running on a RAM constrained device. This API
**Return value**
**Return value**
| Type| Description|
| Type| Description|
| -------- | -------- |
| -------- | -------- |
| Promise<boolean> | Promise used to return whether the application is running on a RAM constrained device. If the application is running on a RAM constrained device, **true** will be returned; otherwise, **false** will be returned.|
| Promise<boolean> | Promise used to return whether the application is running on a RAM constrained device. If the application is running on a RAM constrained device, **true** will be returned; otherwise, **false** will be returned.|
@@ -99,14 +100,14 @@ Checks whether this application is running on a RAM constrained device. This API
...
@@ -99,14 +100,14 @@ Checks whether this application is running on a RAM constrained device. This API
**Parameters**
**Parameters**
| Name| Type| Mandatory| Description|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| -------- | -------- | -------- | -------- |
| callback | AsyncCallback<boolean> | No| Callback used to return whether the application is running on a RAM constrained device. If the application is running on a RAM constrained device, **true** will be returned; otherwise, **false** will be returned.|
| callback | AsyncCallback<boolean> | No| Callback used to return whether the application is running on a RAM constrained device. If the application is running on a RAM constrained device, **true** will be returned; otherwise, **false** will be returned.|
**Example**
**Example**
```js
```js
app.isRamConstrainedDevicePromise((err,data)=>{
app.isRamConstrainedDevice((err,data)=>{
console.log('startAbility result failed:'+JSON.stringify(err));
console.log('startAbility result failed:'+JSON.stringify(err));
console.log('startAbility result success:'+JSON.stringify(data));
console.log('startAbility result success:'+JSON.stringify(data));
})
})
...
@@ -122,9 +123,9 @@ Obtains the memory size of this application. This API uses a promise to return t
...
@@ -122,9 +123,9 @@ Obtains the memory size of this application. This API uses a promise to return t
**Return value**
**Return value**
| Type| Description|
| Type| Description|
| -------- | -------- |
| -------- | -------- |
| Promise<number> | Size of the application memory.|
| Promise<number> | Size of the application memory.|
**Example**
**Example**
...
@@ -146,9 +147,9 @@ Obtains the memory size of this application. This API uses an asynchronous callb
...
@@ -146,9 +147,9 @@ Obtains the memory size of this application. This API uses an asynchronous callb
**Parameters**
**Parameters**
| Name| Type| Mandatory| Description|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| -------- | -------- | -------- | -------- |
| callback | AsyncCallback<number> | No| Size of the application memory.|
| callback | AsyncCallback<number> | No| Size of the application memory.|
**Example**
**Example**
...
@@ -160,7 +161,7 @@ Obtains the memory size of this application. This API uses an asynchronous callb
...
@@ -160,7 +161,7 @@ Obtains the memory size of this application. This API uses an asynchronous callb
> The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version.
> The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version.
>
> The APIs of this module can be used only in the stage model.
> The initial APIs of this module are supported since API 9. Newly added APIs will be marked with a superscript to indicate their earliest API version.
> The initial APIs of this module are supported since API 9. Newly added APIs will be marked with a superscript to indicate their earliest API version.
>
> The APIs of this module can be used only in the stage model.
Implements event subscription, unsubscription, and triggering.
Implements event subscription, unsubscription, and triggering.
## Modules to Import
```js
importAbilityfrom'@ohos.application.Ability'
```
## Usage
## 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
```js
importAbilityfrom'@ohos.application.Ability'
importAbilityfrom'@ohos.application.Ability'
exportdefaultclassMainAbilityextendsAbility{
exportdefaultclassMainAbilityextendsAbility{
func1(){
console.log("func1 is called");
}
onForeground(){
onForeground(){
this.context.eventHub.on("123",this.func1);
this.context.eventHub.on("123",this.func1);
}
}
...
@@ -34,10 +43,10 @@ Subscribes to an event.
...
@@ -34,10 +43,10 @@ Subscribes to an event.
**Parameters**
**Parameters**
| Name | Type | Mandatory | Description |
| Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- |
| -------- | -------- | -------- | -------- |
| event | string | Yes | Event name. |
| event | string | Yes | Event name. |
| callback | Function | Yes | Callback invoked when the event is triggered. |
| callback | Function | Yes | Callback invoked when the event is triggered. |
**Example**
**Example**
...
@@ -72,10 +81,10 @@ Unsubscribes from an event. If **callback** is specified, this API unsubscribes
...
@@ -72,10 +81,10 @@ Unsubscribes from an event. If **callback** is specified, this API unsubscribes
**Parameters**
**Parameters**
| Name | Type | Mandatory | Description |
| Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- |
| -------- | -------- | -------- | -------- |
| event | string | Yes | Event name. |
| event | string | Yes | Event name. |
| callback | Function | No | Callback for the event. If **callback** is unspecified, all callbacks of the event are unsubscribed. |
| callback | Function | No | Callback for the event. If **callback** is unspecified, all callbacks of the event are unsubscribed. |
**Example**
**Example**
...
@@ -110,10 +119,10 @@ Triggers an event.
...
@@ -110,10 +119,10 @@ Triggers an event.
**Parameters**
**Parameters**
| Name | Type | Mandatory | Description |
| Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- |
| -------- | -------- | -------- | -------- |
| event | string | Yes | Event name. |
| event | string | Yes | Event name. |
| ...args | Object[] | Yes | Variable parameters, which are passed to the callback when the event is triggered. |
| ...args | Object[] | Yes | Variable parameters, which are passed to the callback when the event is triggered. |
> The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version.
> The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version.
>
> The APIs of this module can be used only in the stage model.
Implements the extension context. This module is inherited from **Context**.
Implements the extension context. This module is inherited from **Context**.
> The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version.
> The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version.
> The initial APIs of this module are supported since API version 6. Newly added APIs will be marked with a superscript to indicate their earliest API version.
> The initial APIs of this module are supported since API version 6. Newly added APIs will be marked with a superscript to indicate their earliest API version.
>
> The APIs of this module can be used only in the FA model.
## Constraints
## Usage
APIs of the **FeatureAbility** module can be called only by Page abilities.
APIs of the **FeatureAbility** module can be called only by Page abilities.
...
@@ -139,7 +142,7 @@ Starts an ability. This API uses a callback to return the execution result when
...
@@ -139,7 +142,7 @@ Starts an ability. This API uses a callback to return the execution result when
> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version.
> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version.
## Modules to Import
## Modules to Import
...
@@ -38,12 +39,20 @@ Creates a **FormBindingData** object.
...
@@ -38,12 +39,20 @@ Creates a **FormBindingData** object.
> The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version.
> The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version.
>
> The APIs of this module can be used only in the stage model.
Provides **FormExtension** APIs.
Provides **FormExtension** APIs.
...
@@ -33,19 +36,20 @@ Called to notify the widget provider that a **Form** instance (widget) has been
...
@@ -33,19 +36,20 @@ Called to notify the widget provider that a **Form** instance (widget) has been
| want | [Want](js-apis-application-Want.md) | Yes | Information related to the extension, including the widget ID, name, and style. The information must be managed as persistent data to facilitate subsequent widget update and deletion.|
| want | [Want](js-apis-application-Want.md) | Yes | Information related to the extension, including the widget ID, name, and style. The information must be managed as persistent data to facilitate subsequent widget update and deletion.|
| [formBindingData.FormBindingData](js-apis-formbindingdata.md#formbindingdata) | A **formBindingData.FormBindingData** object containing the data to be displayed on the widget.|
| [formBindingData.FormBindingData](js-apis-formbindingdata.md#formbindingdata) | A **formBindingData.FormBindingData** object containing the data to be displayed on the widget.|
| want | [Want](js-apis-application-Want.md) | No | Description of the widget state, including the bundle name, ability name, module name, widget name, and widget dimension. |
> The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version.
> The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version.
>
> The APIs of this module can be used only in the stage model.
Implements the context that provides the capabilities and APIs of **FormExtension**. This class is inherited from **ExtensionContext**.
Implements the context that provides the capabilities and APIs of **FormExtension**. This class is inherited from **ExtensionContext**.
> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version.
> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version.
Provides APIs related to the widget host.
Provides APIs related to the widget host.
...
@@ -57,15 +58,15 @@ SystemCapability.Ability.Form
...
@@ -57,15 +58,15 @@ SystemCapability.Ability.Form
**Parameters**
**Parameters**
| Name| Type | Mandatory| Description |
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ------- |
| ------ | ------ | ---- | ------- |
| formId | string | Yes | ID of a widget.|
| formId | string | Yes | ID of a widget.|
**Return value**
**Return value**
| Type| Description|
| Type| Description|
| -------- | -------- |
| -------- | -------- |
| Promise<void> | Promise used to return the result indicating whether the API is successfully called.|
| Promise<void> | Promise used to return the result indicating whether the API is successfully called.|
> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version.
> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version.
...
@@ -15,6 +16,9 @@ missionManager provides APIs to lock, unlock, and clear missions, and switch a m
...
@@ -15,6 +16,9 @@ missionManager provides APIs to lock, unlock, and clear missions, and switch a m
import missionManager from '@ohos.application.missionManager'
import missionManager from '@ohos.application.missionManager'
```
```
## Required Permissions
ohos.permission.MANAGE_MISSIONS
## missionManager.registerMissionListener
## missionManager.registerMissionListener
...
@@ -26,24 +30,25 @@ Registers a listener to observe the mission status.
...
@@ -26,24 +30,25 @@ Registers a listener to observe the mission status.
**Parameters**
**Parameters**
| Name| Type| Mandatory| Description|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| -------- | -------- | -------- | -------- |
| listener | MissionListener | Yes| Listener to register.|
| listener | MissionListener | Yes| Listener to register.|
**Return value**
**Return value**
| Type| Description|
| Type| Description|
| -------- | -------- |
| -------- | -------- |
| number | Returns the unique index of the mission status listener, which is created by the system and allocated when the listener is registered.|
| number | Returns the unique index of the mission status listener, which is created by the system and allocated when the listener is registered.|
@@ -197,11 +205,11 @@ Obtains information about all missions. This API uses an asynchronous callback t
...
@@ -197,11 +205,11 @@ Obtains information about all missions. This API uses an asynchronous callback t
**Parameters**
**Parameters**
| Name| Type| Mandatory| Description|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| -------- | -------- | -------- | -------- |
| deviceId | string | Yes| Device ID. It is a null string by default for the local device.|
| deviceId | string | Yes| Device ID. It is a null string by default for the local device.|
| numMax | number | Yes| Maximum number of missions whose information can be obtained.|
| numMax | number | Yes| Maximum number of missions whose information can be obtained.|
| callback | AsyncCallback<Array<[MissionInfo](#missioninfo)>> | Yes| Callback used to return the array of mission information obtained.|
| callback | AsyncCallback<Array<[MissionInfo](#missioninfo)>> | Yes| Callback used to return the array of mission information obtained.|
**Example**
**Example**
...
@@ -226,16 +234,16 @@ Obtains information about all missions. This API uses a promise to return the re
...
@@ -226,16 +234,16 @@ Obtains information about all missions. This API uses a promise to return the re
**Parameters**
**Parameters**
| Name| Type| Mandatory| Description|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| -------- | -------- | -------- | -------- |
| deviceId | string | Yes| Device ID. It is a null string by default for the local device.|
| deviceId | string | Yes| Device ID. It is a null string by default for the local device.|
| numMax | number | Yes| Maximum number of missions whose information can be obtained.|
| numMax | number | Yes| Maximum number of missions whose information can be obtained.|
**Return value**
**Return value**
| Type| Description|
| Type| Description|
| -------- | -------- |
| -------- | -------- |
| Promise<Array<[MissionInfo](#missioninfo)>> | Promise used to return the array of mission information obtained.|
| Promise<Array<[MissionInfo](#missioninfo)>> | Promise used to return the array of mission information obtained.|
**Example**
**Example**
...
@@ -258,11 +266,11 @@ Obtains the snapshot of a given mission. This API uses an asynchronous callback
...
@@ -258,11 +266,11 @@ Obtains the snapshot of a given mission. This API uses an asynchronous callback
**Parameters**
**Parameters**
| Name| Type| Mandatory| Description|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| -------- | -------- | -------- | -------- |
| deviceId | string | Yes| Device ID. It is a null string by default for the local device.|
| deviceId | string | Yes| Device ID. It is a null string by default for the local device.|
| missionId | number | Yes| Mission ID.|
| missionId | number | Yes| Mission ID.|
| callback | AsyncCallback<[MissionSnapshot](js-apis-application-MissionSnapshot.md)> | Yes| Callback used to return the snapshot information obtained.|
| callback | AsyncCallback<[MissionSnapshot](js-apis-application-MissionSnapshot.md)> | Yes| Callback used to return the snapshot information obtained.|
**Example**
**Example**
...
@@ -293,31 +301,33 @@ Obtains the snapshot of a given mission. This API uses a promise to return the r
...
@@ -293,31 +301,33 @@ Obtains the snapshot of a given mission. This API uses a promise to return the r
**Parameters**
**Parameters**
| Name| Type| Mandatory| Description|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| -------- | -------- | -------- | -------- |
| deviceId | string | Yes| Device ID. It is a null string by default for the local device.|
| deviceId | string | Yes| Device ID. It is a null string by default for the local device.|
| missionId | number | Yes| Mission ID.|
| missionId | number | Yes| Mission ID.|
**Return value**
**Return value**
| Type| Description|
| Type| Description|
| -------- | -------- |
| -------- | -------- |
| Promise<[MissionSnapshot](js-apis-application-MissionSnapshot.md)> | Promise used to return the snapshot information obtained.|
| Promise<[MissionSnapshot](js-apis-application-MissionSnapshot.md)> | Promise used to return the snapshot information obtained.|
@@ -566,9 +578,9 @@ Clears all unlocked missions. This API uses a promise to return the result.
...
@@ -566,9 +578,9 @@ Clears all unlocked missions. This API uses a promise to return the result.
**Return value**
**Return value**
| Type| Description|
| Type| Description|
| -------- | -------- |
| -------- | -------- |
| Promise<void> | Promise used to return the result.|
| Promise<void> | Promise used to return the result.|
**Example**
**Example**
...
@@ -590,10 +602,10 @@ Switches a given mission to the foreground. This API uses an asynchronous callba
...
@@ -590,10 +602,10 @@ Switches a given mission to the foreground. This API uses an asynchronous callba
**Parameters**
**Parameters**
| Name| Type| Mandatory| Description|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| -------- | -------- | -------- | -------- |
| missionId | number | Yes| Mission ID.|
| missionId | number | Yes| Mission ID.|
| callback | AsyncCallback<void> | Yes| Callback used to return the result.|
| callback | AsyncCallback<void> | Yes| Callback used to return the result.|
**Example**
**Example**
...
@@ -623,11 +635,11 @@ Switches a given mission to the foreground, with the startup parameters for the
...
@@ -623,11 +635,11 @@ Switches a given mission to the foreground, with the startup parameters for the
**Parameters**
**Parameters**
| Name| Type| Mandatory| Description|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| -------- | -------- | -------- | -------- |
| missionId | number | Yes| Mission ID.|
| missionId | number | Yes| Mission ID.|
| options | StartOptions | Yes| Startup parameters, which are used to specify the window mode and device ID for switching the mission to the foreground.|
| options | StartOptions | Yes| Startup parameters, which are used to specify the window mode and device ID for switching the mission to the foreground.|
| callback | AsyncCallback<void> | Yes| Callback used to return the result.|
| callback | AsyncCallback<void> | Yes| Callback used to return the result.|
**Example**
**Example**
...
@@ -657,25 +669,26 @@ Switches a given mission to the foreground, with the startup parameters for the
...
@@ -657,25 +669,26 @@ Switches a given mission to the foreground, with the startup parameters for the
**Parameters**
**Parameters**
| Name| Type| Mandatory| Description|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| -------- | -------- | -------- | -------- |
| missionId | number | Yes| Mission ID.|
| missionId | number | Yes| Mission ID.|
| options | StartOptions | No| Startup parameters, which are used to specify the window mode and device ID for switching the mission to the foreground.|
| options | StartOptions | No| Startup parameters, which are used to specify the window mode and device ID for switching the mission to the foreground.|
**Return value**
**Return value**
| Type| Description|
| Type| Description|
| -------- | -------- |
| -------- | -------- |
| Promise<void> | Promise used to return the result.|
| Promise<void> | Promise used to return the result.|
> 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.
>
> The APIs of this module can be used only in the FA module.
## Constraints
## Usage
The ParticleAbility module is used to perform operations on abilities of the Data and Service types.
The ParticleAbility module is used to perform operations on abilities of the Data and Service types.
...
@@ -196,11 +199,11 @@ Requests a continuous task from the system. This API uses an asynchronous callba
...
@@ -196,11 +199,11 @@ Requests a continuous task from the system. This API uses an asynchronous callba
**Parameters**
**Parameters**
| Name| Type| Mandatory| Description|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| -------- | -------- | -------- | -------- |
| id | number | Yes| Notification ID of a continuous task.|
| id | number | Yes| Notification ID of a continuous task.|
| request | NotificationRequest | Yes| Notification parameter, which is used to display information in the notification bar.|
| request | NotificationRequest | Yes| Notification parameter, which is used to display information in the notification bar.|
| callback | AsyncCallback<void> | Yes| Callback used to return the result.|
| callback | AsyncCallback<void> | Yes| Callback used to return the result.|
> The initial APIs of this module are supported since API 9. Newly added APIs will be marked with a superscript to indicate their earliest API version.
> The initial APIs of this module are supported since API 9. Newly added APIs will be marked with a superscript to indicate their earliest API version.
>
> The APIs of this module can be used only in the stage model.
Provides the permission request result.
Provides the permission request result.
## Modules to Import
```js
importAbilityfrom'@ohos.application.Ability'
```
## Usage
The permission request result is obtained through an **AbilityStage** instance.
| authResults | Array<number> | Yes| No| Whether the requested permissions are granted or denied. The value **0** means that the requests permissions are granted, and **-1** means the opposite. |
| authResults | Array<number> | Yes| No| Whether the requested permissions are granted or denied. The value **0** means that the requests permissions are granted, and **-1** means the opposite. |
> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version.
> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version.
> The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version.
> The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version.
>
> The APIs of this module can be used only in the stage model.
| context | [ServiceExtensionContext](js-apis-service-extension-context.md) | Yes| No| Service extension context, which is inherited from **ExtensionContext**.|
| context | [ServiceExtensionContext](js-apis-service-extension-context.md) | Yes| No| Service extension context, which is inherited from **ExtensionContext**.|
## ServiceExtensionAbility.onCreate
## ServiceExtensionAbility.onCreate
...
@@ -38,9 +41,9 @@ Called when an extension is created to initialize the service logic.
...
@@ -38,9 +41,9 @@ Called when an extension is created to initialize the service logic.
**Parameters**
**Parameters**
| Name| Type| Mandatory| Description|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| -------- | -------- | -------- | -------- |
| want | [Want](js-apis-application-Want.md) | Yes| Information related to this extension, including the ability name and bundle name.|
| want | [Want](js-apis-application-Want.md) | Yes| Information related to this extension, including the ability name and bundle name.|
**Example**
**Example**
...
@@ -82,10 +85,10 @@ Called after **onCreate** is invoked when an ability is started by calling **sta
...
@@ -82,10 +85,10 @@ Called after **onCreate** is invoked when an ability is started by calling **sta
**Parameters**
**Parameters**
| Name| Type| Mandatory| Description|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| -------- | -------- | -------- | -------- |
| want | [Want](js-apis-application-Want.md) | Yes| Information related to this extension, including the ability name and bundle name.|
| want | [Want](js-apis-application-Want.md) | Yes| Information related to this extension, including the ability name and bundle name.|
| startId | number | Yes| Number of ability start times. The initial value is **1**, and the value is automatically incremented for each ability started.|
| startId | number | Yes| Number of ability start times. The initial value is **1**, and the value is automatically incremented for each ability started.|
**Example**
**Example**
...
@@ -108,15 +111,15 @@ Called after **onCreate** is invoked when an ability is started by calling **con
...
@@ -108,15 +111,15 @@ Called after **onCreate** is invoked when an ability is started by calling **con
**Parameters**
**Parameters**
| Name| Type| Mandatory| Description|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| -------- | -------- | -------- | -------- |
| want | [Want](js-apis-application-Want.md)| Yes| Information related to this extension, including the ability name and bundle name.|
| want | [Want](js-apis-application-Want.md)| Yes| Information related to this extension, including the ability name and bundle name.|
**Return value**
**Return value**
| Type| Description|
| Type| Description|
| -------- | -------- |
| -------- | -------- |
| rpc.RemoteObject | A **RemoteObject** object used for communication with the client.|
| rpc.RemoteObject | A **RemoteObject** object used for communication with the client.|
**Example**
**Example**
...
@@ -126,7 +129,7 @@ Called after **onCreate** is invoked when an ability is started by calling **con
...
@@ -126,7 +129,7 @@ Called after **onCreate** is invoked when an ability is started by calling **con
constructor(des){
constructor(des){
super(des);
super(des);
}
}
onRemoteRequest(code,data,reply,option){
onConnect(code,data,reply,option){
}
}
}
}
classServiceExtextendsServiceExtension{
classServiceExtextendsServiceExtension{
...
@@ -148,9 +151,9 @@ Called when the ability is disconnected.
...
@@ -148,9 +151,9 @@ Called when the ability is disconnected.
**Parameters**
**Parameters**
| Name| Type| Mandatory| Description|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| -------- | -------- | -------- | -------- |
| want |[Want](js-apis-application-Want.md)| Yes| Information related to this extension, including the ability name and bundle name.|
| want |[Want](js-apis-application-Want.md)| Yes| Information related to this extension, including the ability name and bundle name.|
> The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version.
> The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version.
>
> The APIs of this module can be used only in the stage model.
Implements the context that provides the capabilities and APIs of **ServiceExtension**. This class is inherited from **ExtensionContext**.
Implements the context that provides the capabilities and APIs of **ServiceExtension**. This class is inherited from **ExtensionContext**.
## Modules to Import
```
import ExtensionContext from '@ohos.application.ServiceExtensionAbility';
```
## startAbility
## startAbility
...
@@ -17,21 +25,26 @@ Starts an ability. This API uses a callback to return the result.
...
@@ -17,21 +25,26 @@ Starts an ability. This API uses a callback to return the result.
**Parameters**
**Parameters**
| Name| Type| Mandatory| Description|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| -------- | -------- | -------- | -------- |
| want | [Want](js-apis-application-Want.md) | Yes| Information about the ability to start, such as the ability name and bundle name.|
| want | [Want](js-apis-application-Want.md) | Yes| Information about the ability to start, such as the ability name and bundle name.|
| callback | AsyncCallback<void> | No| Callback used to return the result indicating whether the API is successfully called.|
| callback | AsyncCallback<void> | No| Callback used to return the result indicating whether the API is successfully called.|
@@ -128,23 +161,23 @@ Connects this ability to a Service ability.
...
@@ -128,23 +161,23 @@ Connects this ability to a Service ability.
**Parameters**
**Parameters**
| Name| Type| Mandatory| Description|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| -------- | -------- | -------- | -------- |
| want | [Want](js-apis-application-Want.md) | Yes| Information about the ability to connect to, such as the ability name and bundle name.|
| want | [Want](js-apis-application-Want.md) | Yes| Information about the ability to connect to, such as the ability name and bundle name.|
| options | [ConnectOptions](#connectoptions) | Yes| Callback used to return the information indicating that the connection is successful, interrupted, or failed.|
| options | [ConnectOptions](#connectoptions) | Yes| Callback used to return the information indicating that the connection is successful, interrupted, or failed.|
**Return value**
**Return value**
| Type| Description|
| Type| Description|
| -------- | -------- |
| -------- | -------- |
| number | A number, based on which the connection will be interrupted.|
| number | A number, based on which the connection will be interrupted.|
**Example**
**Example**
```js
```js
letwant={
letwant={
"bundleName":"com.example.myapp",
"bundleName":"com.example.myapp",
"abilityName":"com.example.myapp.MyAbility"
"abilityName":"MyAbility"
};
};
letoptions={
letoptions={
onConnect:function(elementName,proxy){},
onConnect:function(elementName,proxy){},
...
@@ -165,17 +198,26 @@ Disconnects this ability from the Service ability. This API uses a callback to r
...
@@ -165,17 +198,26 @@ Disconnects this ability from the Service ability. This API uses a callback to r
**Parameters**
**Parameters**
| Name| Type| Mandatory| Description|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| -------- | -------- | -------- | -------- |
| connection | number | Yes| Number returned after **connectAbility** is called.|
| connection | number | Yes| Number returned after **connectAbility** is called.|
| callback | AsyncCallback<void> | No| Callback used to return the result indicating whether the API is successfully called.|
| callback | AsyncCallback<void> | No| Callback used to return the result indicating whether the API is successfully called.|
**Example**
**Example**
```js
```js
this.context.disconnectAbility(connection,(err)=>{// connection is the return value of connectAbility.
> The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version.
> The 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.
...
@@ -11,7 +12,7 @@ Implements URI permission management.
...
@@ -11,7 +12,7 @@ Implements URI permission management.
```
```
import uriPermissionManager from '@ohos.application.uriPermissionManager';
import UriPermissionManager from '@ohos.application.uriPermissionManager';
| uri | string | Yes | URI of a file, for example, **fileshare:///com.samples.filesharetest.FileShare/person/10**. |
| 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. |
| 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. |
| accessTokenId | number | Yes | Unique ID of an application, which is obtained through the **BundleManager** API. |
| callback | AsyncCallback<number> | Yes | Callback used to return the check result. The value **0** means that the application has the specified permission, and **-1** means the opposite. |
| callback | AsyncCallback<number> | Yes | Callback used to return the check result. The value **0** means that the application has the specified permission, and **-1** means the opposite. |
| uri | string | Yes | URI of a file, for example, **fileshare:///com.samples.filesharetest.FileShare/person/10**. |
| 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. |
| 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. |
| accessTokenId | number | Yes | Unique ID of an application, which is obtained through the **BundleManager** API. |
**Return value**
**Return value**
| Type | Description |
| Type | Description |
| -------- | -------- |
| -------- | -------- |
| Promise<number> | Promise used to return the check result. The value **0** means that the application has the specified permission, and **-1** means the opposite. |
| Promise<number> | Promise used to return the check result. The value **0** means that the application has the specified permission, and **-1** means the opposite. |