4

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?

Android Developer
  • 9,157
  • 18
  • 82
  • 139

1 Answers1

4

See ScanResult.capabilities

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