Android 虚拟设备:从主机系统访问 NanoHTTPD
问题描述:
我在 Android 应用程序中使用了 NanoHTTPD.
I used NanoHTTPD for my android application.
在开发过程中,我在 AVD 上运行该应用程序.有没有办法从我的主机系统访问 Web 服务?AVD 的 IP 地址是什么?
During the development I am running the app on an AVD. Is there a way to accessing the web service from my host system? What´s the IP address of the AVD?
答
使用 adb 向前.
例如,如果您的 NanoHTTPD 在 AVD 上侦听端口 80,请运行
For example, if your NanoHTTPD listens to port 80 on AVD, run
adb forward tcp:20001 tcp:80
然后就可以连接到宿主机上的localhost:20001
来访问服务器了.
then you can connect to localhost:20001
on the host machine to access the server.