Reputation: 2688
I am trying to compare the SSID of the connected wifi to the one I want it connect to. So I am using the following code:
WifiInfo wifiInfo = returnedWifiManager.getConnectionInfo();
String ssid = wifiInfo.getSSID().toString();
if (ssid.equalsIgnoreCase("MarkV")) {
Toast.makeText(WalkitalkiMainActivity.this,
"Connected to: " + ssid, Toast.LENGTH_SHORT).show();
}
when I debug, I find the right SSID name, but the Toast inside the if statement never execute. What is the problem ?
Upvotes: 1
Views: 888
Reputation: 642
I just found the solution to this problem. The reason is ssid has double quotation marks around it. So you have to check like this.
if(ssid.equals("\"MarkV\"")){//or ssid.equalsIgnoreCase("\"MarkV\"")
//Do
}
else{
//Else do
}
Upvotes: 1