Search code examples
androidpositionwireless

check if wireless is on (even if not connected to any network)


Can I check if the wireless is enabled, even if not connected to any network. I need wireless enabled to get more accurate gps readings. But I don't need to be concede to any of the networks (It seams that unless wi-fi is active, the device can not use networks for positioning). For data transfer I will use the mobile network.

So, How do I check if wireless is activated?


Solution

  • public boolean isWifiOn() {
         WifiManager wifi = (WifiManager) getSystemService(Context.WIFI_SERVICE);
         return wifi.isWifiEnabled();
    }