gpt4 book ai didi

android - SupplicantState COMPLETED 但 DetailedState OBTAINING_IPADDR 实际连接到 Wifi 时?

转载 作者:太空狗 更新时间:2023-10-29 14:41:16 24 4
gpt4 key购买 nike

我使用的是 API 级别 27,但在 6.0 平板电脑上运行我的应用程序。这是可疑代码:

WifiManager wm = (WifiManager)pContext.getSystemService(Context.WIFI_SERVICE);
WifiInfo wi = wm.getConnectionInfo();
SupplicantState ss = wi.getSupplicantState();
NetworkInfo.DetailedState ds = wi.getDetailedStateOf( ss );
String ssid = wi.getSSID();
int ip = wi.getIpAddress();

我的平板电脑已连接(我在 WiFi 面板中看到“已连接”)到笔记本电脑上创建的临时网络。没有互联网接入。

ssCOMPLETED

dsOBTAINING_IPADDR

ip-745953088 (192.168.137.211)

为什么 DetailedState 设置为 OBTAINING_IPADDR 而不是 CONNECTED

最佳答案

查看类 android.net.wifi.WifiInfo

static {
stateMap.put(SupplicantState.DISCONNECTED, DetailedState.DISCONNECTED);
stateMap.put(SupplicantState.INTERFACE_DISABLED, DetailedState.DISCONNECTED);
stateMap.put(SupplicantState.INACTIVE, DetailedState.IDLE);
stateMap.put(SupplicantState.SCANNING, DetailedState.SCANNING);
stateMap.put(SupplicantState.AUTHENTICATING, DetailedState.CONNECTING);
stateMap.put(SupplicantState.ASSOCIATING, DetailedState.CONNECTING);
stateMap.put(SupplicantState.ASSOCIATED, DetailedState.CONNECTING);
stateMap.put(SupplicantState.FOUR_WAY_HANDSHAKE, DetailedState.AUTHENTICATING);
stateMap.put(SupplicantState.GROUP_HANDSHAKE, DetailedState.AUTHENTICATING);
stateMap.put(SupplicantState.COMPLETED, DetailedState.OBTAINING_IPADDR);
stateMap.put(SupplicantState.DORMANT, DetailedState.DISCONNECTED);
stateMap.put(SupplicantState.UNINITIALIZED, DetailedState.IDLE);
stateMap.put(SupplicantState.INVALID, DetailedState.FAILED);
}

您可以看到 DetailedState.CONNECTED 没有映射到任何 SupplicantState 值。不知道为什么..

使用 SupplicantState 而不是 DetailedState 来检查状态是否已连接。

关于android - SupplicantState COMPLETED 但 DetailedState OBTAINING_IPADDR 实际连接到 Wifi 时?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47892204/

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