get SSID from WifiManager - Android android.net.wifi

Android examples for android.net.wifi:Wifi SSID

Description

get SSID from WifiManager

Demo Code

import android.net.wifi.WifiManager;

public class Main{

    public static String getSSID(WifiManager wifiManager) {
        if (wifiManager == null)
            return null;

        if (!wifiManager.isWifiEnabled())
            return null;

        String ssid = wifiManager.getConnectionInfo().getSSID();
        if (ssid.startsWith("\"") && ssid.endsWith("\"")) {
            ssid = ssid.substring(1, ssid.length() - 1);
        }/*from ww w.  j a va  2  s .c  om*/

        return ssid;
    }


}

Related Tutorials