我建立一个Web服务,和一个Android应用程序,利用它。我通过Eclipse的这两项工作。当我在本地运行的Web服务器,我可以从我的主机的网络浏览器在 HTTP连接://本地主机:8888 / 。我怎样才能连接到从我的Android应用程序运行在同一台机器上的仿真器?
解决方案我怎样才能连接到从我的Android应用程序在同一台机器?
在模拟器上运行如果您是从Android模拟器指本地主机系统上,那么你必须使用 http://10.0.2.2:8888/
。由于Android模拟器在虚拟机中运行(QEMU),因此在这里 127.0.0.1
或本地主机
将仿真器自身的环回地址
参见:Emulator网络
I am building a web service, and an android app to utilize it. I am doing both through Eclipse. When I'm running the web server locally, I can connect from my host machine's web browser at http://localhost:8888/. How can I connect to that from my android app running on the emulator on the same machine?
解决方案How can I connect to that from my android app running on the emulator on the same machine?
If you are referring your localhost on your system from the Android emulator then you have to use http://10.0.2.2:8888/
. Because Android emulator runs inside a Virtual Machine(QEMU) therefore here 127.0.0.1
or localhost
will be emulator's own loopback address.
Refer: Emulator Networking