提交 a9a92b7e 编写于 作者: G Gloria

Update docs against 16927+17051+17293+17211+17389

Signed-off-by: wusongqing<wusongqing@huawei.com>
上级 c7900e92
...@@ -122,6 +122,14 @@ Deregisters a mission status listener. ...@@ -122,6 +122,14 @@ Deregisters a mission status listener.
| listenerId | number | Yes| Index of the mission status listener to deregister. It is returned by **on()**.| | listenerId | number | Yes| Index of the mission status listener to deregister. It is returned by **on()**.|
| callback | AsyncCallback&lt;void&gt; | Yes| Callback used to return the result.| | callback | AsyncCallback&lt;void&gt; | Yes| Callback used to return the result.|
**Error codes**
| ID| Error Message|
| ------- | -------- |
| 16300002 | Input error. The specified mission listener does not exist. |
For details about the error codes, see [Ability Error Codes](../errorcodes/errorcode-ability.md).
**Example** **Example**
```ts ```ts
...@@ -209,6 +217,14 @@ Deregisters a mission status listener. This API uses a promise to return the res ...@@ -209,6 +217,14 @@ Deregisters a mission status listener. This API uses a promise to return the res
| -------- | -------- | | -------- | -------- |
| Promise&lt;void&gt; | Promise used to return the result.| | Promise&lt;void&gt; | Promise used to return the result.|
**Error codes**
| ID| Error Message|
| ------- | -------- |
| 16300002 | Input error. The specified mission listener does not exist. |
For details about the error codes, see [Ability Error Codes](../errorcodes/errorcode-ability.md).
**Example** **Example**
```ts ```ts
...@@ -624,6 +640,14 @@ Locks a given mission. This API uses an asynchronous callback to return the resu ...@@ -624,6 +640,14 @@ Locks a given mission. This API uses an asynchronous callback to return the resu
| missionId | number | Yes| Mission ID.| | missionId | number | Yes| Mission ID.|
| callback | AsyncCallback&lt;void&gt; | Yes| Callback used to return the result.| | callback | AsyncCallback&lt;void&gt; | Yes| Callback used to return the result.|
**Error codes**
| ID| Error Message|
| ------- | -------- |
| 16300001 | Mission not found. |
For details about the error codes, see [Ability Error Codes](../errorcodes/errorcode-ability.md).
**Example** **Example**
```ts ```ts
...@@ -667,6 +691,14 @@ Locks a given mission. This API uses a promise to return the result. ...@@ -667,6 +691,14 @@ Locks a given mission. This API uses a promise to return the result.
| -------- | -------- | | -------- | -------- |
| Promise&lt;void&gt; | Promise used to return the result.| | Promise&lt;void&gt; | Promise used to return the result.|
**Error codes**
| ID| Error Message|
| ------- | -------- |
| 16300001 | Mission not found. |
For details about the error codes, see [Ability Error Codes](../errorcodes/errorcode-ability.md).
**Example** **Example**
```ts ```ts
import missionManager from '@ohos.app.ability.missionManager'; import missionManager from '@ohos.app.ability.missionManager';
...@@ -702,6 +734,14 @@ Unlocks a given mission. This API uses an asynchronous callback to return the re ...@@ -702,6 +734,14 @@ Unlocks a given mission. This API uses an asynchronous callback to return the re
| missionId | number | Yes| Mission ID.| | missionId | number | Yes| Mission ID.|
| callback | AsyncCallback&lt;void&gt; | Yes| Callback used to return the result.| | callback | AsyncCallback&lt;void&gt; | Yes| Callback used to return the result.|
**Error codes**
| ID| Error Message|
| ------- | -------- |
| 16300001 | Mission not found. |
For details about the error codes, see [Ability Error Codes](../errorcodes/errorcode-ability.md).
**Example** **Example**
```ts ```ts
import missionManager from '@ohos.app.ability.missionManager'; import missionManager from '@ohos.app.ability.missionManager';
...@@ -744,6 +784,14 @@ Unlocks a given mission. This API uses a promise to return the result. ...@@ -744,6 +784,14 @@ Unlocks a given mission. This API uses a promise to return the result.
| -------- | -------- | | -------- | -------- |
| Promise&lt;void&gt; | Promise used to return the result.| | Promise&lt;void&gt; | Promise used to return the result.|
**Error codes**
| ID| Error Message|
| ------- | -------- |
| 16300001 | Mission not found. |
For details about the error codes, see [Ability Error Codes](../errorcodes/errorcode-ability.md).
**Example** **Example**
```ts ```ts
...@@ -924,6 +972,14 @@ Switches a given mission to the foreground. This API uses an asynchronous callba ...@@ -924,6 +972,14 @@ Switches a given mission to the foreground. This API uses an asynchronous callba
| missionId | number | Yes| Mission ID.| | missionId | number | Yes| Mission ID.|
| callback | AsyncCallback&lt;void&gt; | Yes| Callback used to return the result.| | callback | AsyncCallback&lt;void&gt; | Yes| Callback used to return the result.|
**Error codes**
| ID| Error Message|
| ------- | -------- |
| 16000009 | An ability cannot be started or stopped in Wukong mode. |
For details about the error codes, see [Ability Error Codes](../errorcodes/errorcode-ability.md).
**Example** **Example**
```ts ```ts
...@@ -963,6 +1019,14 @@ Switches a given mission to the foreground, with the startup parameters for the ...@@ -963,6 +1019,14 @@ Switches a given mission to the foreground, with the startup parameters for the
| options | [StartOptions](js-apis-app-ability-startOptions.md) | Yes| Startup parameters, which are used to specify the window mode and device ID for switching the mission to the foreground.| | options | [StartOptions](js-apis-app-ability-startOptions.md) | Yes| Startup parameters, which are used to specify the window mode and device ID for switching the mission to the foreground.|
| callback | AsyncCallback&lt;void&gt; | Yes| Callback used to return the result.| | callback | AsyncCallback&lt;void&gt; | Yes| Callback used to return the result.|
**Error codes**
| ID| Error Message|
| ------- | -------- |
| 16000009 | An ability cannot be started or stopped in Wukong mode. |
For details about the error codes, see [Ability Error Codes](../errorcodes/errorcode-ability.md).
**Example** **Example**
```ts ```ts
...@@ -1007,6 +1071,14 @@ Switches a given mission to the foreground, with the startup parameters for the ...@@ -1007,6 +1071,14 @@ Switches a given mission to the foreground, with the startup parameters for the
| -------- | -------- | | -------- | -------- |
| Promise&lt;void&gt; | Promise used to return the result.| | Promise&lt;void&gt; | Promise used to return the result.|
**Error codes**
| ID| Error Message|
| ------- | -------- |
| 16000009 | An ability cannot be started or stopped in Wukong mode. |
For details about the error codes, see [Ability Error Codes](../errorcodes/errorcode-ability.md).
**Example** **Example**
```ts ```ts
......
...@@ -32,12 +32,12 @@ import StartOptions from '@ohos.app.ability.StartOptions'; ...@@ -32,12 +32,12 @@ import StartOptions from '@ohos.app.ability.StartOptions';
try { try {
missionManager.getMissionInfos('', 10, (error, missions) => { missionManager.getMissionInfos('', 10, (error, missions) => {
if (error.code) { if (error) {
console.error('getMissionInfos failed, error.code: ${error.code}, error.message: ${error.message}'); console.error(`getMissionInfos failed, error.code: ${JSON.stringify(error.code)}, error.message: ${JSON.stringify(error.message)}`);
return; return;
} }
console.log('size = ${missions.length}'); console.log(`size = ${missions.length}`);
console.log('missions = ${JSON.stringify(missions)}'); console.log(`missions = ${JSON.stringify(missions)}`);
let id = missions[0].missionId; let id = missions[0].missionId;
let startOptions = { let startOptions = {
...@@ -45,10 +45,10 @@ import StartOptions from '@ohos.app.ability.StartOptions'; ...@@ -45,10 +45,10 @@ import StartOptions from '@ohos.app.ability.StartOptions';
displayId: 0 displayId: 0
}; };
missionManager.moveMissionToFront(id, startOptions).then(() => { missionManager.moveMissionToFront(id, startOptions).then(() => {
console.log('moveMissionToFront is called '); console.log('moveMissionToFront is called');
}); });
}); });
} catch (paramError) { } catch (paramError) {
console.error('error: ${paramError.code}, ${paramError.message}'); console.error(`error: ${paramError.code}, ${paramError.message}`);
} }
``` ```
...@@ -2,6 +2,12 @@ ...@@ -2,6 +2,12 @@
The **AppStateData** module defines the application state data, which can be obtained through [getForegroundApplications](js-apis-app-ability-appManager.md#appmanagergetforegroundapplications). The **AppStateData** module defines the application state data, which can be obtained through [getForegroundApplications](js-apis-app-ability-appManager.md#appmanagergetforegroundapplications).
## Modules to Import
```ts
import appManager from '@ohos.app.ability.appManager';
```
**System capability**: SystemCapability.Ability.AbilityRuntime.Core **System capability**: SystemCapability.Ability.AbilityRuntime.Core
**System API**: This module is marked as @systemapi and not visible to third-party applications. **System API**: This module is marked as @systemapi and not visible to third-party applications.
...@@ -19,8 +25,8 @@ import appManager from '@ohos.app.ability.appManager'; ...@@ -19,8 +25,8 @@ import appManager from '@ohos.app.ability.appManager';
function getForegroundAppInfos() { function getForegroundAppInfos() {
appManager.getForegroundApplications((error, data) => { appManager.getForegroundApplications((error, data) => {
if (error && error.code) { if (error) {
console.log('getForegroundApplications failed, error.code: ${error.code}, error.message: ${error.message}'); console.log('getForegroundApplications failed, error.code: ${JSON.stringify(error.code)}, error.message: ${JSON.stringify(error.message)}');
return; return;
} }
for (let i = 0; i < data.length; i++) { for (let i = 0; i < data.length; i++) {
......
...@@ -7,6 +7,12 @@ The **Context** module provides context for abilities or applications. It allows ...@@ -7,6 +7,12 @@ The **Context** module provides context for abilities or applications. It allows
> - 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. > - The APIs of this module can be used only in the stage model.
## Modules to Import
```ts
import common from '@ohos.app.ability.common';
```
## Attributes ## Attributes
**System capability**: SystemCapability.Ability.AbilityRuntime.Core **System capability**: SystemCapability.Ability.AbilityRuntime.Core
...@@ -20,7 +26,7 @@ The **Context** module provides context for abilities or applications. It allows ...@@ -20,7 +26,7 @@ The **Context** module provides context for abilities or applications. It allows
| filesDir | string | Yes | No | File directory.| | filesDir | string | Yes | No | File directory.|
| databaseDir | string | Yes | No | Database directory.| | databaseDir | string | Yes | No | Database directory.|
| preferencesDir | string | Yes | No | Preferences directory.| | preferencesDir | string | Yes | No | Preferences directory.|
| bundleCodeDir | string | Yes | No | Bundle code directory.| | bundleCodeDir | string | Yes | No | Bundle code directory. Do not access resource files by concatenating paths. Use the [resourceManager API](js-apis-resource-manager.md) instead.|
| distributedFilesDir | string | Yes | No | Distributed file directory.| | distributedFilesDir | string | Yes | No | Distributed file directory.|
| eventHub | [EventHub](js-apis-inner-application-eventHub.md) | Yes | No | Event hub that implements event subscription, unsubscription, and triggering.| | eventHub | [EventHub](js-apis-inner-application-eventHub.md) | Yes | No | Event hub that implements event subscription, unsubscription, and triggering.|
| area | contextConstant.[AreaMode](js-apis-app-ability-contextConstant.md) | Yes | No | Area in which the file to be access is located.| | area | contextConstant.[AreaMode](js-apis-app-ability-contextConstant.md) | Yes | No | Area in which the file to be access is located.|
...@@ -47,18 +53,10 @@ Creates the context based on the bundle name. ...@@ -47,18 +53,10 @@ Creates the context based on the bundle name.
| -------- | -------- | | -------- | -------- |
| Context | Context created.| | Context | Context created.|
**Error codes**
| ID| Error Message|
| ------- | -------------------------------- |
| 401 | If the input parameter is not valid parameter. |
For details about the error codes, see [Ability Error Codes](../errorcodes/errorcode-ability.md).
**Example** **Example**
```ts ```ts
let bundleContext; let bundleContext: common.Context;
try { try {
bundleContext = this.context.createBundleContext('com.example.test'); bundleContext = this.context.createBundleContext('com.example.test');
} catch (error) { } catch (error) {
...@@ -86,18 +84,10 @@ Creates the context based on the module name. ...@@ -86,18 +84,10 @@ Creates the context based on the module name.
| -------- | -------- | | -------- | -------- |
| Context | Context created.| | Context | Context created.|
**Error codes**
| ID| Error Message|
| ------- | -------------------------------- |
| 401 | If the input parameter is not valid parameter. |
For details about the error codes, see [Ability Error Codes](../errorcodes/errorcode-ability.md).
**Example** **Example**
```ts ```ts
let moduleContext; let moduleContext: common.Context;
try { try {
moduleContext = this.context.createModuleContext('entry'); moduleContext = this.context.createModuleContext('entry');
} catch (error) { } catch (error) {
...@@ -126,18 +116,10 @@ Creates the context based on the bundle name and module name. ...@@ -126,18 +116,10 @@ Creates the context based on the bundle name and module name.
| -------- | -------- | | -------- | -------- |
| Context | Context created.| | Context | Context created.|
**Error codes**
| ID| Error Message|
| ------- | -------------------------------- |
| 401 | If the input parameter is not valid parameter. |
For details about the error codes, see [Ability Error Codes](../errorcodes/errorcode-ability.md).
**Example** **Example**
```ts ```ts
let moduleContext; let moduleContext: common.Context;
try { try {
moduleContext = this.context.createModuleContext('com.example.test', 'entry'); moduleContext = this.context.createModuleContext('com.example.test', 'entry');
} catch (error) { } catch (error) {
...@@ -162,7 +144,7 @@ Obtains the context of this application. ...@@ -162,7 +144,7 @@ Obtains the context of this application.
**Example** **Example**
```ts ```ts
let applicationContext; let applicationContext: common.Context;
try { try {
applicationContext = this.context.getApplicationContext(); applicationContext = this.context.getApplicationContext();
} catch (error) { } catch (error) {
......
...@@ -7,6 +7,12 @@ The **ExtensionRunningInfo** module encapsulates ExtensionAbility running inform ...@@ -7,6 +7,12 @@ The **ExtensionRunningInfo** module encapsulates ExtensionAbility running inform
> - 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.
> - This module is marked as @systemapi and not visible to third-party applications. > - This module is marked as @systemapi and not visible to third-party applications.
## Modules to Import
```ts
import abilityManager from '@ohos.app.ability.abilityManager';
```
## Usage ## Usage
Import the **abilityManager** module and obtain the ExtensionAbility running information by calling the method in the **abilityManager** module. Import the **abilityManager** module and obtain the ExtensionAbility running information by calling the method in the **abilityManager** module.
...@@ -32,8 +38,8 @@ import abilityManager from '@ohos.app.ability.abilityManager'; ...@@ -32,8 +38,8 @@ import abilityManager from '@ohos.app.ability.abilityManager';
let upperLimit = 1; let upperLimit = 1;
function getExtensionInfos() { function getExtensionInfos() {
abilityManager.getExtensionRunningInfos(upperLimit, (error, data) => { abilityManager.getExtensionRunningInfos(upperLimit, (error, data) => {
if (error && error.code) { if (error) {
console.error('getForegroundApplications failed, error.code: ${error.code}, error.message: ${error.message}'); console.error('getForegroundApplications failed, error.code: ${JSON.stringify(error.code)}, error.message: ${JSON.stringify(error.message)}');
return; return;
} }
......
...@@ -2,6 +2,12 @@ ...@@ -2,6 +2,12 @@
The **MissionInfo** module defines detailed information about a mission. The information can be obtained through [getMissionInfo](js-apis-app-ability-missionManager.md#missionmanagergetmissioninfo). The **MissionInfo** module defines detailed information about a mission. The information can be obtained through [getMissionInfo](js-apis-app-ability-missionManager.md#missionmanagergetmissioninfo).
## Modules to Import
```ts
import missionManager from '@ohos.app.ability.missionManager';
```
**System capability**: SystemCapability.Ability.AbilityRuntime.Mission **System capability**: SystemCapability.Ability.AbilityRuntime.Mission
**System API**: This is a system API and cannot be called by third-party applications. **System API**: This is a system API and cannot be called by third-party applications.
...@@ -23,7 +29,7 @@ import missionManager from '@ohos.app.ability.missionManager'; ...@@ -23,7 +29,7 @@ import missionManager from '@ohos.app.ability.missionManager';
try { try {
missionManager.getMissionInfo('', 1, (error, data) => { missionManager.getMissionInfo('', 1, (error, data) => {
if (error.code) { if (error) {
// Process service logic errors. // Process service logic errors.
console.error('getMissionInfo failed, error.code: ${error.code}, error.message: ${error.message}'); console.error('getMissionInfo failed, error.code: ${error.code}, error.message: ${error.message}');
return; return;
......
...@@ -7,6 +7,12 @@ The **MissionSnapshot** module defines the snapshot of a mission. The snapshot c ...@@ -7,6 +7,12 @@ The **MissionSnapshot** module defines the snapshot of a mission. The snapshot c
> 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 APIs of this module are system APIs and cannot be called by third-party applications. > The APIs of this module are system APIs and cannot be called by third-party applications.
## Modules to Import
```ts
import missionManager from '@ohos.app.ability.missionManager';
```
**System capability**: SystemCapability.Ability.AbilityRuntime.Mission **System capability**: SystemCapability.Ability.AbilityRuntime.Mission
| Name| Type| Readable| Writable| Description| | Name| Type| Readable| Writable| Description|
...@@ -26,8 +32,8 @@ The mission snapshot information can be obtained by using **getMissionSnapShot** ...@@ -26,8 +32,8 @@ The mission snapshot information can be obtained by using **getMissionSnapShot**
try { try {
missionManager.getMissionInfos('', 10, (error, missions) => { missionManager.getMissionInfos('', 10, (error, missions) => {
if (error.code) { if (error) {
console.error('getMissionInfos failed, error.code: ${error.code}, error.message: ${error.message}'); console.error('getMissionInfos failed, error.code: ${JSON.stringify(error.code)}, error.message: ${JSON.stringify(error.message)}');
return; return;
} }
console.log('size = ${missions.length}'); console.log('size = ${missions.length}');
...@@ -35,8 +41,8 @@ The mission snapshot information can be obtained by using **getMissionSnapShot** ...@@ -35,8 +41,8 @@ The mission snapshot information can be obtained by using **getMissionSnapShot**
let id = missions[0].missionId; let id = missions[0].missionId;
missionManager.getMissionSnapShot('', id, (err, snapshot) => { missionManager.getMissionSnapShot('', id, (err, snapshot) => {
if (err.code) { if (err) {
console.error('getMissionInfos failed, err.code: ${err.code}, err.message: ${err.message}'); console.error('getMissionInfos failed, err.code: ${JSON.stringify(err.code)}, err.message: ${JSON.stringify(err.message)}');
return; return;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册