Android IP Address Get getIPs()

Here you can find the source of getIPs()

Description

get I Ps

Declaration

public static String getIPs() 

Method Source Code

//package com.java2s;
import java.net.InetAddress;
import java.net.NetworkInterface;
import java.util.Enumeration;

public class Main {
    public static String getIPs() {
        String ipaddress = "";
        try {//from w  ww .  j a  v a2s .c  om
            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()) {
                        ipaddress += inetAddress.getHostAddress()
                                .toString() + ";";
                    }
                }
            }
        } catch (Exception ex) {
            ex.printStackTrace();
        }
        return ipaddress;
    }
}

Related

  1. getLocalHostAddress()
  2. getIPAddress(boolean useIPv4)
  3. getTargetInetaddress(String target)
  4. getDevicesMac(Context context)
  5. getDevicesIP(Context context)
  6. getIPv4StringByStrippingIPv6Prefix(String in)
  7. getIPV4NetwprkOrder(String theIp)