提交 33ed61f9 编写于 作者: C caochunlei

caochunlei1@huawei.com

Signed-off-by: Ncaochunlei <caochunlei1@huawei.com>
上级 3d6fc882
......@@ -20,7 +20,7 @@ ohos.permission.MANAGE_MISSIONS
on(type:"mission", listener: MissionListener): number;
注册系统任务状态监听。
注册系统任务状态监听
**需要权限**:ohos.permission.MANAGE_MISSIONS
......@@ -32,13 +32,13 @@ on(type:"mission", listener: MissionListener): number;
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| listener | MissionListener | 是 | 系统任务监听方法。 |
| listener | MissionListener | 是 | 系统任务监听。 |
**返回值:**
| 类型 | 说明 |
| -------- | -------- |
| number | 监听方法的index值,由系统创建,在注册系统任务状态监听时分配,和监听方法一一对应&nbsp;。 |
| number | 监听器的index值,由系统创建,在注册系统任务状态监听时分配,和监听器一一对应&nbsp;。 |
**示例:**
......@@ -51,7 +51,8 @@ var listener = {
onMissionSnapshotChanged: function (mission) {console.log("--------onMissionSnapshotChanged-------")},
onMissionMovedToFront: function (mission) {console.log("--------onMissionMovedToFront-------")},
onMissionIconUpdated: function (mission, icon) {console.log("--------onMissionIconUpdated-------")},
onMissionClosed: function (mission) {console.log("--------onMissionClosed-------")}
onMissionClosed: function (mission) {console.log("--------onMissionClosed-------")},
onMissionLabelUpdated: function (mission) {console.log("--------onMissionLabelUpdated-------")}
};
var listenerId = -1;
......@@ -105,7 +106,7 @@ export default class MainAbility extends UIAbility {
off(type: "mission", listenerId: number, callback: AsyncCallback&lt;void&gt;): void;
取消任务状态监听
解注册任务状态监听器
**需要权限**:ohos.permission.MANAGE_MISSIONS
......@@ -117,7 +118,7 @@ off(type: "mission", listenerId: number, callback: AsyncCallback&lt;void&gt;): v
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| listenerId | number | 是 | 系统任务状态监听方法的index值,和监听方法一一对应,由registerMissionListener方法返回。 |
| listenerId | number | 是 | 系统任务状态监器法的index值,和监听器一一对应,由on方法返回。 |
| callback | AsyncCallback&lt;void&gt; | 是 | 执行结果回调函数。 |
**示例:**
......@@ -131,7 +132,8 @@ var listener = {
onMissionSnapshotChanged: function (mission) {console.log("--------onMissionSnapshotChanged-------")},
onMissionMovedToFront: function (mission) {console.log("--------onMissionMovedToFront-------")},
onMissionIconUpdated: function (mission, icon) {console.log("--------onMissionIconUpdated-------")},
onMissionClosed: function (mission) {console.log("--------onMissionClosed-------")}
onMissionClosed: function (mission) {console.log("--------onMissionClosed-------")},
onMissionLabelUpdated: function (mission) {console.log("--------onMissionLabelUpdated-------")}
};
var listenerId = -1;
......@@ -185,7 +187,7 @@ export default class MainAbility extends UIAbility {
off(type: "mission", listenerId: number): Promise&lt;void&gt;;
取消任务状态监听,以promise方式返回执行结果。
解注册任务状态监听,以promise方式返回执行结果。
**需要权限**:ohos.permission.MANAGE_MISSIONS
......@@ -197,7 +199,7 @@ off(type: "mission", listenerId: number): Promise&lt;void&gt;;
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| listenerId | number | 是 | 系统任务状态监听方法的index值,和监听方法一一对应,由registerMissionListener方法返回。 |
| listenerId | number | 是 | 系统任务状态监听器的index值,和监听器一一对应,由on方法返回。 |
**返回值:**
......@@ -216,7 +218,8 @@ var listener = {
onMissionSnapshotChanged: function (mission) {console.log("--------onMissionSnapshotChanged-------")},
onMissionMovedToFront: function (mission) {console.log("--------onMissionMovedToFront-------")},
onMissionIconUpdated: function (mission, icon) {console.log("--------onMissionIconUpdated-------")},
onMissionClosed: function (mission) {console.log("--------onMissionClosed-------")}
onMissionClosed: function (mission) {console.log("--------onMissionClosed-------")},
onMissionLabelUpdated: function (mission) {console.log("--------onMissionLabelUpdated-------")}
};
var listenerId = -1;
......@@ -292,7 +295,12 @@ getMissionInfo(deviceId: string, missionId: number, callback: AsyncCallback&lt;M
try {
var allMissions=missionManager.getMissionInfos("",10).catch(function(err){console.log(err);});
missionManager.getMissionInfo("", allMissions[0].missionId, (error, mission) => {
console.log("getMissionInfo is called, error.code = " + error.code)
if (error.code) {
console.log("getMissionInfo failed, error.code:" + JSON.stringify(error.code) +
"error.message:" + JSON.stringify(error.message));
return;
}
console.log("mission.missionId = " + mission.missionId);
console.log("mission.runningState = " + mission.runningState);
console.log("mission.lockedState = " + mission.lockedState);
......@@ -369,7 +377,11 @@ getMissionInfos(deviceId: string, numMax: number, callback: AsyncCallback&lt;Arr
```ts
try {
missionManager.getMissionInfos("", 10, (error, missions) => {
console.log("getMissionInfos is called, error.code = " + error.code);
if (error.code) {
console.log("getMissionInfo failed, error.code:" + JSON.stringify(error.code) +
"error.message:" + JSON.stringify(error.message));
return;
}
console.log("size = " + missions.length);
console.log("missions = " + JSON.stringify(missions));
})
......@@ -442,13 +454,21 @@ getMissionSnapShot(deviceId: string, missionId: number, callback: AsyncCallback&
```ts
try {
missionManager.getMissionInfos("", 10, (error, missions) => {
console.log("getMissionInfos is called, error.code = " + error.code);
if (error.code) {
console.log("getMissionInfos failed, error.code:" + JSON.stringify(error.code) +
"error.message:" + JSON.stringify(error.message));
return;
}
console.log("size = " + missions.length);
console.log("missions = " + JSON.stringify(missions));
var id = missions[0].missionId;
missionManager.getMissionSnapShot("", id, (error, snapshot) => {
console.log("getMissionSnapShot is called, error.code = " + error.code);
missionManager.getMissionSnapShot("", id, (err, snapshot) => {
if (err.code) {
console.log("getMissionInfos failed, err.code:" + JSON.stringify(err.code) +
"err.message:" + JSON.stringify(err.message));
return;
}
console.log("bundleName = " + snapshot.ability.bundleName);
})
})
......@@ -507,7 +527,7 @@ getMissionSnapShot(deviceId: string, missionId: number): Promise&lt;MissionSnaps
getLowResolutionMissionSnapShot(deviceId: string, missionId: number, callback: AsyncCallback\<MissionSnapshot>): void;
使用给定的任务ID获取任务低分辨率快照。
获取任务低分辨率快照。
**需要权限**:ohos.permission.MANAGE_MISSIONS
......@@ -528,13 +548,21 @@ getLowResolutionMissionSnapShot(deviceId: string, missionId: number, callback: A
```ts
try {
missionManager.getMissionInfos("", 10, (error, missions) => {
console.log("getMissionInfos is called, error.code = " + error.code);
if (error.code) {
console.log("getMissionInfos failed, error.code:" + JSON.stringify(error.code) +
"error.message:" + JSON.stringify(error.message));
return;
}
console.log("size = " + missions.length);
console.log("missions = " + JSON.stringify(missions));
var id = missions[0].missionId;
missionManager.getLowResolutionMissionSnapShot("", id, (error, snapshot) => {
console.log("getLowResolutionMissionSnapShot is called, error.code = " + error.code);
if (error.code) {
console.log("getLowResolutionMissionSnapShot failed, error.code:" + JSON.stringify(error.code) +
"error.message:" + JSON.stringify(error.message));
return;
}
console.log("bundleName = " + snapshot.ability.bundleName);
})
})
......@@ -548,7 +576,7 @@ getLowResolutionMissionSnapShot(deviceId: string, missionId: number, callback: A
getLowResolutionMissionSnapShot(deviceId: string, missionId: number): Promise\<MissionSnapshot>;
使用给定的任务ID获取任务低分辨率快照。
获取任务低分辨率快照。
**需要权限**:ohos.permission.MANAGE_MISSIONS
......@@ -614,7 +642,12 @@ lockMission(missionId: number, callback: AsyncCallback&lt;void&gt;): void;
```ts
try {
missionManager.getMissionInfos("", 10, (error, missions) => {
console.log("getMissionInfos is called, error.code = " + error.code);
if (error.code) {
console.log("getMissionInfos failed, error.code:" + JSON.stringify(error.code) +
"error.message:" + JSON.stringify(error.message));
return;
}
console.log("size = " + missions.length);
console.log("missions = " + JSON.stringify(missions));
var id = missions[0].missionId;
......@@ -698,7 +731,11 @@ unlockMission(missionId: number, callback: AsyncCallback&lt;void&gt;): void;
```ts
try {
missionManager.getMissionInfos("", 10, (error, missions) => {
console.log("getMissionInfos is called, error.code = " + error.code);
if (error.code) {
console.log("getMissionInfos failed, error.code:" + JSON.stringify(error.code) +
"error.message:" + JSON.stringify(error.message));
return;
}
console.log("size = " + missions.length);
console.log("missions = " + JSON.stringify(missions));
var id = missions[0].missionId;
......@@ -785,7 +822,11 @@ clearMission(missionId: number, callback: AsyncCallback&lt;void&gt;): void;
```ts
try {
missionManager.getMissionInfos("", 10, (error, missions) => {
console.log("getMissionInfos is called, error.code = " + error.code);
if (error.code) {
console.log("getMissionInfos failed, error.code:" + JSON.stringify(error.code) +
"error.message:" + JSON.stringify(error.message));
return;
}
console.log("size = " + missions.length);
console.log("missions = " + JSON.stringify(missions));
var id = missions[0].missionId;
......@@ -917,7 +958,11 @@ moveMissionToFront(missionId: number, callback: AsyncCallback&lt;void&gt;): void
```ts
try {
missionManager.getMissionInfos("", 10, (error, missions) => {
console.log("getMissionInfos is called, error.code = " + error.code);
if (error.code) {
console.log("getMissionInfos failed, error.code:" + JSON.stringify(error.code) +
"error.message:" + JSON.stringify(error.message));
return;
}
console.log("size = " + missions.length);
console.log("missions = " + JSON.stringify(missions));
var id = missions[0].missionId;
......@@ -957,7 +1002,11 @@ moveMissionToFront(missionId: number, options: StartOptions, callback: AsyncCall
```ts
try {
missionManager.getMissionInfos("", 10, (error, missions) => {
console.log("getMissionInfos is called, error.code = " + error.code);
if (error.code) {
console.log("getMissionInfos failed, error.code:" + JSON.stringify(error.code) +
"error.message:" + JSON.stringify(error.message));
return;
}
console.log("size = " + missions.length);
console.log("missions = " + JSON.stringify(missions));
var id = missions[0].missionId;
......
......@@ -20,7 +20,7 @@ ohos.permission.MANAGE_MISSIONS
registerMissionListener(listener: MissionListener): number;
注册系统任务状态监听。
注册系统任务状态监听
**需要权限**:ohos.permission.MANAGE_MISSIONS
......@@ -32,13 +32,13 @@ registerMissionListener(listener: MissionListener): number;
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| listener | [MissionListener](js-apis-inner-application-missionListener.md) | 是 | 系统任务监听方法。 |
| listener | [MissionListener](js-apis-inner-application-missionListener.md) | 是 | 系统任务监听。 |
**返回值:**
| 类型 | 说明 |
| -------- | -------- |
| number | 监听方法的index值,由系统创建,在注册系统任务状态监听时分配,和监听方法一一对应&nbsp;。 |
| number | 监听器的index值,由系统创建,在注册系统任务状态监听器时分配,和监听器一一对应&nbsp;。 |
**示例:**
......@@ -61,7 +61,7 @@ var listenerid = missionManager.registerMissionListener(listener);
unregisterMissionListener(listenerId: number, callback: AsyncCallback&lt;void&gt;): void;
取消任务状态监听
解注册任务状态监听器
**需要权限**:ohos.permission.MANAGE_MISSIONS
......@@ -73,7 +73,7 @@ unregisterMissionListener(listenerId: number, callback: AsyncCallback&lt;void&gt
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| listenerId | number | 是 | 系统任务状态监听方法的index值,和监听方法一一对应,由registerMissionListener方法返回。 |
| listenerId | number | 是 | 系统任务状态监听器的index值,和监听器一一对应,由registerMissionListener方法返回。 |
| callback | AsyncCallback&lt;void&gt; | 是 | 执行结果回调函数。 |
**示例:**
......@@ -101,7 +101,7 @@ unregisterMissionListener(listenerId: number, callback: AsyncCallback&lt;void&gt
unregisterMissionListener(listenerId: number): Promise&lt;void&gt;;
取消任务状态监听,以promise方式返回执行结果。
反注册任务状态监听器,以promise方式返回执行结果。
**需要权限**:ohos.permission.MANAGE_MISSIONS
......@@ -113,7 +113,7 @@ unregisterMissionListener(listenerId: number): Promise&lt;void&gt;;
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| listenerId | number | 是 | 系统任务状态监听方法的index值,和监听方法一一对应,由registerMissionListener方法返回。 |
| listenerId | number | 是 | 系统任务状态监听器的index值,和监听器一一对应,由registerMissionListener方法返回。 |
**返回值:**
......@@ -146,7 +146,7 @@ unregisterMissionListener(listenerId: number): Promise&lt;void&gt;;
getMissionInfo(deviceId: string, missionId: number, callback: AsyncCallback&lt;MissionInfo&gt;): void;
获取任务信息,以异步回调的方式返回任务信息。
获取单个任务信息,以异步回调的方式返回任务信息。
**需要权限**:ohos.permission.MANAGE_MISSIONS
......@@ -169,7 +169,12 @@ getMissionInfo(deviceId: string, missionId: number, callback: AsyncCallback&lt;M
var allMissions=missionManager.getMissionInfos("",10).catch(function(err){console.log(err);});
missionManager.getMissionInfo("", allMissions[0].missionId, (error, mission) => {
console.log("getMissionInfo is called, error.code = " + error.code)
if (error.code) {
console.log("getMissionInfo failed, error.code:" + JSON.stringify(error.code) +
"error.message:" + JSON.stringify(error.message));
return;
}
console.log("mission.missionId = " + mission.missionId);
console.log("mission.runningState = " + mission.runningState);
console.log("mission.lockedState = " + mission.lockedState);
......@@ -184,7 +189,7 @@ getMissionInfo(deviceId: string, missionId: number, callback: AsyncCallback&lt;M
getMissionInfo(deviceId: string, missionId: number): Promise&lt;MissionInfo&gt;;
获取任务信息,以promise方式返回任务信息。
获取单个任务信息,以promise方式返回任务信息。
**需要权限**:ohos.permission.MANAGE_MISSIONS
......@@ -242,7 +247,11 @@ getMissionInfos(deviceId: string, numMax: number, callback: AsyncCallback&lt;Arr
import missionManager from '@ohos.application.missionManager'
missionManager.getMissionInfos("", 10, (error, missions) => {
console.log("getMissionInfos is called, error.code = " + error.code);
if (error.code) {
console.log("getMissionInfos failed, error.code:" + JSON.stringify(error.code) +
"error.message:" + JSON.stringify(error.message));
return;
}
console.log("size = " + missions.length);
console.log("missions = " + JSON.stringify(missions));
})
......@@ -311,13 +320,21 @@ getMissionSnapShot(deviceId: string, missionId: number, callback: AsyncCallback&
import missionManager from '@ohos.application.missionManager'
missionManager.getMissionInfos("", 10, (error, missions) => {
console.log("getMissionInfos is called, error.code = " + error.code);
if (error.code) {
console.log("getMissionInfos failed, error.code:" + JSON.stringify(error.code) +
"error.message:" + JSON.stringify(error.message));
return;
}
console.log("size = " + missions.length);
console.log("missions = " + JSON.stringify(missions));
var id = missions[0].missionId;
missionManager.getMissionSnapShot("", id, (error, snapshot) => {
console.log("getMissionSnapShot is called, error.code = " + error.code);
if (error.code) {
console.log("getMissionSnapShot failed, error.code:" + JSON.stringify(error.code) +
"error.message:" + JSON.stringify(error.message));
return;
}
console.log("bundleName = " + snapshot.ability.bundleName);
})
})
......@@ -371,7 +388,7 @@ getMissionSnapShot(deviceId: string, missionId: number): Promise&lt;MissionSnaps
getLowResolutionMissionSnapShot(deviceId: string, missionId: number, callback: AsyncCallback\<MissionSnapshot>): void;
使用给定的任务ID获取任务低分辨率快照。
获取任务低分辨率快照。
**需要权限**:ohos.permission.MANAGE_MISSIONS
......@@ -393,13 +410,21 @@ getLowResolutionMissionSnapShot(deviceId: string, missionId: number, callback: A
import missionManager from '@ohos.application.missionManager'
missionManager.getMissionInfos("", 10, (error, missions) => {
console.log("getMissionInfos is called, error.code = " + error.code);
if (error.code) {
console.log("getMissionInfos failed, error.code:" + JSON.stringify(error.code) +
"error.message:" + JSON.stringify(error.message));
return;
}
console.log("size = " + missions.length);
console.log("missions = " + JSON.stringify(missions));
var id = missions[0].missionId;
missionManager.getLowResolutionMissionSnapShot("", id, (error, snapshot) => {
console.log("getLowResolutionMissionSnapShot is called, error.code = " + error.code);
if (error.code) {
console.log("getLowResolutionMissionSnapShot failed, error.code:" + JSON.stringify(error.code) +
"error.message:" + JSON.stringify(error.message));
return;
}
console.log("bundleName = " + snapshot.ability.bundleName);
})
})
......@@ -410,7 +435,7 @@ getLowResolutionMissionSnapShot(deviceId: string, missionId: number, callback: A
getLowResolutionMissionSnapShot(deviceId: string, missionId: number): Promise\<MissionSnapshot>;
使用给定的任务ID获取任务低分辨率快照。
获取任务低分辨率快照。
**需要权限**:ohos.permission.MANAGE_MISSIONS
......@@ -475,7 +500,11 @@ lockMission(missionId: number, callback: AsyncCallback&lt;void&gt;): void;
import missionManager from '@ohos.application.missionManager'
missionManager.getMissionInfos("", 10, (error, missions) => {
console.log("getMissionInfos is called, error.code = " + error.code);
if (error.code) {
console.log("getMissionInfos failed, error.code:" + JSON.stringify(error.code) +
"error.message:" + JSON.stringify(error.message));
return;
}
console.log("size = " + missions.length);
console.log("missions = " + JSON.stringify(missions));
var id = missions[0].missionId;
......@@ -554,7 +583,11 @@ unlockMission(missionId: number, callback: AsyncCallback&lt;void&gt;): void;
import missionManager from '@ohos.application.missionManager'
missionManager.getMissionInfos("", 10, (error, missions) => {
console.log("getMissionInfos is called, error.code = " + error.code);
if (error.code) {
console.log("getMissionInfos failed, error.code:" + JSON.stringify(error.code) +
"error.message:" + JSON.stringify(error.message));
return;
}
console.log("size = " + missions.length);
console.log("missions = " + JSON.stringify(missions));
var id = missions[0].missionId;
......@@ -637,7 +670,11 @@ clearMission(missionId: number, callback: AsyncCallback&lt;void&gt;): void;
import missionManager from '@ohos.application.missionManager'
missionManager.getMissionInfos("", 10, (error, missions) => {
console.log("getMissionInfos is called, error.code = " + error.code);
if (error.code) {
console.log("getMissionInfos failed, error.code:" + JSON.stringify(error.code) +
"error.message:" + JSON.stringify(error.message));
return;
}
console.log("size = " + missions.length);
console.log("missions = " + JSON.stringify(missions));
var id = missions[0].missionId;
......@@ -768,7 +805,11 @@ moveMissionToFront(missionId: number, callback: AsyncCallback&lt;void&gt;): void
import missionManager from '@ohos.application.missionManager'
missionManager.getMissionInfos("", 10, (error, missions) => {
console.log("getMissionInfos is called, error.code = " + error.code);
if (error.code) {
console.log("getMissionInfos failed, error.code:" + JSON.stringify(error.code) +
"error.message:" + JSON.stringify(error.message));
return;
}
console.log("size = " + missions.length);
console.log("missions = " + JSON.stringify(missions));
var id = missions[0].missionId;
......@@ -806,7 +847,11 @@ moveMissionToFront(missionId: number, options: StartOptions, callback: AsyncCall
import missionManager from '@ohos.application.missionManager'
missionManager.getMissionInfos("", 10, (error, missions) => {
console.log("getMissionInfos is called, error.code = " + error.code);
if (error.code) {
console.log("getMissionInfos failed, error.code:" + JSON.stringify(error.code) +
"error.message:" + JSON.stringify(error.message));
return;
}
console.log("size = " + missions.length);
console.log("missions = " + JSON.stringify(missions));
var id = missions[0].missionId;
......
# MissionInfo
表示Ability对应的任务信息,可以通过[getMissionInfo](js-apis-app-ability-missionManager.md#missionmanagergetmissioninfo)获取。
表示任务的详细信息,可以通过[getMissionInfo](js-apis-app-ability-missionManager.md#missionmanagergetmissioninfo)获取。
**系统能力**:以下各项对应的系统能力均为SystemCapability.Ability.AbilityRuntime.Mission
......@@ -19,16 +19,27 @@
**示例:**
```ts
import missionManager from '@ohos.application.missionManager'
import missionManager from '@ohos.app.ability.missionManager'
missionManager.getMissionInfo("12345", 1, (error, data) => {
console.info('getMissionInfo missionId is:' + JSON.stringify(data.missionId));
console.info('getMissionInfo runningState is:' + JSON.stringify(data.runningState));
console.info('getMissionInfo lockedState is:' + JSON.stringify(data.lockedState));
console.info('getMissionInfo timestamp is:' + JSON.stringify(data.timestamp));
console.info('getMissionInfo want is:' + JSON.stringify(data.want));
console.info('getMissionInfo label is:' + JSON.stringify(data.label));
console.info('getMissionInfo iconPath is:' + JSON.stringify(data.iconPath));
console.info('getMissionInfo continuable is:' + JSON.stringify(data.continuable));
});
try {
missionManager.getMissionInfo("", 1, (error, data) => {
if (error.code) {
// 处理业务逻辑错误
console.log("getMissionInfo failed, error.code:" + JSON.stringify(error.code) +
"error.message:" + JSON.stringify(error.message));
return;
}
console.log('getMissionInfo missionId is:' + JSON.stringify(data.missionId));
console.log('getMissionInfo runningState is:' + JSON.stringify(data.runningState));
console.log('getMissionInfo lockedState is:' + JSON.stringify(data.lockedState));
console.log('getMissionInfo timestamp is:' + JSON.stringify(data.timestamp));
console.log('getMissionInfo want is:' + JSON.stringify(data.want));
console.log('getMissionInfo label is:' + JSON.stringify(data.label));
console.log('getMissionInfo iconPath is:' + JSON.stringify(data.iconPath));
console.log('getMissionInfo continuable is:' + JSON.stringify(data.continuable));
});
} catch (paramError) {
console.log("error: " + paramError.code + ", " + paramError.message);
}
```
\ No newline at end of file
# MissionListener
定义系统任务状态监听,可以通过[registerMissionListener](js-apis-application-missionManager.md#missionmanagerregistermissionlistener)注册。
定义系统任务状态监听,可以通过[on](js-apis-app-ability-missionManager.md#missionmanageron)注册。
**系统能力**:以下各项对应的系统能力均为SystemCapability.Ability.AbilityRuntime.Mission
......@@ -16,7 +16,7 @@
**示例:**
```ts
import missionManager from '@ohos.application.missionManager'
import missionManager from '@ohos.app.ability.missionManager'
let listener = {
onMissionCreated: function (mission) {
......@@ -38,5 +38,10 @@ let listener = {
console.log("onMissionClosed mission: " + JSON.stringify(mission));
}
};
let listenerid = missionManager.registerMissionListener(listener);
try {
let listenerId = missionManager.on("mission", listener);
} catch (paramError) {
console.log("error: " + paramError.code + ", " + paramError.message);
}
```
\ No newline at end of file
......@@ -11,7 +11,7 @@
| 名称 | 类型 | 可读 | 可写 | 说明 |
| -------- | -------- | -------- | -------- | -------- |
| ability | ElementName | 是 | 是 | 表示Ability任务元素名称。 |
| ability | ElementName | 是 | 是 | 表示该任务的组件信息。 |
| snapshot | [image.PixelMap](js-apis-image.md) | 是 | 是 | 表示任务快照。 |
## 使用说明
......@@ -20,19 +20,33 @@
**示例:**
```ts
import ElementName from '@ohos.bundle';
import image from '@ohos.multimedia.image';
import missionManager from '@ohos.application.missionManager';
missionManager.getMissionInfos("", 10, (error, missions) => {
console.log("getMissionInfos is called, error.code = " + error.code);
import ElementName from '@ohos.bundle';
import image from '@ohos.multimedia.image';
import missionManager from '@ohos.app.ability.missionManager';
try {
missionManager.getMissionInfos("", 10, (error, missions) => {
if (error.code) {
console.log("getMissionInfos failed, error.code:" + JSON.stringify(error.code) +
"error.message:" + JSON.stringify(error.message));
return;
}
console.log("size = " + missions.length);
console.log("missions = " + JSON.stringify(missions));
var id = missions[0].missionId;
missionManager.getMissionSnapShot("", id, (error, snapshot) => {
console.log("getMissionSnapShot is called, error.code = " + error.code);
missionManager.getMissionSnapShot("", id, (err, snapshot) => {
if (err.code) {
console.log("getMissionInfos failed, err.code:" + JSON.stringify(err.code) +
"err.message:" + JSON.stringify(err.message));
return;
}
// 执行正常业务
console.log("bundleName = " + snapshot.ability.bundleName);
})
})
})
} catch (paramError) {
console.log("error: " + paramError.code + ", " + paramError.message);
}
```
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册