我正在使用以下代码获取我的安卓手机的IP地址。
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();
//return inetAddress;
}
}
}
} catch (SocketException ex) {
Log.e("SALMAN", ex.toString());
}
它返回的是fe80::94ae:97c:2680:c6cb%rmnet0
然后我在8080端口上设置了一个服务器。
我如何使用此地址连接客户端?我原本期望得到一个IPv4地址...我能通过Chrome或其他方式连接它以测试连接吗?