未验证 提交 d8450cf9 编写于 作者: O openharmony_ci 提交者: Gitee

!2827 Done! 2448:Fix format and content error of ability api

Merge pull request !2827 from wusongqing/TR2448
# AbilityContext
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**
> The initial APIs of this module are supported since API 9. Newly added APIs will be marked with a superscript to indicate their earliest API version.
> The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version.
Implements the ability context. This module is inherited from **Context**.
......@@ -13,7 +13,7 @@ Implements the ability context. This module is inherited from **Context**.
Before using the **AbilityContext** module, you must define a child class that inherits from **Ability**.
```js
import Ability from '@ohos.application.Ability'
class MainAbility extends Ability {
......@@ -26,10 +26,12 @@ class MainAbility extends Ability {
## Attributes
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
| Name| Type| Readable| Writable| Description|
| -------- | -------- | -------- | -------- | -------- |
| abilityInfo | AbilityInfo | Yes| No| Ability information.<br>**System capability**: SystemCapability.Ability.AbilityRuntime.Core|
| currentHapModuleInfo | HapModuleInfo | Yes| No| Information about the current HAP.<br>**System capability**: SystemCapability.Ability.AbilityRuntime.Core|
| abilityInfo | AbilityInfo | Yes| No| Ability information.|
| currentHapModuleInfo | HapModuleInfo | Yes| No| Information about the current HAP.|
## AbilityContext.startAbility
......@@ -250,7 +252,7 @@ Terminates this ability. This API uses a callback to return the result.
```js
this.context.terminateSelf((err) => {
console.log('terminateSelf result:' + JSON.stringfy(err));
console.log('terminateSelf result:' + JSON.stringify(err));
});
```
......@@ -273,9 +275,9 @@ Terminates this ability. This API uses a promise to return the result.
```js
this.context.terminateSelf(want).then((data) => {
console.log('success:' + JSON.stringfy(data));
console.log('success:' + JSON.stringify(data));
}).catch((error) => {
console.log('failed:' + JSON.stringfy(error));
console.log('failed:' + JSON.stringify(error));
});
```
......@@ -404,7 +406,7 @@ Requests permissions from the user by displaying a pop-up window. This API uses
```
this.context.requestPermissionsFromUser(permissions,(result) => {
console.log('requestPermissionsFromUserresult:' + JSON.stringfy(result));
console.log('requestPermissionsFromUserresult:' + JSON.stringify(result));
});
```
......@@ -433,9 +435,9 @@ Requests permissions from the user by displaying a pop-up window. This API uses
```
this.context.requestPermissionsFromUser(permissions).then((data) => {
console.log('success:' + JSON.stringfy(data));
console.log('success:' + JSON.stringify(data));
}).catch((error) => {
console.log('failed:' + JSON.stringfy(error));
console.log('failed:' + JSON.stringify(error));
});
```
......@@ -459,7 +461,7 @@ Sets the label of the ability displayed in the task. This API uses a callback to
```js
this.context.setMissionLabel("test",(result) => {
console.log('requestPermissionsFromUserresult:' + JSON.stringfy(result));
console.log('requestPermissionsFromUserresult:' + JSON.stringify(result));
});
```
......@@ -488,8 +490,8 @@ Sets the label of the ability displayed in the task. This API uses a promise to
```js
this.context.setMissionLabel("test").then((data) => {
console.log('success:' + JSON.stringfy(data));
console.log('success:' + JSON.stringify(data));
}).catch((error) => {
console.log('failed:' + JSON.stringfy(error));
console.log('failed:' + JSON.stringify(error));
});
```
# ErrorCode
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**
> The initial APIs of this module are supported since API version 6. Newly added APIs will be marked with a superscript to indicate their earliest API version.
## Modules to Import
```
import errorCode from '@ohos.ability.errorCode'
```
## ErrorCode
Defines the error code used when the ability is started.
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
| Name | Value | Description |
| ------------------------------ | ---- | ---------------------------------------- |
| NO_ERROR | 0 | No error occurs. |
| INVALID_PARAMETER | -1 | Invalid parameter.|
| ABILITY_NOT_FOUND | -2 | The ability is not found.|
| PERMISSION_DENY | -3 | Permission denied. |
# wantConstant
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**
> The initial APIs of this module are supported since API version 6. Newly added APIs will be marked with a superscript to indicate their earliest API version.
## Modules to Import
```
import wantConstant from '@ohos.ability.wantConstant'
```
## wantConstant.Action
**System capability**: SystemCapability.Ability.AbilityBase
Lists the permissions.
| Common Event Macro | Common Event Name | Subscriber Permission |
| ------------ | ------------------ | ---------------------- |
| ACTION_HOME | ohos.want.action.home | None |
| ACTION_DIAL | ohos.want.action.dial | None |
| ACTION_SEARCH | ohos.want.action.search | None |
| ACTION_WIRELESS_SETTINGS | ohos.settings.wireless | None |
| ACTION_MANAGE_APPLICATIONS_SETTINGS | ohos.settings.manage.applications | None |
| ACTION_APPLICATION_DETAILS_SETTINGS | ohos.settings.application.details | None |
| ACTION_SET_ALARM | ohos.want.action.setAlarm | None |
| ACTION_SHOW_ALARMS | ohos.want.action.showAlarms | None |
| ACTION_SNOOZE_ALARM | ohos.want.action.snoozeAlarm | None |
| ACTION_DISMISS_ALARM | ohos.want.action.dismissAlarm | None |
| ACTION_DISMISS_TIMER | ohos.want.action.dismissTimer | None |
| ACTION_SEND_SMS | ohos.want.action.sendSms | None |
| ACTION_CHOOSE | ohos.want.action.choose | None |
| ACTION_IMAGE_CAPTURE<sup>8+</sup> | ohos.want.action.imageCapture | None |
| ACTION_VIDEO_CAPTUR<sup>8+</sup> | ohos.want.action.videoCapture | None |
| ACTION_SELECT | ohos.want.action.select | None |
| ACTION_SEND_DATA | ohos.want.action.sendData | None |
| ACTION_SEND_MULTIPLE_DATA | ohos.want.action.sendMultipleData | None |
| ACTION_SCAN_MEDIA_FILE | ohos.want.action.scanMediaFile | None |
| ACTION_VIEW_DATA | ohos.want.action.viewData | None |
| ACTION_EDIT_DATA | ohos.want.action.editData | None |
| INTENT_PARAMS_INTENT | ability.want.params.INTENT | None |
| INTENT_PARAMS_TITLE | ability.want.params.TITLE | None |
| ACTION_FILE_SELECT<sup>7+</sup> | ohos.action.fileSelect | None |
| PARAMS_STREAM<sup>7+</sup> | ability.params.stream | None |
| ACTION_APP_ACCOUNT_OAUTH <sup>8+</sup> | ohos.account.appAccount.action.oauth | None |
## wantConstant.Entity
**System capability**: SystemCapability.Ability.AbilityBase
Lists the permissions.
| Common Event Macro | Common Event Name | Subscriber Permission |
| ------------ | ------------------ | ---------------------- |
| ENTITY_DEFAULT | entity.system.default | None |
| ENTITY_HOME | entity.system.homel | None |
| ENTITY_VOICE | ENTITY_VOICE | None |
| ENTITY_BROWSABLE | entity.system.browsable | None |
| ENTITY_VIDEO | entity.system.video | None |
| ACTION_APPLICATION_DETAILS_SETTINGS | ohos.settings.application.details | None |
## flags
**System capability**: SystemCapability.Ability.AbilityBase
| Name | Value | Description |
| ------------------------------------ | ---------- | ------------------------------------------------------------ |
| FLAG_AUTH_READ_URI_PERMISSION | 0x00000001 | Indicates the permission to read the URI. |
| FLAG_AUTH_WRITE_URI_PERMISSION | 0x00000002 | Indicates the permission to write the URI. |
| FLAG_ABILITY_FORWARD_RESULT | 0x00000004 | Returns the result to the ability. |
| FLAG_ABILITY_CONTINUATION | 0x00000008 | Indicates whether the ability on the local device can be continued on a remote device. |
| FLAG_NOT_OHOS_COMPONENT | 0x00000010 | Indicates that a component does not belong to OHOS. |
| FLAG_ABILITY_FORM_ENABLED | 0x00000020 | Indicates that an ability is enabled. |
| FLAG_AUTH_PERSISTABLE_URI_PERMISSION | 0x00000040 | Indicates the permission to make the URI persistent. |
| FLAG_AUTH_PREFIX_URI_PERMISSION | 0x00000080 | Indicates the permission to verify URIs by prefix matching. |
| FLAG_ABILITYSLICE_MULTI_DEVICE | 0x00000100 | Supports cross-device startup in a distributed scheduler. |
| FLAG_START_FOREGROUND_ABILITY | 0x00000200 | Indicates that the Service ability is started regardless of whether the host application has been started. |
| FLAG_ABILITY_CONTINUATION_REVERSIBLE | 0x00000400 | Indicates that ability continuation is reversible. |
| FLAG_INSTALL_ON_DEMAND | 0x00000800 | Indicates that the specific ability will be installed if it has not been installed. |
| FLAG_INSTALL_WITH_BACKGROUND_MODE | 0x80000000 | Indicates that the specific ability will be installed in the background if it has not been installed. |
| FLAG_ABILITY_CLEAR_MISSION | 0x00008000 | Clears other operation missions. This flag can be set for the **Want** object in the **startAbility** API passed to [ohos.app.Context](js-apis-ability-context.md) and must be used together with **flag_ABILITY_NEW_MISSION**.|
| FLAG_ABILITY_NEW_MISSION | 0x10000000 | Indicates the operation of creating a mission on the history mission stack. |
| FLAG_ABILITY_MISSION_TOP | 0x20000000 | Starts the mission on the top of the existing mission stack; creates an ability instance if no mission exists.|
......@@ -22,6 +22,7 @@ abilitymanager.getAbilityRunningInfos((err,data) => {
```
## Attributes
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
| Name| Type| Readable| Writable| Description|
......@@ -31,10 +32,11 @@ abilitymanager.getAbilityRunningInfos((err,data) => {
| uid | number | Yes| No| User ID. |
| processName | string | Yes| No| Process name. |
| startTime | number | Yes| No| Ability start time. |
| abilityState | [abilityManager.AbilityState](#abilitymanager-abilitystate) | Yes| No| Ability state. |
| abilityState | [abilityManager.AbilityState](#abilitymanagerabilitystate) | Yes| No| Ability state. |
## abilityManager.AbilityState
Enumerates the ability states.
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
......
......@@ -25,6 +25,7 @@ class MyAbilityStage extends AbilityStage {
## Attributes
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
| Name| Type| Readable| Writable| Description|
......
# DataShareExtensionAbility
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**
> The APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version.
Provides the Extension ability for data sharing.
## Modules to Import
```
import DataShareExtensionAbility from '@ohos.application.DataShareExtensionAbility';
```
## Attributes
**System capability**: SystemCapability.DistributedDataManager.DataShare.Provider
| Name| Readable| Writable| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | -------- | -------- |
| context | Yes| No| ExtensionContext | No| Context of the Data Share Extension ability.|
## DataShareExtensionAbility.onCreate
onCreate?(want: Want): void;
Called when the Data Share Extension ability is initialized.
**System capability**: SystemCapability.DistributedDataManager.DataShare.Provider
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| want | Want | Yes| Connection information about the Data Share Extension ability.|
**Example**
```js
class myAbility extends DataShareExtensionAbility {
onCreate(want) {
console.log('onCreate, want:' + want.abilityName);
}
}
```
## DataShareExtensionAbility.getFileTypes
getFileTypes?(uri: string, mimeTypeFilter: string, callback: AsyncCallback<Array\<string>>): void
Obtains the supported MIME types of a specified file. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.DistributedDataManager.DataShare.Provider
**Parameters**
| Name | Type | Mandatory| Description |
| -------------- | ------------------------------ | ---- | ---------------------------------- |
| uri | string | Yes | URI of the file. |
| mimeTypeFilter | string | Yes | MIME type of the file. |
| callback | AsyncCallback\<Array\<string>> | Yes | Callback used to return the supported MIME types.|
**Example**
```js
import featureAbility from '@ohos.ability.featureAbility'
var DAHelper = featureAbility.acquireDataAbilityHelper(
"dataability:///com.example.DataAbility"
);
DAHelper.getFileTypes(
"dataability:///com.example.DataAbility",
"image/*",
(err, data) => {
console.info("==========================>Called=======================>");
});
```
## DataShareExtensionAbility.insert
insert?(uri: string, valueBucket: rdb.ValuesBucket, callback: AsyncCallback\<number>): void
Inserts a single data record into the database. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.DistributedDataManager.DataShare.Provider
**Parameters**
| Name | Type | Mandatory| Description |
| ------------ | ---------------------- | ---- | ------------------------------------------------------ |
| uri | string | Yes | URI of the data to insert. |
| valuesBucket | rdb.ValuesBucket | Yes | Data record to insert. If this parameter is **null**, a blank row will be inserted.|
| callback | AsyncCallback\<number> | Yes | Callback used to return the index of the inserted data record. |
**Example**
```js
import featureAbility from '@ohos.ability.featureAbility'
var DAHelper = featureAbility.acquireDataAbilityHelper(
"dataability:///com.example.DataAbility"
);
const valueBucket = {
"name": "rose",
"age": 22,
"salary": 200.5,
"blobType": u8,
}
DAHelper.insert(
"dataability:///com.example.DataAbility",
valueBucket,
(err, data) => {
console.info("==========================>Called=======================>");
});
```
## DataShareExtensionAbility.update
update?(uri: string, valueBucket: rdb.ValuesBucket, predicates: dataAbility.DataAbilityPredicates, callback: AsyncCallback\<number>): void
Updates one or more data records in the database. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.DistributedDataManager.DataShare.Provider
**Parameters**
| Name | Type | Mandatory| Description |
| ------------ | --------------------------------- | ---- | ------------------------------------------------ |
| uri | string | Yes | URI of the data to update. |
| valuesBucket | rdb.ValuesBucket | Yes | New data. |
| predicates | dataAbility.DataAbilityPredicates | Yes | Filter criteria. You should define the processing logic when this parameter is **null**.|
| callback | AsyncCallback\<number> | Yes | Callback used to return the number of updated data records. |
**Example**
```js
import featureAbility from '@ohos.ability.featureAbility'
import ohos_data_ability from '@ohos.data.dataability'
var DAHelper = featureAbility.acquireDataAbilityHelper(
"dataability:///com.example.DataAbility"
);
const va = {
"name": "roe1",
"age": 21,
"salary": 20.5,
"blobType": u8,
}
let da = new ohos_data_ability.DataAbilityPredicates()
DAHelper.update(
"dataability:///com.example.DataAbility",
va,
da,
(err, data) => {
console.info("==========================>Called=======================>");
});
```
## DataShareExtensionAbility.delete
delete?(uri: string, predicates: dataAbility.DataAbilityPredicates, callback: AsyncCallback\<number>): void
Deletes one or more data records from the database. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.DistributedDataManager.DataShare.Provider
**Parameters**
| Name | Type | Mandatory| Description |
| ------------ | --------------------------------- | ---- | ------------------------------------------------ |
| uri | string | Yes | URI of the data to delete. |
| valuesBucket | dataAbility.DataAbilityPredicates | Yes | Filter criteria. You should define the processing logic when this parameter is **null**.|
| callback | AsyncCallback\<number> | Yes | Callback used to return the number of deleted data records. |
**Example**
```js
import featureAbility from '@ohos.ability.featureAbility'
import ohos_data_ability from '@ohos.data.dataability'
var DAHelper = featureAbility.acquireDataAbilityHelper(
"dataability:///com.example.DataAbility"
);
let da = new ohos_data_ability.DataAbilityPredicates()
DAHelper.delete(
"dataability:///com.example.DataAbility",
da,
(err, data) => {
console.info("==========================>Called=======================>");
});
```
## DataShareExtensionAbility.query
query?(uri: string, columns: Array\<string>, predicates: dataAbility.DataAbilityPredicates, callback: AsyncCallback\<ResultSet>): void
Queries data in the database. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.DistributedDataManager.DataShare.Provider
**Parameters**
| Name | Type | Mandatory| Description |
| ---------- | --------------------------------- | ---- | ------------------------------------------------ |
| uri | string | Yes | URI of the data to query. |
| columns | rdb.ValuesBucket | Yes | Columns to query. If this parameter is **null**, all columns will be queried. |
| predicates | dataAbility.DataAbilityPredicates | Yes | Filter criteria. You should define the processing logic when this parameter is **null**.|
| callback | AsyncCallback\<ResultSet> | Yes | Callback used to return the query result. |
**Example**
```js
import featureAbility from '@ohos.ability.featureAbility'
import ohos_data_ability from '@ohos.data.dataability'
var DAHelper = featureAbility.acquireDataAbilityHelper(
"dataability:///com.example.DataAbility"
);
var cars=new Array("value1", "value2", "value3", "value4");
let da = new ohos_data_ability.DataAbilityPredicates()
DAHelper.query(
"dataability:///com.example.DataAbility",
cars,
da,
(err, data) => {
console.info("==========================>Called=======================>");
});
```
## DataShareExtensionAbility.getType
getType?(uri: string, callback: AsyncCallback\<string>): void
Obtains the MIME type of the data specified by a given URI. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.DistributedDataManager.DataShare.Provider
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ---------------------- | ---- | --------------------------------------------- |
| uri | string | Yes | URI of the data. |
| callback | AsyncCallback\<string> | Yes | Callback used to return the MIME type.|
**Example**
```js
import featureAbility from '@ohos.ability.featureAbility'
var DAHelper = featureAbility.acquireDataAbilityHelper(
"dataability:///com.example.DataAbility"
);
DAHelper.getType(
"dataability:///com.example.DataAbility",
(err, data) => {
console.info("==========================>Called=======================>");
});
```
## DataShareExtensionAbility.batchInsert
batchInsert?(uri: string, valueBuckets: Array<rdb.ValuesBucket>, callback: AsyncCallback\<number>): void
Inserts multiple data records into the database. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.DistributedDataManager.DataShare.Provider
**Parameters**
| Name | Type | Mandatory| Description |
| ------------ | ----------------------- | ---- | -------------------------------- |
| uri | string | Yes | URI of the data to insert. |
| valuesBucket | Array<rdb.ValuesBucket> | Yes | Data record to insert. |
| callback | AsyncCallback\<number> | Yes | Callback used to return the number of inserted data records.|
**Example**
```js
import featureAbility from '@ohos.ability.featureAbility'
var DAHelper = featureAbility.acquireDataAbilityHelper(
"dataability:///com.example.DataAbility"
);
var cars = new Array({"name": "roe11", "age": 21, "salary": 20.5, "blobType": u8,},
{"name": "roe12", "age": 21, "salary": 20.5, "blobType": u8,},
{"name": "roe13", "age": 21, "salary": 20.5, "blobType": u8,})
DAHelper.batchInsert(
"dataability:///com.example.DataAbility",
cars,
(err, data) => {
console.info("==========================>Called=======================>");
});
```
## DataShareExtensionAbility.normalizeUri
normalizeUri?(uri: string, callback: AsyncCallback\<string>): void
Converts the URI that refers to the Data ability into a normalized URI. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.DistributedDataManager.DataShare.Provider
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ---------------------- | ---- | ------------------------------------------------------------ |
| uri | string | Yes | URI object to normalize. |
| callback | AsyncCallback\<string> | Yes | Callback used to return the normalized URI object if the Data ability supports URI normalization. If the Data ability does not support URI normalization, **null** is returned.|
**Example**
```js
import featureAbility from '@ohos.ability.featureAbility'
var DAHelper = featureAbility.acquireDataAbilityHelper(
"dataability:///com.example.DataAbility"
);
DAHelper.normalizeUri(
"dataability:///com.example.DataAbility",
(err, data) => {
console.info("==========================>Called=======================>");
});
```
## DataShareExtensionAbility.denormalizeUri
denormalizeUri?(uri: string, callback: AsyncCallback\<string>): void
Converts a normalized URI generated by **normalizeUri** to a denormalized one. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.DistributedDataManager.DataShare.Provider
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ---------------------- | ---- | --------------------------------------------------- |
| uri | string | Yes | URI object to denormalize. |
| callback | AsyncCallback\<string> | Yes | Callback used to return the denormalized URI object.|
**Example**
```js
import featureAbility from '@ohos.ability.featureAbility'
var DAHelper = featureAbility.acquireDataAbilityHelper(
"dataability:///com.example.DataAbility"
);
DAHelper.denormalizeUri(
"dataability:///com.example.DataAbility",
(err, data) => {
console.info("==========================>Called=======================>");
});
```
# MissionSnapshot
> **NOTE**
> The initial APIs of this module are supported since API 8.
> ![icon-note.gif](public_sys-resources/icon-note.gif)**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 snapshot of a mission.
......@@ -10,8 +10,6 @@ Provides snapshot of a mission.
## Modules to Import
Import ElementName and image before use.
```
import { ElementName } from '../bundle/elementName';
......
# StartOptions
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**
> The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version.
**StartOptions** is the basic communication component of the system.
## Modules to Import
```
import StartOptions from '@ohos.application.StartOptions';
```
## Attributes
**System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore
| Name| Readable| Writable| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | -------- | -------- |
| windowMode | Yes| No| number | No| Window mode.|
| displayId | Yes| No| number | No| Display ID.|
# Ability
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**
> The APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version.
> The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version.
Manages the ability lifecycle and context.
......@@ -16,11 +16,13 @@ import Ability from '@ohos.application.Ability';
## Attributes
**System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore
| Name| Type| Readable| Writable| Description|
| -------- | -------- | -------- | -------- | -------- |
| context | [AbilityContext](js-apis-ability-context.md) | Yes| No| Context of an ability.<br>**System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore|
| launchWant | [Want](js-apis-featureAbility.md#Want)| Yes| No| Parameters for starting the ability.<br>**System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore|
| lastRequestWant | [Want](js-apis-featureAbility.md#Want)| Yes| No| Parameters used when the ability was started last time.<br>**System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore|
| context | [AbilityContext](js-apis-ability-context.md) | Yes| No| Context of an ability.|
| launchWant | [Want](js-apis-featureAbility.md#Want)| Yes| No| Parameters for starting the ability.|
| lastRequestWant | [Want](js-apis-featureAbility.md#Want)| Yes| No| Parameters used when the ability was started last time.|
## Ability.onCreate
......@@ -245,7 +247,7 @@ Called when the configuration of the environment where the ability is running is
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| config | [Configuration](#section188911144124715) | Yes| New configuration.|
| config | [Configuration](js-apis-configuration.md) | Yes| New configuration.|
**Example**
......@@ -363,7 +365,6 @@ Sends sequenceable data to the target ability and obtains the sequenceable data
this.name = name;
this.str = str;
}
constructor() {}
marshalling(messageParcel) {
messageParcel.writeInt(this.num);
messageParcel.writeString(this.str);
......@@ -380,7 +381,6 @@ Sends sequenceable data to the target ability and obtains the sequenceable data
var method = 'call_Function';
var caller;
export default class MainAbility extends Ability {
onWindowStageCreate(windowStage) {
onWindowStageCreate(windowStage) {
this.context.startAbilityByCall({
bundleName: "com.example.myservice",
......@@ -573,15 +573,19 @@ Unregisters a caller notification callback, which is invoked when the target abi
(msg: string): void;
**System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore
| Name| Type| Readable| Writable| Description|
| -------- | -------- | -------- | -------- | -------- |
| (msg: string) | function | Yes| No| Prototype of the listener function interface registered by the caller.<br>**System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore |
| (msg: string) | function | Yes| No| Prototype of the listener function interface registered by the caller.|
## CaleeCallBack
(indata: rpc.MessageParcel): rpc.Sequenceable;
**System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore
| Name| Type| Readable| Writable| Description|
| -------- | -------- | -------- | -------- | -------- |
| (indata: rpc.MessageParcel) | rpc.Sequenceable | Yes| No| Prototype of the message listener function interface registered by the callee.<br>**System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore |
| (indata: rpc.MessageParcel) | rpc.Sequenceable | Yes| No| Prototype of the message listener function interface registered by the callee.|
# AbilityConstant
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**
> The initial APIs of this module are supported since API version 9.
> The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version.
Provides parameters related to ability launch.
......@@ -9,7 +9,7 @@ Provides parameters related to ability launch.
## Modules to Import
```js
import AbilityConstant from '@ohos.application.AbilityConstant';
```
......@@ -17,40 +17,48 @@ import AbilityConstant from '@ohos.application.AbilityConstant';
## Attributes
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
| Name| Type| Readable| Writable| Description|
| -------- | -------- | -------- | -------- | -------- |
| launchReason | LaunchReason| Yes| Yes| Ability launch reason.<br>**System capability**: SystemCapability.Ability.AbilityRuntime.Core|
| lastExitReason | LastExitReason | Yes| Yes| Reason for the last exit.<br>**System capability**: SystemCapability.Ability.AbilityRuntime.Core|
| launchReason | LaunchReason| Yes| Yes| Ability launch reason.|
| lastExitReason | LastExitReason | Yes| Yes| Reason for the last exit.|
## AbilityConstant.LaunchReason
Enumerates ability launch reasons.
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
| Name | Value | Description |
| ----------------------------- | ---- | ------------------------------------------------------------ |
| UNKNOWN | 0 | Unknown reason.<br>**System capability**: SystemCapability.Ability.AbilityRuntime.Core|
| START_ABILITY | 1 | Ability startup.<br>**System capability**: SystemCapability.Ability.AbilityRuntime.Core|
| CALL | 2 | Call.<br>**System capability**: SystemCapability.Ability.AbilityRuntime.Core|
| CONTINUATION | 3 | Ability continuation.<br>**System capability**: SystemCapability.Ability.AbilityRuntime.Core|
| UNKNOWN | 0 | Unknown reason.|
| START_ABILITY | 1 | Ability startup.|
| CALL | 2 | Call.|
| CONTINUATION | 3 | Ability continuation.|
## AbilityConstant.LaunchReason
## AbilityConstant.LastExitReason
Enumerates reasons for the last exit.
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
| Name | Value | Description |
| ----------------------------- | ---- | ------------------------------------------------------------ |
| UNKNOWN | 0 | Unknown reason.<br>**System capability**: SystemCapability.Ability.AbilityRuntime.Core|
| ABILITY_NOT_RESPONDING | 1 | The ability does not respond.<br>**System capability**: SystemCapability.Ability.AbilityRuntime.Core|
| NORMAL | 2 | Normal status.<br>**System capability**: SystemCapability.Ability.AbilityRuntime.Core|
| UNKNOWN | 0 | Unknown reason.|
| ABILITY_NOT_RESPONDING | 1 | The ability does not respond.|
| NORMAL | 2 | Normal status.|
## AbilityConstant.OnContinueResult
Enumerates ability continuation results.
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
| Name | Value | Description |
| ----------------------------- | ---- | ------------------------------------------------------------ |
| AGREE | 0 | Continuation agreed.<br>**System capability**: SystemCapability.Ability.AbilityRuntime.Core|
| REJECT | 1 | Continuation denied.<br>**System capability**: SystemCapability.Ability.AbilityRuntime.Core|
| MISMATCH | 2 | Mismatch.<br>**System capability**: SystemCapability.Ability.AbilityRuntime.Core|
| AGREE | 0 | Continuation agreed.|
| REJECT | 1 | Continuation denied.|
| MISMATCH | 2 | Mismatch.|
......@@ -94,6 +94,8 @@ Called when the global configuration is updated.
Describes the configuration information about the context.
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
| Name | Type | Description |
| ----------- | --------------------------- | ------------------------------------------------------------ |
| context | [AbilityStageContext](js-apis-featureAbility.md) | Called when initialization is performed during ability startup.<br>**System capability**: SystemCapability.Ability.AbilityRuntime.Core|
| context | [AbilityStageContext](js-apis-featureAbility.md) | Called when initialization is performed during ability startup.|
......@@ -14,6 +14,7 @@ You must extend **AbilityContext** to implement this module.
## Attributes
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
| Name| Type| Readable| Writable| Description|
......
# StaticSubscriberExtensionAbility
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**
> The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version.
## Modules to Import
```
import StaticSubscriberExtensionAbility from '@ohos.application.StaticSubscriberExtensionAbility'
```
## StaticSubscriberExtensionAbility.onReceiveEvent
onReceiveEvent(event: CommonEventData): void;
Callback of the common event of a static subscriber.
**System capability**: SystemCapability.Ability.AbilityRuntime.AbilityCore
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| event | CommonEventData | Yes| Callback of the common event of a static subscriber.|
**Example**
```js
var StaticSubscriberExtensionAbility = requireNapi("application.StaticSubscriberExtensionAbility")
{
onReceiveEvent(event){
console.log('onReceiveEvent,event:' + event.code);
}
}
export default MyStaticSubscriberExtensionAbility
```
# DataAbilityHelper Module (JavaScript SDK APIs)
> ![icon-note.gif](public_sys-resources/icon-note.gif)**NOTE**
> The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version.
## Modules to Import
```
......
# ExtensionContext
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**
> The initial APIs of this module are supported since API 8. Newly added APIs will be marked with a superscript to indicate their earliest API version.
> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version.
Implements the extension context. This module is inherited from **Context**.
......@@ -9,6 +9,8 @@ Implements the extension context. This module is inherited from **Context**.
## Attributes
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
| Name| Type| Readable| Writable| Description|
| -------- | -------- | -------- | -------- | -------- |
| currentHapModuleInfo | HapModuleInfo | Yes| No| Information about the current HAP.<br>**System capability**: SystemCapability.Ability.AbilityRuntime.Core |
| currentHapModuleInfo | HapModuleInfo | Yes| No| Information about the current HAP. |
# ExtensionRunningInfo
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**
> The initial APIs of this module are supported since API 8. Newly added APIs will be marked with a superscript to indicate their earliest API version.
> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version.
Provides extension running information.
......@@ -26,15 +26,15 @@ abilitymanager.getExtensionRunningInfos(upperLimit, (err,data) => {
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
| Name| Type| Readable| Writable| Description|
| Name| Type| Readable| Writable| Description|
| -------- | -------- | -------- | -------- | -------- |
| extension | ElementName | Yes| No| Information that matches an extension.|
| pid | number | Yes| No| Process ID.|
| uid | number | Yes| No| User ID.|
| processName | string | Yes| No| Process name.|
| startTime | number | Yes| No| Extension start time.|
| clientPackage | Array&lt;String&gt; | Yes| No| Names of all packages in the process.|
| type | [bundle.ExtensionAbilityType](#bundle-extensionabilitytype) | Yes| No| Extension type.|
| extension | ElementName | Yes| No| Information that matches an extension.|
| pid | number | Yes| No| Process ID.|
| uid | number | Yes| No| User ID.|
| processName | string | Yes| No| Process name.|
| startTime | number | Yes| No| Extension start time.|
| clientPackage | Array&lt;String&gt; | Yes| No| Names of all packages in the process.|
| type | [bundle.ExtensionAbilityType](#bundleextensionabilitytype) | Yes| No| Extension type.|
## bundle.ExtensionAbilityType
......@@ -45,13 +45,13 @@ Enumerates extension types.
| Name| Value| Description|
| -------- | -------- | -------- |
| FORM | 0 | Extension information of the form type. |
| WORK_SCHEDULER | 1 | Extension information of the work scheduler type. |
| INPUT_METHOD | 2 | Extension information of the input method type. |
| SERVICE | 3 | Extension information of the service type. |
| ACCESSIBILITY | 4 | Extension information of the accessibility type. |
| DATA_SHARE | 5 | Extension information of the data share type. |
| FILE_SHARE | 6 | Extension information of the file share type. |
| STATIC_SUBSCRIBER | 7 | Extension information of the static subscriber type. |
| WALLPAPER | 8 | Extension information of the wallpaper type. |
| UNSPECIFIED | 9 | Extension information of the unspecified type. |
| FORM | 0 | Extension information of the form type.< |
| WORK_SCHEDULER | 1 | Extension information of the work scheduler type.< |
| INPUT_METHOD | 2 | Extension information of the input method type.< |
| SERVICE | 3 | Extension information of the service type.< |
| ACCESSIBILITY | 4 | Extension information of the accessibility type.< |
| DATA_SHARE | 5 | Extension information of the data share type.< |
| FILE_SHARE | 6 | Extension information of the file share type.< |
| STATIC_SUBSCRIBER | 7 | Extension information of the static subscriber type.< |
| WALLPAPER | 8 | Extension information of the wallpaper type.< |
| UNSPECIFIED | 9 | Extension information of the unspecified type.< |
......@@ -17,9 +17,11 @@ None
## Attributes
**System capability**: SystemCapability.Ability.Form
| Name | Type | Readable| Writable| Description |
| ------- | ------------------------------------------------------- | ---- | ---- | --------------------------------------------------- |
| context | [FormExtensionContext](js-apis-formextensioncontext.md) | Yes | No | Context of the **FormExtension**. This class is inherited from **ExtensionContext**.<br>**System capability**: SystemCapability.Ability.Form|
| context | [FormExtensionContext](js-apis-formextensioncontext.md) | Yes | No | Context of the **FormExtension**. This class is inherited from **ExtensionContext**.|
## onCreate
......
# missionManager
> **NOTE**
> The initial APIs of this module are supported since API version 8.
> ![icon-note.gif](public_sys-resources/icon-note.gif) **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 mission management. You can use the APIs to lock, unlock, and clear missions, and switch a mission to the foreground.
......@@ -18,7 +18,7 @@ import missionManager from '@ohos.application.missionManager'
## missionManager.registerMissionListener
function registerMissionListener(listener: MissionListener): number;
registerMissionListener(listener: MissionListener): number;
Registers a listener to observe the mission status.
......@@ -53,7 +53,7 @@ Registers a listener to observe the mission status.
## missionManager.unregisterMissionListener
function unregisterMissionListener(listenerId: number, callback: AsyncCallback&lt;void&gt;): void;
unregisterMissionListener(listenerId: number, callback: AsyncCallback&lt;void&gt;): void;
Unregisters a mission status listener. This API uses an asynchronous callback to return the result.
......@@ -86,7 +86,7 @@ Unregisters a mission status listener. This API uses an asynchronous callback to
## missionManager.unregisterMissionListener
function unregisterMissionListener(listenerId: number): Promise&lt;void&gt;;
unregisterMissionListener(listenerId: number): Promise&lt;void&gt;;
Unregisters a mission status listener. This API uses a promise to return the result.
......@@ -98,6 +98,12 @@ Unregisters a mission status listener. This API uses a promise to return the res
| -------- | -------- | -------- | -------- |
| listenerId | number | Yes| Index of the mission status listener to unregister. Each listener has a unique index, which is returned by **registerMissionListener**.|
**Return value**
| Type| Description|
| -------- | -------- |
| Promise&lt;void&gt; | Promise used to return the result.|
**Example**
```js
......@@ -110,7 +116,7 @@ Unregisters a mission status listener. This API uses a promise to return the res
console.log("registerMissionListener")
var listenerid = missionManager.registerMissionListener(listener);
await missionManager.unregisterMissionListener(listenerid).catch(function (err){
missionManager.unregisterMissionListener(listenerid).catch(function (err){
console.log(err);
});
```
......@@ -118,7 +124,7 @@ Unregisters a mission status listener. This API uses a promise to return the res
## missionManager.getMissionInfo
function getMissionInfo(deviceId: string, missionId: number, callback: AsyncCallback&lt;MissionInfo&gt;): void;
getMissionInfo(deviceId: string, missionId: number, callback: AsyncCallback&lt;MissionInfo&gt;): void;
Obtains the information of a given mission. This API uses an asynchronous callback to return the result.
......@@ -130,7 +136,7 @@ Obtains the information of a given mission. This API uses an asynchronous callba
| -------- | -------- | -------- | -------- |
| deviceId | string | Yes| Device ID. It is a null string by default for the local device.|
| missionId | number | Yes| Mission ID.|
| callback | AsyncCallback&lt;MissionInfo&gt; | Yes| Callback used to return the mission information obtained.|
| callback | AsyncCallback&lt;[MissionInfo](#missioninfo)&gt; | Yes| Callback used to return the mission information obtained.|
**Example**
......@@ -145,13 +151,13 @@ Obtains the information of a given mission. This API uses an asynchronous callba
console.log("mission.timestamp = " + mission.timestamp);
console.log("mission.label = " + mission.label);
console.log("mission.iconPath = " + mission.iconPath);
}
});
```
## missionManager.getMissionInfo
function getMissionInfo(deviceId: string, missionId: number): Promise&lt;MissionInfo&gt;;
getMissionInfo(deviceId: string, missionId: number): Promise&lt;MissionInfo&gt;;
Obtains the information of a given mission. This API uses a promise to return the result.
......@@ -168,14 +174,14 @@ Obtains the information of a given mission. This API uses a promise to return th
| Type| Description|
| -------- | -------- |
| [MissionInfo](js-apis-application-MissionInfo.md) | Promise used to return the mission information obtained.|
| Promise&lt;[MissionInfo](#missioninfo)&gt; | Promise used to return the mission information obtained.|
**Example**
```js
import missionManager from '@ohos.application.missionManager'
var mission = await missionManager.getMissionInfo("", id).catch(function (err){
var mission = missionManager.getMissionInfo("", id).catch(function (err){
console.log(err);
});
```
......@@ -183,7 +189,7 @@ Obtains the information of a given mission. This API uses a promise to return th
## missionManager.getMissionInfos
function getMissionInfos(deviceId: string, numMax: number, callback: AsyncCallback&lt;Array&lt;MissionInfo&gt;&gt;): void;
getMissionInfos(deviceId: string, numMax: number, callback: AsyncCallback&lt;Array&lt;MissionInfo&gt;&gt;): void;
Obtains information of all missions. This API uses an asynchronous callback to return the result.
......@@ -195,7 +201,7 @@ Obtains information of all missions. This API uses an asynchronous callback to r
| -------- | -------- | -------- | -------- |
| deviceId | string | Yes| Device ID. It is a null string by default for the local device.|
| numMax | number | Yes| Maximum number of missions whose information can be obtained.|
| callback | AsyncCallback&lt;Array&lt;[MissionInfo](js-apis-application-MissionInfo.md)&gt;&gt; | Yes| Callback used to return the array of mission information obtained.|
| callback | AsyncCallback&lt;Array&lt;[MissionInfo](#missioninfo)&gt;&gt; | Yes| Callback used to return the array of mission information obtained.|
**Example**
......@@ -212,7 +218,7 @@ Obtains information of all missions. This API uses an asynchronous callback to r
## missionManager.getMissionInfos
function getMissionInfos(deviceId: string, numMax: number): Promise&lt;Array&lt;MissionInfo&gt;&gt;;
getMissionInfos(deviceId: string, numMax: number): Promise&lt;Array&lt;MissionInfo&gt;&gt;;
Obtains information of all missions. This API uses a promise to return the result.
......@@ -229,14 +235,14 @@ Obtains information of all missions. This API uses a promise to return the resul
| Type| Description|
| -------- | -------- |
| Array&lt;MissionInfo&gt; | Promise used to return the array of mission information obtained.|
| Promise&lt;Array&lt;[MissionInfo](#missioninfo)&gt;&gt; | Promise used to return the array of mission information obtained.|
**Example**
```js
import missionManager from '@ohos.application.missionManager'
var allMissions = await missionManager.getMissionInfos("", 10).catch(function (err){
var allMissions = missionManager.getMissionInfos("", 10).catch(function (err){
console.log(err);
});
```
......@@ -244,7 +250,7 @@ Obtains information of all missions. This API uses a promise to return the resul
## missionManager.getMissionSnapShot
function getMissionSnapShot(deviceId: string, missionId: number, callback: AsyncCallback&lt;MissionSnapshot&gt;): void;
getMissionSnapShot(deviceId: string, missionId: number, callback: AsyncCallback&lt;MissionSnapshot&gt;): void;
Obtains the snapshot of a given mission. This API uses an asynchronous callback to return the result.
......@@ -279,7 +285,7 @@ Obtains the snapshot of a given mission. This API uses an asynchronous callback
## missionManager.getMissionSnapShot
function getMissionSnapShot(deviceId: string, missionId: number): Promise&lt;MissionSnapshot&gt;;
getMissionSnapShot(deviceId: string, missionId: number): Promise&lt;MissionSnapshot&gt;;
Obtains the snapshot of a given mission. This API uses a promise to return the result.
......@@ -296,20 +302,20 @@ Obtains the snapshot of a given mission. This API uses a promise to return the r
| Type| Description|
| -------- | -------- |
| MissionSnapshot | Promise used to return the snapshot information obtained.|
| Promise&lt;[MissionSnapshot](js-apis-application-MissionSnapshot.md)&gt; | Promise used to return the snapshot information obtained.|
**Example**
```js
import missionManager from '@ohos.application.missionManager'
var allMissions = await missionManager.getMissionInfos("", 10).catch(function (err){
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 = await missionManager.getMissionSnapShot("", id).catch(function (err){
var snapshot = missionManager.getMissionSnapShot("", id).catch(function (err){
console.log(err);
});
```
......@@ -317,7 +323,7 @@ Obtains the snapshot of a given mission. This API uses a promise to return the r
## missionManager.lockMission
function lockMission(missionId: number, callback: AsyncCallback&lt;void&gt;): void;
lockMission(missionId: number, callback: AsyncCallback&lt;void&gt;): void;
Locks a given mission. This API uses an asynchronous callback to return the result.
......@@ -350,7 +356,7 @@ Locks a given mission. This API uses an asynchronous callback to return the resu
## missionManager.lockMission
function lockMission(missionId: number): Promise&lt;void&gt;;
lockMission(missionId: number): Promise&lt;void&gt;;
Locks a given mission. This API uses a promise to return the result.
......@@ -362,19 +368,25 @@ Locks a given mission. This API uses a promise to return the result.
| -------- | -------- | -------- | -------- |
| missionId | number | Yes| Mission ID.|
**Return value**
| Type| Description|
| -------- | -------- |
| Promise&lt;void&gt; | Promise used to return the result.|
**Example**
```js
import missionManager from '@ohos.application.missionManager'
var allMissions = await missionManager.getMissionInfos("", 10).catch(function (err){
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;
await missionManager.lockMission(id).catch(function (err){
missionManager.lockMission(id).catch(function (err){
console.log(err);
});
```
......@@ -382,7 +394,7 @@ Locks a given mission. This API uses a promise to return the result.
## missionManager.unlockMission
function unlockMission(missionId: number, callback: AsyncCallback&lt;void&gt;): void;
unlockMission(missionId: number, callback: AsyncCallback&lt;void&gt;): void;
Unlocks a given mission. This API uses an asynchronous callback to return the result.
......@@ -390,9 +402,10 @@ Unlocks a given mission. This API uses an asynchronous callback to return the re
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| missionId | number | Yes| Mission ID.|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| missionId | number | Yes| Mission ID.|
| callback | AsyncCallback&lt;void&gt; | Yes| Callback used to return the result.|
**Example**
......@@ -414,7 +427,7 @@ Unlocks a given mission. This API uses an asynchronous callback to return the re
## missionManager.unlockMission
function unlockMission(missionId: number): Promise&lt;void&gt;;
unlockMission(missionId: number): Promise&lt;void&gt;;
Unlocks a given mission. This API uses a promise to return the result.
......@@ -426,22 +439,28 @@ Unlocks a given mission. This API uses a promise to return the result.
| -------- | -------- | -------- | -------- |
| missionId | number | Yes| Mission ID.|
**Return value**
| Type| Description|
| -------- | -------- |
| Promise&lt;void&gt; | Promise used to return the result.|
**Example**
```js
import missionManager from '@ohos.application.missionManager'
var allMissions = await missionManager.getMissionInfos("", 10).catch(function (err){
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;
await missionManager.lockMission(id).catch(function (err){
missionManager.lockMission(id).catch(function (err){
console.log(err);
});
await missionManager.unlockMission(id).catch(function (err){
missionManager.unlockMission(id).catch(function (err){
console.log(err);
});
```
......@@ -449,7 +468,7 @@ Unlocks a given mission. This API uses a promise to return the result.
## missionManager.clearMission
function clearMission(missionId: number, callback: AsyncCallback&lt;void&gt;): void;
clearMission(missionId: number, callback: AsyncCallback&lt;void&gt;): void;
Clears a given mission, regardless of whether it is locked. This API uses an asynchronous callback to return the result.
......@@ -482,7 +501,7 @@ Clears a given mission, regardless of whether it is locked. This API uses an asy
## missionManager.clearMission
function clearMission(missionId: number): Promise&lt;void&gt;;
clearMission(missionId: number): Promise&lt;void&gt;;
Clears a given mission, regardless of whether it is locked. This API uses a promise to return the result.
......@@ -494,19 +513,25 @@ Clears a given mission, regardless of whether it is locked. This API uses a prom
| -------- | -------- | -------- | -------- |
| missionId | number | Yes| Mission ID.|
**Return value**
| Type| Description|
| -------- | -------- |
| Promise&lt;void&gt; | Promise used to return the result.|
**Example**
```js
import missionManager from '@ohos.application.missionManager'
var allMissions = await missionManager.getMissionInfos("", 10).catch(function (err){
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;
await missionManager.clearMission(id).catch(function (err){
missionManager.clearMission(id).catch(function (err){
console.log(err);
});
```
......@@ -514,7 +539,7 @@ Clears a given mission, regardless of whether it is locked. This API uses a prom
## missionManager.clearAllMissions
function clearAllMissions(callback: AsyncCallback&lt;void&gt;): void;
clearAllMissions(callback: AsyncCallback&lt;void&gt;): void;
Clears all unlocked missions. This API uses an asynchronous callback to return the result.
......@@ -533,17 +558,23 @@ Clears all unlocked missions. This API uses an asynchronous callback to return t
## missionManager.clearAllMissions
function clearAllMissions(): Promise&lt;void&gt;;
clearAllMissions(): Promise&lt;void&gt;;
Clears all unlocked missions. This API uses a promise to return the result.
**System capability**: SystemCapability.Ability.AbilityRuntime.Mission
**Return value**
| Type| Description|
| -------- | -------- |
| Promise&lt;void&gt; | Promise used to return the result.|
**Example**
```js
import missionManager from '@ohos.application.missionManager'
await missionManager.clearAllMissions().catch(function (err){
missionManager.clearAllMissions().catch(function (err){
console.log(err);
});
```
......@@ -551,7 +582,7 @@ Clears all unlocked missions. This API uses a promise to return the result.
## missionManager.moveMissionToFront
function moveMissionToFront(missionId: number, callback: AsyncCallback&lt;void&gt;): void;
moveMissionToFront(missionId: number, callback: AsyncCallback&lt;void&gt;): void;
Switches a given mission to the foreground. This API uses an asynchronous callback to return the result.
......@@ -584,7 +615,7 @@ Switches a given mission to the foreground. This API uses an asynchronous callba
## missionManager.moveMissionToFront
function moveMissionToFront(missionId: number, options: StartOptions, callback: AsyncCallback&lt;void&gt;): void;
moveMissionToFront(missionId: number, options: StartOptions, callback: AsyncCallback&lt;void&gt;): void;
Switches a given mission to the foreground, with the startup parameters for the switch specified, such as the window mode and device ID. This API uses an asynchronous callback to return the result.
......@@ -618,9 +649,9 @@ Switches a given mission to the foreground, with the startup parameters for the
## missionManager.moveMissionToFront
function moveMissionToFront(missionId: number, options?: StartOptions): Promise&lt;void&gt;;
moveMissionToFront(missionId: number, options?: StartOptions): Promise&lt;void&gt;;
Switches a given mission to the foreground. This API uses a promise to return the result.
Switches a given mission to the foreground, with the startup parameters for the switch specified, such as the window mode and device ID. This API uses a promise to return the result.
**System capability**: SystemCapability.Ability.AbilityRuntime.Mission
......@@ -631,19 +662,42 @@ Switches a given mission to the foreground. This API uses a promise to return th
| missionId | number | Yes| Mission ID.|
| options | StartOptions | No| Startup parameters, which are used to specify the window mode and device ID for switching the mission to the foreground.|
**Return value**
| Type| Description|
| -------- | -------- |
| Promise&lt;void&gt; | Promise used to return the result.|
**Example**
```js
import missionManager from '@ohos.application.missionManager'
var allMissions = await missionManager.getMissionInfos("", 10).catch(function (err){
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;
await missionManager.moveMissionToFront(id).catch(function (err){
missionManager.moveMissionToFront(id).catch(function (err){
console.log(err);
});
```
## MissionInfo
Describes the mission information.
**System capability**: SystemCapability.Ability.AbilityBase
| Name| Type| Readable| Writable| Description|
| -------- | -------- | -------- | -------- | -------- |
| missionId | number | Yes| Yes| Mission ID.|
| runningState | number | Yes| Yes| Running state of the mission.|
| lockedState | boolean | Yes| Yes| Locked state of the mission.|
| timestamp | string | Yes| Yes| Latest time when the mission was created or updated.|
| want | [Want](js-apis-featureAbility.md#want) | Yes| Yes| **Want** information of the mission.|
| label | string | Yes| Yes| Label of the mission.|
| iconPath | string | Yes| Yes| Path of the mission icon.|
| continuable | boolean | Yes| Yes| Whether the mission is continuable.|
# ProcessRunningInfo
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**
> The initial APIs of this module are supported since API 8. Newly added APIs will be marked with a superscript to indicate their earliest API version.
> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version.
Provides process running information.
......
......@@ -21,9 +21,11 @@ None.
## Attributes
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
| Name| Type| Readable| Writable| Description|
| -------- | -------- | -------- | -------- | -------- |
| context | [ServiceExtensionContext](js-apis-service-extension-context.md) | Yes| No| Service extension context, which is inherited from **ExtensionContext**.<br>**System capability**: SystemCapability.Ability.AbilityRuntime.Core|
| context | [ServiceExtensionContext](js-apis-service-extension-context.md) | Yes| No| Service extension context, which is inherited from **ExtensionContext**.|
## ServiceExtensionAbility.onCreate
......
# ServiceExtensionContext
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**
> The initial APIs of this module are supported since API 8. Newly added APIs will be marked with a superscript to indicate their earliest API version.
> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version.
Implements the context that provides the capabilities and APIs of **ServiceExtension**. This class is inherited from **ExtensionContext**.
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册