Get IP Address of a Android Device using Code
by Sasikumar[ Edit ] 2014-02-10 14:42:44
To get ip address of a android device use the following code :
for (Enumeration en = NetworkInterface.getNetworkInterfaces(); en.hasMoreElements();)
{
NetworkInterface intf = en.nextElement();
for (Enumeration enumIpAddr = intf.getInetAddresses(); enumIpAddr.hasMoreElements();)
{
InetAddress inetAddress = enumIpAddr.nextElement();
if (!inetAddress.isLoopbackAddress())
{
ipAddress = inetAddress.getHostAddress();
}
}
}
variable "ipAddress" contains the IP address of the device.