@ohos.continuation.continuationManager (Continuation/Collaboration Management)

The continuationManager module provides the continuation/collaboration management entry. You can use the APIs of this module to connect to and cancel the continuation/collaboration management service, subscribe to and unsubscribe from device connection events, start the device selection module, and update the device connection state.

NOTE

The initial APIs of this module have been supported since API version 8 and deprecated since API version 22. You are advised to use the APIs in Distributed Device Management instead.

The APIs of this module can be used only in the stage model.

Modules to Import

import { continuationManager } from '@kit.AbilityKit';

continuationManager.register(deprecated)

register(callback: AsyncCallback<number>): void

Registers 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.

NOTE

This API has been deprecated since API version 9. You are advised to use ondevicestatechange instead.

Model restriction: This API can be used only in the stage model.

System capability: SystemCapability.Ability.DistributedAbilityManager

Parameters

Name Type Mandatory Description
callback AsyncCallback<number> Yes Callback used to return the token generated after the continuation management service is connected.

Example

import { continuationManager } from '@kit.AbilityKit';

let token: number = -1;
continuationManager.register((err, data) => {
  if (err.code != 0) {
    console.error('register failed, cause: ' + JSON.stringify(err));
    return;
  }
  console.info('register finished, ' + JSON.stringify(data));
  token = data;
});

continuationManager.register(deprecated)

register(options: ContinuationExtraParams, callback: AsyncCallback<number>): void

Registers the continuation management service and obtains a token. This API uses an asynchronous callback to return the result.

NOTE

This API has been deprecated since API version 9. You are advised to use onDeviceStateChange instead.

Model restriction: This API can be used only in the stage model.

System capability: SystemCapability.Ability.DistributedAbilityManager

Parameters

Name Type Mandatory Description
options ContinuationExtraParams Yes Extra parameters used to filter the list of available devices.
callback AsyncCallback<number> Yes Callback used to return the token generated after the continuation management service is connected.

Example

import { continuationManager } from '@kit.AbilityKit';

let token: number = -1;
continuationManager.register(
  {
    deviceType: ["00E"]
  },
  (err, data) => {
    if (err.code != 0) {
      console.error('register failed, cause: ' + JSON.stringify(err));
      return;
    }
    console.info('register finished, ' + JSON.stringify(data));
    token = data;
});

continuationManager.register(deprecated)

register(options?: ContinuationExtraParams): Promise<number>

Registers the continuation management service and obtains a token. This API uses a promise to return the result.

NOTE

This API has been deprecated since API version 9. You are advised to use onDeviceStateChange instead.

Model restriction: This API can be used only in the stage model.

System capability: SystemCapability.Ability.DistributedAbilityManager

Parameters

Name Type Mandatory Description
options ContinuationExtraParams No Extra parameters used to filter the list of available devices. This parameter can be null.

Return value

Type Description
Promise<number> Promise used to return the token generated after the continuation management service is connected.

Example

import { continuationManager } from '@kit.AbilityKit';
import { BusinessError } from '@kit.BasicServicesKit';

let token: number = -1;
continuationManager.register(
  { deviceType: ["00E"] }).then((data) => {
    console.info('register finished, ' + JSON.stringify(data));
    token = data;
  }).catch((err: BusinessError) => {
    console.error('register failed, cause: ' + JSON.stringify(err));
});

continuationManager.registerContinuation(deprecated)

registerContinuation(callback: AsyncCallback<number>): void

Registers 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.

NOTE

This API has been supported since API version 9 and deprecated since API version 22. You are advised to use onDeviceStateChange instead.

Atomic service API: This API can be used in atomic services since API version 11.

Required permissions: ohos.permission.DISTRIBUTED_DATASYNC

Model restriction: This API can be used only in the stage model.

System capability: SystemCapability.Ability.DistributedAbilityManager

Parameters

Name Type Mandatory Description
callback AsyncCallback<number> Yes Callback used to return the token generated after the continuation management service is connected.

Error codes

For details about the error codes, see Universal Error Codes and Distributed Scheduler Error Codes.

ID Error Message
201 Permission denied.
401 Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed.
16600001 The system ability works abnormally.
16600003 The number of token registration times has reached the upper limit.

Example

import { continuationManager } from '@kit.AbilityKit';

let token: number = -1;
try {
  continuationManager.registerContinuation((err, data) => {
    if (err.code != 0) {
      console.error('registerContinuation failed, cause: ' + JSON.stringify(err));
      return;
    }
    console.info('registerContinuation finished, ' + JSON.stringify(data));
    token = data;
  });
} catch (err) {
  console.error('registerContinuation failed, cause: ' + JSON.stringify(err));
}

continuationManager.registerContinuation(deprecated)

