Example usage for android.net.wifi WifiManager getConnectionInfo

List of usage examples for android.net.wifi WifiManager getConnectionInfo

Introduction

In this page you can find the example usage for android.net.wifi WifiManager getConnectionInfo.

Prototype

public WifiInfo getConnectionInfo() 

Source Link

Document

Return dynamic information about the current Wi-Fi connection, if any is active.

Usage

From source file:Main.java

public static String getWifiSSID(Context context) {
    WifiManager wifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
    return wifiManager.getConnectionInfo().getSSID();
}

From source file:Main.java

public static WifiInfo getWifiConnectionInfo(Context context) {
    WifiManager wifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
    return wifiManager.getConnectionInfo();
}

From source file:Main.java

public static String getWifiMac(Context context) {
    try {/* w  ww .  j a va 2s. c  om*/
        WifiManager wifi = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
        WifiInfo info = wifi.getConnectionInfo();
        return info.getMacAddress();
    } catch (Exception e) {
        return "x";
    }
}

From source file:Main.java

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

From source file:Main.java

public static String getLocalMacAddress(Context ctx) {

    String macAddress = "0";

    WifiManager wifi = (WifiManager) ctx.getSystemService(Context.WIFI_SERVICE);

    WifiInfo info = wifi.getConnectionInfo();

    macAddress = info.getMacAddress().replaceAll(":", "");

    return macAddress;

}

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.  ja  va 2 s  .c  o  m*/
        return info.getSSID();
    }
}

From source file:Main.java

public static String getMacAddress(Context context) {
    WifiManager wifi = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
    WifiInfo wifiInfo = wifi.getConnectionInfo();
    if (wifiInfo != null) {
        return wifiInfo.getMacAddress();
    }/*from w w w.j av a  2s  .c o m*/

    return null;
}

From source file:Main.java

private static String getLocalMacAddress(Context context) {
    WifiManager wifi = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
    WifiInfo info = wifi.getConnectionInfo();
    if (info != null) {
        return info.getMacAddress();
    }/* w w w  . j a v a2s  . c o m*/
    return "";
}

From source file:Main.java

public static String getMacAddress(Context context) {
    WifiManager wimanager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
    String macAddress = wimanager.getConnectionInfo().getMacAddress();
    if (macAddress == null) {
        macAddress = "000000000000";
    }// ww  w  . j a v  a  2s  .  com
    return macAddress;
}

From source file:Main.java

public static String getMac(Context ctx) {

    String macAddress = "0";

    WifiManager wifi = (WifiManager) ctx.getSystemService(Context.WIFI_SERVICE);

    WifiInfo info = wifi.getConnectionInfo();

    macAddress = info.getMacAddress();/*  www .ja v a2 s .c o  m*/

    return macAddress;

}