• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# MissionInfo
2
3The **MissionInfo** module defines detailed information about a mission. The information can be obtained through [getMissionInfo](js-apis-app-ability-missionManager.md#missionmanagergetmissioninfo).
4
5> **NOTE**
6>
7> 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.
8
9## Modules to Import
10
11```ts
12import missionManager from '@ohos.app.ability.missionManager';
13```
14
15## Attributes
16
17**System capability**: SystemCapability.Ability.AbilityRuntime.Mission
18
19**System API**: This is a system API and cannot be called by third-party applications.
20
21| Name| Type| Readable| Writable| Description|
22| -------- | -------- | -------- | -------- | -------- |
23| missionId | number | Yes| Yes| Mission ID.|
24| runningState | number | Yes| Yes| Running state of the mission.|
25| lockedState | boolean | Yes| Yes| Locked state of the mission.|
26| timestamp | string | Yes| Yes| Latest time when the mission was created or updated.|
27| want | [Want](js-apis-app-ability-want.md) | Yes| Yes| Want information of the mission.|
28| label | string | Yes| Yes| Label of the mission.|
29| iconPath | string | Yes| Yes| Path of the mission icon.|
30| continuable | boolean | Yes| Yes| Whether the mission can be continued on another device.|
31| abilityState<sup>10+</sup> | number | Yes| Yes| Capability status of the mission.|
32| unclearable<sup>10+</sup> | boolean | Yes| Yes| Whether the mission can be manually deleted.|
33
34**Example**
35```ts
36import missionManager from '@ohos.app.ability.missionManager';
37
38try {
39  missionManager.getMissionInfo('', 1, (error, data) => {
40    if (error) {
41        // Process service logic errors.
42        console.error(`getMissionInfo failed, error.code: ${error.code}, error.message: ${error.message}`);
43        return;
44    }
45
46    console.log(`getMissionInfo missionId is: ${JSON.stringify(data.missionId)}`);
47    console.log(`getMissionInfo runningState is: ${JSON.stringify(data.runningState)}`);
48    console.log(`getMissionInfo lockedState is: ${JSON.stringify(data.lockedState)}`);
49    console.log(`getMissionInfo timestamp is: ${JSON.stringify(data.timestamp)}`);
50    console.log(`getMissionInfo want is: ${JSON.stringify(data.want)}`);
51    console.log(`getMissionInfo label is: ${JSON.stringify(data.label)}`);
52    console.log(`getMissionInfo iconPath is: ${JSON.stringify(data.iconPath)}`);
53    console.log(`getMissionInfo continuable is: ${JSON.stringify(data.continuable)}`);
54    console.log(`getMissionInfo unclearable is: ${JSON.stringify(data.unclearable)}`);
55    });
56} catch (paramError) {
57    console.error(`error: ${paramError.code}, ${paramError.message}`);
58}
59```
60