From e5497c6e02510a435d81d2a1412d98a3ebce528f Mon Sep 17 00:00:00 2001 From: xinking129 Date: Mon, 8 May 2023 11:02:10 +0800 Subject: [PATCH] fix review Signed-off-by: xinking129 --- .../hop-multi-device-collaboration.md | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/zh-cn/application-dev/application-models/hop-multi-device-collaboration.md b/zh-cn/application-dev/application-models/hop-multi-device-collaboration.md index a423efcbf4..ca1085fa85 100644 --- a/zh-cn/application-dev/application-models/hop-multi-device-collaboration.md +++ b/zh-cn/application-dev/application-models/hop-multi-device-collaboration.md @@ -273,26 +273,22 @@ getRemoteDeviceId方法参照[通过跨设备启动uiability和serviceextensionability组件实现多端协同无返回数据](#通过跨设备启动uiability和serviceextensionability组件实现多端协同无返回数据)。 -5. 断开连接。调用disconnectServiceExtensionAbility()断开与后台服务的连接。 +5. 断开连接或退出远端ServiceExtensionAbility ```ts + // 断开与ServiceExtensionAbility的链接时,可以使用disconnectServiceExtensionAbility接口断开与后台服务的连接。 let connectionId = 1 // 在通过connectServiceExtensionAbility绑定服务时返回的Id this.context.disconnectServiceExtensionAbility(connectionId).then((data) => { console.info('disconnectServiceExtensionAbility success'); }).catch((error) => { console.error('disconnectServiceExtensionAbility failed'); }) - ``` - -6. 退出远端ServiceExtensionAbility。调用[stopServiceExtensionAbility](../reference/apis/js-apis-inner-application-serviceExtensionContext.md#serviceextensioncontextstopserviceextensionability)接口不只是断开与ServiceExtensionAbility之间的链接, 还会退出由connectServiceExtensionAbility接口拉起的跨设备ServiceExtensionAbility。 - - ```ts + // 退出由connectServiceExtensionAbility接口拉起的跨设备ServiceExtensionAbility时,可以调用stopServiceExtensionAbility退出ServiceExtensionAbility let want = { "deviceId": getRemoteDeviceId(), "bundleName": "com.example.myapplication", "abilityName": "ServiceExtAbility" }; - // 退出由connectServiceExtensionAbility接口跨设备启动的ServiceExtensionAbility this.context.stopServiceExtensionAbility(want).then(() => { console.info("stop service extension ability success") }).catch((err) => { -- GitLab