diff --git a/zh-cn/application-dev/ability/stage-call.md b/zh-cn/application-dev/ability/stage-call.md index 47369f84914869dacf09e69ac4fdcde2c9fd457f..a276484e8f37b91ce14c077721a73f3a75c9bd2f 100644 --- a/zh-cn/application-dev/ability/stage-call.md +++ b/zh-cn/application-dev/ability/stage-call.md @@ -134,8 +134,7 @@ context.startAbilityByCall({ console.error(TAG + 'get caller failed with ' + error) }) ``` - 在跨设备场景下,需指定对端设备deviceId,具体获取接口参照[DeviceManager](https://gitee.com/openharmony/device_manager/blob/master/README_zh.md)。应用开发者 - 根据实际需要做相应处理。具体示例代码如下: +在跨设备场景下,需指定对端设备deviceId。应用开发者 根据实际需要做相应处理。具体示例代码如下: ```ts let TAG = '[MainAbility] ' var caller = undefined @@ -159,7 +158,23 @@ context.startAbilityByCall({ console.error(TAG + 'get remote caller failed with ' + error) }) ``` - 在跨设备场景下,需要向用户申请数据同步的权限。具体示例代码如下: +从DeviceManager获取指定设备的deviceId,具体示例代码如下: +```ts +function getRemoteDeviceId() { + if (typeof dmClass === 'object' && dmClass != null) { + var list = dmClass.getTrustedDeviceListSync(); + if (typeof (list) == 'undefined' || typeof (list.length) == 'undefined') { + console.log("MainAbility onButtonClick getRemoteDeviceId err: list is null"); + return; + } + console.log("MainAbility onButtonClick getRemoteDeviceId success:" + list[0].deviceId); + return list[0].deviceId; + } else { + console.log("MainAbility onButtonClick getRemoteDeviceId err: dmClass is null"); + } +} +``` +在跨设备场景下,需要向用户申请数据同步的权限。具体示例代码如下: ```ts let context = this.context let permissions = ohos.permission.DISTRIBUTED_DATASYNC