Dear all !
I am currently developping an application using sockets to communicate
over an IPv6 network.
However I am unable to retrieve the ipv6 address of the WiFi interface
(wlan0).
My code works only for IPv4 :(
Is there anyway to adapt this code to retrieve only IPv6 address
(global) of the wifi interface?
Many thanks in advance,
I am using following code:
private String getLocalIpAddress() {
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());
}
return null;
}
--
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