registerContinuation(options: ContinuationExtraParams, callback: AsyncCallback<number>): void

Registers the continuation management service and obtains a token. This API uses an asynchronous callback to return the result.

NOTE

This API has been supported since API version 9 and deprecated since API version 22. You are advised to use onDeviceStateChange instead.

Atomic service API: This API can be used in atomic services since API version 11.

Required permissions: ohos.permission.DISTRIBUTED_DATASYNC

Model restriction: This API can be used only in the stage model.

System capability: SystemCapability.Ability.DistributedAbilityManager

Parameters

Name Type Mandatory Description
options ContinuationExtraParams Yes Extra parameters used to filter the list of available devices.
callback AsyncCallback<number> Yes Callback used to return the token generated after the continuation management service is connected.

Error codes

For details about the error codes, see Universal Error Codes and Distributed Scheduler Error Codes.

ID Error Message
201 Permission denied.
401 Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed.
16600001 The system ability works abnormally.
16600003 The number of token registration times has reached the upper limit.

Example

import { continuationManager } from '@kit.AbilityKit';

let token: number = -1;
try {
  continuationManager.registerContinuation(
    {
      deviceType: ["00E"]
    },
    (err, data) => {
      if (err.code != 0) {
        console.error('registerContinuation failed, cause: ' + JSON.stringify(err));
        return;
      }
      console.info('registerContinuation finished, ' + JSON.stringify(data));
      token = data;
  });
} catch (err) {
  console.error('registerContinuation failed, cause: ' + JSON.stringify(err));
}

continuationManager.registerContinuation(deprecated)

registerContinuation(options?: ContinuationExtraParams): Promise<number>

Registers the continuation management service and obtains a token. This API uses a promise to return the result.

NOTE

This API has been supported since API version 9 and deprecated since API version 22. You are advised to use onDeviceStateChange instead.

Atomic service API: This API can be used in atomic services since API version 11.

Required permissions: ohos.permission.DISTRIBUTED_DATASYNC

Model restriction: This API can be used only in the stage model.

System capability: SystemCapability.Ability.DistributedAbilityManager

Parameters

Name Type Mandatory Description
options ContinuationExtraParams No Extra parameters used to filter the list of available devices. This parameter can be null.

Return value

Type Description
Promise<number> Promise used to return the token generated after the continuation management service is connected.

Error codes

For details about the error codes, see Universal Error Codes and Distributed Scheduler Error Codes.

ID Error Message
201 Permission denied.
401 Parameter error. Possible causes: 1. Incorrect parameter types; 2. Parameter verification failed.
16600001 The system ability works abnormally.
16600003 The number of token registration times has reached the upper limit.

Example

import { continuationManager } from '@kit.AbilityKit';
import { BusinessError } from '@kit.BasicServicesKit';

let token: number = -1;
try {
  continuationManager.registerContinuation(
    {
      deviceType: ["00E"]
    }).then((data) => {
      console.info('registerContinuation finished, ' + JSON.stringify(data));
      token = data;
    }).catch((err: BusinessError) => {
      console.error('registerContinuation failed, cause: ' + JSON.stringify(err));
  });
} catch (err) {
  console.error('registerContinuation failed, cause: ' + JSON.stringify(err));
}

continuationManager.on('deviceConnect')(deprecated)

on(type: 'deviceConnect', callback: Callback<ContinuationResult>): void

Subscribes to device connection events. This API uses an asynchronous callback to return the result.

NOTE

This API has been deprecated since API version 9. You are advised to use onDeviceStateChange instead.

Model restriction: This API can be used only in the stage model.

System capability: SystemCapability.Ability.DistributedAbilityManager

Parameters

Name Type Mandatory Description
type string Yes Event type. The value is fixed at deviceConnect.
callback Callback<ContinuationResult> 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.

Example

import { continuationManager } from '@kit.AbilityKit';

continuationManager.on("deviceConnect", (data) => {
  console.info('onDeviceConnect deviceId: ' + JSON.stringify(data.id));
  console.info('onDeviceConnect deviceType: ' + JSON.stringify(data.type));
  console.info('onDeviceConnect deviceName: ' + JSON.stringify(data.name));
});

continuationManager.on('deviceDisconnect')(deprecated)

on(type: 'deviceDisconnect', callback: Callback<string>): void

Subscribes to device disconnection events. This API uses an asynchronous callback to return the result.

NOTE

This API has been deprecated since API version 9. You are advised to use onDeviceStateChange instead.

Model restriction: This API can be used only in the stage model.

System capability: SystemCapability.Ability.DistributedAbilityManager

Parameters

Name Type Mandatory Description
type string Yes Event type. The value is fixed at deviceDisconnect.
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.

Example

import { continuationManager } from '@kit.AbilityKit';

