1e41f4b71Sopenharmony_ci# @ohos.app.ability.missionManager (missionManager) (System API)
2e41f4b71Sopenharmony_ci
3e41f4b71Sopenharmony_ciThe missionManager module provides APIs to lock, unlock, and clear missions, and switch a mission to the foreground.
4e41f4b71Sopenharmony_ci
5e41f4b71Sopenharmony_ci> **NOTE**
6e41f4b71Sopenharmony_ci>
7e41f4b71Sopenharmony_ci> 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.
8e41f4b71Sopenharmony_ci>
9e41f4b71Sopenharmony_ci> The APIs of this module are system APIs and cannot be called by third-party applications.
10e41f4b71Sopenharmony_ci
11e41f4b71Sopenharmony_ci## Modules to Import
12e41f4b71Sopenharmony_ci
13e41f4b71Sopenharmony_ci```ts
14e41f4b71Sopenharmony_ciimport { missionManager } from '@kit.AbilityKit';
15e41f4b71Sopenharmony_ci```
16e41f4b71Sopenharmony_ci
17e41f4b71Sopenharmony_ci## Required Permissions
18e41f4b71Sopenharmony_ci
19e41f4b71Sopenharmony_ciohos.permission.MANAGE_MISSIONS
20e41f4b71Sopenharmony_ci
21e41f4b71Sopenharmony_ci## missionManager.on('mission')
22e41f4b71Sopenharmony_ci
23e41f4b71Sopenharmony_cion(type:'mission', listener: MissionListener): number
24e41f4b71Sopenharmony_ci
25e41f4b71Sopenharmony_ciRegisters a listener to observe the mission status.
26e41f4b71Sopenharmony_ci
27e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.MANAGE_MISSIONS
28e41f4b71Sopenharmony_ci
29e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Ability.AbilityRuntime.Mission
30e41f4b71Sopenharmony_ci
31e41f4b71Sopenharmony_ci**System API**: This is a system API and cannot be called by third-party applications.
32e41f4b71Sopenharmony_ci
33e41f4b71Sopenharmony_ci**Parameters**
34e41f4b71Sopenharmony_ci
35e41f4b71Sopenharmony_ci  | Name| Type| Mandatory| Description|
36e41f4b71Sopenharmony_ci  | -------- | -------- | -------- | -------- |
37e41f4b71Sopenharmony_ci  | type     | string   | Yes      | Name of the target mission.|
38e41f4b71Sopenharmony_ci  | listener | [MissionListener](js-apis-inner-application-missionListener-sys.md) | Yes| Mission status listener to register.|
39e41f4b71Sopenharmony_ci
40e41f4b71Sopenharmony_ci**Error codes**
41e41f4b71Sopenharmony_ci
42e41f4b71Sopenharmony_ciFor details about the error codes, see [Universal Error Codes](../errorcode-universal.md).
43e41f4b71Sopenharmony_ci
44e41f4b71Sopenharmony_ci| ID| Error Message|
45e41f4b71Sopenharmony_ci| ------- | -------------------------------- |
46e41f4b71Sopenharmony_ci| 201 | Permission denied. |
47e41f4b71Sopenharmony_ci| 202 | Not System App. Interface caller is not a system app. |
48e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
49e41f4b71Sopenharmony_ci
50e41f4b71Sopenharmony_ci**Return value**
51e41f4b71Sopenharmony_ci
52e41f4b71Sopenharmony_ci  | Type| Description|
53e41f4b71Sopenharmony_ci  | -------- | -------- |
54e41f4b71Sopenharmony_ci  | number | Index of the mission status listener, which is created by the system and allocated when the listener is registered.|
55e41f4b71Sopenharmony_ci
56e41f4b71Sopenharmony_ci**Example**
57e41f4b71Sopenharmony_ci
58e41f4b71Sopenharmony_ci```ts
59e41f4b71Sopenharmony_ciimport { missionManager, UIAbility, AbilityConstant, common, Want } from '@kit.AbilityKit';
60e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
61e41f4b71Sopenharmony_ciimport { window } from '@kit.ArkUI';
62e41f4b71Sopenharmony_ciimport { image } from '@kit.ImageKit';
63e41f4b71Sopenharmony_ci
64e41f4b71Sopenharmony_cilet listener: missionManager.MissionListener = {
65e41f4b71Sopenharmony_ci  onMissionCreated: (mission: number) => {console.log('--------onMissionCreated-------');},
66e41f4b71Sopenharmony_ci  onMissionDestroyed: (mission: number) => {console.log('--------onMissionDestroyed-------');},
67e41f4b71Sopenharmony_ci  onMissionSnapshotChanged: (mission: number) => {console.log('--------onMissionSnapshotChanged-------');},
68e41f4b71Sopenharmony_ci  onMissionMovedToFront: (mission: number) => {console.log('--------onMissionMovedToFront-------');},
69e41f4b71Sopenharmony_ci  onMissionIconUpdated: (mission: number, icon: image.PixelMap) => {console.log('--------onMissionIconUpdated-------');},
70e41f4b71Sopenharmony_ci  onMissionClosed: (mission: number) => {console.log('--------onMissionClosed-------');},
71e41f4b71Sopenharmony_ci  onMissionLabelUpdated: (mission: number) => {console.log('--------onMissionLabelUpdated-------');}
72e41f4b71Sopenharmony_ci};
73e41f4b71Sopenharmony_ci
74e41f4b71Sopenharmony_cilet listenerId = -1;
75e41f4b71Sopenharmony_cilet abilityWant: Want;
76e41f4b71Sopenharmony_cilet context: common.UIAbilityContext;
77e41f4b71Sopenharmony_ci
78e41f4b71Sopenharmony_ciexport default class EntryAbility extends UIAbility {
79e41f4b71Sopenharmony_ci  onCreate(want: Want, launchParam: AbilityConstant.LaunchParam) {
80e41f4b71Sopenharmony_ci    console.log('[Demo] EntryAbility onCreate');
81e41f4b71Sopenharmony_ci    abilityWant = want;
82e41f4b71Sopenharmony_ci    context = this.context;
83e41f4b71Sopenharmony_ci  }
84e41f4b71Sopenharmony_ci
85e41f4b71Sopenharmony_ci  onDestroy() {
86e41f4b71Sopenharmony_ci    try {
87e41f4b71Sopenharmony_ci      if (listenerId !== -1) {
88e41f4b71Sopenharmony_ci        missionManager.off('mission', listenerId).catch((err: BusinessError) => {
89e41f4b71Sopenharmony_ci          console.log(JSON.stringify(err));
90e41f4b71Sopenharmony_ci        });
91e41f4b71Sopenharmony_ci      }
92e41f4b71Sopenharmony_ci    } catch (paramError) {
93e41f4b71Sopenharmony_ci      let code = (paramError as BusinessError).code;
94e41f4b71Sopenharmony_ci      let message = (paramError as BusinessError).message;
95e41f4b71Sopenharmony_ci      console.error(`error: ${code}, ${message} `);
96e41f4b71Sopenharmony_ci    }
97e41f4b71Sopenharmony_ci    console.log('[Demo] EntryAbility onDestroy');
98e41f4b71Sopenharmony_ci  }
99e41f4b71Sopenharmony_ci
100e41f4b71Sopenharmony_ci  onWindowStageCreate(windowStage: window.WindowStage) {
101e41f4b71Sopenharmony_ci    // The main window is created. Set a main page for this ability.
102e41f4b71Sopenharmony_ci    console.log('[Demo] EntryAbility onWindowStageCreate');
103e41f4b71Sopenharmony_ci    try {
104e41f4b71Sopenharmony_ci      listenerId = missionManager.on('mission', listener);
105e41f4b71Sopenharmony_ci    } catch (paramError) {
106e41f4b71Sopenharmony_ci      let code = (paramError as BusinessError).code;
107e41f4b71Sopenharmony_ci      let message = (paramError as BusinessError).message;
108e41f4b71Sopenharmony_ci      console.error(`error: ${code}, ${message} `);
109e41f4b71Sopenharmony_ci    }
110e41f4b71Sopenharmony_ci
111e41f4b71Sopenharmony_ci    windowStage.loadContent('pages/index', (err, data) => {
112e41f4b71Sopenharmony_ci      if (err.code) {
113e41f4b71Sopenharmony_ci        console.error(`Failed to load the content. Cause: ${JSON.stringify(err)}`);
114e41f4b71Sopenharmony_ci        return;
115e41f4b71Sopenharmony_ci      }
116e41f4b71Sopenharmony_ci      console.info(`Succeeded in loading the content. Data: ${JSON.stringify(data)}`);
117e41f4b71Sopenharmony_ci    });
118e41f4b71Sopenharmony_ci  }
119e41f4b71Sopenharmony_ci}
120e41f4b71Sopenharmony_ci```
121e41f4b71Sopenharmony_ci
122e41f4b71Sopenharmony_ci
123e41f4b71Sopenharmony_ci## missionManager.off('mission')
124e41f4b71Sopenharmony_ci
125e41f4b71Sopenharmony_cioff(type: 'mission', listenerId: number, callback: AsyncCallback<void>): void
126e41f4b71Sopenharmony_ci
127e41f4b71Sopenharmony_ciDeregisters a mission status listener.
128e41f4b71Sopenharmony_ci
129e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.MANAGE_MISSIONS
130e41f4b71Sopenharmony_ci
131e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Ability.AbilityRuntime.Mission
132e41f4b71Sopenharmony_ci
133e41f4b71Sopenharmony_ci**System API**: This is a system API and cannot be called by third-party applications.
134e41f4b71Sopenharmony_ci
135e41f4b71Sopenharmony_ci**Parameters**
136e41f4b71Sopenharmony_ci
137e41f4b71Sopenharmony_ci  | Name| Type| Mandatory| Description|
138e41f4b71Sopenharmony_ci  | -------- | -------- | -------- | -------- |
139e41f4b71Sopenharmony_ci  | type     | string   | Yes      | Name of the target mission.|
140e41f4b71Sopenharmony_ci  | listenerId | number | Yes| Index of the mission status listener to deregister. It is returned by **on()**.|
141e41f4b71Sopenharmony_ci  | callback | AsyncCallback<void> | Yes| Callback used to return the result.|
142e41f4b71Sopenharmony_ci
143e41f4b71Sopenharmony_ci**Error codes**
144e41f4b71Sopenharmony_ci
145e41f4b71Sopenharmony_ciFor details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Ability Error Codes](errorcode-ability.md).
146e41f4b71Sopenharmony_ci
147e41f4b71Sopenharmony_ci| ID| Error Message|
148e41f4b71Sopenharmony_ci| ------- | -------- |
149e41f4b71Sopenharmony_ci| 201 | Permission denied. |
150e41f4b71Sopenharmony_ci| 202 | Not System App. Interface caller is not a system app. |
151e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
152e41f4b71Sopenharmony_ci| 16300002 | The specified mission listener does not exist. |
153e41f4b71Sopenharmony_ci
154e41f4b71Sopenharmony_ci**Example**
155e41f4b71Sopenharmony_ci
156e41f4b71Sopenharmony_ci```ts
157e41f4b71Sopenharmony_ciimport { missionManager, UIAbility, AbilityConstant, common, Want } from '@kit.AbilityKit';
158e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
159e41f4b71Sopenharmony_ciimport { window } from '@kit.ArkUI';
160e41f4b71Sopenharmony_ciimport { image } from '@kit.ImageKit';
161e41f4b71Sopenharmony_ci
162e41f4b71Sopenharmony_cilet listener: missionManager.MissionListener = {
163e41f4b71Sopenharmony_ci  onMissionCreated: (mission: number) => {console.log('--------onMissionCreated-------');},
164e41f4b71Sopenharmony_ci  onMissionDestroyed: (mission: number) => {console.log('--------onMissionDestroyed-------');},
165e41f4b71Sopenharmony_ci  onMissionSnapshotChanged: (mission: number) => {console.log('--------onMissionSnapshotChanged-------');},
166e41f4b71Sopenharmony_ci  onMissionMovedToFront: (mission: number) => {console.log('--------onMissionMovedToFront-------');},
167e41f4b71Sopenharmony_ci  onMissionIconUpdated: (mission: number, icon: image.PixelMap) => {console.log('--------onMissionIconUpdated-------');},
168e41f4b71Sopenharmony_ci  onMissionClosed: (mission: number) => {console.log('--------onMissionClosed-------');},
169e41f4b71Sopenharmony_ci  onMissionLabelUpdated: (mission: number) => {console.log('--------onMissionLabelUpdated-------');}
170e41f4b71Sopenharmony_ci};
171e41f4b71Sopenharmony_ci
172e41f4b71Sopenharmony_cilet listenerId = -1;
173e41f4b71Sopenharmony_cilet abilityWant: Want;
174e41f4b71Sopenharmony_cilet context: common.UIAbilityContext;
175e41f4b71Sopenharmony_ci
176e41f4b71Sopenharmony_ciexport default class EntryAbility extends UIAbility {
177e41f4b71Sopenharmony_ci  onCreate(want: Want, launchParam: AbilityConstant.LaunchParam) {
178e41f4b71Sopenharmony_ci    console.log('[Demo] EntryAbility onCreate');
179e41f4b71Sopenharmony_ci    abilityWant = want;
180e41f4b71Sopenharmony_ci    context = this.context;
181e41f4b71Sopenharmony_ci  }
182e41f4b71Sopenharmony_ci
183e41f4b71Sopenharmony_ci  onDestroy() {
184e41f4b71Sopenharmony_ci    try {
185e41f4b71Sopenharmony_ci      if (listenerId !== -1) {
186e41f4b71Sopenharmony_ci        missionManager.off('mission', listenerId, (err: BusinessError) => {
187e41f4b71Sopenharmony_ci          console.log(`${err.code}`);
188e41f4b71Sopenharmony_ci        });
189e41f4b71Sopenharmony_ci      }
190e41f4b71Sopenharmony_ci    } catch (paramError) {
191e41f4b71Sopenharmony_ci      let code = (paramError as BusinessError).code;
192e41f4b71Sopenharmony_ci      let message = (paramError as BusinessError).message;
193e41f4b71Sopenharmony_ci      console.error(`error: ${code}, ${message} `);
194e41f4b71Sopenharmony_ci    }
195e41f4b71Sopenharmony_ci    console.log('[Demo] EntryAbility onDestroy');
196e41f4b71Sopenharmony_ci  }
197e41f4b71Sopenharmony_ci
198e41f4b71Sopenharmony_ci  onWindowStageCreate(windowStage: window.WindowStage) {
199e41f4b71Sopenharmony_ci    // The main window is created. Set a main page for this ability.
200e41f4b71Sopenharmony_ci    console.log('[Demo] EntryAbility onWindowStageCreate');
201e41f4b71Sopenharmony_ci    try {
202e41f4b71Sopenharmony_ci      listenerId = missionManager.on('mission', listener);
203e41f4b71Sopenharmony_ci    } catch (paramError) {
204e41f4b71Sopenharmony_ci      let code = (paramError as BusinessError).code;
205e41f4b71Sopenharmony_ci      let message = (paramError as BusinessError).message;
206e41f4b71Sopenharmony_ci      console.error(`error: ${code}, ${message} `);
207e41f4b71Sopenharmony_ci    }
208e41f4b71Sopenharmony_ci
209e41f4b71Sopenharmony_ci    windowStage.loadContent('pages/index', (err: BusinessError, data) => {
210e41f4b71Sopenharmony_ci      if (err.code) {
211e41f4b71Sopenharmony_ci        console.error(`Failed to load the content. Cause: ${JSON.stringify(err)}`);
212e41f4b71Sopenharmony_ci        return;
213e41f4b71Sopenharmony_ci      }
214e41f4b71Sopenharmony_ci      console.info(`Succeeded in loading the content. Data: ${JSON.stringify(data)}`);
215e41f4b71Sopenharmony_ci    });
216e41f4b71Sopenharmony_ci  }
217e41f4b71Sopenharmony_ci}
218e41f4b71Sopenharmony_ci```
219e41f4b71Sopenharmony_ci
220e41f4b71Sopenharmony_ci
221e41f4b71Sopenharmony_ci## missionManager.off('mission')
222e41f4b71Sopenharmony_ci
223e41f4b71Sopenharmony_cioff(type: 'mission', listenerId: number): Promise<void>
224e41f4b71Sopenharmony_ci
225e41f4b71Sopenharmony_ciDeregisters a mission status listener. This API uses a promise to return the result.
226e41f4b71Sopenharmony_ci
227e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.MANAGE_MISSIONS
228e41f4b71Sopenharmony_ci
229e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Ability.AbilityRuntime.Mission
230e41f4b71Sopenharmony_ci
231e41f4b71Sopenharmony_ci**System API**: This is a system API and cannot be called by third-party applications.
232e41f4b71Sopenharmony_ci
233e41f4b71Sopenharmony_ci**Parameters**
234e41f4b71Sopenharmony_ci
235e41f4b71Sopenharmony_ci  | Name| Type| Mandatory| Description|
236e41f4b71Sopenharmony_ci  | -------- | -------- | -------- | -------- |
237e41f4b71Sopenharmony_ci  | type     | string   | Yes      | Name of the target mission.|
238e41f4b71Sopenharmony_ci  | listenerId | number | Yes| Index of the mission status listener to deregister. It is returned by **on()**.|
239e41f4b71Sopenharmony_ci
240e41f4b71Sopenharmony_ci**Return value**
241e41f4b71Sopenharmony_ci
242e41f4b71Sopenharmony_ci  | Type| Description|
243e41f4b71Sopenharmony_ci  | -------- | -------- |
244e41f4b71Sopenharmony_ci  | Promise<void> | Promise used to return the result.|
245e41f4b71Sopenharmony_ci
246e41f4b71Sopenharmony_ci**Error codes**
247e41f4b71Sopenharmony_ci
248e41f4b71Sopenharmony_ciFor details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Ability Error Codes](errorcode-ability.md).
249e41f4b71Sopenharmony_ci
250e41f4b71Sopenharmony_ci| ID| Error Message|
251e41f4b71Sopenharmony_ci| ------- | -------- |
252e41f4b71Sopenharmony_ci| 201 | Permission denied. |
253e41f4b71Sopenharmony_ci| 202 | Not System App. Interface caller is not a system app. |
254e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
255e41f4b71Sopenharmony_ci| 16300002 | The specified mission listener does not exist. |
256e41f4b71Sopenharmony_ci
257e41f4b71Sopenharmony_ci**Example**
258e41f4b71Sopenharmony_ci
259e41f4b71Sopenharmony_ci```ts
260e41f4b71Sopenharmony_ciimport { missionManager, UIAbility, AbilityConstant, common, Want } from '@kit.AbilityKit';
261e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
262e41f4b71Sopenharmony_ciimport { window } from '@kit.ArkUI';
263e41f4b71Sopenharmony_ciimport { image } from '@kit.ImageKit';
264e41f4b71Sopenharmony_ci
265e41f4b71Sopenharmony_cilet listener: missionManager.MissionListener = {
266e41f4b71Sopenharmony_ci  onMissionCreated: (mission: number) => {console.log('--------onMissionCreated-------');},
267e41f4b71Sopenharmony_ci  onMissionDestroyed: (mission: number) => {console.log('--------onMissionDestroyed-------');},
268e41f4b71Sopenharmony_ci  onMissionSnapshotChanged: (mission: number) => {console.log('--------onMissionSnapshotChanged-------');},
269e41f4b71Sopenharmony_ci  onMissionMovedToFront: (mission: number) => {console.log('--------onMissionMovedToFront-------');},
270e41f4b71Sopenharmony_ci  onMissionIconUpdated: (mission: number, icon: image.PixelMap) => {console.log('--------onMissionIconUpdated-------');},
271e41f4b71Sopenharmony_ci  onMissionClosed: (mission: number) => {console.log('--------onMissionClosed-------');},
272e41f4b71Sopenharmony_ci  onMissionLabelUpdated: (mission: number) => {console.log('--------onMissionLabelUpdated-------');}
273e41f4b71Sopenharmony_ci};
274e41f4b71Sopenharmony_ci
275e41f4b71Sopenharmony_cilet listenerId = -1;
276e41f4b71Sopenharmony_cilet abilityWant: Want;
277e41f4b71Sopenharmony_cilet context: common.UIAbilityContext;
278e41f4b71Sopenharmony_ci
279e41f4b71Sopenharmony_ciexport default class EntryAbility extends UIAbility {
280e41f4b71Sopenharmony_ci  onCreate(want: Want, launchParam: AbilityConstant.LaunchParam) {
281e41f4b71Sopenharmony_ci    console.log('[Demo] EntryAbility onCreate');
282e41f4b71Sopenharmony_ci    abilityWant = want;
283e41f4b71Sopenharmony_ci    context = this.context;
284e41f4b71Sopenharmony_ci  }
285e41f4b71Sopenharmony_ci
286e41f4b71Sopenharmony_ci  onDestroy() {
287e41f4b71Sopenharmony_ci    try {
288e41f4b71Sopenharmony_ci      if (listenerId !== -1) {
289e41f4b71Sopenharmony_ci        missionManager.off('mission', listenerId).catch((err: BusinessError) => {
290e41f4b71Sopenharmony_ci          console.log(`${err.code}`);
291e41f4b71Sopenharmony_ci        });
292e41f4b71Sopenharmony_ci      }
293e41f4b71Sopenharmony_ci    } catch (paramError) {
294e41f4b71Sopenharmony_ci      let code = (paramError as BusinessError).code;
295e41f4b71Sopenharmony_ci      let message = (paramError as BusinessError).message;
296e41f4b71Sopenharmony_ci      console.error(`error: ${code}, ${message} `);
297e41f4b71Sopenharmony_ci    }
298e41f4b71Sopenharmony_ci    console.log('[Demo] EntryAbility onDestroy');
299e41f4b71Sopenharmony_ci  }
300e41f4b71Sopenharmony_ci
301e41f4b71Sopenharmony_ci  onWindowStageCreate(windowStage: window.WindowStage) {
302e41f4b71Sopenharmony_ci    // The main window is created. Set a main page for this ability.
303e41f4b71Sopenharmony_ci    console.log('[Demo] EntryAbility onWindowStageCreate');
304e41f4b71Sopenharmony_ci    try {
305e41f4b71Sopenharmony_ci      listenerId = missionManager.on('mission', listener);
306e41f4b71Sopenharmony_ci    } catch (paramError) {
307e41f4b71Sopenharmony_ci      let code = (paramError as BusinessError).code;
308e41f4b71Sopenharmony_ci      let message = (paramError as BusinessError).message;
309e41f4b71Sopenharmony_ci      console.error(`error: ${code}, ${message} `);
310e41f4b71Sopenharmony_ci    }
311e41f4b71Sopenharmony_ci
312e41f4b71Sopenharmony_ci    windowStage.loadContent('pages/index', (err: BusinessError, data) => {
313e41f4b71Sopenharmony_ci      if (err.code) {
314e41f4b71Sopenharmony_ci        console.error(`Failed to load the content. Cause: ${JSON.stringify(err)}`);
315e41f4b71Sopenharmony_ci        return;
316e41f4b71Sopenharmony_ci      }
317e41f4b71Sopenharmony_ci      console.info(`Succeeded in loading the content. Data: ${JSON.stringify(data)}`);
318e41f4b71Sopenharmony_ci    });
319e41f4b71Sopenharmony_ci  }
320e41f4b71Sopenharmony_ci}
321e41f4b71Sopenharmony_ci```
322e41f4b71Sopenharmony_ci
323e41f4b71Sopenharmony_ci## missionManager.getMissionInfo
324e41f4b71Sopenharmony_ci
325e41f4b71Sopenharmony_cigetMissionInfo(deviceId: string, missionId: number, callback: AsyncCallback<MissionInfo>): void
326e41f4b71Sopenharmony_ci
327e41f4b71Sopenharmony_ciObtains the information about a given mission. This API uses an asynchronous callback to return the result.
328e41f4b71Sopenharmony_ci
329e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.MANAGE_MISSIONS
330e41f4b71Sopenharmony_ci
331e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Ability.AbilityRuntime.Mission
332e41f4b71Sopenharmony_ci
333e41f4b71Sopenharmony_ci**System API**: This is a system API and cannot be called by third-party applications.
334e41f4b71Sopenharmony_ci
335e41f4b71Sopenharmony_ci**Parameters**
336e41f4b71Sopenharmony_ci
337e41f4b71Sopenharmony_ci  | Name| Type| Mandatory| Description|
338e41f4b71Sopenharmony_ci  | -------- | -------- | -------- | -------- |
339e41f4b71Sopenharmony_ci  | deviceId | string | Yes| Device ID. It is a null string by default for the local device.|
340e41f4b71Sopenharmony_ci  | missionId | number | Yes| Mission ID.|
341e41f4b71Sopenharmony_ci  | callback | AsyncCallback<[MissionInfo](js-apis-inner-application-missionInfo-sys.md)> | Yes| Callback used to return the mission information obtained.|
342e41f4b71Sopenharmony_ci
343e41f4b71Sopenharmony_ci**Error codes**
344e41f4b71Sopenharmony_ci
345e41f4b71Sopenharmony_ciFor details about the error codes, see [Universal Error Codes](../errorcode-universal.md).
346e41f4b71Sopenharmony_ci
347e41f4b71Sopenharmony_ci| ID| Error Message|
348e41f4b71Sopenharmony_ci| ------- | -------------------------------- |
349e41f4b71Sopenharmony_ci| 201 | Permission denied. |
350e41f4b71Sopenharmony_ci| 202 | Not System App. Interface caller is not a system app. |
351e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
352e41f4b71Sopenharmony_ci
353e41f4b71Sopenharmony_ci**Example**
354e41f4b71Sopenharmony_ci
355e41f4b71Sopenharmony_ci```ts
356e41f4b71Sopenharmony_ciimport { missionManager } from '@kit.AbilityKit';
357e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
358e41f4b71Sopenharmony_ci
359e41f4b71Sopenharmony_cilet testMissionId = 1;
360e41f4b71Sopenharmony_ci
361e41f4b71Sopenharmony_cimissionManager.getMissionInfos('',10)
362e41f4b71Sopenharmony_ci  .then((allMissions: Array<missionManager.MissionInfo>) => {
363e41f4b71Sopenharmony_ci    try {
364e41f4b71Sopenharmony_ci      if (allMissions && allMissions.length > 0) {
365e41f4b71Sopenharmony_ci        testMissionId = allMissions[0].missionId;
366e41f4b71Sopenharmony_ci      }
367e41f4b71Sopenharmony_ci
368e41f4b71Sopenharmony_ci      missionManager.getMissionInfo('', testMissionId, (error: BusinessError, mission: missionManager.MissionInfo) => {
369e41f4b71Sopenharmony_ci        if (error) {
370e41f4b71Sopenharmony_ci          console.error(`getMissionInfo failed, error.code: ${error.code}, error.message: ${error.message}`);
371e41f4b71Sopenharmony_ci        } else {
372e41f4b71Sopenharmony_ci          console.log(`mission.missionId = ${mission.missionId}`);
373e41f4b71Sopenharmony_ci          console.log(`mission.runningState = ${mission.runningState}`);
374e41f4b71Sopenharmony_ci          console.log(`mission.lockedState = ${mission.lockedState}`);
375e41f4b71Sopenharmony_ci          console.log(`mission.timestamp = ${mission.timestamp}`);
376e41f4b71Sopenharmony_ci          console.log(`mission.label = ${mission.label}`);
377e41f4b71Sopenharmony_ci          console.log(`mission.iconPath = ${mission.iconPath}`);
378e41f4b71Sopenharmony_ci        }
379e41f4b71Sopenharmony_ci      });
380e41f4b71Sopenharmony_ci    } catch (paramError) {
381e41f4b71Sopenharmony_ci      let code = (paramError as BusinessError).code;
382e41f4b71Sopenharmony_ci      let message = (paramError as BusinessError).message;
383e41f4b71Sopenharmony_ci      console.error(`error: ${code}, ${message} `);
384e41f4b71Sopenharmony_ci    }
385e41f4b71Sopenharmony_ci  })
386e41f4b71Sopenharmony_ci  .catch((err: BusinessError) => {console.log(`${err.code}`);});
387e41f4b71Sopenharmony_ci```
388e41f4b71Sopenharmony_ci
389e41f4b71Sopenharmony_ci## missionManager.getMissionInfo
390e41f4b71Sopenharmony_ci
391e41f4b71Sopenharmony_cigetMissionInfo(deviceId: string, missionId: number): Promise&lt;MissionInfo&gt;
392e41f4b71Sopenharmony_ci
393e41f4b71Sopenharmony_ciObtains the information about a given mission. This API uses a promise to return the result.
394e41f4b71Sopenharmony_ci
395e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.MANAGE_MISSIONS
396e41f4b71Sopenharmony_ci
397e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Ability.AbilityRuntime.Mission
398e41f4b71Sopenharmony_ci
399e41f4b71Sopenharmony_ci**System API**: This is a system API and cannot be called by third-party applications.
400e41f4b71Sopenharmony_ci
401e41f4b71Sopenharmony_ci**Parameters**
402e41f4b71Sopenharmony_ci
403e41f4b71Sopenharmony_ci  | Name| Type| Mandatory| Description|
404e41f4b71Sopenharmony_ci  | -------- | -------- | -------- | -------- |
405e41f4b71Sopenharmony_ci  | deviceId | string | Yes| Device ID. It is a null string by default for the local device.|
406e41f4b71Sopenharmony_ci  | missionId | number | Yes| Mission ID.|
407e41f4b71Sopenharmony_ci
408e41f4b71Sopenharmony_ci**Return value**
409e41f4b71Sopenharmony_ci
410e41f4b71Sopenharmony_ci  | Type| Description|
411e41f4b71Sopenharmony_ci  | -------- | -------- |
412e41f4b71Sopenharmony_ci  | Promise&lt;[MissionInfo](js-apis-inner-application-missionInfo-sys.md)&gt; | Promise used to return the mission information obtained.|
413e41f4b71Sopenharmony_ci
414e41f4b71Sopenharmony_ci**Error codes**
415e41f4b71Sopenharmony_ci
416e41f4b71Sopenharmony_ciFor details about the error codes, see [Universal Error Codes](../errorcode-universal.md).
417e41f4b71Sopenharmony_ci
418e41f4b71Sopenharmony_ci| ID| Error Message|
419e41f4b71Sopenharmony_ci| ------- | -------------------------------- |
420e41f4b71Sopenharmony_ci| 201 | Permission denied. |
421e41f4b71Sopenharmony_ci| 202 | Not System App. Interface caller is not a system app. |
422e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
423e41f4b71Sopenharmony_ci
424e41f4b71Sopenharmony_ci**Example**
425e41f4b71Sopenharmony_ci
426e41f4b71Sopenharmony_ci```ts
427e41f4b71Sopenharmony_ciimport { missionManager } from '@kit.AbilityKit';
428e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
429e41f4b71Sopenharmony_ci
430e41f4b71Sopenharmony_cilet testMissionId = 1;
431e41f4b71Sopenharmony_ci
432e41f4b71Sopenharmony_citry {
433e41f4b71Sopenharmony_ci  missionManager.getMissionInfo('', testMissionId).then((data: missionManager.MissionInfo) => {
434e41f4b71Sopenharmony_ci    console.info(`getMissionInfo successfully. Data: ${JSON.stringify(data)}`);
435e41f4b71Sopenharmony_ci  }).catch((error: BusinessError) => {
436e41f4b71Sopenharmony_ci    console.error(`getMissionInfo failed. Cause: ${error.message}`);
437e41f4b71Sopenharmony_ci  });
438e41f4b71Sopenharmony_ci} catch (error) {
439e41f4b71Sopenharmony_ci  let err: BusinessError = error as BusinessError;
440e41f4b71Sopenharmony_ci  console.error(`getMissionInfo failed. Cause: ${err.message}`);
441e41f4b71Sopenharmony_ci}
442e41f4b71Sopenharmony_ci```
443e41f4b71Sopenharmony_ci
444e41f4b71Sopenharmony_ci## missionManager.getMissionInfos
445e41f4b71Sopenharmony_ci
446e41f4b71Sopenharmony_cigetMissionInfos(deviceId: string, numMax: number, callback: AsyncCallback&lt;Array&lt;MissionInfo&gt;&gt;): void
447e41f4b71Sopenharmony_ci
448e41f4b71Sopenharmony_ciObtains information about all missions. This API uses an asynchronous callback to return the result.
449e41f4b71Sopenharmony_ci
450e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.MANAGE_MISSIONS
451e41f4b71Sopenharmony_ci
452e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Ability.AbilityRuntime.Mission
453e41f4b71Sopenharmony_ci
454e41f4b71Sopenharmony_ci**System API**: This is a system API and cannot be called by third-party applications.
455e41f4b71Sopenharmony_ci
456e41f4b71Sopenharmony_ci**Parameters**
457e41f4b71Sopenharmony_ci
458e41f4b71Sopenharmony_ci  | Name| Type| Mandatory| Description|
459e41f4b71Sopenharmony_ci  | -------- | -------- | -------- | -------- |
460e41f4b71Sopenharmony_ci  | deviceId | string | Yes| Device ID. It is a null string by default for the local device.|
461e41f4b71Sopenharmony_ci  | numMax | number | Yes| Maximum number of missions whose information can be obtained.|
462e41f4b71Sopenharmony_ci  | callback | AsyncCallback&lt;Array&lt;[MissionInfo](js-apis-inner-application-missionInfo-sys.md)&gt;&gt; | Yes| Callback used to return the array of mission information obtained.|
463e41f4b71Sopenharmony_ci
464e41f4b71Sopenharmony_ci**Error codes**
465e41f4b71Sopenharmony_ci
466e41f4b71Sopenharmony_ciFor details about the error codes, see [Universal Error Codes](../errorcode-universal.md).
467e41f4b71Sopenharmony_ci
468e41f4b71Sopenharmony_ci| ID| Error Message|
469e41f4b71Sopenharmony_ci| ------- | -------------------------------- |
470e41f4b71Sopenharmony_ci| 201 | Permission denied. |
471e41f4b71Sopenharmony_ci| 202 | Not System App. Interface caller is not a system app. |
472e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
473e41f4b71Sopenharmony_ci
474e41f4b71Sopenharmony_ci**Example**
475e41f4b71Sopenharmony_ci
476e41f4b71Sopenharmony_ci```ts
477e41f4b71Sopenharmony_ciimport { missionManager } from '@kit.AbilityKit';
478e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
479e41f4b71Sopenharmony_ci
480e41f4b71Sopenharmony_citry {
481e41f4b71Sopenharmony_ci  missionManager.getMissionInfos('', 10, (error: BusinessError, missions: Array<missionManager.MissionInfo>) => {
482e41f4b71Sopenharmony_ci    if (error) {
483e41f4b71Sopenharmony_ci      console.error(`getMissionInfos failed, error.code: ${error.code}, error.message: ${error.message}`);
484e41f4b71Sopenharmony_ci    } else {
485e41f4b71Sopenharmony_ci      console.log(`size = ${missions.length}`);
486e41f4b71Sopenharmony_ci      console.log(`missions = ${JSON.stringify(missions)}`);
487e41f4b71Sopenharmony_ci    }
488e41f4b71Sopenharmony_ci  });
489e41f4b71Sopenharmony_ci} catch (paramError) {
490e41f4b71Sopenharmony_ci  let code = (paramError as BusinessError).code;
491e41f4b71Sopenharmony_ci  let message = (paramError as BusinessError).message;
492e41f4b71Sopenharmony_ci  console.error(`error: ${code}, ${message} `);
493e41f4b71Sopenharmony_ci}
494e41f4b71Sopenharmony_ci```
495e41f4b71Sopenharmony_ci
496e41f4b71Sopenharmony_ci
497e41f4b71Sopenharmony_ci## missionManager.getMissionInfos
498e41f4b71Sopenharmony_ci
499e41f4b71Sopenharmony_cigetMissionInfos(deviceId: string, numMax: number): Promise&lt;Array&lt;MissionInfo&gt;&gt;
500e41f4b71Sopenharmony_ci
501e41f4b71Sopenharmony_ciObtains information about all missions. This API uses a promise to return the result.
502e41f4b71Sopenharmony_ci
503e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.MANAGE_MISSIONS
504e41f4b71Sopenharmony_ci
505e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Ability.AbilityRuntime.Mission
506e41f4b71Sopenharmony_ci
507e41f4b71Sopenharmony_ci**System API**: This is a system API and cannot be called by third-party applications.
508e41f4b71Sopenharmony_ci
509e41f4b71Sopenharmony_ci**Parameters**
510e41f4b71Sopenharmony_ci
511e41f4b71Sopenharmony_ci  | Name| Type| Mandatory| Description|
512e41f4b71Sopenharmony_ci  | -------- | -------- | -------- | -------- |
513e41f4b71Sopenharmony_ci  | deviceId | string | Yes| Device ID. It is a null string by default for the local device.|
514e41f4b71Sopenharmony_ci  | numMax | number | Yes| Maximum number of missions whose information can be obtained.|
515e41f4b71Sopenharmony_ci
516e41f4b71Sopenharmony_ci**Return value**
517e41f4b71Sopenharmony_ci
518e41f4b71Sopenharmony_ci  | Type| Description|
519e41f4b71Sopenharmony_ci  | -------- | -------- |
520e41f4b71Sopenharmony_ci  | Promise&lt;Array&lt;[MissionInfo](js-apis-inner-application-missionInfo-sys.md)&gt;&gt; | Promise used to return the array of mission information obtained.|
521e41f4b71Sopenharmony_ci
522e41f4b71Sopenharmony_ci**Error codes**
523e41f4b71Sopenharmony_ci
524e41f4b71Sopenharmony_ciFor details about the error codes, see [Universal Error Codes](../errorcode-universal.md).
525e41f4b71Sopenharmony_ci
526e41f4b71Sopenharmony_ci| ID| Error Message|
527e41f4b71Sopenharmony_ci| ------- | -------------------------------- |
528e41f4b71Sopenharmony_ci| 201 | Permission denied. |
529e41f4b71Sopenharmony_ci| 202 | Not System App. Interface caller is not a system app. |
530e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
531e41f4b71Sopenharmony_ci
532e41f4b71Sopenharmony_ci**Example**
533e41f4b71Sopenharmony_ci
534e41f4b71Sopenharmony_ci```ts
535e41f4b71Sopenharmony_ciimport { missionManager } from '@kit.AbilityKit';
536e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
537e41f4b71Sopenharmony_ci
538e41f4b71Sopenharmony_citry {
539e41f4b71Sopenharmony_ci  missionManager.getMissionInfos('', 10).then((data: Array<missionManager.MissionInfo>) => {
540e41f4b71Sopenharmony_ci    console.info(`getMissionInfos successfully. Data: ${JSON.stringify(data)}`);
541e41f4b71Sopenharmony_ci  }).catch((error: BusinessError) => {
542e41f4b71Sopenharmony_ci    console.error(`getMissionInfos failed. Cause: ${error.message}`);
543e41f4b71Sopenharmony_ci  });
544e41f4b71Sopenharmony_ci} catch (error) {
545e41f4b71Sopenharmony_ci  let err: BusinessError = error as BusinessError;
546e41f4b71Sopenharmony_ci  console.error(`getMissionInfos failed. Cause: ${err.message}`);
547e41f4b71Sopenharmony_ci}
548e41f4b71Sopenharmony_ci```
549e41f4b71Sopenharmony_ci
550e41f4b71Sopenharmony_ci## missionManager.getMissionSnapShot
551e41f4b71Sopenharmony_ci
552e41f4b71Sopenharmony_cigetMissionSnapShot(deviceId: string, missionId: number, callback: AsyncCallback&lt;MissionSnapshot&gt;): void
553e41f4b71Sopenharmony_ci
554e41f4b71Sopenharmony_ciObtains the snapshot of a given mission. This API uses an asynchronous callback to return the result.
555e41f4b71Sopenharmony_ci
556e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.MANAGE_MISSIONS
557e41f4b71Sopenharmony_ci
558e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Ability.AbilityRuntime.Mission
559e41f4b71Sopenharmony_ci
560e41f4b71Sopenharmony_ci**System API**: This is a system API and cannot be called by third-party applications.
561e41f4b71Sopenharmony_ci
562e41f4b71Sopenharmony_ci**Parameters**
563e41f4b71Sopenharmony_ci
564e41f4b71Sopenharmony_ci  | Name| Type| Mandatory| Description|
565e41f4b71Sopenharmony_ci  | -------- | -------- | -------- | -------- |
566e41f4b71Sopenharmony_ci  | deviceId | string | Yes| Device ID. It is a null string by default for the local device.|
567e41f4b71Sopenharmony_ci  | missionId | number | Yes| Mission ID.|
568e41f4b71Sopenharmony_ci  | callback | AsyncCallback&lt;[MissionSnapshot](js-apis-inner-application-missionSnapshot-sys.md)&gt; | Yes| Callback used to return the snapshot information obtained.|
569e41f4b71Sopenharmony_ci
570e41f4b71Sopenharmony_ci**Error codes**
571e41f4b71Sopenharmony_ci
572e41f4b71Sopenharmony_ciFor details about the error codes, see [Universal Error Codes](../errorcode-universal.md).
573e41f4b71Sopenharmony_ci
574e41f4b71Sopenharmony_ci| ID| Error Message|
575e41f4b71Sopenharmony_ci| ------- | -------------------------------- |
576e41f4b71Sopenharmony_ci| 201 | Permission denied. |
577e41f4b71Sopenharmony_ci| 202 | Not System App. Interface caller is not a system app. |
578e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
579e41f4b71Sopenharmony_ci
580e41f4b71Sopenharmony_ci**Example**
581e41f4b71Sopenharmony_ci```ts
582e41f4b71Sopenharmony_ciimport { missionManager } from '@kit.AbilityKit';
583e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
584e41f4b71Sopenharmony_ci
585e41f4b71Sopenharmony_cilet testMissionId = 2;
586e41f4b71Sopenharmony_ci
587e41f4b71Sopenharmony_citry {
588e41f4b71Sopenharmony_ci  missionManager.getMissionSnapShot('', testMissionId, (err: BusinessError, data: missionManager.MissionSnapshot ) => {
589e41f4b71Sopenharmony_ci    if (err) {
590e41f4b71Sopenharmony_ci      console.error(`getMissionSnapShot failed: ${err.message}`);
591e41f4b71Sopenharmony_ci    } else {
592e41f4b71Sopenharmony_ci      console.info(`getMissionSnapShot successfully: ${JSON.stringify(data)}`);
593e41f4b71Sopenharmony_ci    }
594e41f4b71Sopenharmony_ci  });
595e41f4b71Sopenharmony_ci} catch (error) {
596e41f4b71Sopenharmony_ci  let err: BusinessError = error as BusinessError;
597e41f4b71Sopenharmony_ci  console.error(`getMissionSnapShot failed: ${err.message}`);
598e41f4b71Sopenharmony_ci}
599e41f4b71Sopenharmony_ci```
600e41f4b71Sopenharmony_ci
601e41f4b71Sopenharmony_ci## missionManager.getMissionSnapShot
602e41f4b71Sopenharmony_ci
603e41f4b71Sopenharmony_cigetMissionSnapShot(deviceId: string, missionId: number): Promise&lt;MissionSnapshot&gt;
604e41f4b71Sopenharmony_ci
605e41f4b71Sopenharmony_ciObtains the snapshot of a given mission. This API uses a promise to return the result.
606e41f4b71Sopenharmony_ci
607e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.MANAGE_MISSIONS
608e41f4b71Sopenharmony_ci
609e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Ability.AbilityRuntime.Mission
610e41f4b71Sopenharmony_ci
611e41f4b71Sopenharmony_ci**System API**: This is a system API and cannot be called by third-party applications.
612e41f4b71Sopenharmony_ci
613e41f4b71Sopenharmony_ci**Parameters**
614e41f4b71Sopenharmony_ci
615e41f4b71Sopenharmony_ci  | Name| Type| Mandatory| Description|
616e41f4b71Sopenharmony_ci  | -------- | -------- | -------- | -------- |
617e41f4b71Sopenharmony_ci  | deviceId | string | Yes| Device ID. It is a null string by default for the local device.|
618e41f4b71Sopenharmony_ci  | missionId | number | Yes| Mission ID.|
619e41f4b71Sopenharmony_ci
620e41f4b71Sopenharmony_ci**Return value**
621e41f4b71Sopenharmony_ci
622e41f4b71Sopenharmony_ci  | Type| Description|
623e41f4b71Sopenharmony_ci  | -------- | -------- |
624e41f4b71Sopenharmony_ci  | Promise&lt;[MissionSnapshot](js-apis-inner-application-missionSnapshot-sys.md)&gt; | Promise used to return the snapshot information obtained.|
625e41f4b71Sopenharmony_ci
626e41f4b71Sopenharmony_ci**Error codes**
627e41f4b71Sopenharmony_ci
628e41f4b71Sopenharmony_ciFor details about the error codes, see [Universal Error Codes](../errorcode-universal.md).
629e41f4b71Sopenharmony_ci
630e41f4b71Sopenharmony_ci| ID| Error Message|
631e41f4b71Sopenharmony_ci| ------- | -------------------------------- |
632e41f4b71Sopenharmony_ci| 201 | Permission denied. |
633e41f4b71Sopenharmony_ci| 202 | Not System App. Interface caller is not a system app. |
634e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
635e41f4b71Sopenharmony_ci
636e41f4b71Sopenharmony_ci**Example**
637e41f4b71Sopenharmony_ci```ts
638e41f4b71Sopenharmony_ciimport { missionManager } from '@kit.AbilityKit';
639e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
640e41f4b71Sopenharmony_ci
641e41f4b71Sopenharmony_cilet testMissionId = 2;
642e41f4b71Sopenharmony_ci
643e41f4b71Sopenharmony_citry {
644e41f4b71Sopenharmony_ci  missionManager.getMissionSnapShot('', testMissionId).then((data: missionManager.MissionSnapshot) => {
645e41f4b71Sopenharmony_ci    console.info(`getMissionSnapShot successfully. Data: ${JSON.stringify(data)}`);
646e41f4b71Sopenharmony_ci  }).catch((error: BusinessError) => {
647e41f4b71Sopenharmony_ci    console.error(`getMissionSnapShot failed. Cause: ${error.message}`);
648e41f4b71Sopenharmony_ci  });
649e41f4b71Sopenharmony_ci} catch (error) {
650e41f4b71Sopenharmony_ci  let err: BusinessError = error as BusinessError;
651e41f4b71Sopenharmony_ci  console.error(`getMissionSnapShot failed. Cause: ${err.message}`);
652e41f4b71Sopenharmony_ci}
653e41f4b71Sopenharmony_ci```
654e41f4b71Sopenharmony_ci
655e41f4b71Sopenharmony_ci## missionManager.getLowResolutionMissionSnapShot
656e41f4b71Sopenharmony_ci
657e41f4b71Sopenharmony_cigetLowResolutionMissionSnapShot(deviceId: string, missionId: number, callback: AsyncCallback\<MissionSnapshot>): void
658e41f4b71Sopenharmony_ci
659e41f4b71Sopenharmony_ciObtains the low-resolution snapshot of a given mission. This API uses an asynchronous callback to return the result.
660e41f4b71Sopenharmony_ci
661e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.MANAGE_MISSIONS
662e41f4b71Sopenharmony_ci
663e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Ability.AbilityRuntime.Mission
664e41f4b71Sopenharmony_ci
665e41f4b71Sopenharmony_ci**System API**: This is a system API and cannot be called by third-party applications.
666e41f4b71Sopenharmony_ci
667e41f4b71Sopenharmony_ci**Parameters**
668e41f4b71Sopenharmony_ci
669e41f4b71Sopenharmony_ci  | Name| Type| Mandatory| Description|
670e41f4b71Sopenharmony_ci  | -------- | -------- | -------- | -------- |
671e41f4b71Sopenharmony_ci  | deviceId | string | Yes| Device ID. It is a null string by default for the local device.|
672e41f4b71Sopenharmony_ci  | missionId | number | Yes| Mission ID.|
673e41f4b71Sopenharmony_ci  | callback | AsyncCallback&lt;[MissionSnapshot](js-apis-inner-application-missionSnapshot-sys.md)&gt; | Yes| Callback used to return the snapshot information obtained.|
674e41f4b71Sopenharmony_ci
675e41f4b71Sopenharmony_ci**Error codes**
676e41f4b71Sopenharmony_ci
677e41f4b71Sopenharmony_ciFor details about the error codes, see [Universal Error Codes](../errorcode-universal.md).
678e41f4b71Sopenharmony_ci
679e41f4b71Sopenharmony_ci| ID| Error Message|
680e41f4b71Sopenharmony_ci| ------- | -------------------------------- |
681e41f4b71Sopenharmony_ci| 201 | Permission denied. |
682e41f4b71Sopenharmony_ci| 202 | Not System App. Interface caller is not a system app. |
683e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
684e41f4b71Sopenharmony_ci
685e41f4b71Sopenharmony_ci**Example**
686e41f4b71Sopenharmony_ci```ts
687e41f4b71Sopenharmony_ciimport { missionManager } from '@kit.AbilityKit';
688e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
689e41f4b71Sopenharmony_ci
690e41f4b71Sopenharmony_cilet testMissionId = 2;
691e41f4b71Sopenharmony_ci
692e41f4b71Sopenharmony_citry {
693e41f4b71Sopenharmony_ci  missionManager.getLowResolutionMissionSnapShot('', testMissionId, (err: BusinessError, data: missionManager.MissionSnapshot) => {
694e41f4b71Sopenharmony_ci    if (err) {
695e41f4b71Sopenharmony_ci      console.error(`getLowResolutionMissionSnapShot failed: ${err.message}`);
696e41f4b71Sopenharmony_ci    } else {
697e41f4b71Sopenharmony_ci      console.info(`getLowResolutionMissionSnapShot successfully: ${JSON.stringify(data)}`);
698e41f4b71Sopenharmony_ci    }
699e41f4b71Sopenharmony_ci  });
700e41f4b71Sopenharmony_ci} catch (error) {
701e41f4b71Sopenharmony_ci  let err: BusinessError = error as BusinessError;
702e41f4b71Sopenharmony_ci  console.error(`getLowResolutionMissionSnapShot failed: ${err.message}`);
703e41f4b71Sopenharmony_ci}
704e41f4b71Sopenharmony_ci```
705e41f4b71Sopenharmony_ci
706e41f4b71Sopenharmony_ci## missionManager.getLowResolutionMissionSnapShot
707e41f4b71Sopenharmony_ci
708e41f4b71Sopenharmony_cigetLowResolutionMissionSnapShot(deviceId: string, missionId: number): Promise\<MissionSnapshot>
709e41f4b71Sopenharmony_ci
710e41f4b71Sopenharmony_ciObtains the low-resolution snapshot of a given mission. This API uses a promise to return the result.
711e41f4b71Sopenharmony_ci
712e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.MANAGE_MISSIONS
713e41f4b71Sopenharmony_ci
714e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Ability.AbilityRuntime.Mission
715e41f4b71Sopenharmony_ci
716e41f4b71Sopenharmony_ci**System API**: This is a system API and cannot be called by third-party applications.
717e41f4b71Sopenharmony_ci
718e41f4b71Sopenharmony_ci**Parameters**
719e41f4b71Sopenharmony_ci
720e41f4b71Sopenharmony_ci  | Name| Type| Mandatory| Description|
721e41f4b71Sopenharmony_ci  | -------- | -------- | -------- | -------- |
722e41f4b71Sopenharmony_ci  | deviceId | string | Yes| Device ID. It is a null string by default for the local device.|
723e41f4b71Sopenharmony_ci  | missionId | number | Yes| Mission ID.|
724e41f4b71Sopenharmony_ci
725e41f4b71Sopenharmony_ci**Return value**
726e41f4b71Sopenharmony_ci
727e41f4b71Sopenharmony_ci  | Type| Description|
728e41f4b71Sopenharmony_ci  | -------- | -------- |
729e41f4b71Sopenharmony_ci  | Promise&lt;[MissionSnapshot](js-apis-inner-application-missionSnapshot-sys.md)&gt; | Promise used to return the snapshot information obtained.|
730e41f4b71Sopenharmony_ci
731e41f4b71Sopenharmony_ci**Error codes**
732e41f4b71Sopenharmony_ci
733e41f4b71Sopenharmony_ciFor details about the error codes, see [Universal Error Codes](../errorcode-universal.md).
734e41f4b71Sopenharmony_ci
735e41f4b71Sopenharmony_ci| ID| Error Message|
736e41f4b71Sopenharmony_ci| ------- | -------------------------------- |
737e41f4b71Sopenharmony_ci| 201 | Permission denied. |
738e41f4b71Sopenharmony_ci| 202 | Not System App. Interface caller is not a system app. |
739e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
740e41f4b71Sopenharmony_ci
741e41f4b71Sopenharmony_ci**Example**
742e41f4b71Sopenharmony_ci
743e41f4b71Sopenharmony_ci```ts
744e41f4b71Sopenharmony_ciimport { missionManager } from '@kit.AbilityKit';
745e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
746e41f4b71Sopenharmony_ci
747e41f4b71Sopenharmony_cilet testMissionId = 2;
748e41f4b71Sopenharmony_ci
749e41f4b71Sopenharmony_citry {
750e41f4b71Sopenharmony_ci  missionManager.getLowResolutionMissionSnapShot('', testMissionId).then((data: missionManager.MissionSnapshot) => {
751e41f4b71Sopenharmony_ci    console.info(`getLowResolutionMissionSnapShot successfully. Data: ${JSON.stringify(data)}`);
752e41f4b71Sopenharmony_ci  }).catch((error: BusinessError) => {
753e41f4b71Sopenharmony_ci    console.error(`getLowResolutionMissionSnapShot failed. Cause: ${error.message}`);
754e41f4b71Sopenharmony_ci  });
755e41f4b71Sopenharmony_ci} catch (error) {
756e41f4b71Sopenharmony_ci  let err: BusinessError = error as BusinessError;
757e41f4b71Sopenharmony_ci  console.error(`getLowResolutionMissionSnapShot failed. Cause: ${err.message}`);
758e41f4b71Sopenharmony_ci}
759e41f4b71Sopenharmony_ci```
760e41f4b71Sopenharmony_ci
761e41f4b71Sopenharmony_ci
762e41f4b71Sopenharmony_ci## missionManager.lockMission
763e41f4b71Sopenharmony_ci
764e41f4b71Sopenharmony_cilockMission(missionId: number, callback: AsyncCallback&lt;void&gt;): void
765e41f4b71Sopenharmony_ci
766e41f4b71Sopenharmony_ciLocks a given mission. This API uses an asynchronous callback to return the result.
767e41f4b71Sopenharmony_ci
768e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.MANAGE_MISSIONS
769e41f4b71Sopenharmony_ci
770e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Ability.AbilityRuntime.Mission
771e41f4b71Sopenharmony_ci
772e41f4b71Sopenharmony_ci**System API**: This is a system API and cannot be called by third-party applications.
773e41f4b71Sopenharmony_ci
774e41f4b71Sopenharmony_ci**Parameters**
775e41f4b71Sopenharmony_ci
776e41f4b71Sopenharmony_ci  | Name| Type| Mandatory| Description|
777e41f4b71Sopenharmony_ci  | -------- | -------- | -------- | -------- |
778e41f4b71Sopenharmony_ci  | missionId | number | Yes| Mission ID.|
779e41f4b71Sopenharmony_ci  | callback | AsyncCallback&lt;void&gt; | Yes| Callback used to return the result.|
780e41f4b71Sopenharmony_ci
781e41f4b71Sopenharmony_ci**Error codes**
782e41f4b71Sopenharmony_ci
783e41f4b71Sopenharmony_ciFor details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Ability Error Codes](errorcode-ability.md).
784e41f4b71Sopenharmony_ci
785e41f4b71Sopenharmony_ci| ID| Error Message|
786e41f4b71Sopenharmony_ci| ------- | -------- |
787e41f4b71Sopenharmony_ci| 201 | Permission denied. |
788e41f4b71Sopenharmony_ci| 202 | Not System App. Interface caller is not a system app. |
789e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
790e41f4b71Sopenharmony_ci| 16300001 | Mission not found. |
791e41f4b71Sopenharmony_ci
792e41f4b71Sopenharmony_ci**Example**
793e41f4b71Sopenharmony_ci
794e41f4b71Sopenharmony_ci```ts
795e41f4b71Sopenharmony_ciimport { missionManager } from '@kit.AbilityKit';
796e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
797e41f4b71Sopenharmony_ci
798e41f4b71Sopenharmony_cilet testMissionId = 2;
799e41f4b71Sopenharmony_ci
800e41f4b71Sopenharmony_citry {
801e41f4b71Sopenharmony_ci  missionManager.lockMission(testMissionId, (err: BusinessError, data: void) => {
802e41f4b71Sopenharmony_ci    if (err) {
803e41f4b71Sopenharmony_ci      console.error(`lockMission failed: ${err.message}`);
804e41f4b71Sopenharmony_ci    } else {
805e41f4b71Sopenharmony_ci      console.info(`lockMission successfully: ${JSON.stringify(data)}`);
806e41f4b71Sopenharmony_ci    }
807e41f4b71Sopenharmony_ci  });
808e41f4b71Sopenharmony_ci} catch (error) {
809e41f4b71Sopenharmony_ci  let err: BusinessError = error as BusinessError;
810e41f4b71Sopenharmony_ci  console.error(`lockMission failed: ${err.message}`);
811e41f4b71Sopenharmony_ci}
812e41f4b71Sopenharmony_ci```
813e41f4b71Sopenharmony_ci
814e41f4b71Sopenharmony_ci## missionManager.lockMission
815e41f4b71Sopenharmony_ci
816e41f4b71Sopenharmony_cilockMission(missionId: number): Promise&lt;void&gt;
817e41f4b71Sopenharmony_ci
818e41f4b71Sopenharmony_ciLocks a given mission. This API uses a promise to return the result.
819e41f4b71Sopenharmony_ci
820e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.MANAGE_MISSIONS
821e41f4b71Sopenharmony_ci
822e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Ability.AbilityRuntime.Mission
823e41f4b71Sopenharmony_ci
824e41f4b71Sopenharmony_ci**System API**: This is a system API and cannot be called by third-party applications.
825e41f4b71Sopenharmony_ci
826e41f4b71Sopenharmony_ci**Parameters**
827e41f4b71Sopenharmony_ci
828e41f4b71Sopenharmony_ci  | Name| Type| Mandatory| Description|
829e41f4b71Sopenharmony_ci  | -------- | -------- | -------- | -------- |
830e41f4b71Sopenharmony_ci  | missionId | number | Yes| Mission ID.|
831e41f4b71Sopenharmony_ci
832e41f4b71Sopenharmony_ci**Return value**
833e41f4b71Sopenharmony_ci
834e41f4b71Sopenharmony_ci  | Type| Description|
835e41f4b71Sopenharmony_ci  | -------- | -------- |
836e41f4b71Sopenharmony_ci  | Promise&lt;void&gt; | Promise used to return the result.|
837e41f4b71Sopenharmony_ci
838e41f4b71Sopenharmony_ci**Error codes**
839e41f4b71Sopenharmony_ci
840e41f4b71Sopenharmony_ciFor details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Ability Error Codes](errorcode-ability.md).
841e41f4b71Sopenharmony_ci
842e41f4b71Sopenharmony_ci| ID| Error Message|
843e41f4b71Sopenharmony_ci| ------- | -------- |
844e41f4b71Sopenharmony_ci| 201 | Permission denied. |
845e41f4b71Sopenharmony_ci| 202 | Not System App. Interface caller is not a system app. |
846e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
847e41f4b71Sopenharmony_ci| 16300001 | Mission not found. |
848e41f4b71Sopenharmony_ci
849e41f4b71Sopenharmony_ci**Example**
850e41f4b71Sopenharmony_ci```ts
851e41f4b71Sopenharmony_ciimport { missionManager } from '@kit.AbilityKit';
852e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
853e41f4b71Sopenharmony_ci
854e41f4b71Sopenharmony_cilet testMissionId = 2;
855e41f4b71Sopenharmony_ci
856e41f4b71Sopenharmony_citry {
857e41f4b71Sopenharmony_ci  missionManager.lockMission(testMissionId).then((data: void) => {
858e41f4b71Sopenharmony_ci    console.info(`lockMission successfully. Data: ${JSON.stringify(data)}`);
859e41f4b71Sopenharmony_ci  }).catch((error: BusinessError) => {
860e41f4b71Sopenharmony_ci    console.error(`lockMission failed. Cause: ${error.message}`);
861e41f4b71Sopenharmony_ci  });
862e41f4b71Sopenharmony_ci} catch (error) {
863e41f4b71Sopenharmony_ci  let err: BusinessError = error as BusinessError;
864e41f4b71Sopenharmony_ci  console.error(`lockMission failed. Cause: ${err.message}`);
865e41f4b71Sopenharmony_ci}
866e41f4b71Sopenharmony_ci```
867e41f4b71Sopenharmony_ci
868e41f4b71Sopenharmony_ci## missionManager.unlockMission
869e41f4b71Sopenharmony_ci
870e41f4b71Sopenharmony_ciunlockMission(missionId: number, callback: AsyncCallback&lt;void&gt;): void
871e41f4b71Sopenharmony_ci
872e41f4b71Sopenharmony_ciUnlocks a given mission. This API uses an asynchronous callback to return the result.
873e41f4b71Sopenharmony_ci
874e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.MANAGE_MISSIONS
875e41f4b71Sopenharmony_ci
876e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Ability.AbilityRuntime.Mission
877e41f4b71Sopenharmony_ci
878e41f4b71Sopenharmony_ci**System API**: This is a system API and cannot be called by third-party applications.
879e41f4b71Sopenharmony_ci
880e41f4b71Sopenharmony_ci**Parameters**
881e41f4b71Sopenharmony_ci
882e41f4b71Sopenharmony_ci| Name| Type| Mandatory| Description|
883e41f4b71Sopenharmony_ci| -------- | -------- | -------- | -------- |
884e41f4b71Sopenharmony_ci| missionId | number | Yes| Mission ID.|
885e41f4b71Sopenharmony_ci| callback | AsyncCallback&lt;void&gt; | Yes| Callback used to return the result.|
886e41f4b71Sopenharmony_ci
887e41f4b71Sopenharmony_ci**Error codes**
888e41f4b71Sopenharmony_ci
889e41f4b71Sopenharmony_ciFor details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Ability Error Codes](errorcode-ability.md).
890e41f4b71Sopenharmony_ci
891e41f4b71Sopenharmony_ci| ID| Error Message|
892e41f4b71Sopenharmony_ci| ------- | -------- |
893e41f4b71Sopenharmony_ci| 201 | Permission denied. |
894e41f4b71Sopenharmony_ci| 202 | Not System App. Interface caller is not a system app. |
895e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
896e41f4b71Sopenharmony_ci| 16300001 | Mission not found. |
897e41f4b71Sopenharmony_ci
898e41f4b71Sopenharmony_ci**Example**
899e41f4b71Sopenharmony_ci```ts
900e41f4b71Sopenharmony_ciimport { missionManager } from '@kit.AbilityKit';
901e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
902e41f4b71Sopenharmony_ci
903e41f4b71Sopenharmony_cilet testMissionId = 2;
904e41f4b71Sopenharmony_ci
905e41f4b71Sopenharmony_citry {
906e41f4b71Sopenharmony_ci  missionManager.unlockMission(testMissionId, (err: BusinessError, data: void) => {
907e41f4b71Sopenharmony_ci    if (err) {
908e41f4b71Sopenharmony_ci      console.error(`unlockMission failed: ${err.message}`);
909e41f4b71Sopenharmony_ci    } else {
910e41f4b71Sopenharmony_ci      console.info(`unlockMission successfully: ${JSON.stringify(data)}`);
911e41f4b71Sopenharmony_ci    }
912e41f4b71Sopenharmony_ci  });
913e41f4b71Sopenharmony_ci} catch (error) {
914e41f4b71Sopenharmony_ci  let err: BusinessError = error as BusinessError;
915e41f4b71Sopenharmony_ci  console.error(`unlockMission failed: ${err.message}`);
916e41f4b71Sopenharmony_ci}
917e41f4b71Sopenharmony_ci```
918e41f4b71Sopenharmony_ci
919e41f4b71Sopenharmony_ci## missionManager.unlockMission
920e41f4b71Sopenharmony_ci
921e41f4b71Sopenharmony_ciunlockMission(missionId: number): Promise&lt;void&gt;
922e41f4b71Sopenharmony_ci
923e41f4b71Sopenharmony_ciUnlocks a given mission. This API uses a promise to return the result.
924e41f4b71Sopenharmony_ci
925e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.MANAGE_MISSIONS
926e41f4b71Sopenharmony_ci
927e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Ability.AbilityRuntime.Mission
928e41f4b71Sopenharmony_ci
929e41f4b71Sopenharmony_ci**System API**: This is a system API and cannot be called by third-party applications.
930e41f4b71Sopenharmony_ci
931e41f4b71Sopenharmony_ci**Parameters**
932e41f4b71Sopenharmony_ci
933e41f4b71Sopenharmony_ci  | Name| Type| Mandatory| Description|
934e41f4b71Sopenharmony_ci  | -------- | -------- | -------- | -------- |
935e41f4b71Sopenharmony_ci  | missionId | number | Yes| Mission ID.|
936e41f4b71Sopenharmony_ci
937e41f4b71Sopenharmony_ci**Return value**
938e41f4b71Sopenharmony_ci
939e41f4b71Sopenharmony_ci  | Type| Description|
940e41f4b71Sopenharmony_ci  | -------- | -------- |
941e41f4b71Sopenharmony_ci  | Promise&lt;void&gt; | Promise used to return the result.|
942e41f4b71Sopenharmony_ci
943e41f4b71Sopenharmony_ci**Error codes**
944e41f4b71Sopenharmony_ci
945e41f4b71Sopenharmony_ciFor details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Ability Error Codes](errorcode-ability.md).
946e41f4b71Sopenharmony_ci
947e41f4b71Sopenharmony_ci| ID| Error Message|
948e41f4b71Sopenharmony_ci| ------- | -------- |
949e41f4b71Sopenharmony_ci| 201 | Permission denied. |
950e41f4b71Sopenharmony_ci| 202 | Not System App. Interface caller is not a system app. |
951e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
952e41f4b71Sopenharmony_ci| 16300001 | Mission not found. |
953e41f4b71Sopenharmony_ci
954e41f4b71Sopenharmony_ci**Example**
955e41f4b71Sopenharmony_ci
956e41f4b71Sopenharmony_ci```ts
957e41f4b71Sopenharmony_ciimport { missionManager } from '@kit.AbilityKit';
958e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
959e41f4b71Sopenharmony_ci
960e41f4b71Sopenharmony_cilet testMissionId = 2;
961e41f4b71Sopenharmony_ci
962e41f4b71Sopenharmony_citry {
963e41f4b71Sopenharmony_ci  missionManager.unlockMission(testMissionId).then((data: void) => {
964e41f4b71Sopenharmony_ci    console.info(`unlockMission successfully. Data: ${JSON.stringify(data)}`);
965e41f4b71Sopenharmony_ci  }).catch((error: BusinessError) => {
966e41f4b71Sopenharmony_ci    console.error(`unlockMission failed. Cause: ${error.message}`);
967e41f4b71Sopenharmony_ci  });
968e41f4b71Sopenharmony_ci} catch (error) {
969e41f4b71Sopenharmony_ci  let err: BusinessError = error as BusinessError;
970e41f4b71Sopenharmony_ci  console.error(`unlockMission failed. Cause: ${err.message}`);
971e41f4b71Sopenharmony_ci}
972e41f4b71Sopenharmony_ci```
973e41f4b71Sopenharmony_ci
974e41f4b71Sopenharmony_ci## missionManager.clearMission
975e41f4b71Sopenharmony_ci
976e41f4b71Sopenharmony_ciclearMission(missionId: number, callback: AsyncCallback&lt;void&gt;): void
977e41f4b71Sopenharmony_ci
978e41f4b71Sopenharmony_ciClears a given mission, regardless of whether it is locked. This API uses an asynchronous callback to return the result.
979e41f4b71Sopenharmony_ci
980e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.MANAGE_MISSIONS
981e41f4b71Sopenharmony_ci
982e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Ability.AbilityRuntime.Mission
983e41f4b71Sopenharmony_ci
984e41f4b71Sopenharmony_ci**System API**: This is a system API and cannot be called by third-party applications.
985e41f4b71Sopenharmony_ci
986e41f4b71Sopenharmony_ci**Parameters**
987e41f4b71Sopenharmony_ci
988e41f4b71Sopenharmony_ci  | Name| Type| Mandatory| Description|
989e41f4b71Sopenharmony_ci  | -------- | -------- | -------- | -------- |
990e41f4b71Sopenharmony_ci  | missionId | number | Yes| Mission ID.|
991e41f4b71Sopenharmony_ci  | callback | AsyncCallback&lt;void&gt; | Yes| Callback used to return the result.|
992e41f4b71Sopenharmony_ci
993e41f4b71Sopenharmony_ci**Error codes**
994e41f4b71Sopenharmony_ci
995e41f4b71Sopenharmony_ciFor details about the error codes, see [Universal Error Codes](../errorcode-universal.md).
996e41f4b71Sopenharmony_ci
997e41f4b71Sopenharmony_ci| ID| Error Message|
998e41f4b71Sopenharmony_ci| ------- | -------------------------------- |
999e41f4b71Sopenharmony_ci| 201 | Permission denied. |
1000e41f4b71Sopenharmony_ci| 202 | Not System App. Interface caller is not a system app. |
1001e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
1002e41f4b71Sopenharmony_ci
1003e41f4b71Sopenharmony_ci**Example**
1004e41f4b71Sopenharmony_ci
1005e41f4b71Sopenharmony_ci```ts
1006e41f4b71Sopenharmony_ciimport { missionManager } from '@kit.AbilityKit';
1007e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
1008e41f4b71Sopenharmony_ci
1009e41f4b71Sopenharmony_cilet testMissionId = 2;
1010e41f4b71Sopenharmony_ci
1011e41f4b71Sopenharmony_citry {
1012e41f4b71Sopenharmony_ci  missionManager.clearMission(testMissionId, (err: BusinessError, data: void) => {
1013e41f4b71Sopenharmony_ci    if (err) {
1014e41f4b71Sopenharmony_ci      console.error(`clearMission failed: ${err.message}`);
1015e41f4b71Sopenharmony_ci    } else {
1016e41f4b71Sopenharmony_ci      console.info(`clearMission successfully: ${JSON.stringify(data)}`);
1017e41f4b71Sopenharmony_ci    }
1018e41f4b71Sopenharmony_ci  });
1019e41f4b71Sopenharmony_ci} catch (error) {
1020e41f4b71Sopenharmony_ci  let err: BusinessError = error as BusinessError;
1021e41f4b71Sopenharmony_ci  console.error(`clearMission failed: ${err.message}`);
1022e41f4b71Sopenharmony_ci}
1023e41f4b71Sopenharmony_ci```
1024e41f4b71Sopenharmony_ci
1025e41f4b71Sopenharmony_ci
1026e41f4b71Sopenharmony_ci## missionManager.clearMission
1027e41f4b71Sopenharmony_ci
1028e41f4b71Sopenharmony_ciclearMission(missionId: number): Promise&lt;void&gt;
1029e41f4b71Sopenharmony_ci
1030e41f4b71Sopenharmony_ciClears a given mission, regardless of whether it is locked. This API uses a promise to return the result.
1031e41f4b71Sopenharmony_ci
1032e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.MANAGE_MISSIONS
1033e41f4b71Sopenharmony_ci
1034e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Ability.AbilityRuntime.Mission
1035e41f4b71Sopenharmony_ci
1036e41f4b71Sopenharmony_ci**System API**: This is a system API and cannot be called by third-party applications.
1037e41f4b71Sopenharmony_ci
1038e41f4b71Sopenharmony_ci**Parameters**
1039e41f4b71Sopenharmony_ci
1040e41f4b71Sopenharmony_ci  | Name| Type| Mandatory| Description|
1041e41f4b71Sopenharmony_ci  | -------- | -------- | -------- | -------- |
1042e41f4b71Sopenharmony_ci  | missionId | number | Yes| Mission ID.|
1043e41f4b71Sopenharmony_ci
1044e41f4b71Sopenharmony_ci**Return value**
1045e41f4b71Sopenharmony_ci
1046e41f4b71Sopenharmony_ci  | Type| Description|
1047e41f4b71Sopenharmony_ci  | -------- | -------- |
1048e41f4b71Sopenharmony_ci  | Promise&lt;void&gt; | Promise used to return the result.|
1049e41f4b71Sopenharmony_ci
1050e41f4b71Sopenharmony_ci**Error codes**
1051e41f4b71Sopenharmony_ci
1052e41f4b71Sopenharmony_ciFor details about the error codes, see [Universal Error Codes](../errorcode-universal.md).
1053e41f4b71Sopenharmony_ci
1054e41f4b71Sopenharmony_ci| ID| Error Message|
1055e41f4b71Sopenharmony_ci| ------- | -------------------------------- |
1056e41f4b71Sopenharmony_ci| 201 | Permission denied. |
1057e41f4b71Sopenharmony_ci| 202 | Not System App. Interface caller is not a system app. |
1058e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
1059e41f4b71Sopenharmony_ci
1060e41f4b71Sopenharmony_ci**Example**
1061e41f4b71Sopenharmony_ci
1062e41f4b71Sopenharmony_ci```ts
1063e41f4b71Sopenharmony_ciimport { missionManager } from '@kit.AbilityKit';
1064e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
1065e41f4b71Sopenharmony_ci
1066e41f4b71Sopenharmony_cilet testMissionId = 2;
1067e41f4b71Sopenharmony_ci
1068e41f4b71Sopenharmony_citry {
1069e41f4b71Sopenharmony_ci  missionManager.clearMission(testMissionId).then((data: void) => {
1070e41f4b71Sopenharmony_ci    console.info(`clearMission successfully. Data: ${JSON.stringify(data)}`);
1071e41f4b71Sopenharmony_ci  }).catch((error: BusinessError) => {
1072e41f4b71Sopenharmony_ci    console.error(`clearMission failed. Cause: ${error.message}`);
1073e41f4b71Sopenharmony_ci  });
1074e41f4b71Sopenharmony_ci} catch (error) {
1075e41f4b71Sopenharmony_ci  let err: BusinessError = error as BusinessError;
1076e41f4b71Sopenharmony_ci  console.error(`clearMission failed. Cause: ${err.message}`);
1077e41f4b71Sopenharmony_ci}
1078e41f4b71Sopenharmony_ci```
1079e41f4b71Sopenharmony_ci
1080e41f4b71Sopenharmony_ci## missionManager.clearAllMissions
1081e41f4b71Sopenharmony_ci
1082e41f4b71Sopenharmony_ciclearAllMissions(callback: AsyncCallback&lt;void&gt;): void
1083e41f4b71Sopenharmony_ci
1084e41f4b71Sopenharmony_ciClears all unlocked missions. This API uses an asynchronous callback to return the result.
1085e41f4b71Sopenharmony_ci
1086e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.MANAGE_MISSIONS
1087e41f4b71Sopenharmony_ci
1088e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Ability.AbilityRuntime.Mission
1089e41f4b71Sopenharmony_ci
1090e41f4b71Sopenharmony_ci**System API**: This is a system API and cannot be called by third-party applications.
1091e41f4b71Sopenharmony_ci
1092e41f4b71Sopenharmony_ci**Parameters**
1093e41f4b71Sopenharmony_ci
1094e41f4b71Sopenharmony_ci  | Name| Type| Mandatory| Description|
1095e41f4b71Sopenharmony_ci  | -------- | -------- | -------- | -------- |
1096e41f4b71Sopenharmony_ci  | callback | AsyncCallback&lt;void&gt; | Yes| Callback used to return the result.|
1097e41f4b71Sopenharmony_ci
1098e41f4b71Sopenharmony_ci**Error codes**
1099e41f4b71Sopenharmony_ci
1100e41f4b71Sopenharmony_ciFor details about the error codes, see [Universal Error Codes](../errorcode-universal.md).
1101e41f4b71Sopenharmony_ci
1102e41f4b71Sopenharmony_ci| ID| Error Message|
1103e41f4b71Sopenharmony_ci| ------- | -------------------------------- |
1104e41f4b71Sopenharmony_ci| 201 | Permission denied. |
1105e41f4b71Sopenharmony_ci| 202 | Not System App. Interface caller is not a system app. |
1106e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
1107e41f4b71Sopenharmony_ci
1108e41f4b71Sopenharmony_ci**Example**
1109e41f4b71Sopenharmony_ci
1110e41f4b71Sopenharmony_ci```ts
1111e41f4b71Sopenharmony_ciimport { missionManager } from '@kit.AbilityKit';
1112e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
1113e41f4b71Sopenharmony_ci
1114e41f4b71Sopenharmony_citry {
1115e41f4b71Sopenharmony_ci  missionManager.clearAllMissions((err: BusinessError) => {
1116e41f4b71Sopenharmony_ci    if (err) {
1117e41f4b71Sopenharmony_ci      console.error(`clearAllMissions failed: ${err.message}`);
1118e41f4b71Sopenharmony_ci    } else {
1119e41f4b71Sopenharmony_ci      console.info('clearAllMissions successfully.');
1120e41f4b71Sopenharmony_ci    }
1121e41f4b71Sopenharmony_ci  });
1122e41f4b71Sopenharmony_ci} catch (error) {
1123e41f4b71Sopenharmony_ci  let err: BusinessError = error as BusinessError;
1124e41f4b71Sopenharmony_ci  console.error(`clearAllMissions failed: ${err.message}`);
1125e41f4b71Sopenharmony_ci}
1126e41f4b71Sopenharmony_ci```
1127e41f4b71Sopenharmony_ci
1128e41f4b71Sopenharmony_ci## missionManager.clearAllMissions
1129e41f4b71Sopenharmony_ci
1130e41f4b71Sopenharmony_ciclearAllMissions(): Promise&lt;void&gt;
1131e41f4b71Sopenharmony_ci
1132e41f4b71Sopenharmony_ciClears all unlocked missions. This API uses a promise to return the result.
1133e41f4b71Sopenharmony_ci
1134e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.MANAGE_MISSIONS
1135e41f4b71Sopenharmony_ci
1136e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Ability.AbilityRuntime.Mission
1137e41f4b71Sopenharmony_ci
1138e41f4b71Sopenharmony_ci**System API**: This is a system API and cannot be called by third-party applications.
1139e41f4b71Sopenharmony_ci
1140e41f4b71Sopenharmony_ci**Return value**
1141e41f4b71Sopenharmony_ci
1142e41f4b71Sopenharmony_ci  | Type| Description|
1143e41f4b71Sopenharmony_ci  | -------- | -------- |
1144e41f4b71Sopenharmony_ci  | Promise&lt;void&gt; | Promise used to return the result.|
1145e41f4b71Sopenharmony_ci
1146e41f4b71Sopenharmony_ci**Error codes**
1147e41f4b71Sopenharmony_ci
1148e41f4b71Sopenharmony_ciFor details about the error codes, see [Universal Error Codes](../errorcode-universal.md).
1149e41f4b71Sopenharmony_ci
1150e41f4b71Sopenharmony_ci| ID| Error Message|
1151e41f4b71Sopenharmony_ci| ------- | -------------------------------- |
1152e41f4b71Sopenharmony_ci| 201 | Permission denied. |
1153e41f4b71Sopenharmony_ci| 202 | Not System App. Interface caller is not a system app. |
1154e41f4b71Sopenharmony_ci
1155e41f4b71Sopenharmony_ci**Example**
1156e41f4b71Sopenharmony_ci
1157e41f4b71Sopenharmony_ci```ts
1158e41f4b71Sopenharmony_ciimport { missionManager } from '@kit.AbilityKit';
1159e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
1160e41f4b71Sopenharmony_ci
1161e41f4b71Sopenharmony_citry {
1162e41f4b71Sopenharmony_ci  missionManager.clearAllMissions().then((data: void) => {
1163e41f4b71Sopenharmony_ci    console.info(`clearAllMissions successfully. Data: ${JSON.stringify(data)}`);
1164e41f4b71Sopenharmony_ci  }).catch((err: BusinessError) => {
1165e41f4b71Sopenharmony_ci    console.error(`clearAllMissions failed: ${err.message}`);
1166e41f4b71Sopenharmony_ci  });
1167e41f4b71Sopenharmony_ci} catch (error) {
1168e41f4b71Sopenharmony_ci  let err: BusinessError = error as BusinessError;
1169e41f4b71Sopenharmony_ci  console.error(`clearAllMissions failed: ${err.message}`);
1170e41f4b71Sopenharmony_ci}
1171e41f4b71Sopenharmony_ci```
1172e41f4b71Sopenharmony_ci
1173e41f4b71Sopenharmony_ci## missionManager.moveMissionToFront
1174e41f4b71Sopenharmony_ci
1175e41f4b71Sopenharmony_cimoveMissionToFront(missionId: number, callback: AsyncCallback&lt;void&gt;): void
1176e41f4b71Sopenharmony_ci
1177e41f4b71Sopenharmony_ciSwitches a given mission to the foreground. This API uses an asynchronous callback to return the result.
1178e41f4b71Sopenharmony_ci
1179e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.MANAGE_MISSIONS
1180e41f4b71Sopenharmony_ci
1181e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Ability.AbilityRuntime.Mission
1182e41f4b71Sopenharmony_ci
1183e41f4b71Sopenharmony_ci**System API**: This is a system API and cannot be called by third-party applications.
1184e41f4b71Sopenharmony_ci
1185e41f4b71Sopenharmony_ci**Parameters**
1186e41f4b71Sopenharmony_ci
1187e41f4b71Sopenharmony_ci  | Name| Type| Mandatory| Description|
1188e41f4b71Sopenharmony_ci  | -------- | -------- | -------- | -------- |
1189e41f4b71Sopenharmony_ci  | missionId | number | Yes| Mission ID.|
1190e41f4b71Sopenharmony_ci  | callback | AsyncCallback&lt;void&gt; | Yes| Callback used to return the result.|
1191e41f4b71Sopenharmony_ci
1192e41f4b71Sopenharmony_ci**Error codes**
1193e41f4b71Sopenharmony_ci
1194e41f4b71Sopenharmony_ciFor details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Ability Error Codes](errorcode-ability.md).
1195e41f4b71Sopenharmony_ci
1196e41f4b71Sopenharmony_ci| ID| Error Message|
1197e41f4b71Sopenharmony_ci| ------- | -------- |
1198e41f4b71Sopenharmony_ci| 201 | Permission denied. |
1199e41f4b71Sopenharmony_ci| 202 | Not System App. Interface caller is not a system app. |
1200e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
1201e41f4b71Sopenharmony_ci| 16000009 | An ability cannot be started or stopped in Wukong mode. |
1202e41f4b71Sopenharmony_ci
1203e41f4b71Sopenharmony_ci**Example**
1204e41f4b71Sopenharmony_ci
1205e41f4b71Sopenharmony_ci```ts
1206e41f4b71Sopenharmony_ciimport { missionManager } from '@kit.AbilityKit';
1207e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
1208e41f4b71Sopenharmony_ci
1209e41f4b71Sopenharmony_cilet testMissionId = 2;
1210e41f4b71Sopenharmony_ci
1211e41f4b71Sopenharmony_citry {
1212e41f4b71Sopenharmony_ci  missionManager.moveMissionToFront(testMissionId, (err: BusinessError, data: void) => {
1213e41f4b71Sopenharmony_ci    if (err) {
1214e41f4b71Sopenharmony_ci      console.error(`moveMissionToFront failed: ${err.message}`);
1215e41f4b71Sopenharmony_ci    } else {
1216e41f4b71Sopenharmony_ci      console.info(`moveMissionToFront successfully: ${JSON.stringify(data)}`);
1217e41f4b71Sopenharmony_ci    }
1218e41f4b71Sopenharmony_ci  });
1219e41f4b71Sopenharmony_ci} catch (error) {
1220e41f4b71Sopenharmony_ci  let err: BusinessError = error as BusinessError;
1221e41f4b71Sopenharmony_ci  console.error(`moveMissionToFront failed: ${err.message}`);
1222e41f4b71Sopenharmony_ci}
1223e41f4b71Sopenharmony_ci```
1224e41f4b71Sopenharmony_ci
1225e41f4b71Sopenharmony_ci## missionManager.moveMissionToFront
1226e41f4b71Sopenharmony_ci
1227e41f4b71Sopenharmony_cimoveMissionToFront(missionId: number, options: StartOptions, callback: AsyncCallback&lt;void&gt;): void
1228e41f4b71Sopenharmony_ci
1229e41f4b71Sopenharmony_ciSwitches a given mission to the foreground, with the startup parameters for the switching specified. This API uses an asynchronous callback to return the result.
1230e41f4b71Sopenharmony_ci
1231e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.MANAGE_MISSIONS
1232e41f4b71Sopenharmony_ci
1233e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Ability.AbilityRuntime.Mission
1234e41f4b71Sopenharmony_ci
1235e41f4b71Sopenharmony_ci**System API**: This is a system API and cannot be called by third-party applications.
1236e41f4b71Sopenharmony_ci
1237e41f4b71Sopenharmony_ci**Parameters**
1238e41f4b71Sopenharmony_ci
1239e41f4b71Sopenharmony_ci  | Name| Type| Mandatory| Description|
1240e41f4b71Sopenharmony_ci  | -------- | -------- | -------- | -------- |
1241e41f4b71Sopenharmony_ci  | missionId | number | Yes| Mission ID.|
1242e41f4b71Sopenharmony_ci  | 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.|
1243e41f4b71Sopenharmony_ci  | callback | AsyncCallback&lt;void&gt; | Yes| Callback used to return the result.|
1244e41f4b71Sopenharmony_ci
1245e41f4b71Sopenharmony_ci**Error codes**
1246e41f4b71Sopenharmony_ci
1247e41f4b71Sopenharmony_ciFor details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Ability Error Codes](errorcode-ability.md).
1248e41f4b71Sopenharmony_ci
1249e41f4b71Sopenharmony_ci| ID| Error Message|
1250e41f4b71Sopenharmony_ci| ------- | -------- |
1251e41f4b71Sopenharmony_ci| 201 | Permission denied. |
1252e41f4b71Sopenharmony_ci| 202 | Not System App. Interface caller is not a system app. |
1253e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
1254e41f4b71Sopenharmony_ci| 16000009 | An ability cannot be started or stopped in Wukong mode. |
1255e41f4b71Sopenharmony_ci
1256e41f4b71Sopenharmony_ci**Example**
1257e41f4b71Sopenharmony_ci
1258e41f4b71Sopenharmony_ci```ts
1259e41f4b71Sopenharmony_ciimport { missionManager } from '@kit.AbilityKit';
1260e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
1261e41f4b71Sopenharmony_ci
1262e41f4b71Sopenharmony_cilet testMissionId = 2;
1263e41f4b71Sopenharmony_ci
1264e41f4b71Sopenharmony_citry {
1265e41f4b71Sopenharmony_ci  missionManager.moveMissionToFront(testMissionId, {windowMode : 101}, (err: BusinessError, data: void) => {
1266e41f4b71Sopenharmony_ci    if (err) {
1267e41f4b71Sopenharmony_ci      console.error(`moveMissionToFront failed: ${err.message}`);
1268e41f4b71Sopenharmony_ci    } else {
1269e41f4b71Sopenharmony_ci      console.info(`moveMissionToFront successfully: ${JSON.stringify(data)}`);
1270e41f4b71Sopenharmony_ci    }
1271e41f4b71Sopenharmony_ci  });
1272e41f4b71Sopenharmony_ci} catch (error) {
1273e41f4b71Sopenharmony_ci  let err: BusinessError = error as BusinessError;
1274e41f4b71Sopenharmony_ci  console.error(`moveMissionToFront failed: ${err.message}`);
1275e41f4b71Sopenharmony_ci}
1276e41f4b71Sopenharmony_ci```
1277e41f4b71Sopenharmony_ci
1278e41f4b71Sopenharmony_ci## missionManager.moveMissionToFront
1279e41f4b71Sopenharmony_ci
1280e41f4b71Sopenharmony_cimoveMissionToFront(missionId: number, options?: StartOptions): Promise&lt;void&gt;
1281e41f4b71Sopenharmony_ci
1282e41f4b71Sopenharmony_ciSwitches a given mission to the foreground, with the startup parameters for the switching specified. This API uses a promise to return the result.
1283e41f4b71Sopenharmony_ci
1284e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.MANAGE_MISSIONS
1285e41f4b71Sopenharmony_ci
1286e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Ability.AbilityRuntime.Mission
1287e41f4b71Sopenharmony_ci
1288e41f4b71Sopenharmony_ci**System API**: This is a system API and cannot be called by third-party applications.
1289e41f4b71Sopenharmony_ci
1290e41f4b71Sopenharmony_ci**Parameters**
1291e41f4b71Sopenharmony_ci
1292e41f4b71Sopenharmony_ci  | Name| Type| Mandatory| Description|
1293e41f4b71Sopenharmony_ci  | -------- | -------- | -------- | -------- |
1294e41f4b71Sopenharmony_ci  | missionId | number | Yes| Mission ID.|
1295e41f4b71Sopenharmony_ci  | options | [StartOptions](js-apis-app-ability-startOptions.md) | No| Startup parameters, which are used to specify the window mode and device ID for switching the mission to the foreground. By default, no value is passed in, indicating that the default startup parameters are used.|
1296e41f4b71Sopenharmony_ci
1297e41f4b71Sopenharmony_ci**Return value**
1298e41f4b71Sopenharmony_ci
1299e41f4b71Sopenharmony_ci  | Type| Description|
1300e41f4b71Sopenharmony_ci  | -------- | -------- |
1301e41f4b71Sopenharmony_ci  | Promise&lt;void&gt; | Promise used to return the result.|
1302e41f4b71Sopenharmony_ci
1303e41f4b71Sopenharmony_ci**Error codes**
1304e41f4b71Sopenharmony_ci
1305e41f4b71Sopenharmony_ciFor details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Ability Error Codes](errorcode-ability.md).
1306e41f4b71Sopenharmony_ci
1307e41f4b71Sopenharmony_ci| ID| Error Message|
1308e41f4b71Sopenharmony_ci| ------- | -------- |
1309e41f4b71Sopenharmony_ci| 201 | Permission denied. |
1310e41f4b71Sopenharmony_ci| 202 | Not System App. Interface caller is not a system app. |
1311e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
1312e41f4b71Sopenharmony_ci| 16000009 | An ability cannot be started or stopped in Wukong mode. |
1313e41f4b71Sopenharmony_ci
1314e41f4b71Sopenharmony_ci**Example**
1315e41f4b71Sopenharmony_ci
1316e41f4b71Sopenharmony_ci```ts
1317e41f4b71Sopenharmony_ciimport { missionManager } from '@kit.AbilityKit';
1318e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
1319e41f4b71Sopenharmony_ci
1320e41f4b71Sopenharmony_cilet testMissionId = 2;
1321e41f4b71Sopenharmony_ci
1322e41f4b71Sopenharmony_citry {
1323e41f4b71Sopenharmony_ci  missionManager.moveMissionToFront(testMissionId).then((data: void) => {
1324e41f4b71Sopenharmony_ci    console.info(`moveMissionToFront successfully. Data: ${JSON.stringify(data)}`);
1325e41f4b71Sopenharmony_ci  }).catch((error: BusinessError) => {
1326e41f4b71Sopenharmony_ci    console.error(`moveMissionToFront failed. Cause: ${error.message}`);
1327e41f4b71Sopenharmony_ci  });
1328e41f4b71Sopenharmony_ci} catch (error) {
1329e41f4b71Sopenharmony_ci  let err: BusinessError = error as BusinessError;
1330e41f4b71Sopenharmony_ci  console.error(`moveMissionToFront failed. Cause: ${err.message}`);
1331e41f4b71Sopenharmony_ci}
1332e41f4b71Sopenharmony_ci```
1333e41f4b71Sopenharmony_ci
1334e41f4b71Sopenharmony_ci## missionManager.moveMissionsToForeground<sup>10+</sup>
1335e41f4b71Sopenharmony_ci
1336e41f4b71Sopenharmony_cimoveMissionsToForeground(missionIds: Array&lt;number&gt;, callback: AsyncCallback&lt;void&gt;): void
1337e41f4b71Sopenharmony_ci
1338e41f4b71Sopenharmony_ciSwitches a batch of missions to the foreground. This API uses an asynchronous callback to return the result.
1339e41f4b71Sopenharmony_ci
1340e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.MANAGE_MISSIONS
1341e41f4b71Sopenharmony_ci
1342e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Ability.AbilityRuntime.Mission
1343e41f4b71Sopenharmony_ci
1344e41f4b71Sopenharmony_ci**System API**: This is a system API.
1345e41f4b71Sopenharmony_ci
1346e41f4b71Sopenharmony_ci**Parameters**
1347e41f4b71Sopenharmony_ci
1348e41f4b71Sopenharmony_ci  | Name| Type| Mandatory| Description|
1349e41f4b71Sopenharmony_ci  | -------- | -------- | -------- | -------- |
1350e41f4b71Sopenharmony_ci  | missionIds | Array&lt;number&gt; | Yes| Array holding the mission IDs.|
1351e41f4b71Sopenharmony_ci  | callback | AsyncCallback&lt;void&gt; | Yes| Callback used to return the result.|
1352e41f4b71Sopenharmony_ci
1353e41f4b71Sopenharmony_ci**Error codes**
1354e41f4b71Sopenharmony_ci
1355e41f4b71Sopenharmony_ciFor details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Ability Error Codes](errorcode-ability.md).
1356e41f4b71Sopenharmony_ci
1357e41f4b71Sopenharmony_ci| ID| Error Message|
1358e41f4b71Sopenharmony_ci| ------- | -------- |
1359e41f4b71Sopenharmony_ci| 201 | Permission denied. |
1360e41f4b71Sopenharmony_ci| 202 | Not System App. Interface caller is not a system app. |
1361e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
1362e41f4b71Sopenharmony_ci| 16000050 | Internal error. |
1363e41f4b71Sopenharmony_ci
1364e41f4b71Sopenharmony_ci**Example**
1365e41f4b71Sopenharmony_ci
1366e41f4b71Sopenharmony_ci```ts
1367e41f4b71Sopenharmony_ciimport { abilityManager, missionManager } from '@kit.AbilityKit';
1368e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
1369e41f4b71Sopenharmony_ci
1370e41f4b71Sopenharmony_citry {
1371e41f4b71Sopenharmony_ci  missionManager.getMissionInfos("", 10, (error: BusinessError, missionInfos: Array<missionManager.MissionInfo>) => {
1372e41f4b71Sopenharmony_ci    if (error.code) {
1373e41f4b71Sopenharmony_ci      console.log("getMissionInfos failed, error.code:" + JSON.stringify(error.code));
1374e41f4b71Sopenharmony_ci      return;
1375e41f4b71Sopenharmony_ci    }
1376e41f4b71Sopenharmony_ci    if (missionInfos.length < 1) {
1377e41f4b71Sopenharmony_ci      return;
1378e41f4b71Sopenharmony_ci    }
1379e41f4b71Sopenharmony_ci
1380e41f4b71Sopenharmony_ci    let toShows = new Array<number>();
1381e41f4b71Sopenharmony_ci    for (let missionInfo of missionInfos) {
1382e41f4b71Sopenharmony_ci      if (missionInfo.abilityState == abilityManager.AbilityState.BACKGROUND) {
1383e41f4b71Sopenharmony_ci        toShows.push(missionInfo.missionId);
1384e41f4b71Sopenharmony_ci      }
1385e41f4b71Sopenharmony_ci    }
1386e41f4b71Sopenharmony_ci    missionManager.moveMissionsToForeground(toShows, (err: BusinessError, data: void) => {
1387e41f4b71Sopenharmony_ci      if (err) {
1388e41f4b71Sopenharmony_ci        console.error(`moveMissionsToForeground failed: ${err.message}`);
1389e41f4b71Sopenharmony_ci      } else {
1390e41f4b71Sopenharmony_ci        console.info(`moveMissionsToForeground successfully: ${JSON.stringify(data)}`);
1391e41f4b71Sopenharmony_ci      }
1392e41f4b71Sopenharmony_ci    });
1393e41f4b71Sopenharmony_ci  });
1394e41f4b71Sopenharmony_ci} catch (paramError) {
1395e41f4b71Sopenharmony_ci  let code = (paramError as BusinessError).code;
1396e41f4b71Sopenharmony_ci  let message = (paramError as BusinessError).message;
1397e41f4b71Sopenharmony_ci  console.error(`error: ${code}, ${message} `);
1398e41f4b71Sopenharmony_ci}
1399e41f4b71Sopenharmony_ci```
1400e41f4b71Sopenharmony_ci
1401e41f4b71Sopenharmony_ci## missionManager.moveMissionsToForeground<sup>10+</sup>
1402e41f4b71Sopenharmony_ci
1403e41f4b71Sopenharmony_cimoveMissionsToForeground(missionIds: Array&lt;number&gt;, topMission: number, callback: AsyncCallback&lt;void&gt;): void
1404e41f4b71Sopenharmony_ci
1405e41f4b71Sopenharmony_ciSwitches a batch of missions to the foreground, and moves the mission with the specified ID to the top. This API uses an asynchronous callback to return the result.
1406e41f4b71Sopenharmony_ci
1407e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.MANAGE_MISSIONS
1408e41f4b71Sopenharmony_ci
1409e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Ability.AbilityRuntime.Mission
1410e41f4b71Sopenharmony_ci
1411e41f4b71Sopenharmony_ci**System API**: This is a system API.
1412e41f4b71Sopenharmony_ci
1413e41f4b71Sopenharmony_ci**Parameters**
1414e41f4b71Sopenharmony_ci
1415e41f4b71Sopenharmony_ci  | Name| Type| Mandatory| Description|
1416e41f4b71Sopenharmony_ci  | -------- | -------- | -------- | -------- |
1417e41f4b71Sopenharmony_ci  | missionIds | Array&lt;number&gt; | Yes| Array holding the mission IDs.|
1418e41f4b71Sopenharmony_ci  | topMission | number | Yes| ID of the mission to be moved to the top.|
1419e41f4b71Sopenharmony_ci  | callback | AsyncCallback&lt;void&gt; | Yes| Callback used to return the result.|
1420e41f4b71Sopenharmony_ci
1421e41f4b71Sopenharmony_ci**Error codes**
1422e41f4b71Sopenharmony_ci
1423e41f4b71Sopenharmony_ciFor details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Ability Error Codes](errorcode-ability.md).
1424e41f4b71Sopenharmony_ci
1425e41f4b71Sopenharmony_ci| ID| Error Message|
1426e41f4b71Sopenharmony_ci| ------- | -------- |
1427e41f4b71Sopenharmony_ci| 201 | Permission denied. |
1428e41f4b71Sopenharmony_ci| 202 | Not System App. Interface caller is not a system app. |
1429e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
1430e41f4b71Sopenharmony_ci| 16000050 | Internal error. |
1431e41f4b71Sopenharmony_ci
1432e41f4b71Sopenharmony_ci**Example**
1433e41f4b71Sopenharmony_ci
1434e41f4b71Sopenharmony_ci```ts
1435e41f4b71Sopenharmony_ciimport { abilityManager, missionManager } from '@kit.AbilityKit';
1436e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
1437e41f4b71Sopenharmony_ci
1438e41f4b71Sopenharmony_citry {
1439e41f4b71Sopenharmony_ci  missionManager.getMissionInfos("", 10, (error: BusinessError, missionInfos: Array<missionManager.MissionInfo>) => {
1440e41f4b71Sopenharmony_ci    if (error.code) {
1441e41f4b71Sopenharmony_ci      console.log("getMissionInfos failed, error.code:" + JSON.stringify(error.code));
1442e41f4b71Sopenharmony_ci      return;
1443e41f4b71Sopenharmony_ci    }
1444e41f4b71Sopenharmony_ci    if (missionInfos.length < 1) {
1445e41f4b71Sopenharmony_ci      return;
1446e41f4b71Sopenharmony_ci    }
1447e41f4b71Sopenharmony_ci
1448e41f4b71Sopenharmony_ci    let toShows = new Array<number>();
1449e41f4b71Sopenharmony_ci    for (let missionInfo of missionInfos) {
1450e41f4b71Sopenharmony_ci      if (missionInfo.abilityState == abilityManager.AbilityState.BACKGROUND) {
1451e41f4b71Sopenharmony_ci        toShows.push(missionInfo.missionId);
1452e41f4b71Sopenharmony_ci      }
1453e41f4b71Sopenharmony_ci    }
1454e41f4b71Sopenharmony_ci    missionManager.moveMissionsToForeground(toShows, toShows[0], (err: BusinessError, data: void) => {
1455e41f4b71Sopenharmony_ci      if (err) {
1456e41f4b71Sopenharmony_ci        console.error(`moveMissionsToForeground failed: ${err.message}`);
1457e41f4b71Sopenharmony_ci      } else {
1458e41f4b71Sopenharmony_ci        console.info(`moveMissionsToForeground successfully: ${JSON.stringify(data)}`);
1459e41f4b71Sopenharmony_ci      }
1460e41f4b71Sopenharmony_ci    });
1461e41f4b71Sopenharmony_ci  });
1462e41f4b71Sopenharmony_ci} catch (paramError) {
1463e41f4b71Sopenharmony_ci  let code = (paramError as BusinessError).code;
1464e41f4b71Sopenharmony_ci  let message = (paramError as BusinessError).message;
1465e41f4b71Sopenharmony_ci  console.error(`error: ${code}, ${message} `);
1466e41f4b71Sopenharmony_ci}
1467e41f4b71Sopenharmony_ci```
1468e41f4b71Sopenharmony_ci
1469e41f4b71Sopenharmony_ci## missionManager.moveMissionsToForeground<sup>10+</sup>
1470e41f4b71Sopenharmony_ci
1471e41f4b71Sopenharmony_cimoveMissionsToForeground(missionIds: Array&lt;number&gt;, topMission?: number): Promise&lt;void&gt;
1472e41f4b71Sopenharmony_ci
1473e41f4b71Sopenharmony_ciSwitches a batch of missions to the foreground, and moves the mission with the specified ID to the top. This API uses a promise to return the result.
1474e41f4b71Sopenharmony_ci
1475e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.MANAGE_MISSIONS
1476e41f4b71Sopenharmony_ci
1477e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Ability.AbilityRuntime.Mission
1478e41f4b71Sopenharmony_ci
1479e41f4b71Sopenharmony_ci**System API**: This is a system API.
1480e41f4b71Sopenharmony_ci
1481e41f4b71Sopenharmony_ci**Parameters**
1482e41f4b71Sopenharmony_ci
1483e41f4b71Sopenharmony_ci  | Name| Type| Mandatory| Description|
1484e41f4b71Sopenharmony_ci  | -------- | -------- | -------- | -------- |
1485e41f4b71Sopenharmony_ci  | missionIds | Array&lt;number&gt; | Yes| Array holding the mission IDs.|
1486e41f4b71Sopenharmony_ci  | topMission | number | No| ID of the mission to be moved to the top. The default value is **-1**, indicating that the default mission is moved to the top.|
1487e41f4b71Sopenharmony_ci
1488e41f4b71Sopenharmony_ci**Return value**
1489e41f4b71Sopenharmony_ci
1490e41f4b71Sopenharmony_ci  | Type| Description|
1491e41f4b71Sopenharmony_ci  | -------- | -------- |
1492e41f4b71Sopenharmony_ci  | Promise&lt;void&gt; | Promise used to return the result.|
1493e41f4b71Sopenharmony_ci
1494e41f4b71Sopenharmony_ci**Error codes**
1495e41f4b71Sopenharmony_ci
1496e41f4b71Sopenharmony_ciFor details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Ability Error Codes](errorcode-ability.md).
1497e41f4b71Sopenharmony_ci
1498e41f4b71Sopenharmony_ci| ID| Error Message|
1499e41f4b71Sopenharmony_ci| ------- | -------- |
1500e41f4b71Sopenharmony_ci| 201 | Permission denied. |
1501e41f4b71Sopenharmony_ci| 202 | Not System App. Interface caller is not a system app. |
1502e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
1503e41f4b71Sopenharmony_ci| 16000050 | Internal error. |
1504e41f4b71Sopenharmony_ci
1505e41f4b71Sopenharmony_ci**Example**
1506e41f4b71Sopenharmony_ci
1507e41f4b71Sopenharmony_ci```ts
1508e41f4b71Sopenharmony_ciimport { abilityManager, missionManager } from '@kit.AbilityKit';
1509e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
1510e41f4b71Sopenharmony_ci
1511e41f4b71Sopenharmony_citry {
1512e41f4b71Sopenharmony_ci  missionManager.getMissionInfos("", 10, (error: BusinessError, missionInfos: Array<missionManager.MissionInfo>) => {
1513e41f4b71Sopenharmony_ci    if (error.code) {
1514e41f4b71Sopenharmony_ci      console.log("getMissionInfos failed, error.code:" + JSON.stringify(error.code));
1515e41f4b71Sopenharmony_ci      return;
1516e41f4b71Sopenharmony_ci    }
1517e41f4b71Sopenharmony_ci    if (missionInfos.length < 1) {
1518e41f4b71Sopenharmony_ci      return;
1519e41f4b71Sopenharmony_ci    }
1520e41f4b71Sopenharmony_ci
1521e41f4b71Sopenharmony_ci    let toShows = new Array<number>();
1522e41f4b71Sopenharmony_ci    for (let missionInfo of missionInfos) {
1523e41f4b71Sopenharmony_ci      if (missionInfo.abilityState == abilityManager.AbilityState.BACKGROUND) {
1524e41f4b71Sopenharmony_ci        toShows.push(missionInfo.missionId);
1525e41f4b71Sopenharmony_ci      }
1526e41f4b71Sopenharmony_ci    }
1527e41f4b71Sopenharmony_ci    missionManager.moveMissionsToForeground(toShows, toShows[0]).then(() => {
1528e41f4b71Sopenharmony_ci      console.log("moveMissionsToForeground is called" );
1529e41f4b71Sopenharmony_ci    });
1530e41f4b71Sopenharmony_ci  });
1531e41f4b71Sopenharmony_ci} catch (paramError) {
1532e41f4b71Sopenharmony_ci  let code = (paramError as BusinessError).code;
1533e41f4b71Sopenharmony_ci  let message = (paramError as BusinessError).message;
1534e41f4b71Sopenharmony_ci  console.error(`error: ${code}, ${message} `);
1535e41f4b71Sopenharmony_ci}
1536e41f4b71Sopenharmony_ci```
1537e41f4b71Sopenharmony_ci
1538e41f4b71Sopenharmony_ci## missionManager.moveMissionsToBackground<sup>10+</sup>
1539e41f4b71Sopenharmony_ci
1540e41f4b71Sopenharmony_cimoveMissionsToBackground(missionIds: Array&lt;number&gt;, callback: AsyncCallback&lt;Array&lt;number&gt;&gt;): void
1541e41f4b71Sopenharmony_ci
1542e41f4b71Sopenharmony_ciSwitches a batch of missions to the background. This API uses an asynchronous callback to return the result. The mission IDs in the callback are sorted by mission level when the missions are switched.
1543e41f4b71Sopenharmony_ci
1544e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.MANAGE_MISSIONS
1545e41f4b71Sopenharmony_ci
1546e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Ability.AbilityRuntime.Mission
1547e41f4b71Sopenharmony_ci
1548e41f4b71Sopenharmony_ci**System API**: This is a system API.
1549e41f4b71Sopenharmony_ci
1550e41f4b71Sopenharmony_ci**Parameters**
1551e41f4b71Sopenharmony_ci
1552e41f4b71Sopenharmony_ci  | Name| Type| Mandatory| Description|
1553e41f4b71Sopenharmony_ci  | -------- | -------- | -------- | -------- |
1554e41f4b71Sopenharmony_ci  | missionIds | Array&lt;number&gt; | Yes| Array holding the mission IDs.|
1555e41f4b71Sopenharmony_ci  | callback | AsyncCallback&lt;Array&lt;number&gt;&gt; | Yes| Callback used to return the result.|
1556e41f4b71Sopenharmony_ci
1557e41f4b71Sopenharmony_ci**Error codes**
1558e41f4b71Sopenharmony_ci
1559e41f4b71Sopenharmony_ciFor details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Ability Error Codes](errorcode-ability.md).
1560e41f4b71Sopenharmony_ci
1561e41f4b71Sopenharmony_ci| ID| Error Message|
1562e41f4b71Sopenharmony_ci| ------- | -------- |
1563e41f4b71Sopenharmony_ci| 201 | Permission denied. |
1564e41f4b71Sopenharmony_ci| 202 | Not System App. Interface caller is not a system app. |
1565e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
1566e41f4b71Sopenharmony_ci| 16000050 | Internal error. |
1567e41f4b71Sopenharmony_ci
1568e41f4b71Sopenharmony_ci**Example**
1569e41f4b71Sopenharmony_ci
1570e41f4b71Sopenharmony_ci```ts
1571e41f4b71Sopenharmony_ciimport { abilityManager, missionManager } from '@kit.AbilityKit';
1572e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
1573e41f4b71Sopenharmony_ci
1574e41f4b71Sopenharmony_citry {
1575e41f4b71Sopenharmony_ci  missionManager.getMissionInfos("", 10, (error: BusinessError, missionInfos: Array<missionManager.MissionInfo>) => {
1576e41f4b71Sopenharmony_ci    if (error.code) {
1577e41f4b71Sopenharmony_ci      console.log("getMissionInfos failed, error.code:" + JSON.stringify(error.code));
1578e41f4b71Sopenharmony_ci      return;
1579e41f4b71Sopenharmony_ci    }
1580e41f4b71Sopenharmony_ci
1581e41f4b71Sopenharmony_ci    let toHides = new Array<number>();
1582e41f4b71Sopenharmony_ci    for (let missionInfo of missionInfos) {
1583e41f4b71Sopenharmony_ci      if (missionInfo.abilityState ==  abilityManager.AbilityState.FOREGROUND) {
1584e41f4b71Sopenharmony_ci        toHides.push(missionInfo.missionId);
1585e41f4b71Sopenharmony_ci      }
1586e41f4b71Sopenharmony_ci    }
1587e41f4b71Sopenharmony_ci    missionManager.moveMissionsToBackground(toHides, (err: BusinessError, data: Array<number>) => {
1588e41f4b71Sopenharmony_ci      if (err) {
1589e41f4b71Sopenharmony_ci        console.error(`moveMissionsToBackground failed: ${err.message}`);
1590e41f4b71Sopenharmony_ci      } else {
1591e41f4b71Sopenharmony_ci        console.info(`moveMissionsToBackground successfully: ${JSON.stringify(data)}`);
1592e41f4b71Sopenharmony_ci      }
1593e41f4b71Sopenharmony_ci    });
1594e41f4b71Sopenharmony_ci  });
1595e41f4b71Sopenharmony_ci} catch (paramError) {
1596e41f4b71Sopenharmony_ci  let code = (paramError as BusinessError).code;
1597e41f4b71Sopenharmony_ci  let message = (paramError as BusinessError).message;
1598e41f4b71Sopenharmony_ci  console.error(`error: ${code}, ${message} `);
1599e41f4b71Sopenharmony_ci}
1600e41f4b71Sopenharmony_ci```
1601e41f4b71Sopenharmony_ci
1602e41f4b71Sopenharmony_ci## missionManager.moveMissionsToBackground<sup>10+</sup>
1603e41f4b71Sopenharmony_ci
1604e41f4b71Sopenharmony_cimoveMissionsToBackground(missionIds : Array&lt;number&gt;): Promise&lt;Array&lt;number&gt;&gt;
1605e41f4b71Sopenharmony_ci
1606e41f4b71Sopenharmony_ciSwitches a batch of missions to the background. This API uses a promise to return the result. The mission IDs in the promise are sorted by mission level when the missions are switched.
1607e41f4b71Sopenharmony_ci
1608e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.MANAGE_MISSIONS
1609e41f4b71Sopenharmony_ci
1610e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Ability.AbilityRuntime.Mission
1611e41f4b71Sopenharmony_ci
1612e41f4b71Sopenharmony_ci**System API**: This is a system API.
1613e41f4b71Sopenharmony_ci
1614e41f4b71Sopenharmony_ci**Parameters**
1615e41f4b71Sopenharmony_ci
1616e41f4b71Sopenharmony_ci  | Name| Type| Mandatory| Description|
1617e41f4b71Sopenharmony_ci  | -------- | -------- | -------- | -------- |
1618e41f4b71Sopenharmony_ci  | missionIds | Array&lt;number&gt; | Yes| Array holding the mission IDs.|
1619e41f4b71Sopenharmony_ci
1620e41f4b71Sopenharmony_ci**Return value**
1621e41f4b71Sopenharmony_ci
1622e41f4b71Sopenharmony_ci  | Type| Description|
1623e41f4b71Sopenharmony_ci  | -------- | -------- |
1624e41f4b71Sopenharmony_ci  | Promise&lt;Array&lt;number&gt;&gt; | Promise used to return the result.|
1625e41f4b71Sopenharmony_ci
1626e41f4b71Sopenharmony_ci**Error codes**
1627e41f4b71Sopenharmony_ci
1628e41f4b71Sopenharmony_ciFor details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Ability Error Codes](errorcode-ability.md).
1629e41f4b71Sopenharmony_ci
1630e41f4b71Sopenharmony_ci| ID| Error Message|
1631e41f4b71Sopenharmony_ci| ------- | -------- |
1632e41f4b71Sopenharmony_ci| 201 | Permission denied. |
1633e41f4b71Sopenharmony_ci| 202 | Not System App. Interface caller is not a system app. |
1634e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
1635e41f4b71Sopenharmony_ci| 16000050 | Internal error. |
1636e41f4b71Sopenharmony_ci
1637e41f4b71Sopenharmony_ci**Example**
1638e41f4b71Sopenharmony_ci
1639e41f4b71Sopenharmony_ci```ts
1640e41f4b71Sopenharmony_ciimport { abilityManager, missionManager } from '@kit.AbilityKit';
1641e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
1642e41f4b71Sopenharmony_ci
1643e41f4b71Sopenharmony_citry {
1644e41f4b71Sopenharmony_ci  missionManager.getMissionInfos("", 10, (error: BusinessError, missionInfos: Array<missionManager.MissionInfo>) => {
1645e41f4b71Sopenharmony_ci    if (error.code) {
1646e41f4b71Sopenharmony_ci      console.log("getMissionInfos failed, error.code:" + JSON.stringify(error.code));
1647e41f4b71Sopenharmony_ci      return;
1648e41f4b71Sopenharmony_ci    }
1649e41f4b71Sopenharmony_ci
1650e41f4b71Sopenharmony_ci    let toHides = new Array<number>();
1651e41f4b71Sopenharmony_ci    for (let missionInfo of missionInfos) {
1652e41f4b71Sopenharmony_ci      if (missionInfo.abilityState ==  abilityManager.AbilityState.FOREGROUND) {
1653e41f4b71Sopenharmony_ci        toHides.push(missionInfo.missionId);
1654e41f4b71Sopenharmony_ci      }
1655e41f4b71Sopenharmony_ci    }
1656e41f4b71Sopenharmony_ci    missionManager.moveMissionsToBackground(toHides).then((hideRes: Array<number>) => {
1657e41f4b71Sopenharmony_ci      console.log("moveMissionsToBackground is called, res: "+ JSON.stringify(hideRes));
1658e41f4b71Sopenharmony_ci    });
1659e41f4b71Sopenharmony_ci  });
1660e41f4b71Sopenharmony_ci} catch (paramError) {
1661e41f4b71Sopenharmony_ci  let code = (paramError as BusinessError).code;
1662e41f4b71Sopenharmony_ci  let message = (paramError as BusinessError).message;
1663e41f4b71Sopenharmony_ci  console.error(`error: ${code}, ${message} `);
1664e41f4b71Sopenharmony_ci}
1665e41f4b71Sopenharmony_ci```
1666