----转自:http://blog.csdn.net/android_tutor/article/details/5576544
public String getLocalIpAddress() {
try {
for (Enumeration
NetworkInterface intf = en.nextElement();
for (Enumeration
InetAddress inetAddress = enumIpAddr.nextElement();
if (!inetAddress.isLoopbackAddress()) {
return inetAddress.getHostAddress().toString();
}
}
}
} catch (SocketException ex) {
Log.e(LOG_TAG, ex.toString());
}
return null;
}