I can read ipv4 by this code
public String getLocalIpAddress() {
String ipaddress = null;
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() && !inetAddress.isLinkLocalAddress() && inetAddress.isSiteLocalAddress() ) {
if (!inetAddress.isLoopbackAddress() && InetAddressUtils.isIPv4Address(inetAddress.getHostAddress()) ) {
ipaddress = inetAddress.getHostAddress();
}
}
}
} catch (SocketException ex) {
// Log.d(TAG, ex.toString());
}
return ipaddress;
}
But i cant change it.is there any way to change static ip by code?i can only change it on settings configure ethernet device menu