I'm relatively new to Network/Socket programming so I haven't dabbled too
much into it.
As my phone is connected to a particular Wi-Fi network, I want to get a list
of all other devices (phone, computer, or other misc) that are connected to
the same network. One of the ways that I tried to accomplish this was this:
Enumeration<InetAddress> address;
Enumeration<NetworkInterface> nets;
nets = NetworkInterface.getNetworkInterfaces();
for (NetworkInterface netint : Collections.list(nets))
{
address = netint.getInetAddresses();
for (InetAddress inetAddress : Collections.list(address))
{
Log.d(LOG_TAG, "Host name: " + inetAddress.getHostName() +
" IP: " + inetAddress);
}
}
However, all I get is the phone's IP address and a loopback call with
LocalHost. I get the same result with this code:
InetAddress host = InetAddress.getLocalHost();
InetAddress[] address = InetAddress.getAllByName(host.getHostName());
for (InetAddress result : address)
{
Log.d(LOG_TAG, "IP Address:: " + result.getHostName());
}
When trying to search for this, I've only come across how to detect multiple
networks but not devices. Does anyone know of a way I can retrieve this
list?
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en