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.
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.
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.
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.
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With