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