gpt4 book ai didi

android - Android 10.0如何获取WIFI SSID?

转载 作者:行者123 更新时间:2023-11-29 02:18:40 27 4
gpt4 key购买 nike

Android 9.0&8.0获取SSID没有问题
但我无法在 Android 10.0(Q) 中获取 SSID。
我应该怎么做? Android 10.0 中有关 wifi 的文档链接在哪里?我试图找到该文档,但找不到。

Android 9.0&8.0获取SSID没有问题

WifiManager mWifiManager = (WifiManager) context.getApplicationContext().getSystemService(Context.WIFI_SERVICE);
assert mWifiManager != null;
WifiInfo info = mWifiManager.getConnectionInfo();
return info.getSSID();
ConnectivityManager connManager = (ConnectivityManager) context.getApplicationContext().getSystemService(Context.CONNECTIVITY_SERVICE);
assert connManager != null;
NetworkInfo networkInfo = connManager.getActiveNetworkInfo();
if (networkInfo.isConnected()) {
if (networkInfo.getExtraInfo() != null) {
return networkInfo.getExtraInfo().replace("\"", "");
}
}

最佳答案

它要get.check原帖

From android 8.0 onwards we wont be getting SSID of the connected network unless GPS is turned on.

Get SSID when WIFI is connected

WifiManager mWifiManager = (WifiManager) context.getApplicationContext().getSystemService(Context.WIFI_SERVICE);
assert mWifiManager != null;
WifiInfo info = mWifiManager.getConnectionInfo();
return info.getSSID();

关于android - Android 10.0如何获取WIFI SSID?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57953137/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com