continuationManager.on("deviceDisconnect", (data) => {
  console.info('onDeviceDisconnect deviceId: ' + JSON.stringify(data));
});

continuationManager.off('deviceConnect')(deprecated)

off(type: 'deviceConnect', callback?: Callback<ContinuationResult>): void

Unsubscribes from device connection events. This API uses an asynchronous callback to return the result.

NOTE

This API has been deprecated since API version 9. You are advised to use offDeviceStateChange instead.

Model restriction: This API can be used only in the stage model.

System capability: SystemCapability.Ability.DistributedAbilityManager

Parameters

Name Type Mandatory Description
type string Yes Event type. The value is fixed at deviceConnect.
callback Callback<ContinuationResult> 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.

Example

import { continuationManager } from '@kit.AbilityKit';

continuationManager.off("deviceConnect", (data) => {
  console.info('onDeviceConnect deviceId: ' + JSON.stringify(data.id));
  console.info('onDeviceConnect deviceType: ' + JSON.stringify(data.type));
  console.info('onDeviceConnect deviceName: ' + JSON.stringify(data.name));
});

continuationManager.off('deviceDisconnect')(deprecated)

off(type: 'deviceDisconnect', callback?: Callback<string>): void

Unsubscribes from device disconnection events. This API uses an asynchronous callback to return the result.

NOTE

This API has been deprecated since API version 9. You are advised to use offDeviceStateChange instead.

Model restriction: This API can be used only in the stage model.

System capability: SystemCapability.Ability.DistributedAbilityManager

Parameters

Name Type Mandatory Description
type string Yes Event type. The value is fixed at deviceDisconnect.
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.

Example

import { continuationManager } from '@kit.AbilityKit';

continuationManager.off("deviceDisconnect", (data) => {
  console.info('onDeviceDisconnect deviceId: ' + JSON.stringify(data));
});

continuationManager.on('deviceSelected')(deprecated)

on(type: 'deviceSelected', token: number, callback: Callback<Array<ContinuationResult>>): void

Subscribes to device connection events. This API uses an asynchronous callback to return the result.

NOTE

This API has been supported since API version 9 and deprecated since API version 22. You are advised to use onDeviceStateChange instead.

Atomic service API: This API can be used in atomic services since API version 11.

Required permissions: ohos.permission.DISTRIBUTED_DATASYNC

Model restriction: This API can be used only in the stage model.

System capability: SystemCapability.Ability.DistributedAbilityManager

Parameters

Name Type Mandatory Description
type string Yes Event type. The value is fixed at deviceSelected.
token number Yes Token obtained after the registration of the continuation management service.
callback Callback<Array<ContinuationResult>> 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.

Error codes

For details about the error codes, see Universal Error Codes and Distributed Scheduler Error Codes.

ID Error Message
201 Permission denied.
401 Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed.
16600001 The system ability works abnormally.
16600002 The specified token or callback is not registered.
16600004 The specified callback has been registered.

Example

import { continuationManager } from '@kit.AbilityKit';

let token: number = 1;
try {
  continuationManager.on("deviceSelected", token, (data) => {
    console.info('onDeviceSelected len: ' + data.length);
    for (let i = 0; i < data.length; i++) {
      console.info('onDeviceSelected deviceId: ' + JSON.stringify(data[i].id));
      console.info('onDeviceSelected deviceType: ' + JSON.stringify(data[i].type));
      console.info('onDeviceSelected deviceName: ' + JSON.stringify(data[i].name));
    }
  });
} catch (err) {
  console.error('on failed, cause: ' + JSON.stringify(err));
}

continuationManager.on('deviceUnselected')(deprecated)

on(type: 'deviceUnselected', token: number, callback: Callback<Array<ContinuationResult>>): void

Subscribes to device disconnection events. This API uses an asynchronous callback to return the result.

NOTE

This API has been supported since API version 9 and deprecated since API version 22. You are advised to use onDeviceStateChange instead.

Atomic service API: This API can be used in atomic services since API version 11.

Required permissions: ohos.permission.DISTRIBUTED_DATASYNC

Model restriction: This API can be used only in the stage model.

System capability: SystemCapability.Ability.DistributedAbilityManager

Parameters

Name Type Mandatory Description
type string Yes Event type. The value is fixed at deviceUnselected.
token number Yes Token obtained after the registration of the continuation management service.
callback Callback<Array<ContinuationResult>> 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.

Error codes

For details about the error codes, see Universal Error Codes and Distributed Scheduler Error Codes.

ID Error Message
201 Permission denied.
401 Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed.
16600001 The system ability works abnormally.
16600002 The specified token or callback is not registered.
16600004 The specified callback has been registered.

Example

import { continuationManager } from '@kit.AbilityKit';

