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