Search code examples
androidandroid-wifiandroid-4.2-jelly-beanssid

Jelly Bean Issue - wifiManager.getConnectionInfo().getSSID() - extra ""


Hi all bug reporting for your information. link

Problem details:

The Code - wifiManager.getConnectionInfo().getSSID()

The above code to returns the current SSID, it is returning the current SSID with extra quotations around it.

For eg. the SSID internet is returned as "internet".

This is only seen on Jelly bean 4.2 using device Nexus 7.

This bug is causing errors in our app as we compare the current SSID with the SSID that we are trying to connect too.

The code wifiManager.getScanResults(); however still returns all SSID's without extra quotation marks.



Solution

  • this is not a bug and behavior is correct as per documentation at http://developer.android.com/reference/android/net/wifi/WifiInfo.html#getSSID()

    The so-called bug apparently was in pre 4.2 devices, because they didn't return it with "" enclosure.

    Aiden's method looks good to me in the current state of confusion left by Android. However, being theoritically correct would just require

    if (ssid.startsWith("\"") && ssid.endsWith("\"")){
                 ssid = ssid.substring(1, ssid.length()-1);
    }