Tobi Tobi -4 years ago 284
Android Question

Android: How to get current Wifi encryption?

I have a listener listening for connectivity changes, especially from GSM to WIFI.
Now I would like to log which WIFIs the user connects to, especially the encryption type (none, WEP, WPA, WPA2, ...) of the WIFI.

The listener works perfectly, but I can't find any way to get the current Wifi's encryption type.

Thanks for your help.

Answer Source

Use WifiManager to obtain details of the current connection, and then obtain a WifiConfiguration which should give you further information.

WifiManager wifiManager= (WifiManager) getSystemService(Context.WIFI_SERVICE);
WifiInfo wi = WifiManager.getConnectionInfo();
if( wi != null )
    WifiConfiguration activeConfig = null;
    for( WifiConfiguration conn : wifiManager.getConfiguredNetworks() )
        if( conn.status == WifiConfiguration.Status.CURRENT )
            activeConfig = conn;
    if( activeConfig != null )
        // Analyse encryption of connected network here.
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download