开发者

Wifi reports as "enabled" even though it's not

I'm not sure if this is a Galaxy Tab specific issue or if I'm not utilizing some relevant method of the WifiManager library, but my application correctly reports that the Wifi is disabled at launch, but t开发者_如何学Gohen as soon as I enable it, it deems itself as enabled, even though it's still in the process of connecting.

So, I have a thread in which I'm waiting for the enabled state

//at THIS line it claims to be WIFI_STATE_DISABLED so I turn it on with...
wifiManager.setEnabled(true);
//and at this line it reports as 3 (which according to the doc is WIFI_STATE_ENABLED, even though it clearly isn't
while(wifiManager.getWifiState() == WifiManager.WIFI_STATE_DISABLED || wifiManager.getWifiState() == WifiManager.WIFI_STATE_ENABLING){

but it never never enters the loop, it just jumps right past even though it is NOT enabled

I'm hoping there's some other mechanism that I'm missing, or maybe I'm misunderstanding what "enabled" means?


The WifiManager.WIFI_STATE_ENABLED only tells you, that the wifi device has been turned on. It does not tell you if a connection to a wireless network has been established.

Take a look at the android.net.ConnectivityManager.getActiveNetworkInfo(). This function will return a NetworkState. With the NetworkState.getState() function you can check if a connection is really available.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