let token: number = 1;
try {
  continuationManager.on("deviceUnselected", token, (data) => {
    console.info('onDeviceUnselected len: ' + data.length);
    for (let i = 0; i < data.length; i++) {
      console.info('onDeviceUnselected deviceId: ' + JSON.stringify(data[i].id));
      console.info('onDeviceUnselected deviceType: ' + JSON.stringify(data[i].type));
      console.info('onDeviceUnselected deviceName: ' + JSON.stringify(data[i].name));
    }
    console.info('onDeviceUnselected finished.');
  });
} catch (err) {
  console.error('on failed, cause: ' + JSON.stringify(err));
}

continuationManager.off('deviceSelected')(deprecated)

off(type: 'deviceSelected', token: number): void

Unsubscribes from device connection events.

NOTE

This API has been supported since API version 9 and deprecated since API version 22. You are advised to use offDeviceStateChange instead.

Atomic service API: This API can be used in atomic services since API version 11.

Required permissions: ohos.permission.DISTRIBUTED_DATASYNC

Model restriction: This API can be used only in the stage model.

System capability: SystemCapability.Ability.DistributedAbilityManager

Parameters

Name Type Mandatory Description
type string Yes Event type. The value is fixed at deviceSelected.
token number Yes Token obtained after the registration of the continuation management service.

Error codes

For details about the error codes, see Universal Error Codes and Distributed Scheduler Error Codes.

ID Error Message
201 Permission denied.
401 Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed.
16600001 The system ability works abnormally.
16600002 The specified token or callback is not registered.
16600004 The specified callback has been registered.

Example

import { continuationManager } from '@kit.AbilityKit';

let token: number = 1;
try {
  continuationManager.off("deviceSelected", token);
} catch (err) {
  console.error('off failed, cause: ' + JSON.stringify(err));
}

continuationManager.off('deviceUnselected')(deprecated)

off(type: 'deviceUnselected', token: number): void

Unsubscribes from device disconnection events.

NOTE

This API has been supported since API version 9 and deprecated since API version 22. You are advised to use offDeviceStateChange instead.

Atomic service API: This API can be used in atomic services since API version 11.

Required permissions: ohos.permission.DISTRIBUTED_DATASYNC

Model restriction: This API can be used only in the stage model.

System capability: SystemCapability.Ability.DistributedAbilityManager

Parameters

Name Type Mandatory Description
type string Yes Event type. The value is fixed at deviceUnselected.
token number Yes Token obtained after the registration of the continuation management service.

Error codes

For details about the error codes, see Universal Error Codes and Distributed Scheduler Error Codes.

ID Error Message
201 Permission denied.
401 Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed.
16600001 The system ability works abnormally.
16600002 The specified token or callback is not registered.
16600004 The specified callback has been registered.

Example

import { continuationManager } from '@kit.AbilityKit';

let token: number = 1;
try {
  continuationManager.off("deviceUnselected", token);
} catch (err) {
  console.error('off failed, cause: ' + JSON.stringify(err));
}

continuationManager.startDeviceManager(deprecated)

startDeviceManager(token: number, callback: AsyncCallback<void>): void

Starts 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.

NOTE

This API has been deprecated since API version 9. You are advised to use startDiscovering instead.

Model restriction: This API can be used only in the stage model.

System capability: SystemCapability.Ability.DistributedAbilityManager

Parameters

Name Type Mandatory Description
token number Yes Token obtained after the registration of the continuation management service.
callback AsyncCallback<void> Yes Callback used to return the result. If the module is started, err is undefined; otherwise, err is an error object.

Example

import { continuationManager } from '@kit.AbilityKit';

let token: number = 1;
continuationManager.startDeviceManager(token, (err) => {
  if (err.code != 0) {
    console.error('startDeviceManager failed, cause: ' + JSON.stringify(err));
    return;
  }
  console.info('startDeviceManager finished. ');
});

continuationManager.startDeviceManager(deprecated)

startDeviceManager(token: number, options: ContinuationExtraParams, callback: AsyncCallback<void>): void

Starts the device selection module to show the list of available devices on the network. This API uses an asynchronous callback to return the result.

NOTE

This API has been deprecated since API version 9. You are advised to use startDiscovering instead.

Model restriction: This API can be used only in the stage model.

System capability: SystemCapability.Ability.DistributedAbilityManager

Parameters

Name Type Mandatory Description
token number Yes Token obtained after the registration of the continuation management service.
options ContinuationExtraParams Yes Extra parameters used to filter the list of available devices.
callback AsyncCallback<void> Yes Callback used to return the result. If the module is started, err is undefined; otherwise, err is an error object.

Example

import { continuationManager } from '@kit.AbilityKit';

