Mr.Noob
Mr.Noob

Reputation: 1005

How to obtain wifi security type of current wifi network in android

Is there a way to obtain the wifi security type of the network that the device is currently connected. I know that wifi security could be obtained by scanning network. but is it possible without scanning so that I can get it for the current wifi network??

Upvotes: 4

Views: 2126

Answers (1)

Hanelore Ianoseck
Hanelore Ianoseck

Reputation: 614

You need to use the ScanResult.capabilities to see the security type of a network. You can use this without actually scanning for networks, using something like:

WifiManager wifi = (WifiManager) getSystemService(Context.WIFI_SERVICE);
List<ScanResult> networkList = wifi.getScanResults();
if (networkList != null) {
    for (ScanResult network : networkList)
    {
        String Capabilities =  network.capabilities;        
        Log.w (TAG, network.SSID + " capabilities : " + Capabilities);
    }
}

Upvotes: 3

Related Questions