From 1304bcd6da8c0602c13dfa38e9fe24fecb9f6c12 Mon Sep 17 00:00:00 2001 From: ql Date: Sat, 28 May 2022 03:07:07 +0000 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=90=AF=E5=8A=A8=E8=BF=9C?= =?UTF-8?q?=E7=AB=AFservice=20Signed-off-by:=20ql=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../application-dev/ability/fa-serviceability.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/zh-cn/application-dev/ability/fa-serviceability.md b/zh-cn/application-dev/ability/fa-serviceability.md index f5605b17f9..8bb7531a2b 100644 --- a/zh-cn/application-dev/ability/fa-serviceability.md +++ b/zh-cn/application-dev/ability/fa-serviceability.md @@ -94,6 +94,21 @@ let promise = featureAbility.startAbility( - 如果Service尚未运行,则系统会先调用onStart()来初始化Service,再回调Service的onCommand()方法来启动Service。 - 如果Service正在运行,则系统会直接回调Service的onCommand()方法来启动Service。 +启动远端设备Service的代码示例如下(getRemoteDeviceId()方法详见连接远程Service): + +```javascript +import featureAbility from '@ohos.ability.featureAbility'; +let promise = featureAbility.startAbility( + { + want: + { + deviceId: getRemoteDeviceId(), //远端设备Id + bundleName: "com.jstest.service", + abilityName: "com.jstest.service.ServiceAbility", + }, + } +); +``` ### 停止Service -- GitLab