Wednesday, 15 February 2012

Android WiFiManager - Occasionally throwing error when setWiFiEnabled is used -


Has anyone experienced any problems where

  I / WifiManager (22480) : SetWifiEnabled: True E / WiFi Manager (22480): java.lang.Throughable E / WifiManager (22480): at android.net.wifi.WifiManager.setWifiEnabled (WifiManager.java:959)   < P> I think it's going to hit / miss when Wi-Fi radio is turned on or off via the Android API. It is being used in the bottom function:  
  Public Static Zero Management WiFiRadio (Reference Reference, String On Off) {Log D. (Tag, "Manager WiFiRadio (Reference," + On + ")"); {WifiManager = (WifiManager) try context.getSystemService (Context.WIFI_SERVICE); Thread.Sleep (250); If (onoff == "on") {if WifiManager.isWifiEnabled ()) {Thread.sleep (250); WifiManager.setWifiEnabled (true); } And Log D. (Tag, "WiFi is already" + onoff); } And if (onoff == "off") {if (wifiManager.isWifiEnabled ()) {Thread.sleep (250); WifiManager.setWifiEnabled (wrong); } And Log D. (Tag, "WiFi is already" + onoff); }} Hold (exception e) {log d. (The tag, "was an exception in WiFi:" + E);} WiFi Manager = Faucet; }   

I have put sleeping above for debugging but only reducing the fertility rate.

For testing, I have done it on Sprint Samsung Galaxy S III and there is a Sprint HTC AVO 4G and both have problems. When the error is thrown, it is caught inside the Android OS, but Wi-Fi radio can never change the state.

change

  thread. Sleep (250); WifiManager.setWifiEnabled (wrong);   

to

  wifiManager.setWifiEnabled (wrong); Thread.Sleep (250);    

No comments:

Post a Comment