1# @ohos.continuation.continuationManager (continuationManager)
2
3The **continuationManager** module provides the continuation management entry. You can use the APIs of this module to connect to and cancel the continuation management service, subscribe to and unsubscribe from device connection events, start the device selection module, and update the device connection state.
4
5> **NOTE**
6>
7> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version.
8
9## Modules to Import
10
11```ts
12import { continuationManager } from '@kit.AbilityKit';
13```
14
15## continuationManager.register<sup>(deprecated)</sup>
16
17register(callback: AsyncCallback\<number>): void
18
19Registers the continuation management service and obtains a token. This API does not involve any filter parameters and uses an asynchronous callback to return the result.
20
21> **NOTE**
22>
23> This API is deprecated since API version 9. You are advised to use [registerContinuation](#continuationmanagerregistercontinuation9) instead.
24
25**System capability**: SystemCapability.Ability.DistributedAbilityManager
26
27**Parameters**
28
29  | Name| Type| Mandatory| Description|
30  | -------- | -------- | -------- | -------- |
31  | callback | AsyncCallback\<number> | Yes| Callback used to return the token generated after the continuation management service is connected.|
32
33**Example**
34
35  ```ts
36  import { continuationManager } from '@kit.AbilityKit';
37
38  let token: number = -1;
39  continuationManager.register((err, data) => {
40    if (err.code != 0) {
41      console.error('register failed, cause: ' + JSON.stringify(err));
42      return;
43    }
44    console.info('register finished, ' + JSON.stringify(data));
45    token = data;
46  });
47  ```
48
49## continuationManager.register<sup>(deprecated)</sup>
50
51register(options: ContinuationExtraParams, callback: AsyncCallback\<number>): void
52
53Registers the continuation management service and obtains a token. This API uses an asynchronous callback to return the result.
54
55> **NOTE**
56>
57> This API is deprecated since API version 9. You are advised to use [registerContinuation](#continuationmanagerregistercontinuation9-1) instead.
58
59**System capability**: SystemCapability.Ability.DistributedAbilityManager
60
61**Parameters**
62
63  | Name| Type| Mandatory| Description|
64  | -------- | -------- | -------- | -------- |
65  | options | [ContinuationExtraParams](js-apis-continuation-continuationExtraParams.md) | Yes| Extra parameters used to filter the list of available devices.|
66  | callback | AsyncCallback\<number> | Yes| Callback used to return the token generated after the continuation management service is connected.|
67
68**Example**
69
70  ```ts
71  import { continuationManager } from '@kit.AbilityKit';
72
73  let token: number = -1;
74  continuationManager.register(
75    {
76      deviceType: ["00E"]
77    },
78    (err, data) => {
79      if (err.code != 0) {
80        console.error('register failed, cause: ' + JSON.stringify(err));
81        return;
82      }
83      console.info('register finished, ' + JSON.stringify(data));
84      token = data;
85  });
86  ```
87
88## continuationManager.register<sup>(deprecated)</sup>
89
90register(options?: ContinuationExtraParams): Promise\<number>
91
92Registers the continuation management service and obtains a token. This API uses a promise to return the result.
93
94> **NOTE**
95>
96> This API is deprecated since API version 9. You are advised to use [registerContinuation](#continuationmanagerregistercontinuation9-2) instead.
97
98**System capability**: SystemCapability.Ability.DistributedAbilityManager
99
100**Parameters**
101
102  | Name| Type| Mandatory| Description|
103  | -------- | -------- | -------- | -------- |
104  | options | [ContinuationExtraParams](js-apis-continuation-continuationExtraParams.md) | No| Extra parameters used to filter the list of available devices. This parameter can be null.|
105
106**Return value**
107
108| Type                       | Description                |
109| ------------------------- | ------------------ |
110| Promise\<number> | Promise used to return the token generated after the continuation management service is connected.|
111
112**Example**
113
114  ```ts
115  import { continuationManager } from '@kit.AbilityKit';
116  import { BusinessError } from '@kit.BasicServicesKit';
117
118  let token: number = -1;
119  continuationManager.register(
120    { deviceType: ["00E"] }).then((data) => {
121      console.info('register finished, ' + JSON.stringify(data));
122      token = data;
123    }).catch((err: BusinessError) => {
124      console.error('register failed, cause: ' + JSON.stringify(err));
125  });
126  ```
127
128## continuationManager.registerContinuation<sup>9+</sup>
129
130registerContinuation(callback: AsyncCallback\<number>): void
131
132Registers the continuation management service and obtains a token. This API does not involve any filter parameters and uses an asynchronous callback to return the result.
133
134**Atomic service API**: This API can be used in atomic services since API version 11.
135
136**Required permissions**: ohos.permission.DISTRIBUTED_DATASYNC
137
138**System capability**: SystemCapability.Ability.DistributedAbilityManager
139
140**Parameters**
141
142  | Name| Type| Mandatory| Description|
143  | -------- | -------- | -------- | -------- |
144  | callback | AsyncCallback\<number> | Yes| Callback used to return the token generated after the continuation management service is connected.|
145
146**Error codes**
147
148For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Distributed Scheduler Error Codes](errorcode-DistributedSchedule.md).
149
150| ID| Error Message|
151| ------- | -------------------------------------------- |
152| 201      | Permission denied.|
153| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
154| 16600001 | The system ability works abnormally. |
155| 16600003 | The number of token registration times has reached the upper limit. |
156
157**Example**
158
159  ```ts
160  import { continuationManager } from '@kit.AbilityKit';
161
162  let token: number = -1;
163  try {
164    continuationManager.registerContinuation((err, data) => {
165      if (err.code != 0) {
166        console.error('registerContinuation failed, cause: ' + JSON.stringify(err));
167        return;
168      }
169      console.info('registerContinuation finished, ' + JSON.stringify(data));
170      token = data;
171    });
172  } catch (err) {
173    console.error('registerContinuation failed, cause: ' + JSON.stringify(err));
174  }
175  ```
176
177## continuationManager.registerContinuation<sup>9+</sup>
178
179registerContinuation(options: ContinuationExtraParams, callback: AsyncCallback\<number>): void
180
181Registers the continuation management service and obtains a token. This API uses an asynchronous callback to return the result.
182
183**Atomic service API**: This API can be used in atomic services since API version 11.
184
185**Required permissions**: ohos.permission.DISTRIBUTED_DATASYNC
186
187**System capability**: SystemCapability.Ability.DistributedAbilityManager
188
189**Parameters**
190
191  | Name| Type| Mandatory| Description|
192  | -------- | -------- | -------- | -------- |
193  | options | [ContinuationExtraParams](js-apis-continuation-continuationExtraParams.md) | Yes| Extra parameters used to filter the list of available devices.|
194  | callback | AsyncCallback\<number> | Yes| Callback used to return the token generated after the continuation management service is connected.|
195
196**Error codes**
197
198For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Distributed Scheduler Error Codes](errorcode-DistributedSchedule.md).
199
200| ID| Error Message|
201| ------- | -------------------------------------------- |
202| 201      | Permission denied.|
203| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
204| 16600001 | The system ability works abnormally. |
205| 16600003 | The number of token registration times has reached the upper limit. |
206
207**Example**
208
209  ```ts
210  import { continuationManager } from '@kit.AbilityKit';
211
212  let token: number = -1;
213  try {
214    continuationManager.registerContinuation(
215      {
216        deviceType: ["00E"]
217      },
218      (err, data) => {
219        if (err.code != 0) {
220          console.error('registerContinuation failed, cause: ' + JSON.stringify(err));
221          return;
222        }
223        console.info('registerContinuation finished, ' + JSON.stringify(data));
224        token = data;
225    });
226  } catch (err) {
227    console.error('registerContinuation failed, cause: ' + JSON.stringify(err));
228  }
229  ```
230
231## continuationManager.registerContinuation<sup>9+</sup>
232
233registerContinuation(options?: ContinuationExtraParams): Promise\<number>
234
235Registers the continuation management service and obtains a token. This API uses a promise to return the result.
236
237**Atomic service API**: This API can be used in atomic services since API version 11.
238
239**Required permissions**: ohos.permission.DISTRIBUTED_DATASYNC
240
241**System capability**: SystemCapability.Ability.DistributedAbilityManager
242
243**Parameters**
244
245  | Name| Type| Mandatory| Description|
246  | -------- | -------- | -------- | -------- |
247  | options | [ContinuationExtraParams](js-apis-continuation-continuationExtraParams.md) | No| Extra parameters used to filter the list of available devices. This parameter can be null.|
248
249**Return value**
250
251| Type                       | Description                |
252| ------------------------- | ------------------ |
253| Promise\<number> | Promise used to return the token generated after the continuation management service is connected.|
254
255**Error codes**
256
257For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Distributed Scheduler Error Codes](errorcode-DistributedSchedule.md).
258
259| ID| Error Message|
260| ------- | -------------------------------------------- |
261| 201      | Permission denied.|
262| 401      | Parameter error. Possible causes: 1. Incorrect parameter types; 2. Parameter verification failed. |
263| 16600001 | The system ability works abnormally. |
264| 16600003 | The number of token registration times has reached the upper limit. |
265
266**Example**
267
268  ```ts
269  import { continuationManager } from '@kit.AbilityKit';
270  import { BusinessError } from '@kit.BasicServicesKit';
271
272  let token: number = -1;
273  try {
274    continuationManager.registerContinuation(
275      {
276        deviceType: ["00E"]
277      }).then((data) => {
278        console.info('registerContinuation finished, ' + JSON.stringify(data));
279        token = data;
280      }).catch((err: BusinessError) => {
281        console.error('registerContinuation failed, cause: ' + JSON.stringify(err));
282    });
283  } catch (err) {
284    console.error('registerContinuation failed, cause: ' + JSON.stringify(err));
285  }
286  ```
287
288
289## continuationManager.on('deviceConnect')<sup>(deprecated)</sup>
290
291on(type: 'deviceConnect', callback: Callback\<ContinuationResult>): void
292
293Subscribes to device connection events. This API uses an asynchronous callback to return the result.
294
295> **NOTE**
296>
297> This API is deprecated since API version 9. You are advised to use [on](#continuationmanagerondeviceselected9) instead.
298
299**System capability**: SystemCapability.Ability.DistributedAbilityManager
300
301**Parameters**
302
303  | Name| Type| Mandatory| Description|
304  | -------- | -------- | -------- | -------- |
305  | type | string | Yes| Event type. The value is fixed at **deviceConnect**.|
306  | callback | Callback\<[ContinuationResult](js-apis-continuation-continuationResult.md)> | Yes| Callback invoked when a device is selected from the device list provided by the device selection module. This callback returns the device ID, type, and name.|
307
308**Example**
309
310  ```ts
311  import { continuationManager } from '@kit.AbilityKit';
312
313  continuationManager.on("deviceConnect", (data) => {
314    console.info('onDeviceConnect deviceId: ' + JSON.stringify(data.id));
315    console.info('onDeviceConnect deviceType: ' + JSON.stringify(data.type));
316    console.info('onDeviceConnect deviceName: ' + JSON.stringify(data.name));
317  });
318  ```
319
320## continuationManager.on('deviceDisconnect')<sup>(deprecated)</sup>
321
322on(type: 'deviceDisconnect', callback: Callback\<string>): void
323
324Subscribes to device disconnection events. This API uses an asynchronous callback to return the result.
325
326> **NOTE**
327>
328> This API is deprecated since API version 9. You are advised to use [on](#continuationmanagerondeviceunselected9) instead.
329
330**System capability**: SystemCapability.Ability.DistributedAbilityManager
331
332**Parameters**
333
334  | Name| Type| Mandatory| Description|
335  | -------- | -------- | -------- | -------- |
336  | type | string | Yes| Event type. The value is fixed at **deviceDisconnect**.|
337  | callback | Callback\<string> | Yes| Callback invoked when a device is unselected from the device list provided by the device selection module. This callback returns the device ID.|
338
339**Example**
340
341  ```ts
342  import { continuationManager } from '@kit.AbilityKit';
343
344  continuationManager.on("deviceDisconnect", (data) => {
345    console.info('onDeviceDisconnect deviceId: ' + JSON.stringify(data));
346  });
347  ```
348
349## continuationManager.off('deviceConnect')<sup>(deprecated)</sup>
350
351off(type: 'deviceConnect', callback?: Callback\<ContinuationResult>): void
352
353Unsubscribes from device connection events. This API uses an asynchronous callback to return the result.
354
355> **NOTE**
356>
357> This API is deprecated since API version 9. You are advised to use [off](#continuationmanageroffdeviceselected9) instead.
358
359**System capability**: SystemCapability.Ability.DistributedAbilityManager
360
361**Parameters**
362
363  | Name| Type| Mandatory| Description|
364  | -------- | -------- | -------- | -------- |
365  | type | string | Yes| Event type. The value is fixed at **deviceConnect**.|
366  | callback | Callback\<[ContinuationResult](js-apis-continuation-continuationResult.md)> | No| Callback invoked when a device is selected from the device list provided by the device selection module. This callback returns the device ID, type, and name.|
367
368**Example**
369
370  ```ts
371  import { continuationManager } from '@kit.AbilityKit';
372
373  continuationManager.off("deviceConnect", (data) => {
374    console.info('onDeviceConnect deviceId: ' + JSON.stringify(data.id));
375    console.info('onDeviceConnect deviceType: ' + JSON.stringify(data.type));
376    console.info('onDeviceConnect deviceName: ' + JSON.stringify(data.name));
377  });
378  ```
379
380## continuationManager.off('deviceDisconnect')<sup>(deprecated)</sup>
381
382off(type: 'deviceDisconnect', callback?: Callback\<string>): void
383
384Unsubscribes from device disconnection events. This API uses an asynchronous callback to return the result.
385
386> **NOTE**
387>
388> This API is deprecated since API version 9. You are advised to use [off](#continuationmanageroffdeviceunselected9) instead.
389
390**System capability**: SystemCapability.Ability.DistributedAbilityManager
391
392**Parameters**
393
394  | Name| Type| Mandatory| Description|
395  | -------- | -------- | -------- | -------- |
396  | type | string | Yes| Event type. The value is fixed at **deviceDisconnect**.|
397  | callback | Callback\<string> | No| Callback invoked when a device is unselected from the device list provided by the device selection module. This callback returns the device ID.|
398
399**Example**
400
401  ```ts
402  import { continuationManager } from '@kit.AbilityKit';
403
404  continuationManager.off("deviceDisconnect", (data) => {
405    console.info('onDeviceDisconnect deviceId: ' + JSON.stringify(data));
406  });
407  ```
408
409## continuationManager.on('deviceSelected')<sup>9+</sup>
410
411on(type: 'deviceSelected', token: number, callback: Callback\<Array\<ContinuationResult>>): void
412
413Subscribes to device connection events. This API uses an asynchronous callback to return the result.
414
415**Atomic service API**: This API can be used in atomic services since API version 11.
416
417**Required permissions**: ohos.permission.DISTRIBUTED_DATASYNC
418
419**System capability**: SystemCapability.Ability.DistributedAbilityManager
420
421**Parameters**
422
423  | Name| Type| Mandatory| Description|
424  | -------- | -------- | -------- | -------- |
425  | type | string | Yes| Event type. The value is fixed at **deviceSelected**.|
426  | token | number | Yes| Token obtained after the registration of the continuation management service.|
427  | callback | Callback\<Array\<[ContinuationResult](js-apis-continuation-continuationResult.md)>> | Yes| Callback invoked when a device is selected from the device list provided by the device selection module. This callback returns the device ID, type, and name.|
428
429**Error codes**
430
431For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Distributed Scheduler Error Codes](errorcode-DistributedSchedule.md).
432
433| ID| Error Message|
434| ------- | -------------------------------------------- |
435| 201      | Permission denied.|
436| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
437| 16600001 | The system ability works abnormally. |
438| 16600002 | The specified token or callback is not registered. |
439| 16600004 | The specified callback has been registered. |
440
441**Example**
442
443  ```ts
444  import { continuationManager } from '@kit.AbilityKit';
445
446  let token: number = 1;
447  try {
448    continuationManager.on("deviceSelected", token, (data) => {
449      console.info('onDeviceSelected len: ' + data.length);
450      for (let i = 0; i < data.length; i++) {
451        console.info('onDeviceSelected deviceId: ' + JSON.stringify(data[i].id));
452        console.info('onDeviceSelected deviceType: ' + JSON.stringify(data[i].type));
453        console.info('onDeviceSelected deviceName: ' + JSON.stringify(data[i].name));
454      }
455    });
456  } catch (err) {
457    console.error('on failed, cause: ' + JSON.stringify(err));
458  }
459  ```
460
461## continuationManager.on('deviceUnselected')<sup>9+</sup>
462
463on(type: 'deviceUnselected', token: number, callback: Callback\<Array\<ContinuationResult>>): void
464
465Subscribes to device disconnection events. This API uses an asynchronous callback to return the result.
466
467**Atomic service API**: This API can be used in atomic services since API version 11.
468
469**Required permissions**: ohos.permission.DISTRIBUTED_DATASYNC
470
471**System capability**: SystemCapability.Ability.DistributedAbilityManager
472
473**Parameters**
474
475  | Name| Type| Mandatory| Description|
476  | -------- | -------- | -------- | -------- |
477  | type | string | Yes| Event type. The value is fixed at **deviceUnselected**.|
478  | token | number | Yes| Token obtained after the registration of the continuation management service.|
479  | callback | Callback\<Array\<[ContinuationResult](js-apis-continuation-continuationResult.md)>> | Yes| Callback invoked when a device is unselected from the device list provided by the device selection module. This callback returns the device ID, type, and name.|
480
481**Error codes**
482
483For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Distributed Scheduler Error Codes](errorcode-DistributedSchedule.md).
484
485| ID| Error Message|
486| ------- | -------------------------------------------- |
487| 201      | Permission denied.|
488| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
489| 16600001 | The system ability works abnormally. |
490| 16600002 | The specified token or callback is not registered. |
491| 16600004 | The specified callback has been registered. |
492
493**Example**
494
495  ```ts
496  import { continuationManager } from '@kit.AbilityKit';
497
498  let token: number = 1;
499  try {
500    continuationManager.on("deviceUnselected", token, (data) => {
501      console.info('onDeviceUnselected len: ' + data.length);
502      for (let i = 0; i < data.length; i++) {
503        console.info('onDeviceUnselected deviceId: ' + JSON.stringify(data[i].id));
504        console.info('onDeviceUnselected deviceType: ' + JSON.stringify(data[i].type));
505        console.info('onDeviceUnselected deviceName: ' + JSON.stringify(data[i].name));
506      }
507      console.info('onDeviceUnselected finished.');
508    });
509  } catch (err) {
510    console.error('on failed, cause: ' + JSON.stringify(err));
511  }
512  ```
513
514## continuationManager.off('deviceSelected')<sup>9+</sup>
515
516off(type: 'deviceSelected', token: number): void
517
518Unsubscribes from device connection events.
519
520**Atomic service API**: This API can be used in atomic services since API version 11.
521
522**Required permissions**: ohos.permission.DISTRIBUTED_DATASYNC
523
524**System capability**: SystemCapability.Ability.DistributedAbilityManager
525
526**Parameters**
527
528  | Name| Type| Mandatory| Description|
529  | -------- | -------- | -------- | -------- |
530  | type | string | Yes| Event type. The value is fixed at **deviceSelected**.|
531  | token | number | Yes| Token obtained after the registration of the continuation management service.|
532
533**Error codes**
534
535For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Distributed Scheduler Error Codes](errorcode-DistributedSchedule.md).
536
537| ID| Error Message|
538| ------- | -------------------------------------------- |
539| 201      | Permission denied.|
540| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
541| 16600001 | The system ability works abnormally. |
542| 16600002 | The specified token or callback is not registered. |
543| 16600004 | The specified callback has been registered. |
544
545**Example**
546
547  ```ts
548  import { continuationManager } from '@kit.AbilityKit';
549
550  let token: number = 1;
551  try {
552    continuationManager.off("deviceSelected", token);
553  } catch (err) {
554    console.error('off failed, cause: ' + JSON.stringify(err));
555  }
556  ```
557
558## continuationManager.off('deviceUnselected')<sup>9+</sup>
559
560off(type: 'deviceUnselected', token: number): void
561
562Unsubscribes from device disconnection events.
563
564**Atomic service API**: This API can be used in atomic services since API version 11.
565
566**Required permissions**: ohos.permission.DISTRIBUTED_DATASYNC
567
568**System capability**: SystemCapability.Ability.DistributedAbilityManager
569
570**Parameters**
571
572  | Name| Type| Mandatory| Description|
573  | -------- | -------- | -------- | -------- |
574  | type | string | Yes| Event type. The value is fixed at **deviceUnselected**.|
575  | token | number | Yes| Token obtained after the registration of the continuation management service.|
576
577**Error codes**
578
579For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Distributed Scheduler Error Codes](errorcode-DistributedSchedule.md).
580
581| ID| Error Message|
582| ------- | -------------------------------------------- |
583| 201      | Permission denied.|
584| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
585| 16600001 | The system ability works abnormally. |
586| 16600002 | The specified token or callback is not registered. |
587| 16600004 | The specified callback has been registered. |
588
589**Example**
590
591  ```ts
592  import { continuationManager } from '@kit.AbilityKit';
593
594  let token: number = 1;
595  try {
596    continuationManager.off("deviceUnselected", token);
597  } catch (err) {
598    console.error('off failed, cause: ' + JSON.stringify(err));
599  }
600  ```
601
602## continuationManager.startDeviceManager<sup>(deprecated)</sup>
603
604startDeviceManager(token: number, callback: AsyncCallback\<void>): void
605
606Starts the device selection module to show the list of available devices on the network. This API does not involve any filter parameters and uses an asynchronous callback to return the result.
607
608> **NOTE**
609>
610> This API is deprecated since API version 9. You are advised to use [startContinuationDeviceManager](#continuationmanagerstartcontinuationdevicemanager9) instead.
611
612**System capability**: SystemCapability.Ability.DistributedAbilityManager
613
614**Parameters**
615
616  | Name| Type| Mandatory| Description|
617  | -------- | -------- | -------- | -------- |
618  | token | number | Yes| Token obtained after the registration of the continuation management service.|
619  | callback | AsyncCallback\<void> | Yes| Callback used to return the result. If the module is started, **err** is **undefined**; otherwise, **err** is an error object.|
620
621**Example**
622
623  ```ts
624  import { continuationManager } from '@kit.AbilityKit';
625
626  let token: number = 1;
627  continuationManager.startDeviceManager(token, (err) => {
628    if (err.code != 0) {
629      console.error('startDeviceManager failed, cause: ' + JSON.stringify(err));
630      return;
631    }
632    console.info('startDeviceManager finished. ');
633  });
634  ```
635
636## continuationManager.startDeviceManager<sup>(deprecated)</sup>
637
638startDeviceManager(token: number, options: ContinuationExtraParams, callback: AsyncCallback\<void>): void
639
640Starts the device selection module to show the list of available devices on the network. This API uses an asynchronous callback to return the result.
641
642> **NOTE**
643>
644> This API is deprecated since API version 9. You are advised to use [startContinuationDeviceManager](#continuationmanagerstartcontinuationdevicemanager9-1) instead.
645
646**System capability**: SystemCapability.Ability.DistributedAbilityManager
647
648**Parameters**
649
650  | Name| Type| Mandatory| Description|
651  | -------- | -------- | -------- | -------- |
652  | token | number | Yes| Token obtained after the registration of the continuation management service.|
653  | options | [ContinuationExtraParams](js-apis-continuation-continuationExtraParams.md) | Yes| Extra parameters used to filter the list of available devices.|
654  | callback | AsyncCallback\<void> | Yes| Callback used to return the result. If the module is started, **err** is **undefined**; otherwise, **err** is an error object.|
655
656**Example**
657
658  ```ts
659  import { continuationManager } from '@kit.AbilityKit';
660
661  let token: number = 1;
662  continuationManager.startDeviceManager(
663    token,
664    {
665      deviceType: ["00E"]
666    },
667    (err) => {
668      if (err.code != 0) {
669        console.error('startDeviceManager failed, cause: ' + JSON.stringify(err));
670        return;
671      }
672      console.info('startDeviceManager finished. ');
673  });
674  ```
675
676## continuationManager.startDeviceManager<sup>(deprecated)</sup>
677
678startDeviceManager(token: number, options?: ContinuationExtraParams): Promise\<void>
679
680Starts the device selection module to show the list of available devices on the network. This API uses a promise to return the result.
681
682> **NOTE**
683>
684> This API is deprecated since API version 9. You are advised to use [startContinuationDeviceManager](#continuationmanagerstartcontinuationdevicemanager9-2) instead.
685
686**System capability**: SystemCapability.Ability.DistributedAbilityManager
687
688**Parameters**
689
690  | Name| Type| Mandatory| Description|
691  | -------- | -------- | -------- | -------- |
692  | token | number | Yes| Token obtained after the registration of the continuation management service.|
693  | options | [ContinuationExtraParams](js-apis-continuation-continuationExtraParams.md) | No| Extra parameters used to filter the list of available devices. This parameter can be null.|
694
695**Return value**
696
697| Type                       | Description                |
698| ------------------------- | ------------------ |
699| Promise\<void> | Promise used to return the result.|
700
701**Example**
702
703  ```ts
704  import { continuationManager } from '@kit.AbilityKit';
705  import { BusinessError } from '@kit.BasicServicesKit';
706
707  let token: number = -1;
708  continuationManager.startDeviceManager(
709    token,
710    {
711      deviceType: ["00E"]
712    }).then(() => {
713      console.info('startDeviceManager finished. ');
714    }).catch((err: BusinessError) => {
715      console.error('startDeviceManager failed, cause: ' + JSON.stringify(err));
716  });
717  ```
718
719## continuationManager.startContinuationDeviceManager<sup>9+</sup>
720
721startContinuationDeviceManager(token: number, callback: AsyncCallback\<void>): void
722
723Starts the device selection module to show the list of available devices on the network. This API does not involve any filter parameters and uses an asynchronous callback to return the result.
724
725**Atomic service API**: This API can be used in atomic services since API version 11.
726
727**Required permissions**: ohos.permission.DISTRIBUTED_DATASYNC
728
729**System capability**: SystemCapability.Ability.DistributedAbilityManager
730
731**Parameters**
732
733  | Name| Type| Mandatory| Description|
734  | -------- | -------- | -------- | -------- |
735  | token | number | Yes| Token obtained after the registration of the continuation management service.|
736  | callback | AsyncCallback\<void> | Yes| Callback used to return the result. If the module is started, **err** is **undefined**; otherwise, **err** is an error object.|
737
738**Error codes**
739
740For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Distributed Scheduler Error Codes](errorcode-DistributedSchedule.md).
741
742| ID| Error Message|
743| ------- | -------------------------------------------- |
744| 201      | Permission denied.|
745| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
746| 16600001 | The system ability works abnormally. |
747| 16600002 | The specified token or callback is not registered. |
748
749**Example**
750
751  ```ts
752  import { continuationManager } from '@kit.AbilityKit';
753
754  let token: number = -1;
755  try {
756    continuationManager.startContinuationDeviceManager(token, (err) => {
757      if (err.code != 0) {
758        console.error('startContinuationDeviceManager failed, cause: ' + JSON.stringify(err));
759        return;
760      }
761      console.info('startContinuationDeviceManager finished. ');
762    });
763  } catch (err) {
764    console.error('startContinuationDeviceManager failed, cause: ' + JSON.stringify(err));
765  }
766  ```
767
768## continuationManager.startContinuationDeviceManager<sup>9+</sup>
769
770startContinuationDeviceManager(token: number, options: ContinuationExtraParams, callback: AsyncCallback\<void>): void
771
772Starts the device selection module to show the list of available devices on the network. This API uses an asynchronous callback to return the result.
773
774**Atomic service API**: This API can be used in atomic services since API version 11.
775
776**Required permissions**: ohos.permission.DISTRIBUTED_DATASYNC
777
778**System capability**: SystemCapability.Ability.DistributedAbilityManager
779
780**Parameters**
781
782  | Name| Type| Mandatory| Description|
783  | -------- | -------- | -------- | -------- |
784  | token | number | Yes| Token obtained after the registration of the continuation management service.|
785  | options | [ContinuationExtraParams](js-apis-continuation-continuationExtraParams.md) | Yes| Extra parameters used to filter the list of available devices.|
786  | callback | AsyncCallback\<void> | Yes| Callback used to return the result. If the module is started, **err** is **undefined**; otherwise, **err** is an error object.|
787
788**Error codes**
789
790For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Distributed Scheduler Error Codes](errorcode-DistributedSchedule.md).
791
792| ID| Error Message|
793| ------- | -------------------------------------------- |
794| 201      | Permission denied.|
795| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
796| 16600001 | The system ability works abnormally. |
797| 16600002 | The specified token or callback is not registered. |
798
799**Example**
800
801  ```ts
802  import { continuationManager } from '@kit.AbilityKit';
803
804  let token: number = -1;
805  try {
806    continuationManager.startContinuationDeviceManager(
807      token,
808      {
809        deviceType: ["00E"]
810      },
811      (err) => {
812        if (err.code != 0) {
813          console.error('startContinuationDeviceManager failed, cause: ' + JSON.stringify(err));
814          return;
815        }
816        console.info('startContinuationDeviceManager finished. ');
817    });
818  } catch (err) {
819    console.error('startContinuationDeviceManager failed, cause: ' + JSON.stringify(err));
820  }
821  ```
822
823## continuationManager.startContinuationDeviceManager<sup>9+</sup>
824
825startContinuationDeviceManager(token: number, options?: ContinuationExtraParams): Promise\<void>
826
827Starts the device selection module to show the list of available devices on the network. This API uses a promise to return the result.
828
829**Atomic service API**: This API can be used in atomic services since API version 11.
830
831**Required permissions**: ohos.permission.DISTRIBUTED_DATASYNC
832
833**System capability**: SystemCapability.Ability.DistributedAbilityManager
834
835**Parameters**
836
837  | Name| Type| Mandatory| Description|
838  | -------- | -------- | -------- | -------- |
839  | token | number | Yes| Token obtained after the registration of the continuation management service.|
840  | options | [ContinuationExtraParams](js-apis-continuation-continuationExtraParams.md) | No| Extra parameters used to filter the list of available devices. This parameter can be null.|
841
842**Return value**
843
844| Type                       | Description                |
845| ------------------------- | ------------------ |
846| Promise\<void> | Promise used to return the result.|
847
848**Error codes**
849
850For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Distributed Scheduler Error Codes](errorcode-DistributedSchedule.md).
851
852| ID| Error Message|
853| ------- | -------------------------------------------- |
854| 201      | Permission denied.|
855| 401      | Parameter error. Possible causes: 1. Incorrect parameter types; 2. Parameter verification failed. |
856| 16600001 | The system ability works abnormally. |
857| 16600002 | The specified token or callback is not registered. |
858
859**Example**
860
861  ```ts
862  import { continuationManager } from '@kit.AbilityKit';
863  import { BusinessError } from '@kit.BasicServicesKit';
864
865  let token: number = -1;
866  try {
867    continuationManager.startContinuationDeviceManager(
868      token,
869      {
870        deviceType: ["00E"]
871      }).then(() => {
872        console.info('startContinuationDeviceManager finished. ');
873      }).catch((err: BusinessError) => {
874        console.error('startContinuationDeviceManager failed, cause: ' + JSON.stringify(err));
875      });
876  } catch (err) {
877    console.error('startContinuationDeviceManager failed, cause: ' + JSON.stringify(err));
878  }
879  ```
880
881## continuationManager.updateConnectStatus<sup>(deprecated)</sup>
882
883updateConnectStatus(token: number, deviceId: string, status: DeviceConnectState, callback: AsyncCallback\<void>): void
884
885Instructs the device selection module to update the device connection state. This API uses an asynchronous callback to return the result.
886
887> **NOTE**
888>
889> This API is deprecated since API version 9. You are advised to use [updateContinuationState](#continuationmanagerupdatecontinuationstate9) instead.
890
891**System capability**: SystemCapability.Ability.DistributedAbilityManager
892
893**Parameters**
894
895  | Name| Type| Mandatory| Description|
896  | -------- | -------- | -------- | -------- |
897  | token | number | Yes| Token obtained after the registration of the continuation management service.|
898  | deviceId | string | Yes| Device ID.|
899  | status | [DeviceConnectState](#deviceconnectstate) | Yes| Device connection state.|
900  | callback | AsyncCallback\<void> | Yes| Callback used to return the result. If the state is updated, **err** is **undefined**; otherwise, **err** is an error object.|
901
902**Example**
903
904  ```ts
905  import { continuationManager } from '@kit.AbilityKit';
906
907  let token: number = -1;
908  let deviceId: string = "test deviceId";
909  continuationManager.updateConnectStatus(token, deviceId, continuationManager.DeviceConnectState.CONNECTED, (err) => {
910    if (err.code != 0) {
911      console.error('updateConnectStatus failed, cause: ' + JSON.stringify(err));
912      return;
913    }
914    console.info('updateConnectStatus finished. ');
915  });
916  ```
917
918## continuationManager.updateConnectStatus<sup>(deprecated)</sup>
919
920updateConnectStatus(token: number, deviceId: string, status: DeviceConnectState): Promise\<void>
921
922Instructs the device selection module to update the device connection state. This API uses a promise to return the result.
923
924> **NOTE**
925>
926> This API is deprecated since API version 9. You are advised to use [updateContinuationState](#continuationmanagerupdatecontinuationstate9-1) instead.
927
928**System capability**: SystemCapability.Ability.DistributedAbilityManager
929
930**Parameters**
931
932  | Name| Type| Mandatory| Description|
933  | -------- | -------- | -------- | -------- |
934  | token | number | Yes| Token obtained after the registration of the continuation management service.|
935  | deviceId | string | Yes| Device ID.|
936  | status | [DeviceConnectState](#deviceconnectstate) | Yes| Device connection state.|
937
938**Return value**
939
940| Type                       | Description                |
941| ------------------------- | ------------------ |
942| Promise\<void> | Promise used to return the result.|
943
944**Example**
945
946  ```ts
947  import { continuationManager } from '@kit.AbilityKit';
948  import { BusinessError } from '@kit.BasicServicesKit';
949
950  let token: number = 1;
951  let deviceId: string = "test deviceId";
952  continuationManager.updateConnectStatus(token, deviceId, continuationManager.DeviceConnectState.CONNECTED)
953    .then(() => {
954      console.info('updateConnectStatus finished. ');
955    })
956    .catch((err: BusinessError) => {
957      console.error('updateConnectStatus failed, cause: ' + JSON.stringify(err));
958  });
959  ```
960
961## continuationManager.updateContinuationState<sup>9+</sup>
962
963updateContinuationState(token: number, deviceId: string, status: DeviceConnectState, callback: AsyncCallback\<void>): void
964
965Instructs the device selection module to update the device connection state. This API uses an asynchronous callback to return the result.
966
967**Atomic service API**: This API can be used in atomic services since API version 11.
968
969**Required permissions**: ohos.permission.DISTRIBUTED_DATASYNC
970
971**System capability**: SystemCapability.Ability.DistributedAbilityManager
972
973**Parameters**
974
975  | Name| Type| Mandatory| Description|
976  | -------- | -------- | -------- | -------- |
977  | token | number | Yes| Token obtained after the registration of the continuation management service.|
978  | deviceId | string | Yes| Device ID.|
979  | status | [DeviceConnectState](#deviceconnectstate) | Yes| Device connection state.|
980  | callback | AsyncCallback\<void> | Yes| Callback used to return the result. If the state is updated, **err** is **undefined**; otherwise, **err** is an error object.|
981
982**Error codes**
983
984For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Distributed Scheduler Error Codes](errorcode-DistributedSchedule.md).
985
986| ID| Error Message|
987| ------- | -------------------------------------------- |
988| 201      | Permission denied.|
989| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
990| 16600001 | The system ability works abnormally. |
991| 16600002 | The specified token or callback is not registered. |
992
993**Example**
994
995  ```ts
996  import { continuationManager } from '@kit.AbilityKit';
997
998  let token: number = 1;
999  let deviceId: string = "test deviceId";
1000  try {
1001    continuationManager.updateContinuationState(token, deviceId, continuationManager.DeviceConnectState.CONNECTED, (err) => {
1002      if (err.code != 0) {
1003        console.error('updateContinuationState failed, cause: ' + JSON.stringify(err));
1004        return;
1005      }
1006      console.info('updateContinuationState finished. ');
1007    });
1008  } catch (err) {
1009    console.error('updateContinuationState failed, cause: ' + JSON.stringify(err));
1010  }
1011  ```
1012
1013## continuationManager.updateContinuationState<sup>9+</sup>
1014
1015updateContinuationState(token: number, deviceId: string, status: DeviceConnectState): Promise\<void>
1016
1017Instructs the device selection module to update the device connection state. This API uses a promise to return the result.
1018
1019**Atomic service API**: This API can be used in atomic services since API version 11.
1020
1021**Required permissions**: ohos.permission.DISTRIBUTED_DATASYNC
1022
1023**System capability**: SystemCapability.Ability.DistributedAbilityManager
1024
1025**Parameters**
1026
1027  | Name| Type| Mandatory| Description|
1028  | -------- | -------- | -------- | -------- |
1029  | token | number | Yes| Token obtained after the registration of the continuation management service.|
1030  | deviceId | string | Yes| Device ID.|
1031  | status | [DeviceConnectState](#deviceconnectstate) | Yes| Device connection state.|
1032
1033**Return value**
1034
1035| Type                       | Description                |
1036| ------------------------- | ------------------ |
1037| Promise\<void> | Promise used to return the result.|
1038
1039**Error codes**
1040
1041For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Distributed Scheduler Error Codes](errorcode-DistributedSchedule.md).
1042
1043| ID| Error Message|
1044| ------- | -------------------------------------------- |
1045| 201      | Permission denied.|
1046| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
1047| 16600001 | The system ability works abnormally. |
1048| 16600002 | The specified token or callback is not registered. |
1049
1050**Example**
1051
1052  ```ts
1053  import { continuationManager } from '@kit.AbilityKit';
1054  import { BusinessError } from '@kit.BasicServicesKit';
1055
1056  let token: number = 1;
1057  let deviceId: string = "test deviceId";
1058  try {
1059    continuationManager.updateContinuationState(token, deviceId, continuationManager.DeviceConnectState.CONNECTED)
1060      .then(() => {
1061        console.info('updateContinuationState finished. ');
1062      })
1063      .catch((err: BusinessError) => {
1064        console.error('updateContinuationState failed, cause: ' + JSON.stringify(err));
1065      });
1066  } catch (err) {
1067    console.error('updateContinuationState failed, cause: ' + JSON.stringify(err));
1068  }
1069  ```
1070
1071
1072## continuationManager.unregister<sup>(deprecated)</sup>
1073
1074unregister(token: number, callback: AsyncCallback\<void>): void
1075
1076Unregisters the continuation management service. This API uses an asynchronous callback to return the result.
1077
1078> **NOTE**
1079>
1080> This API is deprecated since API version 9. You are advised to use [unregisterContinuation](#continuationmanagerunregistercontinuation9) instead.
1081
1082**System capability**: SystemCapability.Ability.DistributedAbilityManager
1083
1084**Parameters**
1085
1086  | Name| Type| Mandatory| Description|
1087  | -------- | -------- | -------- | -------- |
1088  | token | number | Yes| Token obtained after the registration of the continuation management service.|
1089  | callback | AsyncCallback\<void> | Yes| Callback used to return the result. If the unregistration is successful, **err** is **undefined**; otherwise, **err** is an error object.|
1090
1091**Example**
1092
1093  ```ts
1094  import { continuationManager } from '@kit.AbilityKit';
1095
1096  let token: number = 1;
1097  continuationManager.unregister(token, (err) => {
1098    if (err.code != 0) {
1099      console.error('unregister failed, cause: ' + JSON.stringify(err));
1100      return;
1101    }
1102    console.info('unregister finished. ');
1103  });
1104  ```
1105
1106## continuationManager.unregister<sup>(deprecated)</sup>
1107
1108unregister(token: number): Promise\<void>
1109
1110Unregisters the continuation management service. This API uses a promise to return the result.
1111
1112> **NOTE**
1113>
1114> This API is deprecated since API version 9. You are advised to use [unregisterContinuation](#continuationmanagerunregistercontinuation9-1) instead.
1115
1116**System capability**: SystemCapability.Ability.DistributedAbilityManager
1117
1118**Parameters**
1119
1120  | Name| Type| Mandatory| Description|
1121  | -------- | -------- | -------- | -------- |
1122  | token | number | Yes| Token obtained after the registration of the continuation management service.|
1123
1124**Return value**
1125
1126| Type                       | Description                |
1127| ------------------------- | ------------------ |
1128| Promise\<void> | Promise used to return the result.|
1129
1130**Example**
1131
1132  ```ts
1133  import { continuationManager } from '@kit.AbilityKit';
1134  import { BusinessError } from '@kit.BasicServicesKit';
1135
1136  let token: number = 1;
1137  continuationManager.unregister(token)
1138    .then(() => {
1139      console.info('unregister finished. ');
1140    }).catch((err: BusinessError) => {
1141      console.error('unregister failed, cause: ' + JSON.stringify(err));
1142  });
1143  ```
1144
1145## continuationManager.unregisterContinuation<sup>9+</sup>
1146
1147unregisterContinuation(token: number, callback: AsyncCallback\<void>): void
1148
1149Unregisters the continuation management service. This API uses an asynchronous callback to return the result.
1150
1151**Atomic service API**: This API can be used in atomic services since API version 11.
1152
1153**Required permissions**: ohos.permission.DISTRIBUTED_DATASYNC
1154
1155**System capability**: SystemCapability.Ability.DistributedAbilityManager
1156
1157**Parameters**
1158
1159  | Name| Type| Mandatory| Description|
1160  | -------- | -------- | -------- | -------- |
1161  | token | number | Yes| Token obtained after the registration of the continuation management service.|
1162  | callback | AsyncCallback\<void> | Yes| Callback used to return the result. If the unregistration is successful, **err** is **undefined**; otherwise, **err** is an error object.|
1163
1164**Error codes**
1165
1166For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Distributed Scheduler Error Codes](errorcode-DistributedSchedule.md).
1167
1168| ID| Error Message|
1169| ------- | -------------------------------------------- |
1170| 201      | Permission denied.|
1171| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
1172| 16600001 | The system ability works abnormally. |
1173| 16600002 | The specified token or callback is not registered. |
1174
1175**Example**
1176
1177  ```ts
1178  import { continuationManager } from '@kit.AbilityKit';
1179
1180  let token: number = 1;
1181  try {
1182    continuationManager.unregisterContinuation(token, (err) => {
1183      if (err.code != 0) {
1184        console.error('unregisterContinuation failed, cause: ' + JSON.stringify(err));
1185        return;
1186      }
1187      console.info('unregisterContinuation finished. ');
1188    });
1189  } catch (err) {
1190    console.error('unregisterContinuation failed, cause: ' + JSON.stringify(err));
1191  }
1192  ```
1193
1194## continuationManager.unregisterContinuation<sup>9+</sup>
1195
1196unregisterContinuation(token: number): Promise\<void>
1197
1198Unregisters the continuation management service. This API uses a promise to return the result.
1199
1200**Atomic service API**: This API can be used in atomic services since API version 11.
1201
1202**Required permissions**: ohos.permission.DISTRIBUTED_DATASYNC
1203
1204**System capability**: SystemCapability.Ability.DistributedAbilityManager
1205
1206**Parameters**
1207
1208  | Name| Type| Mandatory| Description|
1209  | -------- | -------- | -------- | -------- |
1210  | token | number | Yes| Token obtained after the registration of the continuation management service.|
1211
1212**Return value**
1213
1214| Type                       | Description                |
1215| ------------------------- | ------------------ |
1216| Promise\<void> | Promise used to return the result.|
1217
1218**Error codes**
1219
1220For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Distributed Scheduler Error Codes](errorcode-DistributedSchedule.md).
1221
1222| ID| Error Message|
1223| ------- | -------------------------------------------- |
1224| 201      | Permission denied.|
1225| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
1226| 16600001 | The system ability works abnormally. |
1227| 16600002 | The specified token or callback is not registered. |
1228
1229**Example**
1230
1231  ```ts
1232  import { continuationManager } from '@kit.AbilityKit';
1233  import { BusinessError } from '@kit.BasicServicesKit';
1234
1235  let token: number = -1;
1236  try {
1237    continuationManager.unregisterContinuation(token).then(() => {
1238        console.info('unregisterContinuation finished. ');
1239      }).catch((err: BusinessError) => {
1240        console.error('unregisterContinuation failed, cause: ' + JSON.stringify(err));
1241    });
1242  } catch (err) {
1243    console.error('unregisterContinuation failed, cause: ' + JSON.stringify(err));
1244  }
1245  ```
1246
1247
1248## DeviceConnectState
1249
1250Enumerates the device connection states.
1251
1252**Atomic service API**: This API can be used in atomic services since API version 11.
1253
1254**System capability**: SystemCapability.Ability.DistributedAbilityManager
1255
1256| Name| Value| Description|
1257| -------- | -------- | -------- |
1258| IDLE | 0 | The device is in the initial state.|
1259| CONNECTING | 1 | The device is being connected.|
1260| CONNECTED | 2 | The device is connected.|
1261| DISCONNECTING | 3 | The device is being disconnected.|
1262
1263## ContinuationMode
1264
1265Enumerates the continuation modes provided by the device selection module.
1266
1267**Atomic service API**: This API can be used in atomic services since API version 11.
1268
1269**System capability**: SystemCapability.Ability.DistributedAbilityManager
1270
1271| Name| Value| Description|
1272| -------- | -------- | -------- |
1273| COLLABORATION_SINGLE | 0 | Single-choice mode.|
1274| COLLABORATION_MULTIPLE | 1 | Multi-choice mode.|
1275