From 98d1107b762cdbffa6fc1849f73f6b81e9a1d509 Mon Sep 17 00:00:00 2001 From: zengyawen Date: Wed, 22 Feb 2023 03:26:18 +0000 Subject: [PATCH] =?UTF-8?q?=E3=80=90vod=E4=BF=AE=E6=94=B9=E3=80=91?= =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=96=B9=E6=B3=95=E6=AC=A1=E5=BA=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zengyawen --- .../reference/apis/js-apis-net-connection.md | 60 +++++++++---------- 1 file changed, 30 insertions(+), 30 deletions(-) diff --git a/zh-cn/application-dev/reference/apis/js-apis-net-connection.md b/zh-cn/application-dev/reference/apis/js-apis-net-connection.md index 955a1c086f..3df21e05a7 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-net-connection.md +++ b/zh-cn/application-dev/reference/apis/js-apis-net-connection.md @@ -110,6 +110,36 @@ connection.getDefaultNet().then(function (data) { }) ``` +## connection.getDefaultNetSync9+ + +getDefaultNetSync(): NetHandle + +使用同步方法获取默认激活的数据网络。可以使用[getNetCapabilities](#connectiongetnetcapabilities)去获取网络的类型、拥有的能力等信息。 + +**需要权限**:ohos.permission.GET_NETWORK_INFO + +**系统能力**:SystemCapability.Communication.NetManager.Core + +**返回值:** + +| 类型 | 说明 | +| --------- | ---------------------------------- | +| NetHandle | 以同步方式返回默认激活的数据网络。 | + +**错误码:** + +| 错误码ID | 错误信息 | +| ------- | ----------------------------- | +| 201 | Permission denied. | +| 2100002 | Operation failed. Cannot connect to service.| +| 2100003 | System internal error. | + +**示例:** + +```js +let netHandle = connection.getDefaultNetSync(); +``` + ## connection.getGlobalHttpProxy10+ getGlobalHttpProxy(callback: AsyncCallback\): void @@ -406,36 +436,6 @@ connection.getDefaultNet().then(function (netHandle) { }) ``` -## connection.getDefaultNetSync9+ - -getDefaultNetSync(): NetHandle; - -使用同步方法获取默认激活的数据网络。可以使用[getNetCapabilities](#connectiongetnetcapabilities)去获取网络的类型、拥有的能力等信息。 - -**需要权限**:ohos.permission.GET_NETWORK_INFO - -**系统能力**:SystemCapability.Communication.NetManager.Core - -**返回值:** - -| 类型 | 说明 | -| --------- | ---------------------------------- | -| NetHandle | 以同步方式返回默认激活的数据网络。 | - -**错误码:** - -| 错误码ID | 错误信息 | -| ------- | ----------------------------- | -| 201 | Permission denied. | -| 2100002 | Operation failed. Cannot connect to service.| -| 2100003 | System internal error. | - -**示例:** - -```js -let netHandle = connection.getDefaultNetSync(); -``` - ## connection.getAllNets getAllNets(callback: AsyncCallback<Array<NetHandle>>): void -- GitLab