Gas*_*ski 6 android connect android-virtual-device
我正在尝试编写自己的android http服务器.这很好,但我的AVD有问题.每次我想测试更改时,我都不想将我的应用程序下载到手机上.我想通过AVD连接到我的应用程序.要获取IP地址我正在使用此功能:
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;
}
Run Code Online (Sandbox Code Playgroud)
在我的手机上一切正常,但当我在AVD上运行我的应用程序时,它显示ip:10.0.2.15,我无法连接到它.有没有办法连接我在AVD上运行的应用程序?如果它确实重要我的应用程序使用端口8080.
| 归档时间: |
|
| 查看次数: |
2825 次 |
| 最近记录: |