List of usage examples for android.content Context WIFI_SERVICE
String WIFI_SERVICE
To view the source code for android.content Context WIFI_SERVICE.
Click Source Link
From source file:Main.java
public static String getIp(Context ctx) { WifiManager wm = (WifiManager) ctx.getSystemService(Context.WIFI_SERVICE); WifiInfo wi = wm.getConnectionInfo(); int ip = wi.getIpAddress(); String ipAddress = intToIp(ip); return ipAddress; }
From source file:Main.java
public static String getWiFiIP(Context context) { WifiManager wifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE); if (!wifiManager.isWifiEnabled()) { wifiManager.setWifiEnabled(true); }//from ww w.j av a 2 s . com WifiInfo wifiinfo = wifiManager.getConnectionInfo(); String ip = intToIp(wifiinfo.getIpAddress()); return ip; }
From source file:Main.java
public static String getGateWayAddress(Context context) { WifiManager wifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE); boolean enable = wifiManager.isWifiEnabled(); if (!enable) { return null; }/* ww w. ja v a 2 s . c om*/ DhcpInfo info = wifiManager.getDhcpInfo(); return intToIp(info.gateway); }
From source file:Main.java
public static String getWifiMac(Context context) { try {/*from ww w. ja va 2 s . c o m*/ 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 String getMac() { WifiManager wifi = (WifiManager) mContext.getSystemService(Context.WIFI_SERVICE); WifiInfo info = wifi.getConnectionInfo(); if (info.getMacAddress() == null) { return null; } else {//from w ww .j a v a 2 s. c o m return info.getMacAddress(); } }
From source file:Main.java
public static String getLocalIpByWifi(Context context) { WifiManager wifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE); if (wifiManager == null) { return "wifiManager not found"; }/*www . j a v a 2 s .c o m*/ WifiInfo wifiInfo = wifiManager.getConnectionInfo(); if (wifiInfo == null) { return "wifiInfo not found"; } int ipAddress = wifiInfo.getIpAddress(); return String.format("%d.%d.%d.%d", (ipAddress & 0xff), (ipAddress >> 8 & 0xff), (ipAddress >> 16 & 0xff), (ipAddress >> 24 & 0xff)); }
From source file:Main.java
public static String getMacAddress(Context context) { try {/*from ww w .ja v a 2 s .c o m*/ WifiManager wifi = (WifiManager) context.getSystemService(Context.WIFI_SERVICE); WifiInfo info = wifi.getConnectionInfo(); String mac = info.getMacAddress(); return mac == null ? "" : mac; } catch (Exception e) { return ""; } }
From source file:Main.java
public static void enableMulticastLock(Context context) { WifiManager wifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE); MulticastLock multicastLock = wifiManager.createMulticastLock("multicast.test"); multicastLock.acquire();// w w w .j a v a2 s. c o m }
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 ava2 s .co m*/ return info.getSSID(); } }
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(); }