1# @ohos.distributedMissionManager (Distributed Mission Management) (System API)
2
3The **distributedMissionManager** module implements mission management across devices. You can use the APIs provided by this module to register or unregister a mission status listener, start or stop synchronizing a remote mission list, and continue a mission on a remote device by mission ID or bundle name.
4
5> **NOTE**
6>
7> 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.
8>
9> The APIs provided by this module are system APIs.
10
11## Modules to Import
12
13```js
14import { distributedMissionManager } from '@kit.AbilityKit';
15```
16
17## distributedMissionManager.registerMissionListener
18
19registerMissionListener(parameter: MissionDeviceInfo, options: MissionCallback, callback: AsyncCallback<void>): void;
20
21Registers a mission status listener. This API uses an asynchronous callback to return the result.
22
23**Required permissions**: ohos.permission.MANAGE_MISSIONS
24
25**System capability**: SystemCapability.Ability.AbilityRuntime.Mission
26
27**Parameters**
28
29| Name      | Type                                     | Mandatory  | Description       |
30| --------- | --------------------------------------- | ---- | --------- |
31| parameter | [MissionDeviceInfo](#missiondeviceinfo) | Yes   | Information about the device to listen for.|
32| options   | [MissionCallback](#missioncallback)     | Yes   | Callback to register.|
33| callback  | AsyncCallback<void>               | Yes   | Callback used to return the result. If the listener is registered, **err** is **undefined**; otherwise, **err** is an error object.|
34
35**Error codes**
36
37For details about the error codes, see [Universal Error Codes](../errorcode-universal.md).
38
39| ID| Error Message|
40| ------- | -------------------------------- |
41| 201      | Permission denied.|
42| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
43
44**Example**
45
46  ```ts
47  import { distributedMissionManager } from '@kit.AbilityKit';
48  import { BusinessError } from '@kit.BasicServicesKit';
49
50  // Implement a callback function.
51  function NotifyMissionsChanged(deviceId: string): void {
52    console.log('NotifyMissionsChanged deviceId ' + JSON.stringify(deviceId));
53  }
54  function NotifySnapshot(deviceId: string, missionId: number): void {
55    console.log('NotifySnapshot deviceId ' + JSON.stringify(deviceId));
56    console.log('NotifySnapshot missionId ' + JSON.stringify(missionId));
57  }
58  function NotifyNetDisconnect(deviceId: string, state: number): void {
59    console.log('NotifyNetDisconnect deviceId ' + JSON.stringify(deviceId));
60    console.log('NotifyNetDisconnect state ' + JSON.stringify(state));
61  }
62  try {
63    // Call registerMissionListener.
64    distributedMissionManager.registerMissionListener(
65      { deviceId: "" },
66      {
67        notifyMissionsChanged: NotifyMissionsChanged,
68        notifySnapshot: NotifySnapshot,
69        notifyNetDisconnect: NotifyNetDisconnect
70      },
71      (error: BusinessError) => {
72        if (error) {
73          console.error('registerMissionListener failed, cause: ' + JSON.stringify(error));
74          return;
75        }
76        console.info('registerMissionListener finished');
77      });
78  } catch (error) {
79    console.error('registerMissionListener failed, cause: ' + JSON.stringify(error));
80  }
81  ```
82## distributedMissionManager.registerMissionListener
83
84registerMissionListener(parameter: MissionDeviceInfo, options: MissionCallback): Promise<void>
85
86Registers a mission status listener. This API uses a promise to return the result.
87
88**Required permissions**: ohos.permission.MANAGE_MISSIONS
89
90**System capability**: SystemCapability.Ability.AbilityRuntime.Mission
91
92**Parameters**
93
94| Name      | Type                                      | Mandatory  | Description      |
95| --------- | ---------------------------------------- | ---- | -------- |
96| parameter | [MissionDeviceInfo](#missiondeviceinfo)  | Yes   | Information about the device to listen for.  |
97| options   | <a href="#missioncallback">MissionCallback</a> | Yes   | Callback to register.|
98
99**Return value**
100
101| Type                 | Description              |
102| ------------------- | ---------------- |
103| Promise&lt;void&gt; | Promise that returns no value.|
104
105**Error codes**
106
107For details about the error codes, see [Universal Error Codes](../errorcode-universal.md).
108
109| ID| Error Message|
110| ------- | -------------------------------- |
111| 201      | Permission denied.|
112| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
113
114**Example**
115
116  ```ts
117  import { distributedMissionManager } from '@kit.AbilityKit';
118  import { BusinessError } from '@kit.BasicServicesKit';
119
120  // Implement a callback function.
121  function NotifyMissionsChanged(deviceId: string): void {
122    console.log('NotifyMissionsChanged deviceId ' + JSON.stringify(deviceId));
123  }
124  function NotifySnapshot(deviceId: string, missionId: number): void {
125    console.log('NotifySnapshot deviceId ' + JSON.stringify(deviceId));
126    console.log('NotifySnapshot missionId ' + JSON.stringify(missionId));
127  }
128  function NotifyNetDisconnect(deviceId: string, state: number): void {
129    console.log('NotifyNetDisconnect deviceId ' + JSON.stringify(deviceId));
130    console.log('NotifyNetDisconnect state ' + JSON.stringify(state));
131  }
132  try {
133      // Call registerMissionListener.
134      distributedMissionManager.registerMissionListener(
135        { deviceId: "" },
136        {
137          notifyMissionsChanged: NotifyMissionsChanged,
138          notifySnapshot: NotifySnapshot,
139          notifyNetDisconnect: NotifyNetDisconnect
140        }).then(() => {
141          console.info('registerMissionListener finished. ');
142      }).catch((error: BusinessError) => {
143          console.error('registerMissionListener failed, cause: ' + JSON.stringify(error));
144      })
145  } catch (error) {
146      console.error('registerMissionListener failed, cause: ' + JSON.stringify(error));
147  }
148  ```
149
150## distributedMissionManager.unRegisterMissionListener
151
152unRegisterMissionListener(parameter: MissionDeviceInfo, callback: AsyncCallback&lt;void&gt;): void;
153
154Unregisters a mission status listener. This API uses an asynchronous callback to return the result.
155
156**Required permissions**: ohos.permission.MANAGE_MISSIONS
157
158**System capability**: SystemCapability.Ability.AbilityRuntime.Mission
159
160**Parameters**
161
162| Name      | Type                                     | Mandatory  | Description       |
163| --------- | --------------------------------------- | ---- | --------- |
164| parameter | [MissionDeviceInfo](#missiondeviceinfo) | Yes   | Information about the device to listen for.   |
165| callback  | AsyncCallback&lt;void&gt;               | Yes   | Callback used to return the result. If the listener is unregistered, **err** is **undefined**; otherwise, **err** is an error object.|
166
167**Error codes**
168
169For details about the error codes, see [Universal Error Codes](../errorcode-universal.md).
170
171| ID| Error Message|
172| ------- | -------------------------------- |
173| 201      | Permission denied.|
174| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
175
176**Example**
177
178  ```ts
179  import { distributedMissionManager } from '@kit.AbilityKit';
180  import { BusinessError } from '@kit.BasicServicesKit';
181
182  try {
183    distributedMissionManager.unRegisterMissionListener(
184      { deviceId: "" },
185      (error: BusinessError) => {
186        if (error) {
187            console.error('unRegisterMissionListener failed, cause: ' + JSON.stringify(error));
188            return;
189        }
190        console.info('unRegisterMissionListener finished');
191    })
192  } catch (error) {
193      console.error('unRegisterMissionListener failed, cause: ' + JSON.stringify(error));
194  }
195  ```
196
197## distributedMissionManager.unRegisterMissionListener
198
199unRegisterMissionListener(parameter: MissionDeviceInfo): Promise&lt;void&gt;
200
201Unregisters a mission status listener. This API uses a promise to return the result.
202
203**Required permissions**: ohos.permission.MANAGE_MISSIONS
204
205**System capability**: SystemCapability.Ability.AbilityRuntime.Mission
206
207**Parameters**
208
209| Name      | Type                                     | Mandatory  | Description   |
210| --------- | --------------------------------------- | ---- | ----- |
211| parameter | [MissionDeviceInfo](#missiondeviceinfo) | Yes   | Information about the device to listen for.|
212
213**Return value**
214
215| Type                 | Description              |
216| ------------------- | ---------------- |
217| Promise&lt;void&gt; |Promise that returns no value.|
218
219**Error codes**
220
221For details about the error codes, see [Universal Error Codes](../errorcode-universal.md).
222
223| ID| Error Message|
224| ------- | -------------------------------- |
225| 201      | Permission denied.|
226| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
227
228**Example**
229
230  ```ts
231  import { distributedMissionManager } from '@kit.AbilityKit';
232  import { BusinessError } from '@kit.BasicServicesKit';
233
234  try {
235    distributedMissionManager.unRegisterMissionListener({deviceId: ""}).then(() => {
236      console.info('unRegisterMissionListener finished successfully');
237    }).catch((error: BusinessError) => {
238        console.error('unRegisterMissionListener failed, cause: ' + JSON.stringify(error));
239    })
240  } catch (error) {
241      console.error('unRegisterMissionListener failed, cause: ' + JSON.stringify(error));
242  }
243  ```
244
245## distributedMissionManager.startSyncRemoteMissions
246
247startSyncRemoteMissions(parameter: MissionParameter, callback: AsyncCallback&lt;void&gt;): void;
248
249Starts to synchronize the remote mission list. This API uses an asynchronous callback to return the result.
250
251**Required permissions**: ohos.permission.MANAGE_MISSIONS
252
253**System capability**: SystemCapability.Ability.AbilityRuntime.Mission
254
255**Parameters**
256
257| Name      | Type                                   | Mandatory  | Description       |
258| --------- | ------------------------------------- | ---- | --------- |
259| parameter | [MissionParameter](#missionparameter) | Yes   | Parameters required for synchronization.    |
260| callback  | AsyncCallback&lt;void&gt;             | Yes   | Callback used to return the result. If the synchronization is started, **err** is **undefined**; otherwise, **err** is an error object.|
261
262**Error codes**
263
264For details about the error codes, see [Universal Error Codes](../errorcode-universal.md).
265
266| ID| Error Message|
267| ------- | -------------------------------- |
268| 201      | Permission denied.|
269| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
270
271**Example**
272
273  ```ts
274  import { distributedMissionManager } from '@kit.AbilityKit';
275  import { BusinessError } from '@kit.BasicServicesKit';
276
277  try {
278    distributedMissionManager.startSyncRemoteMissions(
279      {
280        deviceId: "",
281        fixConflict: false,
282        tag: 0
283      },
284      (error: BusinessError) => {
285        if (error) {
286          console.error('startSyncRemoteMissions failed, cause: ' + JSON.stringify(error));
287          return;
288        }
289        console.info('startSyncRemoteMissions finished');}
290    )
291  } catch (error) {
292    console.error('startSyncRemoteMissions failed, cause: ' + JSON.stringify(error));
293  }
294  ```
295
296## distributedMissionManager.startSyncRemoteMissions
297
298startSyncRemoteMissions(parameter: MissionParameter): Promise&lt;void&gt;
299
300Starts to synchronize the remote mission list. This API uses a promise to return the result.
301
302**Required permissions**: ohos.permission.MANAGE_MISSIONS
303
304**System capability**: SystemCapability.Ability.AbilityRuntime.Mission
305
306**Parameters**
307
308| Name      | Type                                   | Mandatory  | Description   |
309| --------- | ------------------------------------- | ---- | ----- |
310| parameter | [MissionParameter](#missionparameter) | Yes   | Parameters required for synchronization.|
311
312**Return value**
313
314| Type                 | Description              |
315| ------------------- | ---------------- |
316| Promise&lt;void&gt; | Promise that returns no value.|
317
318**Error codes**
319
320For details about the error codes, see [Universal Error Codes](../errorcode-universal.md).
321
322| ID| Error Message|
323| ------- | -------------------------------- |
324| 201      | Permission denied.|
325| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
326
327**Example**
328
329  ```ts
330  import { distributedMissionManager } from '@kit.AbilityKit';
331  import { BusinessError } from '@kit.BasicServicesKit';
332
333  try {
334    distributedMissionManager.startSyncRemoteMissions(
335      {
336        deviceId: "",
337        fixConflict: false,
338        tag: 0
339      }
340    ).then(() => {
341        console.info('startSyncRemoteMissions finished successfully');
342      }).catch((error: BusinessError) => {
343      console.error('startSyncRemoteMissions failed, cause: ' + JSON.stringify(error));
344    })
345  } catch (error) {
346    console.error('startSyncRemoteMissions failed, cause: ' + JSON.stringify(error));
347  }
348  ```
349
350## distributedMissionManager.stopSyncRemoteMissions
351
352stopSyncRemoteMissions(parameter: MissionDeviceInfo, callback: AsyncCallback&lt;void&gt;): void;
353
354Stops synchronizing the remote mission list. This API uses an asynchronous callback to return the result.
355
356**Required permissions**: ohos.permission.MANAGE_MISSIONS
357
358**System capability**: SystemCapability.Ability.AbilityRuntime.Mission
359
360**Parameters**
361
362| Name      | Type                                     | Mandatory  | Description       |
363| --------- | --------------------------------------- | ---- | --------- |
364| parameter | [MissionDeviceInfo](#missiondeviceinfo) | Yes   | Parameters required for synchronization.    |
365| callback  | AsyncCallback&lt;void&gt;               | Yes   | Callback used to return the result. If the synchronization is stopped, **err** is **undefined**; otherwise, **err** is an error object.|
366
367**Error codes**
368
369For details about the error codes, see [Universal Error Codes](../errorcode-universal.md).
370
371| ID| Error Message|
372| ------- | -------------------------------- |
373| 201      | Permission denied.|
374| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
375
376**Example**
377
378  ```ts
379  import { distributedMissionManager } from '@kit.AbilityKit';
380  import { BusinessError } from '@kit.BasicServicesKit';
381
382  try {
383    distributedMissionManager.stopSyncRemoteMissions(
384      {
385        deviceId: ""
386      },
387      (error: BusinessError) => {
388        if (error) {
389          console.error('stopSyncRemoteMissions failed, cause: ' + JSON.stringify(error));
390          return;
391        }
392        console.info('stopSyncRemoteMissions finished');}
393    )
394  } catch (error) {
395    console.error('stopSyncRemoteMissions failed, cause: ' + JSON.stringify(error));
396  }
397  ```
398
399## distributedMissionManager.stopSyncRemoteMissions
400
401stopSyncRemoteMissions(parameter: MissionDeviceInfo): Promise&lt;void&gt;
402
403Stops synchronizing the remote mission list. This API uses a promise to return the result.
404
405**Required permissions**: ohos.permission.MANAGE_MISSIONS
406
407**System capability**: SystemCapability.Ability.AbilityRuntime.Mission
408
409**Parameters**
410
411| Name      | Type                                     | Mandatory  | Description   |
412| --------- | --------------------------------------- | ---- | ----- |
413| parameter | [MissionDeviceInfo](#missiondeviceinfo) | Yes   | Parameters required for synchronization.|
414
415**Return value**
416
417| Type                 | Description              |
418| ------------------- | ---------------- |
419| Promise&lt;void&gt; | Promise that returns no value.|
420
421**Error codes**
422
423For details about the error codes, see [Universal Error Codes](../errorcode-universal.md).
424
425| ID| Error Message|
426| ------- | -------------------------------- |
427| 201      | Permission denied.|
428| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
429
430**Example**
431
432  ```ts
433  import { distributedMissionManager } from '@kit.AbilityKit';
434  import { BusinessError } from '@kit.BasicServicesKit';
435
436  try {
437    distributedMissionManager.stopSyncRemoteMissions(
438      {
439        deviceId: ""
440      }).then(() => {
441        console.info('stopSyncRemoteMissions finished successfully');
442      }).catch((error: BusinessError) => {
443      console.error('stopSyncRemoteMissions failed, cause: ' + JSON.stringify(error));
444    })
445  } catch (error) {
446    console.error('stopSyncRemoteMissions failed, cause: ' + JSON.stringify(error));
447  }
448  ```
449
450## distributedMissionManager.continueMission
451
452continueMission(parameter: ContinueDeviceInfo, options: ContinueCallback, callback: AsyncCallback&lt;void&gt;): void;
453
454Continues a mission on a remote device, with the mission ID specified. This API uses an asynchronous callback to return the result.
455
456**Required permissions**: ohos.permission.MANAGE_MISSIONS and ohos.permission.DISTRIBUTED_DATASYNC
457
458**System capability**: SystemCapability.Ability.AbilityRuntime.Mission
459
460**Parameters**
461
462| Name      | Type                                     | Mandatory  | Description   |
463| --------- | --------------------------------------- | ---- | ----- |
464| parameter | [ContinueDeviceInfo](js-apis-inner-application-continueDeviceInfo-sys.md) | Yes   | Parameters required for mission continuation.|
465| options | [ContinueCallback](js-apis-inner-application-continueCallback-sys.md) | Yes   | Callback invoked when the mission continuation is complete.|
466| callback | AsyncCallback&lt;void&gt; | Yes   | Callback used to return the result. If the mission is continued, **err** is **undefined**; otherwise, **err** is an error object.|
467
468**Error codes**
469
470For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Distributed Scheduler Error Codes](errorcode-DistributedSchedule.md).
471
472| ID| Error Message|
473| ------- | -------------------------------------------- |
474| 201      | Permission denied.|
475| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
476| 16300501 | The system ability work abnormally. |
477| 16300502 | Failed to get the missionInfo of the specified missionId. |
478| 16300503 | The application is not installed on the remote end and installation-free is not supported. |
479| 16300504 | The application is not installed on the remote end but installation-free is supported, try again with freeInstall flag. |
480| 16300505 | The operation device must be the device where the application to be continued is located or the target device to be continued. |
481| 16300506 | The local continuation task is already in progress. |
482
483**Example**
484
485  ```ts
486  import { distributedMissionManager } from '@kit.AbilityKit';
487  import { BusinessError } from '@kit.BasicServicesKit';
488
489  // Implement a callback function.
490  function onContinueDone(resultCode: number): void {
491    console.log('onContinueDone resultCode: ' + JSON.stringify(resultCode));
492  };
493  try {
494    // Call continueMission.
495    distributedMissionManager.continueMission(
496      {
497        srcDeviceId: "",
498        dstDeviceId: "",
499        missionId: 1,
500        wantParam: {"key": "value"}
501      },
502      { onContinueDone: onContinueDone },
503      (error: BusinessError) => {
504        if (error) {
505          console.error('continueMission failed, cause: ' + JSON.stringify(error));
506          return;
507        }
508        console.info('continueMission finished');
509    })
510  } catch (error) {
511    console.error('continueMission failed, cause: ' + JSON.stringify(error));
512  }
513  ```
514
515## distributedMissionManager.continueMission
516
517continueMission(parameter: ContinueDeviceInfo, options: ContinueCallback): Promise&lt;void&gt;
518
519Continues a mission on a remote device, with the mission ID specified. This API uses a promise to return the result.
520
521**Required permissions**: ohos.permission.MANAGE_MISSIONS and ohos.permission.DISTRIBUTED_DATASYNC
522
523**System capability**: SystemCapability.Ability.AbilityRuntime.Mission
524
525**Parameters**
526
527| Name      | Type                                     | Mandatory  | Description   |
528| --------- | --------------------------------------- | ---- | ----- |
529| parameter | [ContinueDeviceInfo](js-apis-inner-application-continueDeviceInfo-sys.md) | Yes   | Parameters required for mission continuation.|
530| options | [ContinueCallback](js-apis-inner-application-continueCallback-sys.md) | Yes   | Callback invoked when the mission continuation is complete.|
531
532**Return value**
533
534| Type                 | Description              |
535| ------------------- | ---------------- |
536| Promise&lt;void&gt; |Promise that returns no value.|
537
538**Error codes**
539
540For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Distributed Scheduler Error Codes](errorcode-DistributedSchedule.md).
541
542| ID| Error Message|
543| ------- | -------------------------------------------- |
544| 201      | Permission denied.|
545| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
546| 16300501 | The system ability work abnormally. |
547| 16300502 | Failed to get the missionInfo of the specified missionId. |
548| 16300503 | The application is not installed on the remote end and installation-free is not supported. |
549| 16300504 | The application is not installed on the remote end but installation-free is supported, try again with freeInstall flag. |
550| 16300505 | The operation device must be the device where the application to be continued is located or the target device to be continued. |
551| 16300506 | The local continuation task is already in progress. |
552
553**Example**
554
555  ```ts
556  import { distributedMissionManager } from '@kit.AbilityKit';
557  import { BusinessError } from '@kit.BasicServicesKit';
558
559  // Implement a callback function.
560  function onContinueDone(resultCode: number): void {
561    console.log('onContinueDone resultCode: ' + JSON.stringify(resultCode));
562  };
563  try {
564    // Call continueMission.
565    distributedMissionManager.continueMission(
566      {
567        srcDeviceId: "",
568        dstDeviceId: "",
569        missionId: 1,
570        wantParam: {"key": "value"}
571      },
572      { onContinueDone: onContinueDone }).then(() => {
573        console.info('continueMission finished successfully');
574      }).catch((error: BusinessError) => {
575      console.error('continueMission failed, cause: ' + JSON.stringify(error));
576    })
577  } catch (error) {
578    console.error('continueMission failed, cause: ' + JSON.stringify(error));
579  }
580  ```
581
582## distributedMissionManager.continueMission<sup>10+</sup>
583
584continueMission(parameter: ContinueMissionInfo, callback: AsyncCallback&lt;void&gt;): void;
585
586Continues a mission on a remote device, with the bundle name specified. This API uses an asynchronous callback to return the result.
587
588**Required permissions**: ohos.permission.MANAGE_MISSIONS and ohos.permission.DISTRIBUTED_DATASYNC
589
590**System capability**: SystemCapability.Ability.AbilityRuntime.Mission
591
592**Parameters**
593
594| Name      | Type                                     | Mandatory  | Description   |
595| --------- | --------------------------------------- | ---- | ----- |
596| parameter | [ContinueMissionInfo](./js-apis-inner-application-continueMissionInfo-sys.md) | Yes   | Parameters required for mission continuation.|
597| callback | AsyncCallback&lt;void&gt; | Yes   | Callback used to return the result. If the mission is continued, **err** is **undefined**; otherwise, **err** is an error object.|
598
599**Error codes**
600
601For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Distributed Scheduler Error Codes](errorcode-DistributedSchedule.md).
602
603| ID| Error Message|
604| ------- | -------------------------------------------- |
605| 201      | Permission denied.|
606| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
607| 16300501 | The system ability work abnormally. |
608| 16300503 | The application is not installed on the remote end and installation-free is not supported. |
609| 16300504 | The application is not installed on the remote end but installation-free is supported, try again with freeInstall flag. |
610| 16300505 | The operation device must be the device where the application to be continued is located or the target device to be continued. |
611| 16300506 | The local continuation task is already in progress. |
612| 16300507 | Failed to get the missionInfo of the specified bundle name. |
613
614**Example**
615
616  ```ts
617  import { distributedMissionManager } from '@kit.AbilityKit';
618  import { BusinessError } from '@kit.BasicServicesKit';
619
620  try {
621    distributedMissionManager.continueMission(
622      {
623        srcDeviceId: "",
624        dstDeviceId: "",
625        bundleName: "ohos.test.continueapp",
626        wantParam: {"key": "value"}
627      },
628      (error: BusinessError) => {
629        if (error) {
630          console.error('continueMission failed, cause: ' + JSON.stringify(error));
631          return;
632        }
633        console.info('continueMission finished');
634    })
635  } catch (error) {
636    console.error('continueMission failed, cause: ' + JSON.stringify(error));
637  }
638  ```
639
640## distributedMissionManager.continueMission<sup>10+</sup>
641
642continueMission(parameter: ContinueMissionInfo): Promise&lt;void&gt;
643
644Continues a mission on a remote device, with the bundle name specified. This API uses a promise to return the result.
645
646**Required permissions**: ohos.permission.MANAGE_MISSIONS and ohos.permission.DISTRIBUTED_DATASYNC
647
648**System capability**: SystemCapability.Ability.AbilityRuntime.Mission
649
650**Parameters**
651
652| Name      | Type                                     | Mandatory  | Description   |
653| --------- | --------------------------------------- | ---- | ----- |
654| parameter | [ContinueMissionInfo](./js-apis-inner-application-continueMissionInfo-sys.md) | Yes   | Parameters required for mission continuation.|
655
656**Return value**
657
658| Type                 | Description              |
659| ------------------- | ---------------- |
660| Promise&lt;void&gt; | Promise that returns no value.|
661
662**Error codes**
663
664For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Distributed Scheduler Error Codes](errorcode-DistributedSchedule.md).
665
666| ID| Error Message|
667| ------- | -------------------------------------------- |
668| 201      | Permission denied.|
669| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
670| 16300501 | The system ability work abnormally. |
671| 16300503 | The application is not installed on the remote end and installation-free is not supported. |
672| 16300504 | The application is not installed on the remote end but installation-free is supported, try again with freeInstall flag. |
673| 16300505 | The operation device must be the device where the application to be continued is located or the target device to be continued. |
674| 16300506 | The local continuation task is already in progress. |
675| 16300507 | Failed to get the missionInfo of the specified bundle name. |
676
677**Example**
678
679  ```ts
680  import { distributedMissionManager } from '@kit.AbilityKit';
681  import { BusinessError } from '@kit.BasicServicesKit';
682
683  try {
684      distributedMissionManager.continueMission(
685        {
686          srcDeviceId: "",
687          dstDeviceId: "",
688          bundleName: "ohos.test.continueapp",
689          wantParam: {"key": "value"}
690        }
691      ).then(() => {
692          console.info('continueMission finished successfully');
693      }).catch((error: BusinessError) => {
694          console.error('continueMission failed, cause: ' + JSON.stringify(error));
695      })
696  } catch (error) {
697      console.error('continueMission failed, cause: ' + JSON.stringify(error));
698  }
699  ```
700
701## distributedMissionManager.on('continueStateChange')<sup>10+</sup>
702
703on(type: 'continueStateChange',  callback: Callback&lt;ContinueCallbackInfo&gt;): void
704
705Subscribes to continuation state change events of the current mission.
706
707**Required permissions**: ohos.permission.MANAGE_MISSIONS
708
709**System capability**: SystemCapability.Ability.AbilityRuntime.Mission
710
711**Parameters**
712
713| Name      | Type                                      | Mandatory  | Description      |
714| --------- | ---------------------------------------- | ---- | -------- |
715| type | string  | Yes   | Event type. The value **'continueStateChange'** indicates the continuation state change event of the current mission.    |
716| callback | Callback&lt;[ContinueCallbackInfo](#continuecallbackinfo11)&gt; | Yes   | Callback used to return the continuation state and information of the current mission.   |
717
718**Error codes**
719
720For details about the error codes, see [Universal Error Codes](../errorcode-universal.md).
721
722| ID| Error Message|
723| ------- | -------------------------------- |
724| 201      | Permission denied.|
725| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
726
727**Example**
728
729```js
730  import { distributedMissionManager } from '@kit.AbilityKit';
731
732  try {
733    distributedMissionManager.on('continueStateChange', (data) => {
734      console.info("continueStateChange on:" + JSON.stringify(data));
735    });
736  } catch (error) {
737    console.error("continueStateChange err: " + JSON.stringify(error));
738  }
739  ```
740
741## distributedMissionManager.off('continueStateChange')<sup>10+</sup>
742
743off(type: 'continueStateChange',  callback?: Callback&lt;ContinueCallbackInfo&gt;): void
744
745Unsubscribes from continuation state change events of the current mission.
746
747**Required permissions**: ohos.permission.MANAGE_MISSIONS
748
749**System capability**: SystemCapability.Ability.AbilityRuntime.Mission
750
751**Parameters**
752
753| Name      | Type                                      | Mandatory  | Description      |
754| --------- | ---------------------------------------- | ---- | -------- |
755| type | string  | Yes   | Event type. The value **'continueStateChange'** indicates the continuation state change event of the current mission.    |
756| callback | Callback&lt;[ContinueCallbackInfo](#continuecallbackinfo11)&gt; | No   | Callback used for unsubscription.<br>If the callback is unspecified, all subscriptions to the specified event are canceled.   |
757
758**Error codes**
759
760For details about the error codes, see [Universal Error Codes](../errorcode-universal.md).
761
762| ID| Error Message|
763| ------- | -------------------------------- |
764| 201      | Permission denied.|
765| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
766
767**Example**
768
769```js
770  import { distributedMissionManager } from '@kit.AbilityKit';
771
772  try {
773    distributedMissionManager.off('continueStateChange', (data) => {
774      console.info("continueStateChange off:" + JSON.stringify(data));
775    });
776  } catch (err) {
777    console.error("continueStateChange err: " + JSON.stringify(err));
778  }
779  ```
780
781## MissionCallback
782
783Defines the callbacks that can be registered as a mission status listener.
784
785**Required permissions**: ohos.permission.MANAGE_MISSIONS
786
787**System capability**: SystemCapability.Ability.AbilityRuntime.Mission
788
789| Name                   | Type      | Readable  | Writable  | Description                |
790| --------------------- | -------- | ---- | ---- | ------------------ |
791| notifyMissionsChanged | function | Yes   | No   | Callback used to notify the mission change event and return the device ID.    |
792| notifySnapshot        | function | Yes   | No   | Callback used to notify the snapshot change event and return the device ID and mission ID.|
793| notifyNetDisconnect   | function | Yes   | No   | Callback used to notify the disconnection event and return the device ID and network status.|
794
795## MissionParameter
796
797Defines the parameters required for mission synchronization.
798
799**Required permissions**: ohos.permission.MANAGE_MISSIONS
800
801**System capability**: SystemCapability.Ability.AbilityRuntime.Mission
802
803| Name         | Type   | Readable  | Writable  | Description         |
804| ----------- | ------- | ---- | ---- | ----------- |
805| deviceId    | string  | Yes   | Yes   | Device ID. For details, see [getAvailableDeviceListSync](../apis-distributedservice-kit/js-apis-distributedDeviceManager.md#getavailabledevicelistsync).    |
806| fixConflict | boolean | Yes   | Yes   | Whether a version conflict occurs.|
807| tag         | number  | Yes   | Yes   | Tag of the mission.   |
808
809## MissionDeviceInfo
810
811Defines the parameters required for registering a listener.
812
813**Required permissions**: ohos.permission.MANAGE_MISSIONS
814
815**System capability**: SystemCapability.Ability.AbilityRuntime.Mission
816
817| Name      | Type  | Readable  | Writable  | Description     |
818| -------- | ------ | ---- | ---- | ------- |
819| deviceId | string | Yes   | Yes   | Device ID. For details, see [getAvailableDeviceListSync](../apis-distributedservice-kit/js-apis-distributedDeviceManager.md#getavailabledevicelistsync).|
820
821## ContinueState<sup>10+</sup>
822
823Enumerates the mission continuation states.
824
825**System capability**: SystemCapability.Ability.AbilityRuntime.Mission
826
827| Name          | Value      | Description                                                        |
828| ------------- | --------- | ------------------------------------------------------------ |
829| ACTIVE        | 0         | Continuation is activated for the current mission.                             |
830| INACTIVE      | 1         | Continuation is not activated for the current mission.                           |
831
832## ContinueCallbackInfo<sup>11+</sup>
833
834Defines the information about the callback that is triggered for mission continuation state changes.
835
836**System capability**: SystemCapability.Ability.AbilityRuntime.Mission
837
838| Name      | Type   | Readable  | Writable  | Description         |
839| -------- | ------ | ---- | ---- | ----------- |
840| state | [ContinueState](#continuestate10)   | Yes   | No   |   Continuation state of the mission.|
841| info  | [ContinuableInfo](./js-apis-inner-application-continuableInfo-sys.md) | Yes   | No   |   Continuation information of the mission.|
842