简体   繁体   English

android - 如何在没有密码的情况下检查设备是否已连接到wifi?

[英]android - how to check if device has connected to wifi without password?

I am building a feature that warns user if the wifi that the device is connected to has no password.我正在构建一个功能,如果设备连接的 wifi 没有密码,它会警告用户。 Is that possible?那可能吗?

I've read this https://developer.android.com/reference/android/net/NetworkCapabilities我读过这个https://developer.android.com/reference/android/net/NetworkCapabilities

and this https://developer.android.com/reference/android/net/wifi/WifiManager和这个https://developer.android.com/reference/android/net/wifi/WifiManager

And it seems I can get all the data I want ( SSID , BSSID etc) but can't answer the main question: did the wifi require password or not.似乎我可以获得我想要的所有数据( SSIDBSSID等),但无法回答主要问题:wifi 是否需要密码。

It requires root access.它需要root访问权限。 If you have super user privilege you can use WifiManager -> getPrivilegedConfiguredNetworks to get the WiFi connectivity configs and check if the password is blank.如果您有超级用户权限,您可以使用WifiManager -> getPrivilegedConfiguredNetworks来获取 WiFi 连接配置并检查密码是否为空。 Refer to here .请参阅此处

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM