In my app I am getting all available WiFi networks and displaying them in a list using WifiManager.startScan() and WifiManager.getScanResults().Also I am able to show signal strength.But I don't know how to show whether wifi is locked or not.In the Settings screen it shows lock icon for wifi which are locked.How can i know whether wifi is password protected?
            Asked
            
        
        
            Active
            
        
            Viewed 1,874 times
        
    4
            
            
        
        Android Developer
        
- 9,157
 - 18
 - 82
 - 139
 
1 Answers
4
            An example is: [WPA-PSK-TKIP+CCMP][WPA2-PSK-TKIP-CCMP][WPS][ESS]
See this answer if you want to find a way of parsing it.
Basically, if you want to get if it is protected or not:
boolean isProtected = AccessPointState.getScanResultSecurity(scanResult) != AccessPointState.OPEN;
(although it is not nice to compare Strings with the == operator, this will always return the correct answer because the reference in AccessPointState is a static final one)
        Community
        
- 1
 - 1
 
        Daniel Zolnai
        
- 16,487
 - 7
 - 59
 - 71
 
- 
                    so I have to copy AccessPointState from ggogle project and add in my project? – Android Developer Jan 13 '16 at 15:17
 - 
                    You don't have to. Probably it is enough to copy that one method and the constants. – Daniel Zolnai Jan 13 '16 at 15:26
 - 
                    so if scanresults capabilites contains "PSK","WEP" or "EAP" that means wifi is password protected? – Android Developer Jan 13 '16 at 15:36