let token: number = 1;
continuationManager.startDeviceManager(
  token,
  {
    deviceType: ["00E"]
  },
  (err) => {
    if (err.code != 0) {
      console.error('startDeviceManager failed, cause: ' + JSON.stringify(err));
      return;
    }
    console.info('startDeviceManager finished. ');
});

continuationManager.startDeviceManager(deprecated)

startDeviceManager(token: number, options?: ContinuationExtraParams): Promise<void>

Starts the device selection module to show the list of available devices on the network. This API uses a promise to return the result.

NOTE

This API has been deprecated since API version 9. You are advised to use startDiscovering instead.

Model restriction: This API can be used only in the stage model.

System capability: SystemCapability.Ability.DistributedAbilityManager

Parameters

Name Type Mandatory Description
token number Yes Token obtained after the registration of the continuation management service.
options ContinuationExtraParams No Extra parameters used to filter the list of available devices. This parameter can be null.

Return value

Type Description
Promise<void> Promise used to return the result.

Example

import { continuationManager } from '@kit.AbilityKit';
import { BusinessError } from '@kit.BasicServicesKit';

let token: number = -1;
continuationManager.startDeviceManager(
  token,
  {
    deviceType: ["00E"]
  }).then(() => {
    console.info('startDeviceManager finished. ');
  }).catch((err: BusinessError) => {
    console.error('startDeviceManager failed, cause: ' + JSON.stringify(err));
});

continuationManager.startContinuationDeviceManager(deprecated)

startContinuationDeviceManager(token: number, callback: AsyncCallback<void>): void

Starts 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.

NOTE

This API has been supported since API version 9 and deprecated since API version 22. You are advised to use startDiscovering instead.

Atomic service API: This API can be used in atomic services since API version 11.

Required permissions: ohos.permission.DISTRIBUTED_DATASYNC

Model restriction: This API can be used only in the stage model.

System capability: SystemCapability.Ability.DistributedAbilityManager

Parameters

Name Type Mandatory Description
token number Yes Token obtained after the registration of the continuation management service.
callback AsyncCallback<void> Yes Callback used to return the result. If the module is started, err is undefined; otherwise, err is an error object.

Error codes

For details about the error codes, see Universal Error Codes and Distributed Scheduler Error Codes.

ID Error Message
201 Permission denied.
401 Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed.
16600001 The system ability works abnormally.
16600002 The specified token or callback is not registered.

Example

import { continuationManager } from '@kit.AbilityKit';

let token: number = -1;
try {
  continuationManager.startContinuationDeviceManager(token, (err) => {
    if (err.code != 0) {
      console.error('startContinuationDeviceManager failed, cause: ' + JSON.stringify(err));
      return;
    }
    console.info('startContinuationDeviceManager finished. ');
  });
} catch (err) {
  console.error('startContinuationDeviceManager failed, cause: ' + JSON.stringify(err));
}

continuationManager.startContinuationDeviceManager(deprecated)

startContinuationDeviceManager(token: number, options: ContinuationExtraParams, callback: AsyncCallback<void>): void

Starts the device selection module to show the list of available devices on the network. This API uses an asynchronous callback to return the result.

NOTE

This API has been supported since API version 9 and deprecated since API version 22. You are advised to use startDiscovering instead.

Atomic service API: This API can be used in atomic services since API version 11.

Required permissions: ohos.permission.DISTRIBUTED_DATASYNC

Model restriction: This API can be used only in the stage model.

System capability: SystemCapability.Ability.DistributedAbilityManager

Parameters

Name Type Mandatory Description
token number Yes Token obtained after the registration of the continuation management service.
options ContinuationExtraParams Yes Extra parameters used to filter the list of available devices.
callback AsyncCallback<void> Yes Callback used to return the result. If the module is started, err is undefined; otherwise, err is an error object.

Error codes

For details about the error codes, see Universal Error Codes and Distributed Scheduler Error Codes.

ID Error Message
201 Permission denied.
401 Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed.
16600001 The system ability works abnormally.
16600002 The specified token or callback is not registered.

Example

import { continuationManager } from '@kit.AbilityKit';

let token: number = -1;
try {
  continuationManager.startContinuationDeviceManager(
    token,
    {
      deviceType: ["00E"]
    },
    (err) => {
      if (err.code != 0) {
        console.error('startContinuationDeviceManager failed, cause: ' + JSON.stringify(err));
        return;
      }
      console.info('startContinuationDeviceManager finished. ');
  });
} catch (err) {
  console.error('startContinuationDeviceManager failed, cause: ' + JSON.stringify(err));
}

continuationManager.startContinuationDeviceManager(deprecated)

startContinuationDeviceManager(token: number, options?: ContinuationExtraParams): Promise<void>

Starts the device selection module to show the list of available devices on the network. This API uses a promise to return the result.

