1e41f4b71Sopenharmony_ci# @ohos.distributedMissionManager (分布式任务管理)(系统接口)
2e41f4b71Sopenharmony_ci
3e41f4b71Sopenharmony_ci分布式任务管理模块提供跨设备任务管理能力,包括注册和取消任务状态监听、开始和停止同步远端设备任务列表、通过任务ID和包名进行迁移任务等。
4e41f4b71Sopenharmony_ci
5e41f4b71Sopenharmony_ci> **说明:**
6e41f4b71Sopenharmony_ci>
7e41f4b71Sopenharmony_ci> 本模块首批接口从API version 9开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
8e41f4b71Sopenharmony_ci>
9e41f4b71Sopenharmony_ci> 本模块为系统接口。
10e41f4b71Sopenharmony_ci
11e41f4b71Sopenharmony_ci## 导入模块
12e41f4b71Sopenharmony_ci
13e41f4b71Sopenharmony_ci```js
14e41f4b71Sopenharmony_ciimport { distributedMissionManager } from '@kit.AbilityKit';
15e41f4b71Sopenharmony_ci```
16e41f4b71Sopenharmony_ci
17e41f4b71Sopenharmony_ci## distributedMissionManager.registerMissionListener
18e41f4b71Sopenharmony_ci
19e41f4b71Sopenharmony_ciregisterMissionListener(parameter: MissionDeviceInfo, options: MissionCallback, callback: AsyncCallback<void>): void;
20e41f4b71Sopenharmony_ci
21e41f4b71Sopenharmony_ci注册任务状态监听。使用callback异步回调。
22e41f4b71Sopenharmony_ci
23e41f4b71Sopenharmony_ci**需要权限**:ohos.permission.MANAGE_MISSIONS
24e41f4b71Sopenharmony_ci
25e41f4b71Sopenharmony_ci**系统能力**:SystemCapability.Ability.AbilityRuntime.Mission
26e41f4b71Sopenharmony_ci
27e41f4b71Sopenharmony_ci**参数:**
28e41f4b71Sopenharmony_ci
29e41f4b71Sopenharmony_ci| 参数名       | 类型                                      | 必填   | 说明        |
30e41f4b71Sopenharmony_ci| --------- | --------------------------------------- | ---- | --------- |
31e41f4b71Sopenharmony_ci| parameter | [MissionDeviceInfo](#missiondeviceinfo) | 是    | 注册监听时的设备信息。 |
32e41f4b71Sopenharmony_ci| options   | [MissionCallback](#missioncallback)     | 是    | 注册的回调方法。 |
33e41f4b71Sopenharmony_ci| callback  | AsyncCallback<void>               | 是    | 回调函数,注册监听成功,err为undefined,否则为错误对象。 |
34e41f4b71Sopenharmony_ci
35e41f4b71Sopenharmony_ci**错误码:**
36e41f4b71Sopenharmony_ci
37e41f4b71Sopenharmony_ci以下错误码详细介绍请参考[通用错误码](../errorcode-universal.md)。
38e41f4b71Sopenharmony_ci
39e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
40e41f4b71Sopenharmony_ci| ------- | -------------------------------- |
41e41f4b71Sopenharmony_ci| 201      | Permission denied.|
42e41f4b71Sopenharmony_ci| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
43e41f4b71Sopenharmony_ci
44e41f4b71Sopenharmony_ci**示例:**
45e41f4b71Sopenharmony_ci
46e41f4b71Sopenharmony_ci  ```ts
47e41f4b71Sopenharmony_ci  import { distributedMissionManager } from '@kit.AbilityKit';
48e41f4b71Sopenharmony_ci  import { BusinessError } from '@kit.BasicServicesKit';
49e41f4b71Sopenharmony_ci  
50e41f4b71Sopenharmony_ci  // 实现回调函数
51e41f4b71Sopenharmony_ci  function NotifyMissionsChanged(deviceId: string): void {
52e41f4b71Sopenharmony_ci    console.log('NotifyMissionsChanged deviceId ' + JSON.stringify(deviceId));
53e41f4b71Sopenharmony_ci  }
54e41f4b71Sopenharmony_ci  function NotifySnapshot(deviceId: string, missionId: number): void {
55e41f4b71Sopenharmony_ci    console.log('NotifySnapshot deviceId ' + JSON.stringify(deviceId));
56e41f4b71Sopenharmony_ci    console.log('NotifySnapshot missionId ' + JSON.stringify(missionId));
57e41f4b71Sopenharmony_ci  }
58e41f4b71Sopenharmony_ci  function NotifyNetDisconnect(deviceId: string, state: number): void {
59e41f4b71Sopenharmony_ci    console.log('NotifyNetDisconnect deviceId ' + JSON.stringify(deviceId));
60e41f4b71Sopenharmony_ci    console.log('NotifyNetDisconnect state ' + JSON.stringify(state));
61e41f4b71Sopenharmony_ci  }
62e41f4b71Sopenharmony_ci  try {
63e41f4b71Sopenharmony_ci    // 调用registerMissionListener接口
64e41f4b71Sopenharmony_ci    distributedMissionManager.registerMissionListener(
65e41f4b71Sopenharmony_ci      { deviceId: "" },
66e41f4b71Sopenharmony_ci      {
67e41f4b71Sopenharmony_ci        notifyMissionsChanged: NotifyMissionsChanged,
68e41f4b71Sopenharmony_ci        notifySnapshot: NotifySnapshot,
69e41f4b71Sopenharmony_ci        notifyNetDisconnect: NotifyNetDisconnect
70e41f4b71Sopenharmony_ci      },
71e41f4b71Sopenharmony_ci      (error: BusinessError) => {
72e41f4b71Sopenharmony_ci        if (error) {
73e41f4b71Sopenharmony_ci          console.error('registerMissionListener failed, cause: ' + JSON.stringify(error));
74e41f4b71Sopenharmony_ci          return;
75e41f4b71Sopenharmony_ci        }
76e41f4b71Sopenharmony_ci        console.info('registerMissionListener finished');
77e41f4b71Sopenharmony_ci      });
78e41f4b71Sopenharmony_ci  } catch (error) {
79e41f4b71Sopenharmony_ci    console.error('registerMissionListener failed, cause: ' + JSON.stringify(error));
80e41f4b71Sopenharmony_ci  }
81e41f4b71Sopenharmony_ci  ```
82e41f4b71Sopenharmony_ci## distributedMissionManager.registerMissionListener
83e41f4b71Sopenharmony_ci
84e41f4b71Sopenharmony_ciregisterMissionListener(parameter: MissionDeviceInfo, options: MissionCallback): Promise<void>
85e41f4b71Sopenharmony_ci
86e41f4b71Sopenharmony_ci注册任务状态监听。使用promise异步回调。
87e41f4b71Sopenharmony_ci
88e41f4b71Sopenharmony_ci**需要权限**:ohos.permission.MANAGE_MISSIONS
89e41f4b71Sopenharmony_ci
90e41f4b71Sopenharmony_ci**系统能力**:SystemCapability.Ability.AbilityRuntime.Mission
91e41f4b71Sopenharmony_ci
92e41f4b71Sopenharmony_ci**参数:**
93e41f4b71Sopenharmony_ci
94e41f4b71Sopenharmony_ci| 参数名       | 类型                                       | 必填   | 说明       |
95e41f4b71Sopenharmony_ci| --------- | ---------------------------------------- | ---- | -------- |
96e41f4b71Sopenharmony_ci| parameter | [MissionDeviceInfo](#missiondeviceinfo)  | 是    | 注册监听时的设备信息。   |
97e41f4b71Sopenharmony_ci| options   | <a href="#missioncallback">MissionCallback</a> | 是    | 注册的回调方法。|
98e41f4b71Sopenharmony_ci
99e41f4b71Sopenharmony_ci**返回值:**
100e41f4b71Sopenharmony_ci
101e41f4b71Sopenharmony_ci| 类型                  | 说明               |
102e41f4b71Sopenharmony_ci| ------------------- | ---------------- |
103e41f4b71Sopenharmony_ci| Promise&lt;void&gt; | 无返回结果的Promise对象。 |
104e41f4b71Sopenharmony_ci
105e41f4b71Sopenharmony_ci**错误码:**
106e41f4b71Sopenharmony_ci
107e41f4b71Sopenharmony_ci以下错误码详细介绍请参考[通用错误码](../errorcode-universal.md)。
108e41f4b71Sopenharmony_ci
109e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
110e41f4b71Sopenharmony_ci| ------- | -------------------------------- |
111e41f4b71Sopenharmony_ci| 201      | Permission denied.|
112e41f4b71Sopenharmony_ci| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
113e41f4b71Sopenharmony_ci
114e41f4b71Sopenharmony_ci**示例:**
115e41f4b71Sopenharmony_ci
116e41f4b71Sopenharmony_ci  ```ts
117e41f4b71Sopenharmony_ci  import { distributedMissionManager } from '@kit.AbilityKit';
118e41f4b71Sopenharmony_ci  import { BusinessError } from '@kit.BasicServicesKit';
119e41f4b71Sopenharmony_ci
120e41f4b71Sopenharmony_ci  // 实现回调函数
121e41f4b71Sopenharmony_ci  function NotifyMissionsChanged(deviceId: string): void {
122e41f4b71Sopenharmony_ci    console.log('NotifyMissionsChanged deviceId ' + JSON.stringify(deviceId));
123e41f4b71Sopenharmony_ci  }
124e41f4b71Sopenharmony_ci  function NotifySnapshot(deviceId: string, missionId: number): void {
125e41f4b71Sopenharmony_ci    console.log('NotifySnapshot deviceId ' + JSON.stringify(deviceId));
126e41f4b71Sopenharmony_ci    console.log('NotifySnapshot missionId ' + JSON.stringify(missionId));
127e41f4b71Sopenharmony_ci  }
128e41f4b71Sopenharmony_ci  function NotifyNetDisconnect(deviceId: string, state: number): void {
129e41f4b71Sopenharmony_ci    console.log('NotifyNetDisconnect deviceId ' + JSON.stringify(deviceId));
130e41f4b71Sopenharmony_ci    console.log('NotifyNetDisconnect state ' + JSON.stringify(state));
131e41f4b71Sopenharmony_ci  }
132e41f4b71Sopenharmony_ci  try {
133e41f4b71Sopenharmony_ci      // 调用registerMissionListener接口
134e41f4b71Sopenharmony_ci      distributedMissionManager.registerMissionListener(
135e41f4b71Sopenharmony_ci        { deviceId: "" },
136e41f4b71Sopenharmony_ci        {
137e41f4b71Sopenharmony_ci          notifyMissionsChanged: NotifyMissionsChanged,
138e41f4b71Sopenharmony_ci          notifySnapshot: NotifySnapshot,
139e41f4b71Sopenharmony_ci          notifyNetDisconnect: NotifyNetDisconnect
140e41f4b71Sopenharmony_ci        }).then(() => {
141e41f4b71Sopenharmony_ci          console.info('registerMissionListener finished. ');
142e41f4b71Sopenharmony_ci      }).catch((error: BusinessError) => {
143e41f4b71Sopenharmony_ci          console.error('registerMissionListener failed, cause: ' + JSON.stringify(error));
144e41f4b71Sopenharmony_ci      })
145e41f4b71Sopenharmony_ci  } catch (error) {
146e41f4b71Sopenharmony_ci      console.error('registerMissionListener failed, cause: ' + JSON.stringify(error));
147e41f4b71Sopenharmony_ci  }
148e41f4b71Sopenharmony_ci  ```
149e41f4b71Sopenharmony_ci
150e41f4b71Sopenharmony_ci## distributedMissionManager.unRegisterMissionListener
151e41f4b71Sopenharmony_ci
152e41f4b71Sopenharmony_ciunRegisterMissionListener(parameter: MissionDeviceInfo, callback: AsyncCallback&lt;void&gt;): void;
153e41f4b71Sopenharmony_ci
154e41f4b71Sopenharmony_ci取消任务状态监听。使用callback异步回调。
155e41f4b71Sopenharmony_ci
156e41f4b71Sopenharmony_ci**需要权限**:ohos.permission.MANAGE_MISSIONS
157e41f4b71Sopenharmony_ci
158e41f4b71Sopenharmony_ci**系统能力**:SystemCapability.Ability.AbilityRuntime.Mission
159e41f4b71Sopenharmony_ci
160e41f4b71Sopenharmony_ci**参数:**
161e41f4b71Sopenharmony_ci
162e41f4b71Sopenharmony_ci| 参数名       | 类型                                      | 必填   | 说明        |
163e41f4b71Sopenharmony_ci| --------- | --------------------------------------- | ---- | --------- |
164e41f4b71Sopenharmony_ci| parameter | [MissionDeviceInfo](#missiondeviceinfo) | 是    | 注册监听时的设备信息。    |
165e41f4b71Sopenharmony_ci| callback  | AsyncCallback&lt;void&gt;               | 是    | 回调函数,取消监听成功,err为undefined,否则为错误对象。|
166e41f4b71Sopenharmony_ci
167e41f4b71Sopenharmony_ci**错误码:**
168e41f4b71Sopenharmony_ci
169e41f4b71Sopenharmony_ci以下错误码详细介绍请参考[通用错误码](../errorcode-universal.md)。
170e41f4b71Sopenharmony_ci
171e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
172e41f4b71Sopenharmony_ci| ------- | -------------------------------- |
173e41f4b71Sopenharmony_ci| 201      | Permission denied.|
174e41f4b71Sopenharmony_ci| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
175e41f4b71Sopenharmony_ci
176e41f4b71Sopenharmony_ci**示例:**
177e41f4b71Sopenharmony_ci
178e41f4b71Sopenharmony_ci  ```ts
179e41f4b71Sopenharmony_ci  import { distributedMissionManager } from '@kit.AbilityKit';
180e41f4b71Sopenharmony_ci  import { BusinessError } from '@kit.BasicServicesKit';
181e41f4b71Sopenharmony_ci
182e41f4b71Sopenharmony_ci  try {
183e41f4b71Sopenharmony_ci    distributedMissionManager.unRegisterMissionListener(
184e41f4b71Sopenharmony_ci      { deviceId: "" },
185e41f4b71Sopenharmony_ci      (error: BusinessError) => {
186e41f4b71Sopenharmony_ci        if (error) {
187e41f4b71Sopenharmony_ci            console.error('unRegisterMissionListener failed, cause: ' + JSON.stringify(error));
188e41f4b71Sopenharmony_ci            return;
189e41f4b71Sopenharmony_ci        }
190e41f4b71Sopenharmony_ci        console.info('unRegisterMissionListener finished');
191e41f4b71Sopenharmony_ci    })
192e41f4b71Sopenharmony_ci  } catch (error) {
193e41f4b71Sopenharmony_ci      console.error('unRegisterMissionListener failed, cause: ' + JSON.stringify(error));
194e41f4b71Sopenharmony_ci  }
195e41f4b71Sopenharmony_ci  ```
196e41f4b71Sopenharmony_ci
197e41f4b71Sopenharmony_ci## distributedMissionManager.unRegisterMissionListener
198e41f4b71Sopenharmony_ci
199e41f4b71Sopenharmony_ciunRegisterMissionListener(parameter: MissionDeviceInfo): Promise&lt;void&gt;
200e41f4b71Sopenharmony_ci
201e41f4b71Sopenharmony_ci取消任务状态监听。使用promise异步回调。
202e41f4b71Sopenharmony_ci
203e41f4b71Sopenharmony_ci**需要权限**:ohos.permission.MANAGE_MISSIONS
204e41f4b71Sopenharmony_ci
205e41f4b71Sopenharmony_ci**系统能力**:SystemCapability.Ability.AbilityRuntime.Mission
206e41f4b71Sopenharmony_ci
207e41f4b71Sopenharmony_ci**参数:**
208e41f4b71Sopenharmony_ci
209e41f4b71Sopenharmony_ci| 参数名       | 类型                                      | 必填   | 说明    |
210e41f4b71Sopenharmony_ci| --------- | --------------------------------------- | ---- | ----- |
211e41f4b71Sopenharmony_ci| parameter | [MissionDeviceInfo](#missiondeviceinfo) | 是    | 注册监听时的设备信息。 |
212e41f4b71Sopenharmony_ci
213e41f4b71Sopenharmony_ci**返回值:**
214e41f4b71Sopenharmony_ci
215e41f4b71Sopenharmony_ci| 类型                  | 说明               |
216e41f4b71Sopenharmony_ci| ------------------- | ---------------- |
217e41f4b71Sopenharmony_ci| Promise&lt;void&gt; |无返回结果的Promise对象。 |
218e41f4b71Sopenharmony_ci
219e41f4b71Sopenharmony_ci**错误码:**
220e41f4b71Sopenharmony_ci
221e41f4b71Sopenharmony_ci以下错误码详细介绍请参考[通用错误码](../errorcode-universal.md)。
222e41f4b71Sopenharmony_ci
223e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
224e41f4b71Sopenharmony_ci| ------- | -------------------------------- |
225e41f4b71Sopenharmony_ci| 201      | Permission denied.|
226e41f4b71Sopenharmony_ci| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
227e41f4b71Sopenharmony_ci
228e41f4b71Sopenharmony_ci**示例:**
229e41f4b71Sopenharmony_ci
230e41f4b71Sopenharmony_ci  ```ts
231e41f4b71Sopenharmony_ci  import { distributedMissionManager } from '@kit.AbilityKit';
232e41f4b71Sopenharmony_ci  import { BusinessError } from '@kit.BasicServicesKit';
233e41f4b71Sopenharmony_ci
234e41f4b71Sopenharmony_ci  try {
235e41f4b71Sopenharmony_ci    distributedMissionManager.unRegisterMissionListener({deviceId: ""}).then(() => {
236e41f4b71Sopenharmony_ci      console.info('unRegisterMissionListener finished successfully');
237e41f4b71Sopenharmony_ci    }).catch((error: BusinessError) => {
238e41f4b71Sopenharmony_ci        console.error('unRegisterMissionListener failed, cause: ' + JSON.stringify(error));
239e41f4b71Sopenharmony_ci    })
240e41f4b71Sopenharmony_ci  } catch (error) {
241e41f4b71Sopenharmony_ci      console.error('unRegisterMissionListener failed, cause: ' + JSON.stringify(error));
242e41f4b71Sopenharmony_ci  }
243e41f4b71Sopenharmony_ci  ```
244e41f4b71Sopenharmony_ci
245e41f4b71Sopenharmony_ci## distributedMissionManager.startSyncRemoteMissions
246e41f4b71Sopenharmony_ci
247e41f4b71Sopenharmony_cistartSyncRemoteMissions(parameter: MissionParameter, callback: AsyncCallback&lt;void&gt;): void;
248e41f4b71Sopenharmony_ci
249e41f4b71Sopenharmony_ci开始同步远端设备的任务列表。使用callback异步回调。
250e41f4b71Sopenharmony_ci
251e41f4b71Sopenharmony_ci**需要权限**:ohos.permission.MANAGE_MISSIONS
252e41f4b71Sopenharmony_ci
253e41f4b71Sopenharmony_ci**系统能力**:SystemCapability.Ability.AbilityRuntime.Mission
254e41f4b71Sopenharmony_ci
255e41f4b71Sopenharmony_ci**参数:**
256e41f4b71Sopenharmony_ci
257e41f4b71Sopenharmony_ci| 参数名       | 类型                                    | 必填   | 说明        |
258e41f4b71Sopenharmony_ci| --------- | ------------------------------------- | ---- | --------- |
259e41f4b71Sopenharmony_ci| parameter | [MissionParameter](#missionparameter) | 是    | 同步信息。     |
260e41f4b71Sopenharmony_ci| callback  | AsyncCallback&lt;void&gt;             | 是    | 回调函数,同步远端任务列表成功时,err为undefined,否则返回错误对象。 |
261e41f4b71Sopenharmony_ci
262e41f4b71Sopenharmony_ci**错误码:**
263e41f4b71Sopenharmony_ci
264e41f4b71Sopenharmony_ci以下错误码详细介绍请参考[通用错误码](../errorcode-universal.md)。
265e41f4b71Sopenharmony_ci
266e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
267e41f4b71Sopenharmony_ci| ------- | -------------------------------- |
268e41f4b71Sopenharmony_ci| 201      | Permission denied.|
269e41f4b71Sopenharmony_ci| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
270e41f4b71Sopenharmony_ci
271e41f4b71Sopenharmony_ci**示例:**
272e41f4b71Sopenharmony_ci
273e41f4b71Sopenharmony_ci  ```ts
274e41f4b71Sopenharmony_ci  import { distributedMissionManager } from '@kit.AbilityKit';
275e41f4b71Sopenharmony_ci  import { BusinessError } from '@kit.BasicServicesKit';
276e41f4b71Sopenharmony_ci
277e41f4b71Sopenharmony_ci  try {
278e41f4b71Sopenharmony_ci    distributedMissionManager.startSyncRemoteMissions(
279e41f4b71Sopenharmony_ci      {
280e41f4b71Sopenharmony_ci        deviceId: "",
281e41f4b71Sopenharmony_ci        fixConflict: false,
282e41f4b71Sopenharmony_ci        tag: 0
283e41f4b71Sopenharmony_ci      },
284e41f4b71Sopenharmony_ci      (error: BusinessError) => {
285e41f4b71Sopenharmony_ci        if (error) {
286e41f4b71Sopenharmony_ci          console.error('startSyncRemoteMissions failed, cause: ' + JSON.stringify(error));
287e41f4b71Sopenharmony_ci          return;
288e41f4b71Sopenharmony_ci        }
289e41f4b71Sopenharmony_ci        console.info('startSyncRemoteMissions finished');}
290e41f4b71Sopenharmony_ci    )
291e41f4b71Sopenharmony_ci  } catch (error) {
292e41f4b71Sopenharmony_ci    console.error('startSyncRemoteMissions failed, cause: ' + JSON.stringify(error));
293e41f4b71Sopenharmony_ci  }
294e41f4b71Sopenharmony_ci  ```
295e41f4b71Sopenharmony_ci
296e41f4b71Sopenharmony_ci## distributedMissionManager.startSyncRemoteMissions
297e41f4b71Sopenharmony_ci
298e41f4b71Sopenharmony_cistartSyncRemoteMissions(parameter: MissionParameter): Promise&lt;void&gt;
299e41f4b71Sopenharmony_ci
300e41f4b71Sopenharmony_ci开始同步远端设备的任务列表。使用promise异步回调。
301e41f4b71Sopenharmony_ci
302e41f4b71Sopenharmony_ci**需要权限**:ohos.permission.MANAGE_MISSIONS
303e41f4b71Sopenharmony_ci
304e41f4b71Sopenharmony_ci**系统能力**:SystemCapability.Ability.AbilityRuntime.Mission
305e41f4b71Sopenharmony_ci
306e41f4b71Sopenharmony_ci**参数:**
307e41f4b71Sopenharmony_ci
308e41f4b71Sopenharmony_ci| 参数名       | 类型                                    | 必填   | 说明    |
309e41f4b71Sopenharmony_ci| --------- | ------------------------------------- | ---- | ----- |
310e41f4b71Sopenharmony_ci| parameter | [MissionParameter](#missionparameter) | 是    | 同步信息。 |
311e41f4b71Sopenharmony_ci
312e41f4b71Sopenharmony_ci**返回值:**
313e41f4b71Sopenharmony_ci
314e41f4b71Sopenharmony_ci| 类型                  | 说明               |
315e41f4b71Sopenharmony_ci| ------------------- | ---------------- |
316e41f4b71Sopenharmony_ci| Promise&lt;void&gt; | 无返回结果的Promise对象。 |
317e41f4b71Sopenharmony_ci
318e41f4b71Sopenharmony_ci**错误码:**
319e41f4b71Sopenharmony_ci
320e41f4b71Sopenharmony_ci以下错误码详细介绍请参考[通用错误码](../errorcode-universal.md)。
321e41f4b71Sopenharmony_ci
322e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
323e41f4b71Sopenharmony_ci| ------- | -------------------------------- |
324e41f4b71Sopenharmony_ci| 201      | Permission denied.|
325e41f4b71Sopenharmony_ci| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
326e41f4b71Sopenharmony_ci
327e41f4b71Sopenharmony_ci**示例:**
328e41f4b71Sopenharmony_ci
329e41f4b71Sopenharmony_ci  ```ts
330e41f4b71Sopenharmony_ci  import { distributedMissionManager } from '@kit.AbilityKit';
331e41f4b71Sopenharmony_ci  import { BusinessError } from '@kit.BasicServicesKit';
332e41f4b71Sopenharmony_ci
333e41f4b71Sopenharmony_ci  try {
334e41f4b71Sopenharmony_ci    distributedMissionManager.startSyncRemoteMissions(
335e41f4b71Sopenharmony_ci      {
336e41f4b71Sopenharmony_ci        deviceId: "",
337e41f4b71Sopenharmony_ci        fixConflict: false,
338e41f4b71Sopenharmony_ci        tag: 0
339e41f4b71Sopenharmony_ci      }
340e41f4b71Sopenharmony_ci    ).then(() => {
341e41f4b71Sopenharmony_ci        console.info('startSyncRemoteMissions finished successfully');
342e41f4b71Sopenharmony_ci      }).catch((error: BusinessError) => {
343e41f4b71Sopenharmony_ci      console.error('startSyncRemoteMissions failed, cause: ' + JSON.stringify(error));
344e41f4b71Sopenharmony_ci    })
345e41f4b71Sopenharmony_ci  } catch (error) {
346e41f4b71Sopenharmony_ci    console.error('startSyncRemoteMissions failed, cause: ' + JSON.stringify(error));
347e41f4b71Sopenharmony_ci  }
348e41f4b71Sopenharmony_ci  ```
349e41f4b71Sopenharmony_ci
350e41f4b71Sopenharmony_ci## distributedMissionManager.stopSyncRemoteMissions
351e41f4b71Sopenharmony_ci
352e41f4b71Sopenharmony_cistopSyncRemoteMissions(parameter: MissionDeviceInfo, callback: AsyncCallback&lt;void&gt;): void;
353e41f4b71Sopenharmony_ci
354e41f4b71Sopenharmony_ci停止同步远端设备的任务列表。使用callback异步回调。
355e41f4b71Sopenharmony_ci
356e41f4b71Sopenharmony_ci**需要权限**:ohos.permission.MANAGE_MISSIONS
357e41f4b71Sopenharmony_ci
358e41f4b71Sopenharmony_ci**系统能力**:SystemCapability.Ability.AbilityRuntime.Mission
359e41f4b71Sopenharmony_ci
360e41f4b71Sopenharmony_ci**参数:**
361e41f4b71Sopenharmony_ci
362e41f4b71Sopenharmony_ci| 参数名       | 类型                                      | 必填   | 说明        |
363e41f4b71Sopenharmony_ci| --------- | --------------------------------------- | ---- | --------- |
364e41f4b71Sopenharmony_ci| parameter | [MissionDeviceInfo](#missiondeviceinfo) | 是    | 同步信息。     |
365e41f4b71Sopenharmony_ci| callback  | AsyncCallback&lt;void&gt;               | 是    | 回调函数,停止同步远端任务列表成功时,err为undefined,否则为错误对象。 |
366e41f4b71Sopenharmony_ci
367e41f4b71Sopenharmony_ci**错误码:**
368e41f4b71Sopenharmony_ci
369e41f4b71Sopenharmony_ci以下错误码详细介绍请参考[通用错误码](../errorcode-universal.md)。
370e41f4b71Sopenharmony_ci
371e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
372e41f4b71Sopenharmony_ci| ------- | -------------------------------- |
373e41f4b71Sopenharmony_ci| 201      | Permission denied.|
374e41f4b71Sopenharmony_ci| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
375e41f4b71Sopenharmony_ci
376e41f4b71Sopenharmony_ci**示例:**
377e41f4b71Sopenharmony_ci
378e41f4b71Sopenharmony_ci  ```ts
379e41f4b71Sopenharmony_ci  import { distributedMissionManager } from '@kit.AbilityKit';
380e41f4b71Sopenharmony_ci  import { BusinessError } from '@kit.BasicServicesKit';
381e41f4b71Sopenharmony_ci
382e41f4b71Sopenharmony_ci  try {
383e41f4b71Sopenharmony_ci    distributedMissionManager.stopSyncRemoteMissions(
384e41f4b71Sopenharmony_ci      {
385e41f4b71Sopenharmony_ci        deviceId: ""
386e41f4b71Sopenharmony_ci      },
387e41f4b71Sopenharmony_ci      (error: BusinessError) => {
388e41f4b71Sopenharmony_ci        if (error) {
389e41f4b71Sopenharmony_ci          console.error('stopSyncRemoteMissions failed, cause: ' + JSON.stringify(error));
390e41f4b71Sopenharmony_ci          return;
391e41f4b71Sopenharmony_ci        }
392e41f4b71Sopenharmony_ci        console.info('stopSyncRemoteMissions finished');}
393e41f4b71Sopenharmony_ci    )
394e41f4b71Sopenharmony_ci  } catch (error) {
395e41f4b71Sopenharmony_ci    console.error('stopSyncRemoteMissions failed, cause: ' + JSON.stringify(error));
396e41f4b71Sopenharmony_ci  }
397e41f4b71Sopenharmony_ci  ```
398e41f4b71Sopenharmony_ci
399e41f4b71Sopenharmony_ci## distributedMissionManager.stopSyncRemoteMissions
400e41f4b71Sopenharmony_ci
401e41f4b71Sopenharmony_cistopSyncRemoteMissions(parameter: MissionDeviceInfo): Promise&lt;void&gt;
402e41f4b71Sopenharmony_ci
403e41f4b71Sopenharmony_ci停止同步远端设备的任务列表。使用promise异步回调。
404e41f4b71Sopenharmony_ci
405e41f4b71Sopenharmony_ci**需要权限**:ohos.permission.MANAGE_MISSIONS
406e41f4b71Sopenharmony_ci
407e41f4b71Sopenharmony_ci**系统能力**:SystemCapability.Ability.AbilityRuntime.Mission
408e41f4b71Sopenharmony_ci
409e41f4b71Sopenharmony_ci**参数:**
410e41f4b71Sopenharmony_ci
411e41f4b71Sopenharmony_ci| 参数名       | 类型                                      | 必填   | 说明    |
412e41f4b71Sopenharmony_ci| --------- | --------------------------------------- | ---- | ----- |
413e41f4b71Sopenharmony_ci| parameter | [MissionDeviceInfo](#missiondeviceinfo) | 是    | 同步信息。 |
414e41f4b71Sopenharmony_ci
415e41f4b71Sopenharmony_ci**返回值:**
416e41f4b71Sopenharmony_ci
417e41f4b71Sopenharmony_ci| 类型                  | 说明               |
418e41f4b71Sopenharmony_ci| ------------------- | ---------------- |
419e41f4b71Sopenharmony_ci| Promise&lt;void&gt; | 无返回结果的promise对象。 |
420e41f4b71Sopenharmony_ci
421e41f4b71Sopenharmony_ci**错误码:**
422e41f4b71Sopenharmony_ci
423e41f4b71Sopenharmony_ci以下错误码详细介绍请参考[通用错误码](../errorcode-universal.md)。
424e41f4b71Sopenharmony_ci
425e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
426e41f4b71Sopenharmony_ci| ------- | -------------------------------- |
427e41f4b71Sopenharmony_ci| 201      | Permission denied.|
428e41f4b71Sopenharmony_ci| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
429e41f4b71Sopenharmony_ci
430e41f4b71Sopenharmony_ci**示例:**
431e41f4b71Sopenharmony_ci
432e41f4b71Sopenharmony_ci  ```ts
433e41f4b71Sopenharmony_ci  import { distributedMissionManager } from '@kit.AbilityKit';
434e41f4b71Sopenharmony_ci  import { BusinessError } from '@kit.BasicServicesKit';
435e41f4b71Sopenharmony_ci
436e41f4b71Sopenharmony_ci  try {
437e41f4b71Sopenharmony_ci    distributedMissionManager.stopSyncRemoteMissions(
438e41f4b71Sopenharmony_ci      {
439e41f4b71Sopenharmony_ci        deviceId: ""
440e41f4b71Sopenharmony_ci      }).then(() => {
441e41f4b71Sopenharmony_ci        console.info('stopSyncRemoteMissions finished successfully');
442e41f4b71Sopenharmony_ci      }).catch((error: BusinessError) => {
443e41f4b71Sopenharmony_ci      console.error('stopSyncRemoteMissions failed, cause: ' + JSON.stringify(error));
444e41f4b71Sopenharmony_ci    })
445e41f4b71Sopenharmony_ci  } catch (error) {
446e41f4b71Sopenharmony_ci    console.error('stopSyncRemoteMissions failed, cause: ' + JSON.stringify(error));
447e41f4b71Sopenharmony_ci  }
448e41f4b71Sopenharmony_ci  ```
449e41f4b71Sopenharmony_ci
450e41f4b71Sopenharmony_ci## distributedMissionManager.continueMission
451e41f4b71Sopenharmony_ci
452e41f4b71Sopenharmony_cicontinueMission(parameter: ContinueDeviceInfo, options: ContinueCallback, callback: AsyncCallback&lt;void&gt;): void;
453e41f4b71Sopenharmony_ci
454e41f4b71Sopenharmony_ci通过指定任务ID(missionId)的方式进行迁移任务。使用callback异步回调。
455e41f4b71Sopenharmony_ci
456e41f4b71Sopenharmony_ci**需要权限**:ohos.permission.MANAGE_MISSIONSohos.permission.DISTRIBUTED_DATASYNC
457e41f4b71Sopenharmony_ci
458e41f4b71Sopenharmony_ci**系统能力**:SystemCapability.Ability.AbilityRuntime.Mission
459e41f4b71Sopenharmony_ci
460e41f4b71Sopenharmony_ci**参数:**
461e41f4b71Sopenharmony_ci
462e41f4b71Sopenharmony_ci| 参数名       | 类型                                      | 必填   | 说明    |
463e41f4b71Sopenharmony_ci| --------- | --------------------------------------- | ---- | ----- |
464e41f4b71Sopenharmony_ci| parameter | [ContinueDeviceInfo](js-apis-inner-application-continueDeviceInfo-sys.md) | 是    | 迁移信息。 |
465e41f4b71Sopenharmony_ci| options | [ContinueCallback](js-apis-inner-application-continueCallback-sys.md) | 是    | 迁移任务完成回调函数。 |
466e41f4b71Sopenharmony_ci| callback | AsyncCallback&lt;void&gt; | 是    | 回调函数,迁移任务完成时,err为undefined,否则返回错误对象。 |
467e41f4b71Sopenharmony_ci
468e41f4b71Sopenharmony_ci**错误码:**
469e41f4b71Sopenharmony_ci
470e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[分布式调度错误码](./errorcode-DistributedSchedule.md)。
471e41f4b71Sopenharmony_ci
472e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
473e41f4b71Sopenharmony_ci| ------- | -------------------------------------------- |
474e41f4b71Sopenharmony_ci| 201      | Permission denied.|
475e41f4b71Sopenharmony_ci| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
476e41f4b71Sopenharmony_ci| 16300501 | The system ability work abnormally. |
477e41f4b71Sopenharmony_ci| 16300502 | Failed to get the missionInfo of the specified missionId. |
478e41f4b71Sopenharmony_ci| 16300503 | The application is not installed on the remote end and installation-free is not supported. |
479e41f4b71Sopenharmony_ci| 16300504 | The application is not installed on the remote end but installation-free is supported, try again with freeInstall flag. |
480e41f4b71Sopenharmony_ci| 16300505 | The operation device must be the device where the application to be continued is located or the target device to be continued. |
481e41f4b71Sopenharmony_ci| 16300506 | The local continuation task is already in progress. |
482e41f4b71Sopenharmony_ci
483e41f4b71Sopenharmony_ci**示例:**
484e41f4b71Sopenharmony_ci
485e41f4b71Sopenharmony_ci  ```ts
486e41f4b71Sopenharmony_ci  import { distributedMissionManager } from '@kit.AbilityKit';
487e41f4b71Sopenharmony_ci  import { BusinessError } from '@kit.BasicServicesKit';
488e41f4b71Sopenharmony_ci
489e41f4b71Sopenharmony_ci  // 实现回调函数
490e41f4b71Sopenharmony_ci  function onContinueDone(resultCode: number): void {
491e41f4b71Sopenharmony_ci    console.log('onContinueDone resultCode: ' + JSON.stringify(resultCode));
492e41f4b71Sopenharmony_ci  };
493e41f4b71Sopenharmony_ci  try {
494e41f4b71Sopenharmony_ci    // 调用continueMission接口
495e41f4b71Sopenharmony_ci    distributedMissionManager.continueMission(
496e41f4b71Sopenharmony_ci      {
497e41f4b71Sopenharmony_ci        srcDeviceId: "",
498e41f4b71Sopenharmony_ci        dstDeviceId: "",
499e41f4b71Sopenharmony_ci        missionId: 1,
500e41f4b71Sopenharmony_ci        wantParam: {"key": "value"}
501e41f4b71Sopenharmony_ci      },
502e41f4b71Sopenharmony_ci      { onContinueDone: onContinueDone },
503e41f4b71Sopenharmony_ci      (error: BusinessError) => {
504e41f4b71Sopenharmony_ci        if (error) {
505e41f4b71Sopenharmony_ci          console.error('continueMission failed, cause: ' + JSON.stringify(error));
506e41f4b71Sopenharmony_ci          return;
507e41f4b71Sopenharmony_ci        }
508e41f4b71Sopenharmony_ci        console.info('continueMission finished');
509e41f4b71Sopenharmony_ci    })
510e41f4b71Sopenharmony_ci  } catch (error) {
511e41f4b71Sopenharmony_ci    console.error('continueMission failed, cause: ' + JSON.stringify(error));
512e41f4b71Sopenharmony_ci  }
513e41f4b71Sopenharmony_ci  ```
514e41f4b71Sopenharmony_ci
515e41f4b71Sopenharmony_ci## distributedMissionManager.continueMission
516e41f4b71Sopenharmony_ci
517e41f4b71Sopenharmony_cicontinueMission(parameter: ContinueDeviceInfo, options: ContinueCallback): Promise&lt;void&gt;
518e41f4b71Sopenharmony_ci
519e41f4b71Sopenharmony_ci通过指定任务ID(missionId)的方式进行迁移任务。使用promise异步回调。
520e41f4b71Sopenharmony_ci
521e41f4b71Sopenharmony_ci**需要权限**:ohos.permission.MANAGE_MISSIONSohos.permission.DISTRIBUTED_DATASYNC
522e41f4b71Sopenharmony_ci
523e41f4b71Sopenharmony_ci**系统能力**:SystemCapability.Ability.AbilityRuntime.Mission
524e41f4b71Sopenharmony_ci
525e41f4b71Sopenharmony_ci**参数:**
526e41f4b71Sopenharmony_ci
527e41f4b71Sopenharmony_ci| 参数名       | 类型                                      | 必填   | 说明    |
528e41f4b71Sopenharmony_ci| --------- | --------------------------------------- | ---- | ----- |
529e41f4b71Sopenharmony_ci| parameter | [ContinueDeviceInfo](js-apis-inner-application-continueDeviceInfo-sys.md) | 是    | 迁移信息。 |
530e41f4b71Sopenharmony_ci| options | [ContinueCallback](js-apis-inner-application-continueCallback-sys.md) | 是    | 迁移任务完成回调函数。 |
531e41f4b71Sopenharmony_ci
532e41f4b71Sopenharmony_ci**返回值:**
533e41f4b71Sopenharmony_ci
534e41f4b71Sopenharmony_ci| 类型                  | 说明               |
535e41f4b71Sopenharmony_ci| ------------------- | ---------------- |
536e41f4b71Sopenharmony_ci| Promise&lt;void&gt; |无返回结果的promise对象。 |
537e41f4b71Sopenharmony_ci
538e41f4b71Sopenharmony_ci**错误码:**
539e41f4b71Sopenharmony_ci
540e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[分布式调度错误码](./errorcode-DistributedSchedule.md)。
541e41f4b71Sopenharmony_ci
542e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
543e41f4b71Sopenharmony_ci| ------- | -------------------------------------------- |
544e41f4b71Sopenharmony_ci| 201      | Permission denied.|
545e41f4b71Sopenharmony_ci| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
546e41f4b71Sopenharmony_ci| 16300501 | The system ability work abnormally. |
547e41f4b71Sopenharmony_ci| 16300502 | Failed to get the missionInfo of the specified missionId. |
548e41f4b71Sopenharmony_ci| 16300503 | The application is not installed on the remote end and installation-free is not supported. |
549e41f4b71Sopenharmony_ci| 16300504 | The application is not installed on the remote end but installation-free is supported, try again with freeInstall flag. |
550e41f4b71Sopenharmony_ci| 16300505 | The operation device must be the device where the application to be continued is located or the target device to be continued. |
551e41f4b71Sopenharmony_ci| 16300506 | The local continuation task is already in progress. |
552e41f4b71Sopenharmony_ci
553e41f4b71Sopenharmony_ci**示例:**
554e41f4b71Sopenharmony_ci
555e41f4b71Sopenharmony_ci  ```ts
556e41f4b71Sopenharmony_ci  import { distributedMissionManager } from '@kit.AbilityKit';
557e41f4b71Sopenharmony_ci  import { BusinessError } from '@kit.BasicServicesKit';
558e41f4b71Sopenharmony_ci
559e41f4b71Sopenharmony_ci  // 实现回调函数
560e41f4b71Sopenharmony_ci  function onContinueDone(resultCode: number): void {
561e41f4b71Sopenharmony_ci    console.log('onContinueDone resultCode: ' + JSON.stringify(resultCode));
562e41f4b71Sopenharmony_ci  };
563e41f4b71Sopenharmony_ci  try {
564e41f4b71Sopenharmony_ci    // 调用continueMission接口
565e41f4b71Sopenharmony_ci    distributedMissionManager.continueMission(
566e41f4b71Sopenharmony_ci      {
567e41f4b71Sopenharmony_ci        srcDeviceId: "",
568e41f4b71Sopenharmony_ci        dstDeviceId: "",
569e41f4b71Sopenharmony_ci        missionId: 1,
570e41f4b71Sopenharmony_ci        wantParam: {"key": "value"}
571e41f4b71Sopenharmony_ci      },
572e41f4b71Sopenharmony_ci      { onContinueDone: onContinueDone }).then(() => {
573e41f4b71Sopenharmony_ci        console.info('continueMission finished successfully');
574e41f4b71Sopenharmony_ci      }).catch((error: BusinessError) => {
575e41f4b71Sopenharmony_ci      console.error('continueMission failed, cause: ' + JSON.stringify(error));
576e41f4b71Sopenharmony_ci    })
577e41f4b71Sopenharmony_ci  } catch (error) {
578e41f4b71Sopenharmony_ci    console.error('continueMission failed, cause: ' + JSON.stringify(error));
579e41f4b71Sopenharmony_ci  }
580e41f4b71Sopenharmony_ci  ```
581e41f4b71Sopenharmony_ci
582e41f4b71Sopenharmony_ci## distributedMissionManager.continueMission<sup>10+</sup>
583e41f4b71Sopenharmony_ci
584e41f4b71Sopenharmony_cicontinueMission(parameter: ContinueMissionInfo, callback: AsyncCallback&lt;void&gt;): void;
585e41f4b71Sopenharmony_ci
586e41f4b71Sopenharmony_ci通过指定包名(bundleName)的方式进行迁移任务。使用callback异步回调。
587e41f4b71Sopenharmony_ci
588e41f4b71Sopenharmony_ci**需要权限**:ohos.permission.MANAGE_MISSIONSohos.permission.DISTRIBUTED_DATASYNC
589e41f4b71Sopenharmony_ci
590e41f4b71Sopenharmony_ci**系统能力**:SystemCapability.Ability.AbilityRuntime.Mission
591e41f4b71Sopenharmony_ci
592e41f4b71Sopenharmony_ci**参数:**
593e41f4b71Sopenharmony_ci
594e41f4b71Sopenharmony_ci| 参数名       | 类型                                      | 必填   | 说明    |
595e41f4b71Sopenharmony_ci| --------- | --------------------------------------- | ---- | ----- |
596e41f4b71Sopenharmony_ci| parameter | [ContinueMissionInfo](./js-apis-inner-application-continueMissionInfo-sys.md) | 是    | 迁移信息。 |
597e41f4b71Sopenharmony_ci| callback | AsyncCallback&lt;void&gt; | 是    | 回调函数,通过指定包名迁移任务完成时,err为undefined,否则为错误对象。 |
598e41f4b71Sopenharmony_ci
599e41f4b71Sopenharmony_ci**错误码:**
600e41f4b71Sopenharmony_ci
601e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[分布式调度错误码](./errorcode-DistributedSchedule.md)。
602e41f4b71Sopenharmony_ci
603e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
604e41f4b71Sopenharmony_ci| ------- | -------------------------------------------- |
605e41f4b71Sopenharmony_ci| 201      | Permission denied.|
606e41f4b71Sopenharmony_ci| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
607e41f4b71Sopenharmony_ci| 16300501 | The system ability work abnormally. |
608e41f4b71Sopenharmony_ci| 16300503 | The application is not installed on the remote end and installation-free is not supported. |
609e41f4b71Sopenharmony_ci| 16300504 | The application is not installed on the remote end but installation-free is supported, try again with freeInstall flag. |
610e41f4b71Sopenharmony_ci| 16300505 | The operation device must be the device where the application to be continued is located or the target device to be continued. |
611e41f4b71Sopenharmony_ci| 16300506 | The local continuation task is already in progress. |
612e41f4b71Sopenharmony_ci| 16300507 | Failed to get the missionInfo of the specified bundle name. |
613e41f4b71Sopenharmony_ci
614e41f4b71Sopenharmony_ci**示例:**
615e41f4b71Sopenharmony_ci
616e41f4b71Sopenharmony_ci  ```ts
617e41f4b71Sopenharmony_ci  import { distributedMissionManager } from '@kit.AbilityKit';
618e41f4b71Sopenharmony_ci  import { BusinessError } from '@kit.BasicServicesKit';
619e41f4b71Sopenharmony_ci
620e41f4b71Sopenharmony_ci  try {
621e41f4b71Sopenharmony_ci    distributedMissionManager.continueMission(
622e41f4b71Sopenharmony_ci      {
623e41f4b71Sopenharmony_ci        srcDeviceId: "",
624e41f4b71Sopenharmony_ci        dstDeviceId: "",
625e41f4b71Sopenharmony_ci        bundleName: "ohos.test.continueapp",
626e41f4b71Sopenharmony_ci        wantParam: {"key": "value"}
627e41f4b71Sopenharmony_ci      },
628e41f4b71Sopenharmony_ci      (error: BusinessError) => {
629e41f4b71Sopenharmony_ci        if (error) {
630e41f4b71Sopenharmony_ci          console.error('continueMission failed, cause: ' + JSON.stringify(error));
631e41f4b71Sopenharmony_ci          return;
632e41f4b71Sopenharmony_ci        }
633e41f4b71Sopenharmony_ci        console.info('continueMission finished');
634e41f4b71Sopenharmony_ci    })
635e41f4b71Sopenharmony_ci  } catch (error) {
636e41f4b71Sopenharmony_ci    console.error('continueMission failed, cause: ' + JSON.stringify(error));
637e41f4b71Sopenharmony_ci  }
638e41f4b71Sopenharmony_ci  ```
639e41f4b71Sopenharmony_ci
640e41f4b71Sopenharmony_ci## distributedMissionManager.continueMission<sup>10+</sup>
641e41f4b71Sopenharmony_ci
642e41f4b71Sopenharmony_cicontinueMission(parameter: ContinueMissionInfo): Promise&lt;void&gt;
643e41f4b71Sopenharmony_ci
644e41f4b71Sopenharmony_ci通过指定包名(bundleName)的方式进行迁移任务。使用Promise异步回调。
645e41f4b71Sopenharmony_ci
646e41f4b71Sopenharmony_ci**需要权限**:ohos.permission.MANAGE_MISSIONSohos.permission.DISTRIBUTED_DATASYNC
647e41f4b71Sopenharmony_ci
648e41f4b71Sopenharmony_ci**系统能力**:SystemCapability.Ability.AbilityRuntime.Mission
649e41f4b71Sopenharmony_ci
650e41f4b71Sopenharmony_ci**参数:**
651e41f4b71Sopenharmony_ci
652e41f4b71Sopenharmony_ci| 参数名       | 类型                                      | 必填   | 说明    |
653e41f4b71Sopenharmony_ci| --------- | --------------------------------------- | ---- | ----- |
654e41f4b71Sopenharmony_ci| parameter | [ContinueMissionInfo](./js-apis-inner-application-continueMissionInfo-sys.md) | 是    | 迁移信息。 |
655e41f4b71Sopenharmony_ci
656e41f4b71Sopenharmony_ci**返回值:**
657e41f4b71Sopenharmony_ci
658e41f4b71Sopenharmony_ci| 类型                  | 说明               |
659e41f4b71Sopenharmony_ci| ------------------- | ---------------- |
660e41f4b71Sopenharmony_ci| Promise&lt;void&gt; | 无返回结果的promise对象。 |
661e41f4b71Sopenharmony_ci
662e41f4b71Sopenharmony_ci**错误码:**
663e41f4b71Sopenharmony_ci
664e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[通用错误码](../errorcode-universal.md)和[分布式调度错误码](./errorcode-DistributedSchedule.md)。
665e41f4b71Sopenharmony_ci
666e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
667e41f4b71Sopenharmony_ci| ------- | -------------------------------------------- |
668e41f4b71Sopenharmony_ci| 201      | Permission denied.|
669e41f4b71Sopenharmony_ci| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
670e41f4b71Sopenharmony_ci| 16300501 | The system ability work abnormally. |
671e41f4b71Sopenharmony_ci| 16300503 | The application is not installed on the remote end and installation-free is not supported. |
672e41f4b71Sopenharmony_ci| 16300504 | The application is not installed on the remote end but installation-free is supported, try again with freeInstall flag. |
673e41f4b71Sopenharmony_ci| 16300505 | The operation device must be the device where the application to be continued is located or the target device to be continued. |
674e41f4b71Sopenharmony_ci| 16300506 | The local continuation task is already in progress. |
675e41f4b71Sopenharmony_ci| 16300507 | Failed to get the missionInfo of the specified bundle name. |
676e41f4b71Sopenharmony_ci
677e41f4b71Sopenharmony_ci**示例:**
678e41f4b71Sopenharmony_ci
679e41f4b71Sopenharmony_ci  ```ts
680e41f4b71Sopenharmony_ci  import { distributedMissionManager } from '@kit.AbilityKit';
681e41f4b71Sopenharmony_ci  import { BusinessError } from '@kit.BasicServicesKit';
682e41f4b71Sopenharmony_ci
683e41f4b71Sopenharmony_ci  try {
684e41f4b71Sopenharmony_ci      distributedMissionManager.continueMission(
685e41f4b71Sopenharmony_ci        {
686e41f4b71Sopenharmony_ci          srcDeviceId: "",
687e41f4b71Sopenharmony_ci          dstDeviceId: "",
688e41f4b71Sopenharmony_ci          bundleName: "ohos.test.continueapp",
689e41f4b71Sopenharmony_ci          wantParam: {"key": "value"}
690e41f4b71Sopenharmony_ci        }
691e41f4b71Sopenharmony_ci      ).then(() => {
692e41f4b71Sopenharmony_ci          console.info('continueMission finished successfully');
693e41f4b71Sopenharmony_ci      }).catch((error: BusinessError) => {
694e41f4b71Sopenharmony_ci          console.error('continueMission failed, cause: ' + JSON.stringify(error));
695e41f4b71Sopenharmony_ci      })
696e41f4b71Sopenharmony_ci  } catch (error) {
697e41f4b71Sopenharmony_ci      console.error('continueMission failed, cause: ' + JSON.stringify(error));
698e41f4b71Sopenharmony_ci  }
699e41f4b71Sopenharmony_ci  ```
700e41f4b71Sopenharmony_ci
701e41f4b71Sopenharmony_ci## distributedMissionManager.on('continueStateChange')<sup>10+</sup>
702e41f4b71Sopenharmony_ci
703e41f4b71Sopenharmony_cion(type: 'continueStateChange',  callback: Callback&lt;ContinueCallbackInfo&gt;): void
704e41f4b71Sopenharmony_ci
705e41f4b71Sopenharmony_ci注册当前任务流转状态的监听。
706e41f4b71Sopenharmony_ci
707e41f4b71Sopenharmony_ci**需要权限**:ohos.permission.MANAGE_MISSIONS
708e41f4b71Sopenharmony_ci
709e41f4b71Sopenharmony_ci**系统能力**:SystemCapability.Ability.AbilityRuntime.Mission
710e41f4b71Sopenharmony_ci
711e41f4b71Sopenharmony_ci**参数:**
712e41f4b71Sopenharmony_ci
713e41f4b71Sopenharmony_ci| 参数名       | 类型                                       | 必填   | 说明       |
714e41f4b71Sopenharmony_ci| --------- | ---------------------------------------- | ---- | -------- |
715e41f4b71Sopenharmony_ci| type | string  | 是    | 当前任务流转状态,取值为'continueStateChange'。    |
716e41f4b71Sopenharmony_ci| callback | Callback&lt;[ContinueCallbackInfo](#continuecallbackinfo11)&gt; | 是    | 回调函数,返回当前任务的流转状态和流转信息。    |
717e41f4b71Sopenharmony_ci
718e41f4b71Sopenharmony_ci**错误码:**
719e41f4b71Sopenharmony_ci
720e41f4b71Sopenharmony_ci以下错误码详细介绍请参考[通用错误码](../errorcode-universal.md)。
721e41f4b71Sopenharmony_ci
722e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
723e41f4b71Sopenharmony_ci| ------- | -------------------------------- |
724e41f4b71Sopenharmony_ci| 201      | Permission denied.|
725e41f4b71Sopenharmony_ci| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
726e41f4b71Sopenharmony_ci
727e41f4b71Sopenharmony_ci**示例:**
728e41f4b71Sopenharmony_ci
729e41f4b71Sopenharmony_ci```js
730e41f4b71Sopenharmony_ci  import { distributedMissionManager } from '@kit.AbilityKit';
731e41f4b71Sopenharmony_ci
732e41f4b71Sopenharmony_ci  try {
733e41f4b71Sopenharmony_ci    distributedMissionManager.on('continueStateChange', (data) => {
734e41f4b71Sopenharmony_ci      console.info("continueStateChange on:" + JSON.stringify(data));
735e41f4b71Sopenharmony_ci    });
736e41f4b71Sopenharmony_ci  } catch (error) {
737e41f4b71Sopenharmony_ci    console.error("continueStateChange err: " + JSON.stringify(error));
738e41f4b71Sopenharmony_ci  }
739e41f4b71Sopenharmony_ci  ```
740e41f4b71Sopenharmony_ci
741e41f4b71Sopenharmony_ci## distributedMissionManager.off('continueStateChange')<sup>10+</sup>
742e41f4b71Sopenharmony_ci
743e41f4b71Sopenharmony_cioff(type: 'continueStateChange',  callback?: Callback&lt;ContinueCallbackInfo&gt;): void
744e41f4b71Sopenharmony_ci
745e41f4b71Sopenharmony_ci取消当前任务流转的状态监听。
746e41f4b71Sopenharmony_ci
747e41f4b71Sopenharmony_ci**需要权限**:ohos.permission.MANAGE_MISSIONS
748e41f4b71Sopenharmony_ci
749e41f4b71Sopenharmony_ci**系统能力**:SystemCapability.Ability.AbilityRuntime.Mission
750e41f4b71Sopenharmony_ci
751e41f4b71Sopenharmony_ci**参数:**
752e41f4b71Sopenharmony_ci
753e41f4b71Sopenharmony_ci| 参数名       | 类型                                       | 必填   | 说明       |
754e41f4b71Sopenharmony_ci| --------- | ---------------------------------------- | ---- | -------- |
755e41f4b71Sopenharmony_ci| type | string  | 是    | 当前任务流转状态,取值为'continueStateChange'。    |
756e41f4b71Sopenharmony_ci| callback | Callback&lt;[ContinueCallbackInfo](#continuecallbackinfo11)&gt; | 否    | 需要取消的回调函数。<br>参数不填写,取消type对应的所有回调监听。    |
757e41f4b71Sopenharmony_ci
758e41f4b71Sopenharmony_ci**错误码:**
759e41f4b71Sopenharmony_ci
760e41f4b71Sopenharmony_ci以下错误码详细介绍请参考[通用错误码](../errorcode-universal.md)。
761e41f4b71Sopenharmony_ci
762e41f4b71Sopenharmony_ci| 错误码ID | 错误信息 |
763e41f4b71Sopenharmony_ci| ------- | -------------------------------- |
764e41f4b71Sopenharmony_ci| 201      | Permission denied.|
765e41f4b71Sopenharmony_ci| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
766e41f4b71Sopenharmony_ci
767e41f4b71Sopenharmony_ci**示例:**
768e41f4b71Sopenharmony_ci
769e41f4b71Sopenharmony_ci```js
770e41f4b71Sopenharmony_ci  import { distributedMissionManager } from '@kit.AbilityKit';
771e41f4b71Sopenharmony_ci
772e41f4b71Sopenharmony_ci  try {
773e41f4b71Sopenharmony_ci    distributedMissionManager.off('continueStateChange', (data) => {
774e41f4b71Sopenharmony_ci      console.info("continueStateChange off:" + JSON.stringify(data));
775e41f4b71Sopenharmony_ci    });
776e41f4b71Sopenharmony_ci  } catch (err) {
777e41f4b71Sopenharmony_ci    console.error("continueStateChange err: " + JSON.stringify(err));
778e41f4b71Sopenharmony_ci  }
779e41f4b71Sopenharmony_ci  ```
780e41f4b71Sopenharmony_ci
781e41f4b71Sopenharmony_ci## MissionCallback
782e41f4b71Sopenharmony_ci
783e41f4b71Sopenharmony_ci开始同步后,建立的回调函数。
784e41f4b71Sopenharmony_ci
785e41f4b71Sopenharmony_ci**需要权限**:ohos.permission.MANAGE_MISSIONS
786e41f4b71Sopenharmony_ci
787e41f4b71Sopenharmony_ci**系统能力**:SystemCapability.Ability.AbilityRuntime.Mission
788e41f4b71Sopenharmony_ci
789e41f4b71Sopenharmony_ci| 名称                    | 类型       | 可读   | 可写   | 说明                 |
790e41f4b71Sopenharmony_ci| --------------------- | -------- | ---- | ---- | ------------------ |
791e41f4b71Sopenharmony_ci| notifyMissionsChanged | function | 是    | 否    | 通知任务变化,返回设备ID。     |
792e41f4b71Sopenharmony_ci| notifySnapshot        | function | 是    | 否    | 通知快照变化,返回设备ID,任务ID。 |
793e41f4b71Sopenharmony_ci| notifyNetDisconnect   | function | 是    | 否    | 通知断开连接,返回设备ID,网络状态。 |
794e41f4b71Sopenharmony_ci
795e41f4b71Sopenharmony_ci## MissionParameter
796e41f4b71Sopenharmony_ci
797e41f4b71Sopenharmony_ci同步时所需参数的枚举。
798e41f4b71Sopenharmony_ci
799e41f4b71Sopenharmony_ci**需要权限**:ohos.permission.MANAGE_MISSIONS
800e41f4b71Sopenharmony_ci
801e41f4b71Sopenharmony_ci**系统能力**:SystemCapability.Ability.AbilityRuntime.Mission
802e41f4b71Sopenharmony_ci
803e41f4b71Sopenharmony_ci| 名称          | 类型    | 可读   | 可写   | 说明          |
804e41f4b71Sopenharmony_ci| ----------- | ------- | ---- | ---- | ----------- |
805e41f4b71Sopenharmony_ci| deviceId    | string  | 是    | 是    | 表示设备ID。详细介绍请参见[getAvailableDeviceListSync](../apis-distributedservice-kit/js-apis-distributedDeviceManager.md#getavailabledevicelistsync)     |
806e41f4b71Sopenharmony_ci| fixConflict | boolean | 是    | 是    | 表示是否存在版本冲突。 |
807e41f4b71Sopenharmony_ci| tag         | number  | 是    | 是    | 表示特定的标签。    |
808e41f4b71Sopenharmony_ci
809e41f4b71Sopenharmony_ci## MissionDeviceInfo
810e41f4b71Sopenharmony_ci
811e41f4b71Sopenharmony_ci注册监听时所需参数的枚举。
812e41f4b71Sopenharmony_ci
813e41f4b71Sopenharmony_ci**需要权限**:ohos.permission.MANAGE_MISSIONS
814e41f4b71Sopenharmony_ci
815e41f4b71Sopenharmony_ci**系统能力**:SystemCapability.Ability.AbilityRuntime.Mission
816e41f4b71Sopenharmony_ci
817e41f4b71Sopenharmony_ci| 名称       | 类型   | 可读   | 可写   | 说明      |
818e41f4b71Sopenharmony_ci| -------- | ------ | ---- | ---- | ------- |
819e41f4b71Sopenharmony_ci| deviceId | string | 是    | 是    | 表示设备ID。详细介绍请参见[getAvailableDeviceListSync](../apis-distributedservice-kit/js-apis-distributedDeviceManager.md#getavailabledevicelistsync) |
820e41f4b71Sopenharmony_ci
821e41f4b71Sopenharmony_ci## ContinueState<sup>10+</sup>
822e41f4b71Sopenharmony_ci
823e41f4b71Sopenharmony_ci当前任务流转状态的枚举。
824e41f4b71Sopenharmony_ci
825e41f4b71Sopenharmony_ci**系统能力**:SystemCapability.Ability.AbilityRuntime.Mission
826e41f4b71Sopenharmony_ci
827e41f4b71Sopenharmony_ci| 名称           | 值       | 说明                                                         |
828e41f4b71Sopenharmony_ci| ------------- | --------- | ------------------------------------------------------------ |
829e41f4b71Sopenharmony_ci| ACTIVE        | 0         | 表示当前任务流转处于激活状态。                              |
830e41f4b71Sopenharmony_ci| INACTIVE      | 1         | 表示当前任务流转处于未激活状态。                            |
831e41f4b71Sopenharmony_ci
832e41f4b71Sopenharmony_ci## ContinueCallbackInfo<sup>11+</sup>
833e41f4b71Sopenharmony_ci
834e41f4b71Sopenharmony_ci当前任务流转状态监听的回调信息,包含流转状态和流转信息。
835e41f4b71Sopenharmony_ci
836e41f4b71Sopenharmony_ci**系统能力**:SystemCapability.Ability.AbilityRuntime.Mission
837e41f4b71Sopenharmony_ci
838e41f4b71Sopenharmony_ci| 名称       | 类型    | 可读   | 可写   | 说明          |
839e41f4b71Sopenharmony_ci| -------- | ------ | ---- | ---- | ----------- |
840e41f4b71Sopenharmony_ci| state | [ContinueState](#continuestate10)   | 是    | 否    |   表示当前任务的流转状态。 |
841e41f4b71Sopenharmony_ci| info  | [ContinuableInfo](./js-apis-inner-application-continuableInfo-sys.md) | 是    | 否    |   表示当前任务的流转信息。 |