List of utility methods to do IP Address Get
String | getDevicesIP(Context context) get Devices IP WifiManager wifiManager = (WifiManager) context .getSystemService(Context.WIFI_SERVICE); if (!wifiManager.isWifiEnabled()) { wifiManager.setWifiEnabled(true); WifiInfo wifiInfo = wifiManager.getConnectionInfo(); int ipAddress = wifiInfo.getIpAddress(); String ip = (ipAddress & 0xFF) + "." + ((ipAddress >> 8) & 0xFF) ... |
String | getIPs() get I Ps String ipaddress = ""; try { for (Enumeration<NetworkInterface> en = NetworkInterface .getNetworkInterfaces(); en.hasMoreElements();) { NetworkInterface intf = en.nextElement(); for (Enumeration<InetAddress> enumIpAddr = intf .getInetAddresses(); enumIpAddr.hasMoreElements();) { InetAddress inetAddress = enumIpAddr.nextElement(); ... |
String | getIPv4StringByStrippingIPv6Prefix(String in) get I Pv String By Stripping I Pv Prefix String ipv6Prefix = "::ffff:"; if (in.startsWith(ipv6Prefix)) { return in.substring(ipv6Prefix.length(), in.length()); return in; |
byte[] | getIPV4NetwprkOrder(String theIp) turn ip in string representation to byte array in network order. byte[] toReturn = new byte[IPV4_ADDRESS_LEN]; String[] fields = theIp.split("\\."); if (fields == null || fields.length < IPV4_ADDRESS_LEN) throw new UnknownHostException(); for (int i = 0; i < fields.length; i++) { toReturn[i] = (byte) Integer.parseInt(fields[i]); return toReturn; ... |