NOTE

This API has been supported since API version 9 and deprecated since API version 22. You are advised to use startDiscovering instead.

Atomic service API: This API can be used in atomic services since API version 11.

Required permissions: ohos.permission.DISTRIBUTED_DATASYNC

Model restriction: This API can be used only in the stage model.

System capability: SystemCapability.Ability.DistributedAbilityManager

Parameters

Name Type Mandatory Description
token number Yes Token obtained after the registration of the continuation management service.
options ContinuationExtraParams No Extra parameters used to filter the list of available devices. This parameter can be null.

Return value

Type Description
Promise<void> Promise used to return the result.

Error codes

For details about the error codes, see Universal Error Codes and Distributed Scheduler Error Codes.

ID Error Message
201 Permission denied.
401 Parameter error. Possible causes: 1. Incorrect parameter types; 2. Parameter verification failed.
16600001 The system ability works abnormally.
16600002 The specified token or callback is not registered.

Example

import { continuationManager } from '@kit.AbilityKit';
import { BusinessError } from '@kit.BasicServicesKit';

let token: number = -1;
try {
  continuationManager.startContinuationDeviceManager(
    token,
    {
      deviceType: ["00E"]
    }).then(() => {
      console.info('startContinuationDeviceManager finished. ');
    }).catch((err: BusinessError) => {
      console.error('startContinuationDeviceManager failed, cause: ' + JSON.stringify(err));
    });
} catch (err) {
  console.error('startContinuationDeviceManager failed, cause: ' + JSON.stringify(err));
}

continuationManager.updateConnectStatus(deprecated)

updateConnectStatus(token: number, deviceId: string, status: DeviceConnectState, callback: AsyncCallback<void>): void

Instructs the device selection module to update the device connection state. This API uses an asynchronous callback to return the result.

NOTE

This API has been deprecated since API version 9. You are advised to use getAvailableDeviceListSync instead.

Model restriction: This API can be used only in the stage model.

System capability: SystemCapability.Ability.DistributedAbilityManager

Parameters

Name Type Mandatory Description
token number Yes Token obtained after the registration of the continuation management service.
deviceId string Yes Device ID.
status DeviceConnectState Yes Device connection state.
callback AsyncCallback<void> Yes Callback used to return the result. If the state is updated, err is undefined; otherwise, err is an error object.

Example

import { continuationManager } from '@kit.AbilityKit';

let token: number = -1;
let deviceId: string = "test deviceId";
continuationManager.updateConnectStatus(token, deviceId, continuationManager.DeviceConnectState.CONNECTED, (err) => {
  if (err.code != 0) {
    console.error('updateConnectStatus failed, cause: ' + JSON.stringify(err));
    return;
  }
  console.info('updateConnectStatus finished. ');
});

continuationManager.updateConnectStatus(deprecated)

updateConnectStatus(token: number, deviceId: string, status: DeviceConnectState): Promise<void>

Instructs the device selection module to update the device connection state. This API uses a promise to return the result.

NOTE

This API has been deprecated since API version 9. You are advised to use getAvailableDeviceListSync instead.

Model restriction: This API can be used only in the stage model.

System capability: SystemCapability.Ability.DistributedAbilityManager

Parameters

Name Type Mandatory Description
token number Yes Token obtained after the registration of the continuation management service.
deviceId string Yes Device ID.
status DeviceConnectState Yes Device connection state.

Return value

Type Description
Promise<void> Promise used to return the result.

Example

import { continuationManager } from '@kit.AbilityKit';
import { BusinessError } from '@kit.BasicServicesKit';

let token: number = 1;
let deviceId: string = "test deviceId";
continuationManager.updateConnectStatus(token, deviceId, continuationManager.DeviceConnectState.CONNECTED)
  .then(() => {
    console.info('updateConnectStatus finished. ');
  })
  .catch((err: BusinessError) => {
    console.error('updateConnectStatus failed, cause: ' + JSON.stringify(err));
});

continuationManager.updateContinuationState(deprecated)

updateContinuationState(token: number, deviceId: string, status: DeviceConnectState, callback: AsyncCallback<void>): void

Instructs the device selection module to update the device connection state. This API uses an asynchronous callback to return the result.

NOTE

This API has been supported since API version 9 and deprecated since API version 22. You are advised to use getAvailableDeviceListSync instead.

Atomic service API: This API can be used in atomic services since API version 11.

Required permissions: ohos.permission.DISTRIBUTED_DATASYNC

Model restriction: This API can be used only in the stage model.

System capability: SystemCapability.Ability.DistributedAbilityManager

Parameters

Name Type Mandatory Description
token number Yes Token obtained after the registration of the continuation management service.
deviceId string Yes Device ID.
status DeviceConnectState Yes Device connection state.
callback AsyncCallback<void> Yes Callback used to return the result. If the state is updated, err is undefined; otherwise, err is an error object.

