Android SDK中连接到主机上的Web服务器 [英] Android SDK Connect to Web Server on Host
问题描述
我建立一个Web服务,和一个Android应用程序,利用它。我通过Eclipse的这两项工作。当我在本地运行的Web服务器,我可以从我的主机的网络浏览器在 HTTP连接://本地主机:8888 / 一>。我怎样才能连接到从我的Android应用程序运行在同一台机器上的仿真器?
我怎样才能连接到从我的Android应用程序在同一台机器?
在模拟器上运行
如果您是从Android模拟器指本地主机系统上,那么你必须使用 http://10.0.2.2:8888/
。由于Android模拟器在虚拟机中运行(QEMU),因此在这里 127.0.0.1
或本地主机
将仿真器自身的环回地址
参见:<一href="http://developer.android.com/guide/developing/devices/emulator.html#emulatornetworking">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
这篇关于Android SDK中连接到主机上的Web服务器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!