Example usage for android.net.wifi WifiInfo getSSID

List of usage examples for android.net.wifi WifiInfo getSSID

Introduction

In this page you can find the example usage for android.net.wifi WifiInfo getSSID.

Prototype

public String getSSID() 

Source Link

Document

Returns the service set identifier (SSID) of the current 802.11 network.

Usage

From source file:Main.java

public static String getSSID() {

    WifiManager wifi = (WifiManager) mContext.getSystemService(Context.WIFI_SERVICE);
    WifiInfo info = wifi.getConnectionInfo();
    if (info.getSSID() == null) {
        return null;
    } else {//from   w  w w  .j a  v  a  2  s  . c om
        return info.getSSID();
    }
}

From source file:Main.java

static public String get_wifi_ssid(Context context) {
    final WifiManager wifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
    final WifiInfo wifiInfo = wifiManager.getConnectionInfo();
    return wifiInfo.getSSID();
}

From source file:Main.java

public static String getSSID(Context context) {

    WifiManager wifi = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
    WifiInfo info = wifi.getConnectionInfo();
    if (info.getSSID() == null) {
        return null;
    } else {//from   w ww.j a v a  2 s . com
        return info.getSSID();
    }
}

From source file:Main.java

public static String getConnectWifiSsid(Context context) {
    if (isWifiConnected(context)) {
        WifiManager wifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
        WifiInfo wifiInfo = wifiManager.getConnectionInfo();
        return wifiInfo.getSSID();
    }//  w w  w  .  ja va  2s  . c  o  m
    return null;
}

From source file:Main.java

public static String getCurrentSSID(Context context) {
    WifiManager wifiMan = (WifiManager) (context.getSystemService(Context.WIFI_SERVICE));
    WifiInfo wifiInfo = wifiMan.getConnectionInfo();

    if (wifiInfo != null)
        return wifiInfo.getSSID();
    else//from www  .j a va  2s .co m
        return null;
}

From source file:Main.java

public static String getCurrentWifiSSID(Context context) {
    if (context == null) {
        return "";
    }//  w ww .  j a  v  a2s  .com
    WifiManager wifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
    WifiInfo info = wifiManager.getConnectionInfo();
    if (info != null) {
        return info.getSSID() == null ? "" : info.getSSID();
    } else {
        return "";
    }
}

From source file:Main.java

public static String getSSid(Context ctx) {
    WifiManager wm = (WifiManager) ctx.getSystemService(Context.WIFI_SERVICE);
    if (wm != null) {
        WifiInfo wi = wm.getConnectionInfo();
        if (wi != null) {
            String s = wi.getSSID();
            if (s.length() > 2 && s.charAt(0) == '"' && s.charAt(s.length() - 1) == '"') {
                return s.substring(1, s.length() - 1);
            }/*from ww w.java 2s .  c  o  m*/
        }
    }
    return "";
}

From source file:Main.java

public static String getCurrentSsid(Context context) {
    String ssid = null;/*from ww w . j  av a  2 s  .  co  m*/
    ConnectivityManager connManager = (ConnectivityManager) context
            .getSystemService(Context.CONNECTIVITY_SERVICE);
    NetworkInfo networkInfo = connManager.getNetworkInfo(ConnectivityManager.TYPE_WIFI);
    if (networkInfo.isConnected()) {
        final WifiManager wifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
        final WifiInfo connectionInfo = wifiManager.getConnectionInfo();
        if (connectionInfo != null && connectionInfo.getSSID() != null
                && !connectionInfo.getSSID().equals("")) {
            ssid = connectionInfo.getSSID();
        }
    }
    return ssid == null ? ssid : ssid.replace("\"", "");
}

From source file:Main.java

public static String getWifiName(Context ctx) {
    WifiManager wifiManager = (WifiManager) ctx.getSystemService(Context.WIFI_SERVICE);
    WifiInfo wifiInfo = wifiManager.getConnectionInfo();
    Log.d("wifiInfo", wifiInfo.toString());
    Log.d("SSID", wifiInfo.getSSID());
    return wifiInfo.getSSID();
}

From source file:Main.java

public static String getWifiName(Context context) {
    Log.v(TAG, "-- Calling WIFI NAME --");
    if (context != null) {
        ConnectivityManager conMgr = (ConnectivityManager) context
                .getSystemService(Context.CONNECTIVITY_SERVICE);
        WifiManager wifiMgr = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
        if (conMgr.getNetworkInfo(ConnectivityManager.TYPE_WIFI).isConnectedOrConnecting()) {
            WifiInfo wifiInfo = wifiMgr.getConnectionInfo();
            Log.v(TAG, "-- WIFI is Enabled Name = " + wifiInfo.getSSID());
            return wifiInfo.getSSID();
        }/*from   w w w.jav a  2  s.c  om*/
    }
    return "";
}