Android - detecting if wifi is WEP, WPA, WPA2, etc. programmatically

Jon

I am looking for a programmatic way on Android to determine whether the WIFI my device is currently connected to is "secured" using either WEP, WPA, or WPA2. I've tried Google searching and I cannot find a programmatic way to determine this. I've also looked at the TelephonyManager (http://developer.android.com/reference/android/telephony/TelephonyManager.html) which also lacks this information.

Thanks, J

Daniel Nugent

There is a way using the ScanResult object.

Something like this:

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
            }
        }
    }
}

References:

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: Determine security type of wifi networks in range (without connecting to them)

ScanResult capabilities interpretation

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

How to get WiFi security (NONE, WEP, WPA, WPA2) from Android WifiConfiguration entry?

From Dev

How to connect android device to "WPA2 PSK" secured wifi hotspot network programmatically?

From Dev

How to confirm/verify WiFi is WPA2?

From Dev

Ubuntu 14.04 Server - WiFi WPA2 Personal

From Dev

Ubuntu 14.04 Server - WiFi WPA2 Personal

From Dev

wifi connection down intermittently (only with WPA2)

From Dev

"Wifi network not secure" notification with WPA2 Personal

From Dev

Connect to WEP/WPA without nmcli?

From Dev

How to enable WPA/WPA2 in NetworkManager?

From Dev

How do I configure Ubuntu Server to access a WPA2 Enterprise WiFi Access Point?

From Dev

After upgrade to 15.10 Wifi to a corporate network (WPA2) is not working anymore

From Dev

WiFi / WLAN: WPA2 authentication appears to be successful, but dhclient won't get a response

From Dev

After upgrade to 15.10 Wifi to a corporate network (WPA2) is not working anymore

From Dev

How do I configure Ubuntu Server to access a WPA2 Enterprise WiFi Access Point?

From Dev

Xubuntu 12.10 wifi won't connect to wpa2 enterprise network

From Dev

how to connect to WPA2 enterprise WiFi in Ubuntu Core Raspberry Pi 3

From Dev

Connecting to a WPA2 network

From Dev

What does WPA/WPA2 really encrypt?

From Dev

WPA vs. WPA2: Exception for one device?

From Dev

Problem with setting up WPA2 personal with wpa_supplicant

From Dev

WPA2 / wpa_supplicant wireless hotspot logs

From Dev

Cannot connect to WPA2/WPA Enterprise (PEAP and MSCHAP)

From Dev

How to connect to WPA_EAP WIFI on Android with 4.3 API

From Dev

wpa_supplicant wifi-direct connection between Linux and Android

From Dev

Retrieve the WPA2 Enterprise username in iOS

From Dev

ddwrt and wpa2 KRACK patch or update?

From Dev

Eavesdropping on a WPA2 (PSK) network

From Dev

Windows XP will not connect to WPA2

From Dev

Connecting to WPA2 network from console

Related Related

  1. 1

    How to get WiFi security (NONE, WEP, WPA, WPA2) from Android WifiConfiguration entry?

  2. 2

    How to connect android device to "WPA2 PSK" secured wifi hotspot network programmatically?

  3. 3

    How to confirm/verify WiFi is WPA2?

  4. 4

    Ubuntu 14.04 Server - WiFi WPA2 Personal

  5. 5

    Ubuntu 14.04 Server - WiFi WPA2 Personal

  6. 6

    wifi connection down intermittently (only with WPA2)

  7. 7

    "Wifi network not secure" notification with WPA2 Personal

  8. 8

    Connect to WEP/WPA without nmcli?

  9. 9

    How to enable WPA/WPA2 in NetworkManager?

  10. 10

    How do I configure Ubuntu Server to access a WPA2 Enterprise WiFi Access Point?

  11. 11

    After upgrade to 15.10 Wifi to a corporate network (WPA2) is not working anymore

  12. 12

    WiFi / WLAN: WPA2 authentication appears to be successful, but dhclient won't get a response

  13. 13

    After upgrade to 15.10 Wifi to a corporate network (WPA2) is not working anymore

  14. 14

    How do I configure Ubuntu Server to access a WPA2 Enterprise WiFi Access Point?

  15. 15

    Xubuntu 12.10 wifi won't connect to wpa2 enterprise network

  16. 16

    how to connect to WPA2 enterprise WiFi in Ubuntu Core Raspberry Pi 3

  17. 17

    Connecting to a WPA2 network

  18. 18

    What does WPA/WPA2 really encrypt?

  19. 19

    WPA vs. WPA2: Exception for one device?

  20. 20

    Problem with setting up WPA2 personal with wpa_supplicant

  21. 21

    WPA2 / wpa_supplicant wireless hotspot logs

  22. 22

    Cannot connect to WPA2/WPA Enterprise (PEAP and MSCHAP)

  23. 23

    How to connect to WPA_EAP WIFI on Android with 4.3 API

  24. 24

    wpa_supplicant wifi-direct connection between Linux and Android

  25. 25

    Retrieve the WPA2 Enterprise username in iOS

  26. 26

    ddwrt and wpa2 KRACK patch or update?

  27. 27

    Eavesdropping on a WPA2 (PSK) network

  28. 28

    Windows XP will not connect to WPA2

  29. 29

    Connecting to WPA2 network from console

HotTag

Archive