Android: How to get current Wifi encryption?

I have a listener that listens for communication changes, especially from GSM to WIFI. Now I would like to register with which WIFI the user is connecting, especially the type of encryption (no, WEP, WPA, WPA2, ...) WIFI.

The listener works fine, but I cannot find a way to get the current type of Wifi encryption.

Thanks for your help.

+6
source share
1 answer

Use WifiManager to get information about the current connection, and then get WifiConfiguration , which should provide you with additional 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. } } 
+7
source

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


All Articles