I am looking for a software way for Android to determine if my device’s WIFI is currently connected to “secure” using WEP, WPA or WPA2. I tried a google search and I cannot find a programmatic way to determine this. I also looked at TelephonyManager ( http://developer.android.com/reference/android/telephony/TelephonyManager.html ) which also lacks this information.
Thanks J
There is a way to use the ScanResult object.
Something like that:
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 } } } }
Literature:
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: determining the security type of Wi-Fi networks in a range (without connecting to them)
Interpreting ScanResult Features
Refer to the AccessPointState class in this project . The method you are looking for is getScanResultSecurity .
AccessPointState
getScanResultSecurity
Hope this helps!
Source: https://habr.com/ru/post/983441/More articles:Any way to extend two or more classes in java? - javasave data in DB problem by getting NULL on console - javascriptSwift: Enum 'cannot be constructed because it does not have initializers available' - enumsIs it best to drop the temp table after using it in addition to creating the temp table? - sql-serverwindow.devicePixelRatio change listener - javascriptMultiple inheritance without multiple inheritance and without code duplication - javaHow to add an application to a test suite in ALM OTA via C #? - c #What is the preferred method for creating, using and deleting temporary tables in sql server? - sql-serverHow to reference a web service from an ASP.NET MVC project? - c #how to get class from jquery datatable string object? - jqueryAll Articles