List of usage examples for android.net.wifi WifiInfo getIpAddress
public int getIpAddress()
From source file:Main.java
public static String getLocalIp(Context context) { WifiManager wifi = (WifiManager) context.getSystemService(Context.WIFI_SERVICE); WifiInfo info = wifi.getConnectionInfo(); int ip = info.getIpAddress(); return (ip & 0xFF) + "." + ((ip >> 8) & 0xFF) + "." + ((ip >> 16) & 0xFF) + "." + (ip >> 24 & 0xFF); }
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
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
public static String getWifiIP(Context context) { String ip = null;// w w w. ja v a 2s .co m WifiManager wifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE); if (wifiManager.isWifiEnabled()) { WifiInfo wifiInfo = wifiManager.getConnectionInfo(); int i = wifiInfo.getIpAddress(); ip = (i & 0xFF) + "." + ((i >> 8) & 0xFF) + "." + ((i >> 16) & 0xFF) + "." + (i >> 24 & 0xFF); } return ip; }
From source file:Main.java
public static long getIPAdress(Context context) { WifiManager wifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE); WifiInfo wifiInfo = wifiManager.getConnectionInfo(); long ipAddress = wifiInfo.getIpAddress(); if (ipAddress == 0) ipAddress = 1001;/*ww w .j a v a 2 s . c om*/ return ipAddress; }
From source file:Main.java
public static String getWifiIp(Context context) { WifiManager wifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE); boolean enable = wifiManager.isWifiEnabled(); if (!enable) { return null; }//from www . j a va 2s. c o m WifiInfo wifiinfo = wifiManager.getConnectionInfo(); return intToIp(wifiinfo.getIpAddress()); }
From source file:Main.java
public static int getIpAddressInt(Context context) { WifiManager wifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE); if (wifiManager == null) return 0; WifiInfo info = wifiManager.getConnectionInfo(); return info == null ? 0 : info.getIpAddress(); }
From source file:Main.java
public static String getDevicesIP(Context context) { WifiManager wifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE); if (!wifiManager.isWifiEnabled()) { wifiManager.setWifiEnabled(true); }// w w w.j a va 2 s . c o m WifiInfo wifiInfo = wifiManager.getConnectionInfo(); int ipAddress = wifiInfo.getIpAddress(); String ip = (ipAddress & 0xFF) + "." + ((ipAddress >> 8) & 0xFF) + "." + ((ipAddress >> 16) & 0xFF) + "." + (ipAddress >> 24 & 0xFF); if (ip == null || ip.equals("0.0.0.0")) { } return ip; }
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 w w w . ja va 2 s . com*/ WifiInfo wifiinfo = wifiManager.getConnectionInfo(); String ip = intToIp(wifiinfo.getIpAddress()); return ip; }
From source file:Main.java
public static String getWIFIIP(Context context) { WifiManager wifimanage = (WifiManager) context.getSystemService(Context.WIFI_SERVICE); if (!wifimanage.isWifiEnabled()) { wifimanage.setWifiEnabled(true); }//from w ww . ja v a2 s . c om WifiInfo wifiinfo = wifimanage.getConnectionInfo(); String ip = intToIp(wifiinfo.getIpAddress()); return ip; }