Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 952
Tobi Avatar asked Jun 16 '11 12:06

Tobi


People also ask

How do I check my Wi-Fi encryption status?

To check on an Android phone, go into Settings, then open the Wi-Fi category. Select the router you're connected to and view its details. It will state what security type your connection is.

What is the latest Wi-Fi encryption?

WPA3 (Wi-Fi Protected Access 3) is the newest wireless security protocol designed to encrypt data using a frequent and automatic encryption type called Perfect Forward Secrecy. It's more secure than its predecessor, WPA2, but it hasn't been widely adopted yet.


1 Answers

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;
            break;
        }
    }
    if( activeConfig != null )
    {
        // Analyse encryption of connected network here.
    }
}
like image 92
Mark Allison Avatar answered Oct 10 '22 10:10

Mark Allison