List of utility methods to do IP Address Get
String | getIPAddr() get IP Addr InetAddress Address = null; try { Address = InetAddress.getLocalHost(); } catch (UnknownHostException e) { e.printStackTrace(); return Address.getHostAddress(); |
byte[] | getByteAddress(BluetoothDevice device) get Byte Address return getBytesFromAddress(device.getAddress());
|
String | getInetIpAddress() get Inet Ip Address try { for (Enumeration<NetworkInterface> en = NetworkInterface .getNetworkInterfaces(); en.hasMoreElements();) { NetworkInterface intf = en.nextElement(); for (Enumeration<InetAddress> ipAddr = intf .getInetAddresses(); ipAddr.hasMoreElements();) { InetAddress inetAddress = ipAddr.nextElement(); return inetAddress.getHostAddress(); ... |
InetAddress | getLocalIpAddress() get Local Ip Address 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(); if (!inetAddress.isLoopbackAddress()) { ... |
String | getIPAddress(boolean useIPv4) Get IP address from first non-localhost interface try { List<NetworkInterface> interfaces = Collections .list(NetworkInterface.getNetworkInterfaces()); for (NetworkInterface intf : interfaces) { List<InetAddress> addrs = Collections.list(intf .getInetAddresses()); for (InetAddress addr : addrs) { if (!addr.isLoopbackAddress()) { ... |
String | getHostAddress(int address) Returns 32-bit integer address to IPv4 address string "%d.%d.%d.%d" format. return ((address >>> 24) & 0xFF) + "." + ((address >>> 16) & 0xFF) + "." + ((address >>> 8) & 0xFF) + "." + ((address >>> 0) & 0xFF); |
String | getLocalHostAddress() get Local Host Address boolean useIPv4 = true; try { List<NetworkInterface> interfaces = Collections .list(NetworkInterface.getNetworkInterfaces()); for (NetworkInterface intf : interfaces) { List<InetAddress> addrs = Collections.list(intf .getInetAddresses()); for (InetAddress addr : addrs) { ... |
String | getIPAddress(boolean useIPv4) Get IP address from first non-localhost interface try { List<NetworkInterface> networkInterfaces = Collections .list(NetworkInterface.getNetworkInterfaces()); for (NetworkInterface networkInterface : networkInterfaces) { List<InetAddress> inetAddresses = Collections .list(networkInterface.getInetAddresses()); for (InetAddress inetAddress : inetAddresses) { if (!inetAddress.isLoopbackAddress()) { ... |
InetAddress | getTargetInetaddress(String target) get Target Inetaddress InetAddress targetInetAddress = null; try { targetInetAddress = InetAddress.getByName(target.trim()); } catch (UnknownHostException e) { e.printStackTrace(); return targetInetAddress; |
String | getDevicesMac(Context context) get Devices Mac WifiManager wifiManager = (WifiManager) context .getSystemService(Context.WIFI_SERVICE); if (!wifiManager.isWifiEnabled()) { wifiManager.setWifiEnabled(true); WifiInfo wifiInfo = wifiManager.getConnectionInfo(); String mac = wifiInfo.getMacAddress().toString(); return mac; ... |