Error codes

For details about the error codes, see Universal Error Codes and Distributed Scheduler Error Codes.

ID Error Message
201 Permission denied.
401 Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed.
16600001 The system ability works abnormally.
16600002 The specified token or callback is not registered.

Example

import { continuationManager } from '@kit.AbilityKit';

let token: number = 1;
let deviceId: string = "test deviceId";
try {
  continuationManager.updateContinuationState(token, deviceId, continuationManager.DeviceConnectState.CONNECTED, (err) => {
    if (err.code != 0) {
      console.error('updateContinuationState failed, cause: ' + JSON.stringify(err));
      return;
    }
    console.info('updateContinuationState finished. ');
  });
} catch (err) {
  console.error('updateContinuationState failed, cause: ' + JSON.stringify(err));
}

continuationManager.updateContinuationState(deprecated)

updateContinuationState(token: number, deviceId: string, status: DeviceConnectState): Promise<void>

Instructs the device selection module to update the device connection state. This API uses a promise to return the result.

NOTE

This API has been supported since API version 9 and deprecated since API version 22. You are advised to use getAvailableDeviceListSync instead.

Atomic service API: This API can be used in atomic services since API version 11.

Required permissions: ohos.permission.DISTRIBUTED_DATASYNC

Model restriction: This API can be used only in the stage model.

System capability: SystemCapability.Ability.DistributedAbilityManager

Parameters

Name Type Mandatory Description
token number Yes Token obtained after the registration of the continuation management service.
deviceId string Yes Device ID.
status DeviceConnectState Yes Device connection state.

Return value

Type Description
Promise<void> Promise used to return the result.

Error codes

For details about the error codes, see Universal Error Codes and Distributed Scheduler Error Codes.

ID Error Message
201 Permission denied.
401 Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed.
16600001 The system ability works abnormally.
16600002 The specified token or callback is not registered.

Example

import { continuationManager } from '@kit.AbilityKit';
import { BusinessError } from '@kit.BasicServicesKit';

let token: number = 1;
let deviceId: string = "test deviceId";
try {
  continuationManager.updateContinuationState(token, deviceId, continuationManager.DeviceConnectState.CONNECTED)
    .then(() => {
      console.info('updateContinuationState finished. ');
    })
    .catch((err: BusinessError) => {
      console.error('updateContinuationState failed, cause: ' + JSON.stringify(err));
    });
} catch (err) {
  console.error('updateContinuationState failed, cause: ' + JSON.stringify(err));
}

continuationManager.unregister(deprecated)

unregister(token: number, callback: AsyncCallback<void>): void

Unregisters the continuation management service by passing the token obtained during registration. This API uses an asynchronous callback to return the result.

NOTE

This API has been deprecated since API version 9. You are advised to use offDeviceStateChange instead.

Model restriction: This API can be used only in the stage model.

System capability: SystemCapability.Ability.DistributedAbilityManager

Parameters

Name Type Mandatory Description
token number Yes Token obtained after the registration of the continuation management service.
callback AsyncCallback<void> Yes Callback used to return the result. If the unregistration is successful, err is undefined; otherwise, err is an error object.

Example

import { continuationManager } from '@kit.AbilityKit';

let token: number = 1;
continuationManager.unregister(token, (err) => {
  if (err.code != 0) {
    console.error('unregister failed, cause: ' + JSON.stringify(err));
    return;
  }
  console.info('unregister finished. ');
});

continuationManager.unregister(deprecated)

unregister(token: number): Promise<void>

Unregisters the continuation management service by passing the token obtained during registration. This API uses a promise to return the result.

NOTE

This API has been deprecated since API version 9. You are advised to use offDeviceStateChange instead.

Model restriction: This API can be used only in the stage model.

System capability: SystemCapability.Ability.DistributedAbilityManager

Parameters

Name Type Mandatory Description
token number Yes Token obtained after the registration of the continuation management service.

Return value

Type Description
Promise<void> Promise used to return the result.

Example

import { continuationManager } from '@kit.AbilityKit';
import { BusinessError } from '@kit.BasicServicesKit';

let token: number = 1;
continuationManager.unregister(token)
  .then(() => {
    console.info('unregister finished. ');
  }).catch((err: BusinessError) => {
    console.error('unregister failed, cause: ' + JSON.stringify(err));
});

continuationManager.unregisterContinuation(deprecated)

unregisterContinuation(token: number, callback: AsyncCallback<void>): void

Unregisters the continuation management service by passing the token obtained during registration. This API uses an asynchronous callback to return the result.

NOTE

This API has been supported since API version 9 and deprecated since API version 22. You are advised to use offDeviceStateChange instead.

