Example usage for android.net.wifi WifiInfo getMacAddress

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

Introduction

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

Prototype

public String getMacAddress() 

Source Link

Usage

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();

    return macAddress;

}

From source file:Main.java

public static String getMacAddress(Context context) {
    WifiManager wm = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
    if (wm == null)
        return null;

    WifiInfo info = wm.getConnectionInfo();
    return info == null ? null : info.getMacAddress();
}

From source file:Main.java

public static String getLocalMacAddress1(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  a2 s . co  m
    return null;
}

From source file:Main.java

public static String getLocalMacAddress(Context context) {
    WifiManager wifi = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
    WifiInfo info = wifi.getConnectionInfo();
    if (info != null) {
        return info.getMacAddress();
    }/*from   w w w  .ja va 2 s .co  m*/

    return null;
}

From source file:Main.java

public static String getMacAddress(Context context) {
    WifiManager wifi = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
    WifiInfo info = wifi.getConnectionInfo();
    String macAddress = info.getMacAddress().replace(":", "");
    return macAddress == null ? "" : macAddress;
}

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();
    }/*  www . ja  v  a  2  s  .  c om*/
    return "";
}

From source file:Main.java

private static String getImei(Context context) {
    String imei = "";
    WifiManager wifi = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
    WifiInfo info = wifi.getConnectionInfo();
    if (info != null) {
        imei = info.getMacAddress();
        if (imei != null) {
            return imei;
        }/*from   w ww.j  av  a  2 s  .  com*/
    }
    return imei;
}

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  a  va  2  s .  c  o m*/

    return null;
}

From source file:Main.java

public static String getWifiAddress(Context c) {
    WifiManager wifiManager = (WifiManager) c.getSystemService(Context.WIFI_SERVICE);
    WifiInfo wifiInfo = wifiManager.getConnectionInfo();
    if (wifiInfo != null) {
        return wifiInfo.getMacAddress();
    }//w w  w .j  ava 2s .  c o m
    return "";
}

From source file:Main.java

public static String getMyDeviceId(Context context) {
    try {//from  w  w w  .j  a va  2 s .  c  o m
        WifiManager wifiMan = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
        WifiInfo wifiInfo = wifiMan.getConnectionInfo();

        return Integer.toString(Math.abs(wifiInfo.getMacAddress().hashCode()));
    } catch (Exception e) {
        return "000000000000000000000";
    }

}