I'm trying to write my own Android http server. It's quite OK but I have a problem with my AVD. I don't want to download my app to phone every time I want to test changes. I would like to connect to my app via AVD.
To get the IP address I'm using this function:
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;
}
on my phone everything works but when I run my app on AVD it shows ip: 10.0.2.15
and I'm unable to connect to it.
Is there any way to connect to my app running on AVD?
If it matters my app uses port 8080.