Get IP Address of a Android Device using Code

by Sasikumar 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.
Very Happy
Laughing
Very Happy
1072
like
0
dislike
0
mail
flag

You must LOGIN to add comments