How to Get Each Device's Ip Address in Wi-Fi Direct Scenario

Get peer device's IP address in wifi-direct p2p connection

There isnt. YOu need to use a service discovery protocol.

How to find Ip address of a device via wifi?

If you want to detect the ip address of the "Emulator" or android device which is connected to any Network then use this code in Your program. it will give you the exact IP Address which the network have assigned to your device.

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())
return inetAddress.getHostAddress().toString();
}
}

}
catch (SocketException ex)
{
Log.e("ServerActivity", ex.toString());
}


Related Topics



Leave a reply



Submit