Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Docs
提交
75aaa5ed
D
Docs
项目概览
OpenHarmony
/
Docs
1 年多 前同步成功
通知
159
Star
292
Fork
28
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
Docs
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
75aaa5ed
编写于
9月 04, 2023
作者:
O
openharmony_ci
提交者:
Gitee
9月 04, 2023
浏览文件
操作
浏览文件
下载
差异文件
!23727 【分布式DM--monthly_20230815】鸿蒙指南文档ArkTS适配
Merge pull request !23727 from qinlong/monthly_20230815
上级
78e5ac30
0b720145
变更
2
展开全部
隐藏空白更改
内联
并排
Showing
2 changed file
with
767 addition
and
284 deletion
+767
-284
zh-cn/application-dev/reference/apis/js-apis-device-manager.md
.../application-dev/reference/apis/js-apis-device-manager.md
+516
-191
zh-cn/application-dev/reference/apis/js-apis-distributedDeviceManager.md
...on-dev/reference/apis/js-apis-distributedDeviceManager.md
+251
-93
未找到文件。
zh-cn/application-dev/reference/apis/js-apis-device-manager.md
浏览文件 @
75aaa5ed
此差异已折叠。
点击以展开。
zh-cn/application-dev/reference/apis/js-apis-distributedDeviceManager.md
浏览文件 @
75aaa5ed
...
@@ -18,7 +18,7 @@
...
@@ -18,7 +18,7 @@
## 导入模块
## 导入模块
```
j
s
```
t
s
import
deviceManager
from
'
@ohos.distributedDeviceManager
'
;
import
deviceManager
from
'
@ohos.distributedDeviceManager
'
;
```
```
...
@@ -45,11 +45,15 @@ createDeviceManager(bundleName: string): DeviceManager;
...
@@ -45,11 +45,15 @@ createDeviceManager(bundleName: string): DeviceManager;
**示例:**
**示例:**
```
js
```
ts
import
deviceManager
from
'
@ohos.distributedDeviceManager
'
import
{
BusinessError
}
from
'
@ohos.base
'
try
{
try
{
let
dmInstance
=
deviceManager
.
createDeviceManager
(
"
ohos.samples.jshelloworld
"
);
let
dmInstance
=
deviceManager
.
createDeviceManager
(
"
ohos.samples.jshelloworld
"
);
}
catch
(
err
)
{
}
catch
(
err
)
{
console
.
error
(
"
createDeviceManager errCode:
"
+
err
.
code
+
"
,errMessage:
"
+
err
.
message
);
let
e
:
BusinessError
=
err
as
BusinessError
;
console
.
error
(
"
createDeviceManager errCode:
"
+
e
.
code
+
"
,errMessage:
"
+
e
.
message
);
}
}
```
```
...
@@ -79,11 +83,14 @@ releaseDeviceManager(deviceManager: DeviceManager): void;
...
@@ -79,11 +83,14 @@ releaseDeviceManager(deviceManager: DeviceManager): void;
**示例:**
**示例:**
```
js
```
ts
import
{
BusinessError
}
from
'
@ohos.base
'
try
{
try
{
deviceManager
.
releaseDeviceManager
(
dmInstance
);
deviceManager
.
releaseDeviceManager
(
dmInstance
);
}
catch
(
err
)
{
}
catch
(
err
)
{
console
.
error
(
"
release device manager errCode:
"
+
err
.
code
+
"
,errMessage:
"
+
err
.
message
);
let
e
:
BusinessError
=
err
as
BusinessError
;
console
.
error
(
"
release device manager errCode:
"
+
e
.
code
+
"
,errMessage:
"
+
e
.
message
);
}
}
```
```
...
@@ -143,11 +150,15 @@ getAvailableDeviceListSync(): Array<DeviceBasicInfo>;
...
@@ -143,11 +150,15 @@ getAvailableDeviceListSync(): Array<DeviceBasicInfo>;
**示例:**
**示例:**
```
js
```
ts
import
deviceManager
from
'
@ohos.distributedDeviceManager
'
import
{
BusinessError
}
from
'
@ohos.base
'
try
{
try
{
var
deviceInfoList
=
dmInstance
.
getAvailableDeviceListSync
();
let
deviceInfoList
:
Array
<
deviceManager
.
eviceBasicInfo
>
=
dmInstance
.
getAvailableDeviceListSync
();
}
catch
(
err
)
{
}
catch
(
err
)
{
console
.
error
(
"
getAvailableDeviceListSync errCode:
"
+
err
.
code
+
"
,errMessage:
"
+
err
.
message
);
let
e
:
BusinessError
=
err
as
BusinessError
;
console
.
error
(
"
getAvailableDeviceListSync errCode:
"
+
e
.
code
+
"
,errMessage:
"
+
e
.
message
);
}
}
```
```
...
@@ -177,9 +188,12 @@ getAvailableDeviceList(callback:AsyncCallback<Array<DeviceBasicInfo>>
...
@@ -177,9 +188,12 @@ getAvailableDeviceList(callback:AsyncCallback<Array<DeviceBasicInfo>>
**示例:**
**示例:**
```
js
```
ts
import
deviceManager
from
'
@ohos.distributedDeviceManager
'
import
{
BusinessError
}
from
'
@ohos.base
'
try
{
try
{
dmInstance
.
getAvailableDeviceList
((
err
,
data
)
=>
{
dmInstance
.
getAvailableDeviceList
((
err
:
BusinessError
,
data
:
Array
<
deviceManager
.
DeviceBasicInfo
>
)
=>
{
if
(
err
)
{
if
(
err
)
{
console
.
error
(
"
getAvailableDeviceList errCode:
"
+
err
.
code
+
"
,errMessage:
"
+
err
.
message
);
console
.
error
(
"
getAvailableDeviceList errCode:
"
+
err
.
code
+
"
,errMessage:
"
+
err
.
message
);
return
;
return
;
...
@@ -187,7 +201,8 @@ getAvailableDeviceList(callback:AsyncCallback<Array<DeviceBasicInfo>>
...
@@ -187,7 +201,8 @@ getAvailableDeviceList(callback:AsyncCallback<Array<DeviceBasicInfo>>
console
.
log
(
'
get available device info:
'
+
JSON
.
stringify
(
data
));
console
.
log
(
'
get available device info:
'
+
JSON
.
stringify
(
data
));
});
});
}
catch
(
err
)
{
}
catch
(
err
)
{
console
.
error
(
"
getAvailableDeviceList errCode:
"
+
err
.
code
+
"
,errMessage:
"
+
err
.
message
);
let
e
:
BusinessError
=
err
as
BusinessError
;
console
.
error
(
"
getAvailableDeviceList errCode:
"
+
e
.
code
+
"
,errMessage:
"
+
e
.
message
);
}
}
```
```
...
@@ -217,10 +232,13 @@ getAvailableDeviceList(): Promise<Array<DeviceBasicInfo>>;
...
@@ -217,10 +232,13 @@ getAvailableDeviceList(): Promise<Array<DeviceBasicInfo>>;
**示例:**
**示例:**
```
js
```
ts
dmInstance
.
getAvailableDeviceList
().
then
((
data
)
=>
{
import
deviceManager
from
'
@ohos.distributedDeviceManager
'
import
{
BusinessError
}
from
'
@ohos.base
'
dmInstance
.
getAvailableDeviceList
().
then
((
data
:
Array
<
deviceManager
.
DeviceBasicInfo
>
)
=>
{
console
.
log
(
'
get available device info:
'
+
JSON
.
stringify
(
data
));
console
.
log
(
'
get available device info:
'
+
JSON
.
stringify
(
data
));
}).
catch
((
err
)
=>
{
}).
catch
((
err
:
BusinessError
)
=>
{
console
.
error
(
"
getAvailableDeviceList errCode:
"
+
err
.
code
+
"
,errMessage:
"
+
err
.
message
);
console
.
error
(
"
getAvailableDeviceList errCode:
"
+
err
.
code
+
"
,errMessage:
"
+
err
.
message
);
});
});
```
```
...
@@ -251,12 +269,15 @@ getLocalDeviceNetworkId(): string;
...
@@ -251,12 +269,15 @@ getLocalDeviceNetworkId(): string;
**示例:**
**示例:**
```
js
```
ts
import
{
BusinessError
}
from
'
@ohos.base
'
try
{
try
{
var
deviceNetworkId
=
dmInstance
.
getLocalDeviceNetworkId
();
let
deviceNetworkId
:
string
=
dmInstance
.
getLocalDeviceNetworkId
();
console
.
log
(
'
local device networkId:
'
+
JSON
.
stringify
(
deviceNetworkId
));
console
.
log
(
'
local device networkId:
'
+
JSON
.
stringify
(
deviceNetworkId
));
}
catch
(
err
)
{
}
catch
(
err
)
{
console
.
error
(
"
getLocalDeviceNetworkId errCode:
"
+
err
.
code
+
"
,errMessage:
"
+
err
.
message
);
let
e
:
BusinessError
=
err
as
BusinessError
;
console
.
error
(
"
getLocalDeviceNetworkId errCode:
"
+
e
.
code
+
"
,errMessage:
"
+
e
.
message
);
}
}
```
```
...
@@ -286,12 +307,15 @@ getLocalDeviceName(): string;
...
@@ -286,12 +307,15 @@ getLocalDeviceName(): string;
**示例:**
**示例:**
```
js
```
ts
import
{
BusinessError
}
from
'
@ohos.base
'
try
{
try
{
var
deviceName
=
dmInstance
.
getLocalDeviceName
();
let
deviceName
:
string
=
dmInstance
.
getLocalDeviceName
();
console
.
log
(
'
local device name:
'
+
JSON
.
stringify
(
deviceName
));
console
.
log
(
'
local device name:
'
+
JSON
.
stringify
(
deviceName
));
}
catch
(
err
)
{
}
catch
(
err
)
{
console
.
error
(
"
getLocalDeviceName errCode:
"
+
err
.
code
+
"
,errMessage:
"
+
err
.
message
);
let
e
:
BusinessError
=
err
as
BusinessError
;
console
.
error
(
"
getLocalDeviceName errCode:
"
+
e
.
code
+
"
,errMessage:
"
+
e
.
message
);
}
}
```
```
...
@@ -321,12 +345,15 @@ getLocalDeviceType(): number;
...
@@ -321,12 +345,15 @@ getLocalDeviceType(): number;
**示例:**
**示例:**
```
js
```
ts
import
{
BusinessError
}
from
'
@ohos.base
'
try
{
try
{
var
deviceType
=
dmInstance
.
getLocalDeviceType
();
let
deviceType
:
number
=
dmInstance
.
getLocalDeviceType
();
console
.
log
(
'
local device type:
'
+
JSON
.
stringify
(
deviceType
));
console
.
log
(
'
local device type:
'
+
JSON
.
stringify
(
deviceType
));
}
catch
(
err
)
{
}
catch
(
err
)
{
console
.
error
(
"
getLocalDeviceType errCode:
"
+
err
.
code
+
"
,errMessage:
"
+
err
.
message
);
let
e
:
BusinessError
=
err
as
BusinessError
;
console
.
error
(
"
getLocalDeviceType errCode:
"
+
e
.
code
+
"
,errMessage:
"
+
e
.
message
);
}
}
```
```
...
@@ -356,12 +383,15 @@ getLocalDeviceId(): string;
...
@@ -356,12 +383,15 @@ getLocalDeviceId(): string;
**示例:**
**示例:**
```
js
```
ts
import
{
BusinessError
}
from
'
@ohos.base
'
try
{
try
{
var
deviceId
=
dmInstance
.
getLocalDeviceId
();
let
deviceId
:
string
=
dmInstance
.
getLocalDeviceId
();
console
.
log
(
'
local device id:
'
+
JSON
.
stringify
(
deviceId
));
console
.
log
(
'
local device id:
'
+
JSON
.
stringify
(
deviceId
));
}
catch
(
err
)
{
}
catch
(
err
)
{
console
.
error
(
"
getLocalDeviceId errCode:
"
+
err
.
code
+
"
,errMessage:
"
+
err
.
message
);
let
e
:
BusinessError
=
err
as
BusinessError
;
console
.
error
(
"
getLocalDeviceId errCode:
"
+
e
.
code
+
"
,errMessage:
"
+
e
.
message
);
}
}
```
```
...
@@ -397,14 +427,17 @@ getDeviceName(networkId: string): string;
...
@@ -397,14 +427,17 @@ getDeviceName(networkId: string): string;
**示例:**
**示例:**
```
js
```
ts
import
{
BusinessError
}
from
'
@ohos.base
'
try
{
try
{
// 设备网络标识,可以从可信设备列表中获取
// 设备网络标识,可以从可信设备列表中获取
let
networkId
=
"
xxxxxxx
"
let
networkId
=
"
xxxxxxx
"
var
deviceName
=
dmInstance
.
getDeviceName
(
networkId
);
let
deviceName
:
string
=
dmInstance
.
getDeviceName
(
networkId
);
console
.
log
(
'
device name:
'
+
JSON
.
stringify
(
deviceName
));
console
.
log
(
'
device name:
'
+
JSON
.
stringify
(
deviceName
));
}
catch
(
err
)
{
}
catch
(
err
)
{
console
.
error
(
"
getDeviceName errCode:
"
+
err
.
code
+
"
,errMessage:
"
+
err
.
message
);
let
e
:
BusinessError
=
err
as
BusinessError
;
console
.
error
(
"
getDeviceName errCode:
"
+
e
.
code
+
"
,errMessage:
"
+
e
.
message
);
}
}
```
```
...
@@ -440,14 +473,17 @@ getDeviceType(networkId: string): number;
...
@@ -440,14 +473,17 @@ getDeviceType(networkId: string): number;
**示例:**
**示例:**
```
js
```
ts
import
{
BusinessError
}
from
'
@ohos.base
'
try
{
try
{
// 设备网络标识,可以从可信设备列表中获取
// 设备网络标识,可以从可信设备列表中获取
let
networkId
=
"
xxxxxxx
"
let
networkId
=
"
xxxxxxx
"
var
deviceType
=
dmInstance
.
getDeviceType
(
networkId
);
let
deviceType
:
number
=
dmInstance
.
getDeviceType
(
networkId
);
console
.
log
(
'
device type:
'
+
JSON
.
stringify
(
deviceType
));
console
.
log
(
'
device type:
'
+
JSON
.
stringify
(
deviceType
));
}
catch
(
err
)
{
}
catch
(
err
)
{
console
.
error
(
"
getDeviceType errCode:
"
+
err
.
code
+
"
,errMessage:
"
+
err
.
message
);
let
e
:
BusinessError
=
err
as
BusinessError
;
console
.
error
(
"
getDeviceType errCode:
"
+
e
.
code
+
"
,errMessage:
"
+
e
.
message
);
}
}
```
```
...
@@ -479,20 +515,36 @@ startDiscovering(discoverParam: {[key: string]: Object} , filterOption
...
@@ -479,20 +515,36 @@ startDiscovering(discoverParam: {[key: string]: Object} , filterOption
**示例:**
**示例:**
```
js
```
ts
var
discoverParam
=
{
import
{
BusinessError
}
from
'
@ohos.base
'
'
discoverTargetType
'
:
1
interface
DiscoverParam
{
discoverTargetType
:
number
}
interface
FilterOptions
{
availableStatus
:
number
,
discoverDistance
:
number
,
authenticationStatus
:
number
,
authorizationType
:
number
}
let
discoverParam
:
DiscoverParam
=
{
discoverTargetType
:
1
};
};
var
filterOptions
=
{
'
availableStatus
'
:
1
,
let
filterOptions
:
FilterOptions
=
{
'
discoverDistance
'
:
50
,
availableStatus
:
1
,
'
authenticationStatus
'
:
0
,
discoverDistance
:
50
,
'
authorizationType
'
:
0
authenticationStatus
:
0
,
authorizationType
:
0
};
};
try
{
try
{
dmInstance
.
startDiscovering
(
discoverParam
,
filterOptions
);
// 当有设备发现时,通过discoverSuccess回调通知给应用程序
dmInstance
.
startDiscovering
(
discoverParam
,
filterOptions
);
// 当有设备发现时,通过discoverSuccess回调通知给应用程序
}
catch
(
err
)
{
}
catch
(
err
)
{
console
.
error
(
"
startDiscovering errCode:
"
+
err
.
code
+
"
,errMessage:
"
+
err
.
message
);
let
e
:
BusinessError
=
err
as
BusinessError
;
console
.
error
(
"
startDiscovering errCode:
"
+
e
.
code
+
"
,errMessage:
"
+
e
.
message
);
}
}
```
```
...
@@ -517,11 +569,14 @@ stopDiscovering(): void;
...
@@ -517,11 +569,14 @@ stopDiscovering(): void;
**示例:**
**示例:**
```
js
```
ts
import
{
BusinessError
}
from
'
@ohos.base
'
try
{
try
{
dmInstance
.
stopDiscovering
();
dmInstance
.
stopDiscovering
();
}
catch
(
err
)
{
}
catch
(
err
)
{
console
.
error
(
"
stopDiscovering errCode:
"
+
err
.
code
+
"
,errMessage:
"
+
err
.
message
);
let
e
:
BusinessError
=
err
as
BusinessError
;
console
.
error
(
"
stopDiscovering errCode:
"
+
e
.
code
+
"
,errMessage:
"
+
e
.
message
);
}
}
```
```
...
@@ -554,18 +609,32 @@ bindTarget(deviceId: string, bindParam: {[key: string]: Object} , call
...
@@ -554,18 +609,32 @@ bindTarget(deviceId: string, bindParam: {[key: string]: Object} , call
**示例:**
**示例:**
```
js
```
ts
import
{
BusinessError
}
from
'
@ohos.base
'
class
Data
{
deviceId
:
string
=
""
}
interface
BindParam
{
bindType
:
number
,
// 认证类型: 1 - 无帐号PIN码认证
targetPkgName
:
string
,
appName
:
string
,
appOperation
:
string
,
customDescription
:
string
}
// 认证的设备信息,可以从发现的结果中获取
// 认证的设备信息,可以从发现的结果中获取
var
deviceId
=
"
XXXXXXXX
"
;
let
deviceId
=
"
XXXXXXXX
"
;
let
bindParam
=
{
let
bindParam
:
BindParam
=
{
'
bindType
'
:
1
,
// 认证类型: 1 - 无帐号PIN码认证
bindType
:
1
,
// 认证类型: 1 - 无帐号PIN码认证
'
targetPkgName
'
:
'
xxxx
'
,
targetPkgName
:
'
xxxx
'
,
'
appName
'
:
'
xxxx
'
,
appName
:
'
xxxx
'
,
'
appOperation
'
:
'
xxxx
'
,
appOperation
:
'
xxxx
'
,
'
customDescription
'
:
'
xxxx
'
customDescription
:
'
xxxx
'
}
}
try
{
try
{
dmInstance
.
bindTarget
(
deviceId
,
bindParam
,
(
err
,
d
ata
)
=>
{
dmInstance
.
bindTarget
(
deviceId
,
bindParam
,
(
err
:
BusinessError
,
data
:
D
ata
)
=>
{
if
(
err
)
{
if
(
err
)
{
console
.
error
(
"
bindTarget errCode:
"
+
err
.
code
+
"
,errMessage:
"
+
err
.
message
);
console
.
error
(
"
bindTarget errCode:
"
+
err
.
code
+
"
,errMessage:
"
+
err
.
message
);
return
;
return
;
...
@@ -573,7 +642,8 @@ bindTarget(deviceId: string, bindParam: {[key: string]: Object} , call
...
@@ -573,7 +642,8 @@ bindTarget(deviceId: string, bindParam: {[key: string]: Object} , call
console
.
info
(
"
bindTarget result:
"
+
JSON
.
stringify
(
data
));
console
.
info
(
"
bindTarget result:
"
+
JSON
.
stringify
(
data
));
});
});
}
catch
(
err
)
{
}
catch
(
err
)
{
console
.
error
(
"
bindTarget errCode:
"
+
err
.
code
+
"
,errMessage:
"
+
err
.
message
);
let
e
:
BusinessError
=
err
as
BusinessError
;
console
.
error
(
"
bindTarget errCode:
"
+
e
.
code
+
"
,errMessage:
"
+
e
.
message
);
}
}
```
```
...
@@ -603,12 +673,15 @@ unbindTarget(deviceId: string): void;
...
@@ -603,12 +673,15 @@ unbindTarget(deviceId: string): void;
**示例:**
**示例:**
```
js
```
ts
import
{
BusinessError
}
from
'
@ohos.base
'
try
{
try
{
var
deviceId
=
"
XXXXXXXX
"
;
let
deviceId
=
"
XXXXXXXX
"
;
dmInstance
.
unbindTarget
(
deviceId
);
dmInstance
.
unbindTarget
(
deviceId
);
}
catch
(
err
)
{
}
catch
(
err
)
{
console
.
error
(
"
unbindTarget errCode:
"
+
err
.
code
+
"
,errMessage:
"
+
err
.
message
);
let
e
:
BusinessError
=
err
as
BusinessError
;
console
.
error
(
"
unbindTarget errCode:
"
+
e
.
code
+
"
,errMessage:
"
+
e
.
message
);
}
}
```
```
...
@@ -633,7 +706,9 @@ replyUiAction(action: number, actionResult: string): void;
...
@@ -633,7 +706,9 @@ replyUiAction(action: number, actionResult: string): void;
**示例:**
**示例:**
```
js
```
ts
import
{
BusinessError
}
from
'
@ohos.base
'
try
{
try
{
/*
/*
action = 0 - 允许授权
action = 0 - 允许授权
...
@@ -646,7 +721,8 @@ replyUiAction(action: number, actionResult: string): void;
...
@@ -646,7 +721,8 @@ replyUiAction(action: number, actionResult: string): void;
let
operation
=
0
;
let
operation
=
0
;
dmInstance
.
replyUiAction
(
operation
,
"
extra
"
)
dmInstance
.
replyUiAction
(
operation
,
"
extra
"
)
}
catch
(
err
)
{
}
catch
(
err
)
{
console
.
error
(
"
replyUiAction errCode:
"
+
err
.
code
+
"
,errMessage:
"
+
err
.
message
);
let
e
:
BusinessError
=
err
as
BusinessError
;
console
.
error
(
"
replyUiAction errCode:
"
+
e
.
code
+
"
,errMessage:
"
+
e
.
message
);
}
}
```
```
...
@@ -671,16 +747,27 @@ on(type: 'replyResult', callback: Callback<{ param: string}>): void;
...
@@ -671,16 +747,27 @@ on(type: 'replyResult', callback: Callback<{ param: string}>): void;
**示例:**
**示例:**
```
js
```
ts
import
{
BusinessError
}
from
'
@ohos.base
'
class
Data
{
param
:
string
=
""
}
interface
TmpStr
{
verifyFailed
:
boolean
}
try
{
try
{
dmInstance
.
on
(
'
replyResult
'
,
(
data
)
=>
{
dmInstance
.
on
(
'
replyResult
'
,
(
data
:
Data
)
=>
{
console
.
log
(
"
replyResult executed, dialog closed
"
+
JSON
.
stringify
(
data
))
console
.
log
(
"
replyResult executed, dialog closed
"
+
JSON
.
stringify
(
data
))
var
t
mpStr
=
JSON
.
parse
(
data
.
param
)
let
tmpStr
:
T
mpStr
=
JSON
.
parse
(
data
.
param
)
var
isShow
=
tmpStr
.
verifyFailed
let
isShow
=
tmpStr
.
verifyFailed
console
.
log
(
"
replyResult executed, dialog closed
"
+
isShow
)
console
.
log
(
"
replyResult executed, dialog closed
"
+
isShow
)
});
});
}
catch
(
err
)
{
}
catch
(
err
)
{
console
.
error
(
"
replyResult errCode:
"
+
err
.
code
+
"
,errMessage:
"
+
err
.
message
);
let
e
:
BusinessError
=
err
as
BusinessError
;
console
.
error
(
"
replyResult errCode:
"
+
e
.
code
+
"
,errMessage:
"
+
e
.
message
);
}
}
```
```
...
@@ -705,11 +792,14 @@ off(type: 'replyResult', callback?: Callback<{ param: string}>): void;
...
@@ -705,11 +792,14 @@ off(type: 'replyResult', callback?: Callback<{ param: string}>): void;
**示例:**
**示例:**
```
js
```
ts
import
{
BusinessError
}
from
'
@ohos.base
'
try
{
try
{
dmInstance
.
off
(
'
replyResult
'
);
dmInstance
.
off
(
'
replyResult
'
);
}
catch
(
err
)
{
}
catch
(
err
)
{
console
.
error
(
"
replyResult errCode:
"
+
err
.
code
+
"
,errMessage:
"
+
err
.
message
);
let
e
:
BusinessError
=
err
as
BusinessError
;
console
.
error
(
"
replyResult errCode:
"
+
e
.
code
+
"
,errMessage:
"
+
e
.
message
);
}
}
```
```
...
@@ -732,13 +822,22 @@ on(type: 'deviceStateChange', callback: Callback<{ action: DeviceStateChange,
...
@@ -732,13 +822,22 @@ on(type: 'deviceStateChange', callback: Callback<{ action: DeviceStateChange,
**示例:**
**示例:**
```
js
```
ts
import
deviceManager
from
'
@ohos.distributedDeviceManager
'
import
{
BusinessError
}
from
'
@ohos.base
'
class
Data
{
action
:
deviceManager
.
DeviceStateChange
=
0
device
:
deviceManager
.
DeviceBasicInfo
=
{}
}
try
{
try
{
dmInstance
.
on
(
'
deviceStateChange
'
,
(
data
)
=>
{
dmInstance
.
on
(
'
deviceStateChange
'
,
(
data
:
Data
)
=>
{
console
.
info
(
"
deviceStateChange on:
"
+
JSON
.
stringify
(
data
));
console
.
info
(
"
deviceStateChange on:
"
+
JSON
.
stringify
(
data
));
});
});
}
catch
(
err
)
{
}
catch
(
err
)
{
console
.
error
(
"
deviceStateChange errCode:
"
+
err
.
code
+
"
,errMessage:
"
+
err
.
message
);
let
e
:
BusinessError
=
err
as
BusinessError
;
console
.
error
(
"
deviceStateChange errCode:
"
+
e
.
code
+
"
,errMessage:
"
+
e
.
message
);
}
}
```
```
...
@@ -761,13 +860,22 @@ off(type: 'deviceStateChange', callback?: Callback<{ action: DeviceStateChang
...
@@ -761,13 +860,22 @@ off(type: 'deviceStateChange', callback?: Callback<{ action: DeviceStateChang
**示例:**
**示例:**
```
js
```
ts
import
deviceManager
from
'
@ohos.distributedDeviceManager
'
import
{
BusinessError
}
from
'
@ohos.base
'
class
Data
{
action
:
deviceManager
.
DeviceStateChange
=
0
device
:
deviceManager
.
DeviceBasicInfo
=
{}
}
try
{
try
{
dmInstance
.
off
(
'
deviceStatusChange
'
,
(
data
)
=>
{
dmInstance
.
off
(
'
deviceStatusChange
'
,
(
data
:
Data
)
=>
{
console
.
info
(
'
deviceStatusChange
'
+
JSON
.
stringify
(
data
));
console
.
info
(
'
deviceStatusChange
'
+
JSON
.
stringify
(
data
));
});
});
}
catch
(
err
)
{
}
catch
(
err
)
{
console
.
error
(
"
deviceStatusChange errCode:
"
+
err
.
code
+
"
,errMessage:
"
+
err
.
message
);
let
e
:
BusinessError
=
err
as
BusinessError
;
console
.
error
(
"
deviceStatusChange errCode:
"
+
e
.
code
+
"
,errMessage:
"
+
e
.
message
);
}
}
```
```
...
@@ -790,13 +898,21 @@ on(type: 'discoverSuccess', callback: Callback<{ device: DeviceBasicInfo }>
...
@@ -790,13 +898,21 @@ on(type: 'discoverSuccess', callback: Callback<{ device: DeviceBasicInfo }>
**示例:**
**示例:**
```
js
```
ts
import
deviceManager
from
'
@ohos.distributedDeviceManager
'
import
{
BusinessError
}
from
'
@ohos.base
'
class
Data
{
device
:
deviceManager
.
DeviceBasicInfo
=
{}
}
try
{
try
{
dmInstance
.
on
(
'
discoverSuccess
'
,
(
data
)
=>
{
dmInstance
.
on
(
'
discoverSuccess
'
,
(
data
:
Data
)
=>
{
console
.
info
(
"
discoverSuccess:
"
+
JSON
.
stringify
(
data
));
console
.
info
(
"
discoverSuccess:
"
+
JSON
.
stringify
(
data
));
});
});
}
catch
(
err
)
{
}
catch
(
err
)
{
console
.
error
(
"
discoverSuccess errCode:
"
+
err
.
code
+
"
,errMessage:
"
+
err
.
message
);
let
e
:
BusinessError
=
err
as
BusinessError
;
console
.
error
(
"
discoverSuccess errCode:
"
+
e
.
code
+
"
,errMessage:
"
+
e
.
message
);
}
}
```
```
...
@@ -819,13 +935,21 @@ off(type: 'discoverSuccess', callback?: Callback<{ device: DeviceBasicInfo }&
...
@@ -819,13 +935,21 @@ off(type: 'discoverSuccess', callback?: Callback<{ device: DeviceBasicInfo }&
**示例:**
**示例:**
```
js
```
ts
import
deviceManager
from
'
@ohos.distributedDeviceManager
'
import
{
BusinessError
}
from
'
@ohos.base
'
class
Data
{
device
:
deviceManager
.
DeviceBasicInfo
=
{}
}
try
{
try
{
dmInstance
.
off
(
'
discoverSuccess
'
,
(
data
)
=>
{
dmInstance
.
off
(
'
discoverSuccess
'
,
(
data
:
Data
)
=>
{
console
.
info
(
'
discoverSuccess
'
+
JSON
.
stringify
(
data
));
console
.
info
(
'
discoverSuccess
'
+
JSON
.
stringify
(
data
));
});
});
}
catch
(
err
)
{
}
catch
(
err
)
{
console
.
error
(
"
discoverSuccess errCode:
"
+
err
.
code
+
"
,errMessage:
"
+
err
.
message
);
let
e
:
BusinessError
=
err
as
BusinessError
;
console
.
error
(
"
discoverSuccess errCode:
"
+
e
.
code
+
"
,errMessage:
"
+
e
.
message
);
}
}
```
```
...
@@ -848,13 +972,20 @@ on(type: 'deviceNameChange', callback: Callback<{ deviceName: string }>):
...
@@ -848,13 +972,20 @@ on(type: 'deviceNameChange', callback: Callback<{ deviceName: string }>):
**示例:**
**示例:**
```
js
```
ts
import
{
BusinessError
}
from
'
@ohos.base
'
class
Data
{
deviceName
:
string
=
""
}
try
{
try
{
dmInstance
.
on
(
'
deviceNameChange
'
,
(
data
)
=>
{
dmInstance
.
on
(
'
deviceNameChange
'
,
(
data
:
Data
)
=>
{
console
.
info
(
"
deviceNameChange on:
"
+
JSON
.
stringify
(
data
));
console
.
info
(
"
deviceNameChange on:
"
+
JSON
.
stringify
(
data
));
});
});
}
catch
(
err
)
{
}
catch
(
err
)
{
console
.
error
(
"
deviceNameChange errCode:
"
+
err
.
code
+
"
,errMessage:
"
+
err
.
message
);
let
e
:
BusinessError
=
err
as
BusinessError
;
console
.
error
(
"
deviceNameChange errCode:
"
+
e
.
code
+
"
,errMessage:
"
+
e
.
message
);
}
}
```
```
...
@@ -877,13 +1008,20 @@ off(type: 'deviceNameChange', callback?: Callback<{ deviceName: string }>)
...
@@ -877,13 +1008,20 @@ off(type: 'deviceNameChange', callback?: Callback<{ deviceName: string }>)
**示例:**
**示例:**
```
js
```
ts
import
{
BusinessError
}
from
'
@ohos.base
'
class
Data
{
deviceName
:
string
=
""
}
try
{
try
{
dmInstance
.
off
(
'
deviceNameChange
'
,
(
data
)
=>
{
dmInstance
.
off
(
'
deviceNameChange
'
,
(
data
:
Data
)
=>
{
console
.
info
(
'
deviceNameChange
'
+
JSON
.
stringify
(
data
));
console
.
info
(
'
deviceNameChange
'
+
JSON
.
stringify
(
data
));
});
});
}
catch
(
err
)
{
}
catch
(
err
)
{
console
.
error
(
"
deviceNameChange errCode:
"
+
err
.
code
+
"
,errMessage:
"
+
err
.
message
);
let
e
:
BusinessError
=
err
as
BusinessError
;
console
.
error
(
"
deviceNameChange errCode:
"
+
e
.
code
+
"
,errMessage:
"
+
e
.
message
);
}
}
```
```
...
@@ -906,13 +1044,20 @@ on(type: 'discoverFailure', callback: Callback<{ reason: number }>): void;
...
@@ -906,13 +1044,20 @@ on(type: 'discoverFailure', callback: Callback<{ reason: number }>): void;
**示例:**
**示例:**
```
js
```
ts
import
{
BusinessError
}
from
'
@ohos.base
'
class
Data
{
reason
:
number
=
0
}
try
{
try
{
dmInstance
.
on
(
'
discoverFailure
'
,
(
data
)
=>
{
dmInstance
.
on
(
'
discoverFailure
'
,
(
data
:
Data
)
=>
{
console
.
info
(
"
discoverFailure on:
"
+
JSON
.
stringify
(
data
));
console
.
info
(
"
discoverFailure on:
"
+
JSON
.
stringify
(
data
));
});
});
}
catch
(
err
)
{
}
catch
(
err
)
{
console
.
error
(
"
discoverFailure errCode:
"
+
err
.
code
+
"
,errMessage:
"
+
err
.
message
);
let
e
:
BusinessError
=
err
as
BusinessError
;
console
.
error
(
"
discoverFailure errCode:
"
+
e
.
code
+
"
,errMessage:
"
+
e
.
message
);
}
}
```
```
...
@@ -935,13 +1080,20 @@ off(type: 'discoverFailure', callback?: Callback<{ reason: number }>): voi
...
@@ -935,13 +1080,20 @@ off(type: 'discoverFailure', callback?: Callback<{ reason: number }>): voi
**示例:**
**示例:**
```
js
```
ts
import
{
BusinessError
}
from
'
@ohos.base
'
class
Data
{
reason
:
number
=
0
}
try
{
try
{
dmInstance
.
off
(
'
discoverFailure
'
,
(
data
)
=>
{
dmInstance
.
off
(
'
discoverFailure
'
,
(
data
:
Data
)
=>
{
console
.
info
(
'
discoverFailure
'
+
JSON
.
stringify
(
data
));
console
.
info
(
'
discoverFailure
'
+
JSON
.
stringify
(
data
));
});
});
}
catch
(
err
)
{
}
catch
(
err
)
{
console
.
error
(
"
discoverFailure errCode:
"
+
err
.
code
+
"
,errMessage:
"
+
err
.
message
);
let
e
:
BusinessError
=
err
as
BusinessError
;
console
.
error
(
"
discoverFailure errCode:
"
+
e
.
code
+
"
,errMessage:
"
+
e
.
message
);
}
}
```
```
...
@@ -964,13 +1116,16 @@ on(type: 'serviceDie', callback?: Callback<{}>): void;
...
@@ -964,13 +1116,16 @@ on(type: 'serviceDie', callback?: Callback<{}>): void;
**示例:**
**示例:**
```
js
```
ts
import
{
BusinessError
}
from
'
@ohos.base
'
try
{
try
{
dmInstance
.
on
(
"
serviceDie
"
,
()
=>
{
dmInstance
.
on
(
"
serviceDie
"
,
()
=>
{
console
.
info
(
"
serviceDie on
"
);
console
.
info
(
"
serviceDie on
"
);
});
});
}
catch
(
err
)
{
}
catch
(
err
)
{
console
.
error
(
"
serviceDie errCode:
"
+
err
.
code
+
"
,errMessage:
"
+
err
.
message
);
let
e
:
BusinessError
=
err
as
BusinessError
;
console
.
error
(
"
serviceDie errCode:
"
+
e
.
code
+
"
,errMessage:
"
+
e
.
message
);
}
}
```
```
...
@@ -993,13 +1148,16 @@ off(type: 'serviceDie', callback?: Callback<{}>): void;
...
@@ -993,13 +1148,16 @@ off(type: 'serviceDie', callback?: Callback<{}>): void;
**示例:**
**示例:**
```
js
```
ts
import
{
BusinessError
}
from
'
@ohos.base
'
try
{
try
{
dmInstance
.
off
(
"
serviceDie
"
,
()
=>
{
dmInstance
.
off
(
"
serviceDie
"
,
()
=>
{
console
.
info
(
"
serviceDie off
"
);
console
.
info
(
"
serviceDie off
"
);
});
});
}
catch
(
err
)
{
}
catch
(
err
)
{
console
.
error
(
"
serviceDie errCode:
"
+
err
.
code
+
"
,errMessage:
"
+
err
.
message
);
let
e
:
BusinessError
=
err
as
BusinessError
;
console
.
error
(
"
serviceDie errCode:
"
+
e
.
code
+
"
,errMessage:
"
+
e
.
message
);
}
}
```
```
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录