How to connect to a http server running in android emulator?

浪尽此生 提交于 2020-08-23 02:45:50

问题


I have a HTTP server working on my android emulator listening to port 8080. How can I connect to it from same PC's browser? I tried 127.0.0.1 but it couldn't connect.


回答1:


You have to enable port forwarding in adb. For example:

adb forward tcp:8080 tcp:8080

This will forward incoming connections to localhost TCP/8080 to the emulator TCP/8080.

Here's the reference.




回答2:


You can use 10.0.2.2 to access your actual machine, it is an alias set up to help in development.



来源:https://stackoverflow.com/questions/14684411/how-to-connect-to-a-http-server-running-in-android-emulator

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!