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

private static String getIpAddr(WifiManager wifiManager) {
    WifiInfo wifiInfo = wifiManager.getConnectionInfo();
    int ip = wifiInfo.getIpAddress();

    String ipString = String.format("%d.%d.%d.%d", (ip & 0xff), (ip >> 8 & 0xff), (ip >> 16 & 0xff),
            (ip >> 24 & 0xff));

    return ipString;
}

From source file:Main.java

/**
 * Gets the device id.//from  w w  w. jav a 2  s.  c  o  m
 *
 * @param context the context
 * @return the device id
 */
public synchronized static String getDeviceId(Context context) {
    WifiManager wm = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
    return wm.getConnectionInfo().getMacAddress();
}

From source file:Main.java

/**
 * <uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
 *///  w w  w  . ja va 2s  .c o  m
public static WifiInfo getConnectionWifi(@NonNull Context context) {
    WifiManager wifi = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
    return wifi.getConnectionInfo();
}

From source file:Main.java

public static String getWifiMacAddress(Context mc) {
    WifiManager wifi = (WifiManager) mc.getSystemService(Context.WIFI_SERVICE);
    WifiInfo info = wifi.getConnectionInfo();
    return info.getMacAddress();
}

From source file:Main.java

private static WifiInfo getWifiInfo(Context context) {
    WifiManager mWifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
    return mWifiManager.getConnectionInfo();
}

From source file:Main.java

public static String getMac(Context context) {
    WifiManager wifi = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
    WifiInfo info = wifi.getConnectionInfo();
    return info.getMacAddress();
}

From source file:Main.java

public static String getWifiIP(WifiManager wifiManager) {
    WifiInfo wifiInfo = wifiManager.getConnectionInfo();
    String ip = intToIp(wifiInfo.getIpAddress());
    return ip != null ? ip : "";
}

From source file:Main.java

/**
 * @param context Context of application
 * @return    MAC address/*from  w w  w.  jav a 2s  . c  o  m*/
 */
public static String getMacAddress(Context context) {
    WifiManager wifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
    return wifiManager.getConnectionInfo().getMacAddress();
}

From source file:Main.java

public static final String getLocalMacAddress(Context context) {
    WifiManager wifi = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
    WifiInfo info = wifi.getConnectionInfo();
    return info.getMacAddress();
}

From source file:Main.java

/**
 * @param ctx//from   w  ww.  j  a  va 2  s . c  om
 *         The {@link context}.
 * 
 * @return A {@link String} representing the device's MAC address
 */

public static String getDeviceId(Context ctx) {
    WifiManager wm = (WifiManager) ctx.getSystemService(Context.WIFI_SERVICE);
    String wmac = wm.getConnectionInfo().getMacAddress();
    return wmac;
}