0

I have trying to do something when I get to know that in my wifilist this SSID is present

My code is somewhat :

List<ScanResult> wifilist = wifi.getScanResults();

for(int i=0;i<wifilist.size();i++){
 if (wifilist.get(i).SSID.equals("Wifi1")){

                        // Do somthing  
                      }
}

Where Wifi1 is name of the wifi network.

But I m not able to do so as if it seem wifilist.get(i).SSID isn't able to compare it to "Wifi1". If you can tell me where I am wrong

3 Answers3

0
     WifiManager mWifiManager;

   List<ScanResult> mScanResults = mWifiManager.getScanResults();

    for(ScanResult results : mScanResults) {

        Log.d("SSID  result", results.SSID);

        if (results.SSID.equals("WIFI NAME")) {

            break;
        }


    }
sherin
  • 1,091
  • 2
  • 17
  • 27
0

What does wifilist.get(i).SSID.getClass() say? If it isn't java.lang.String, then you most probably need to call .toString() and you're done.

maaartinus
  • 44,714
  • 32
  • 161
  • 320
0

SSID has double quotation marks. Instead of

SSID.equals("Wifi1")

you should use

SSID.equals("\"Wifi1\"")
kmchmk
  • 592
  • 9
  • 16