• Home
Name Date Size #Lines LOC

..--

AppScope/12-May-2024-3633

entry/12-May-2024-1,7291,603

screenshots/device/12-May-2024-

.gitignoreD12-May-2024143 1211

README.mdD12-May-20241.1 KiB2010

README_zh.mdD12-May-20243.1 KiB5127

build-profile.json5D12-May-20241,017 4140

hvigorfile.tsD12-May-2024158 21

package.jsonD12-May-2024368 1918

README.md

1#  WLAN
2
3### Introduction
4
5This sample shows how to use WLAN with eTS, including disabling and enabling the WLAN, scanning the WLAN and obtaining the scanning result, listening for WLAN status and Wi-Fi connection status, obtaining the IP address, country code, and checking whether the device supports WLAN features.
6
7### Usage
8
91. After the app is started, it checks whether the WLAN is activated. If it is activated, the app scans for available Wi-Fi networks and displays the list of available and connected Wi-Fi networks.
10
112. Touch the toggle on the page to enable or disable the WLAN. The device listens for the WLAN statue, scans for available Wi-Fi networks, and displays the connected Wi-Fi network.
12
133. Touch a Wi-Fi network in the list of available Wi-Fi networks to connect to the Wi-Fi network. If the Wi-Fi network is encrypted, a dialog box will be displayed asking you to enter the password.
14
154. Touch **About** in the upper right corner of the home page. The obtained IP address, country code, and supported WLAN features are displayed.
16
17### Constraints
18
19This sample can only be run on standard-system devices.
20

README_zh.md

1# WLAN
2
3### 介绍
4
5本示例通过@ohos.wifiManager相关API实现wlan激活、扫描和连接WIFI等功能。
6
7使用说明
8
91. 启动应用后会判断WLAN是否激活,如果是激活状态,会扫描并展示可用WiFi列表,同时获取已连接WiFi信息并展示。
10
112. 点击界面的Switch开关可以禁用和激活WLAN,界面会监听WLAN状态扫描可用WiFi列表,也会监听WiFi连接状态展示已连接WiFi。
12
133. 点击可用WLAN列表中的WLAN信息,可以连接WiFi,如果是加密类型,会弹窗输入密码后连接。
14
154. 点击首页右上角的**关于**图标,进入关于界面,展示获取的IP信息、国家码和支持WLAN相关特性信息。
16
17### 效果预览
18
19|连接wifi                                     |主页                                     |wifi详情                                 |
20|---------------------------------------------|---------------------------------------|-----------------------------------------|
21|![password](screenshots/device/connect.png)|![password](screenshots/device/main.png)|![password](screenshots/device/detail.png)|
22
23### 相关权限
24
25[ohos.permission.GET_WIFI_INFO](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/security/permission-list.md#ohospermissionget_wifi_info)
26
27[ohos.permission.GET_WIFI_INFO_INTERNAL](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/security/permission-list.md#ohospermissionget_wifi_info_internal)
28
29[ohos.permission.SET_WIFI_INFO](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/security/permission-list.md#ohospermissionset_wifi_info)
30
31[ohos.permission.GET_WIFI_CONFIG](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/security/permission-list.md#ohospermissionget_wifi_config)
32
33[ohos.permission.SET_WIFI_CONFIG](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/security/permission-list.md#ohospermissionset_wifi_config)
34
35[ohos.permission.MANAGE_WIFI_CONNECTION](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/security/permission-list.md#ohospermissionmanage_wifi_connection)
36
37[ohos.permission.APPROXIMATELY_LOCATION](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/security/permission-list.md#ohospermissionapproximately_location)
38
39### 依赖
40
41不涉及。
42
43### 约束与限制
44
451.本示例仅支持标准系统上运行。
46
472.本示例需要使用DevEco Studio 3.1 Canary1 (Build Version: 3.1.0.100, built on November 3, 2022)才可编译运行。
48
493.本示例需要使用@ohos.wifi系统权限的系统接口。使用Full SDK时需要手动从镜像站点获取,并在DevEco Studio中替换,具体操作可参考[替换指南](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/quick-start/full-sdk-switch-guide.md)50
514.本示例需要使用ohos.permission.GET_WIFI_INFO_INTERNALohos.permission.MANAGE_WIFI_CONNECTION的权限为system_core级别(相关权限级别可通过[权限定义列表](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/security/permission-list.md) 查看),需要手动配置对应级别的权限签名。