Monday, 15 July 2013

Crash when detect wifi state at android.net.wifi.STATE_CHANGE -


I want to get the wifi state , when there is a change in the wifi status:

Clear:

  & lt; Intent-Filter & gt; & Lt; Action Android: name = "android.net.wifi.STATE_CHANGE" /> & Lt; / Intent-Filter & gt;  

Service:

  Wifi manager chief wifia obz; Override public zero at @Receive (reference reference, intent to intent) {WifiInfo wifiInfo = mainWifiObj.getConnectionInfo (); String WifiState = ""; If (mainWifiObj.isWifiEnabled ()) {WifiState = "WiFi On"; } And {wifiastat = "wifi off"; }}  

but it crashes on WifiInfo wifiInfo = mainWifiObj.getConnectionInfo (); What's wrong?

You have not initiated the WifiManager object on this method obtained in this way

Main WiFiobject = (Wifi Manager) Reference. Gate System System (Reference. WIFI_SERVICE);

No comments:

Post a Comment