Android - detect if wifi is WEP, WPA, WPA2, etc. Programmatically

I am looking for a software way for Android to determine if my device’s WIFI is currently connected to “secure” using WEP, WPA or WPA2. I tried a google search and I cannot find a programmatic way to determine this. I also looked at TelephonyManager ( http://developer.android.com/reference/android/telephony/TelephonyManager.html ) which also lacks this information.

Thanks J

+6
source share
2 answers

There is a way to use the ScanResult object.

Something like that:

WifiManager wifi = (WifiManager) getSystemService(Context.WIFI_SERVICE); List<ScanResult> networkList = wifi.getScanResults(); //get current connected SSID for comparison to ScanResult WifiInfo wi = wifi.getConnectionInfo(); String currentSSID = wi.getSSID(); if (networkList != null) { for (ScanResult network : networkList) { //check if current connected SSID if (currentSSID.equals(network.SSID)){ //get capabilities of current connection String Capabilities = network.capabilities; Log.d (TAG, network.SSID + " capabilities : " + Capabilities); if (Capabilities.contains("WPA2")) { //do something } else if (Capabilities.contains("WPA")) { //do something } else if (Capabilities.contains("WEP")) { //do something } } } } 

Literature:

http://developer.android.com/reference/android/net/wifi/WifiManager.html#getScanResults ()

http://developer.android.com/reference/android/net/wifi/ScanResult.html#capabilities

http://developer.android.com/reference/android/net/wifi/WifiInfo.html

android: determining the security type of Wi-Fi networks in a range (without connecting to them)

Interpreting ScanResult Features

+9
source

Refer to the AccessPointState class in this project . The method you are looking for is getScanResultSecurity .

Hope this helps!

+4
source

Source: https://habr.com/ru/post/983441/


All Articles