0

I create an WifiNetwork class that holds information about Wifis networks.

I have the method:

public static WifiNetwork fromScanResult(ScanResult scanResult) {
    String capabilities = scanResult.capabilities;
    String ssid = scanResult.SSID;
    String bssid = scanResult.BSSID;
    int frequency = scanResult.frequency;
    int level = scanResult.level;
    long timestamp = 0L;
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
        timestamp = scanResult.timestamp;
    }
    return new WifiNetwork(capabilities, ssid, bssid, frequency, level, timestamp);
}

That converts an ScanResult into my object.

I need another method populate my object from a WifiInfo:

public static WifiNetwork fromWifiInfo (WifiInfo wifiInfo){
....
}

The WifiInfo object is obtained by:

WifiManager wifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
wifiManager.getConnectionInfo()

From ScanResult, the security mode (if the network is WEP, WAP, etc) is getted by scanResult.capabilities();

But I cannot see an equivalent in WifiInfo.

Is there another way to get the security mode from the active Wifi Connection?

alexpfx
  • 6,412
  • 12
  • 52
  • 88
  • to prevent your question from downvoting I edited its content, but next prevent from asking vital question in subject unless you want to be ignored and downvoted. – Marcin Orlowski Aug 02 '15 at 23:54
  • I don't understand what means "vital question"? – alexpfx Aug 03 '15 at 00:14
  • From WifiInfo, you can get the SSID, map it with your ScanResult, then you can refer to this link to get security mode http://stackoverflow.com/questions/6866153/android-determine-security-type-of-wifi-networks-in-range-without-connecting-t/7019338#7019338 – justHooman Aug 03 '15 at 01:39

0 Answers0