Atomic service API: This API can be used in atomic services since API version 11.

Required permissions: ohos.permission.DISTRIBUTED_DATASYNC

Model restriction: This API can be used only in the stage model.

System capability: SystemCapability.Ability.DistributedAbilityManager

Parameters

Name Type Mandatory Description
token number Yes Token obtained after the registration of the continuation management service.
callback AsyncCallback<void> Yes Callback used to return the result. If the unregistration is successful, err is undefined; otherwise, err is an error object.

Error codes

For details about the error codes, see Universal Error Codes and Distributed Scheduler Error Codes.

ID Error Message
201 Permission denied.
401 Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed.
16600001 The system ability works abnormally.
16600002 The specified token or callback is not registered.

Example

import { continuationManager } from '@kit.AbilityKit';

let token: number = 1;
try {
  continuationManager.unregisterContinuation(token, (err) => {
    if (err.code != 0) {
      console.error('unregisterContinuation failed, cause: ' + JSON.stringify(err));
      return;
    }
    console.info('unregisterContinuation finished. ');
  });
} catch (err) {
  console.error('unregisterContinuation failed, cause: ' + JSON.stringify(err));
}

continuationManager.unregisterContinuation(deprecated)

unregisterContinuation(token: number): Promise<void>

Unregisters the continuation management service by passing the token obtained during registration. This API uses a promise to return the result.

NOTE

This API has been supported since API version 9 and deprecated since API version 22. You are advised to use offDeviceStateChange instead.

Atomic service API: This API can be used in atomic services since API version 11.

Required permissions: ohos.permission.DISTRIBUTED_DATASYNC

Model restriction: This API can be used only in the stage model.

System capability: SystemCapability.Ability.DistributedAbilityManager

Parameters

Name Type Mandatory Description
token number Yes Token obtained after the registration of the continuation management service.

Return value

Type Description
Promise<void> Promise used to return the result.

Error codes

For details about the error codes, see Universal Error Codes and Distributed Scheduler Error Codes.

ID Error Message
201 Permission denied.
401 Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed.
16600001 The system ability works abnormally.
16600002 The specified token or callback is not registered.

Example

import { continuationManager } from '@kit.AbilityKit';
import { BusinessError } from '@kit.BasicServicesKit';

let token: number = -1;
try {
  continuationManager.unregisterContinuation(token).then(() => {
      console.info('unregisterContinuation finished. ');
    }).catch((err: BusinessError) => {
      console.error('unregisterContinuation failed, cause: ' + JSON.stringify(err));
  });
} catch (err) {
  console.error('unregisterContinuation failed, cause: ' + JSON.stringify(err));
}

DeviceConnectState(deprecated)

Device connection state.

NOTE

This API has been deprecated since API version 22. You are advised to use DeviceStateChange instead.

Atomic service API: This API can be used in atomic services since API version 11.

Model restriction: This API can be used only in the stage model.

System capability: SystemCapability.Ability.DistributedAbilityManager

Name Value Description
IDLE 0 The device is in the initial state.
CONNECTING 1 The device is being connected.
CONNECTED 2 The device is connected.
DISCONNECTING 3 The device is being disconnected.

ContinuationMode(deprecated)

Enumerates the continuation modes provided by the device selection module.

NOTE

This API has been deprecated since API version 22. You are advised to use DeviceStateChange instead.

Atomic service API: This API can be used in atomic services since API version 11.

Model restriction: This API can be used only in the stage model.

System capability: SystemCapability.Ability.DistributedAbilityManager

Name Value Description
COLLABORATION_SINGLE 0 Single-choice mode.
COLLABORATION_MULTIPLE 1 Multi-choice mode.

ContinuationResult(deprecated)

type ContinuationResult = _ContinuationResult

Defines the device information returned by the continuation management entry.

NOTE

This API has been supported since API version 10 and deprecated since API version 22. You are advised to use DeviceBasicInfo instead.

Atomic service API: This API can be used in atomic services since API version 11.

Model restriction: This API can be used only in the stage model.

System capability: SystemCapability.Ability.DistributedAbilityManager

Type Description
_ContinuationResult Device information returned by the continuation management entry.

ContinuationExtraParams(deprecated)

type ContinuationExtraParams = _ContinuationExtraParams

Defines the extra parameters required by the device selection module in the continuation management entry.

NOTE

This API has been supported since API version 10 and deprecated since API version 22. You are advised to use DeviceBasicInfo instead.

Atomic service API: This API can be used in atomic services since API version 11.

Model restriction: This API can be used only in the stage model.

System capability: SystemCapability.Ability.DistributedAbilityManager

Type Description
_ContinuationExtraParams Extra parameters required by the device selection module in the continuation management entry.