Android SDK 连接到主机上的 Web 服务器

标签 android android-emulator

我正在构建一个 Web 服务,以及一个使用它的 Android 应用程序。我正在通过 Eclipse 来做这两件事。当我在本地运行网络服务器时,我可以从主机的网络浏览器连接 http://localhost:8888/ .如何从在同一台机器上的模拟器上运行的 Android 应用程序连接到它?

最佳答案

How can I connect to that from my android app running on the emulator on the same machine?

如果您从 Android 模拟器引用系统上的本地主机,则必须使用 http://10.0.2.2:8888/。因为 Android 模拟器在虚拟机 (QEMU) 中运行,所以这里 127.0.0.1localhost 将是模拟器自己的环回地址。

引用:Emulator Networking

关于Android SDK 连接到主机上的 Web 服务器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5114301/

相关文章:

android - 不应用进度条可绘制的填充

java - 大图像的 Android OutOfMemoryError

android - 以编程方式创建多行 EditText

android - Flutter:未处理的异常:断言失败: bool 表达式不能为null

android - 奇怪的 TagHandler 行为检测开始和结束标签

android - “kernel-qemu” 丢失。 - AVD 经理

android - 如何将设备连接到 Eclipse?

Android:如何在 Nexus One 上调试应用程序

android - 尝试连接到模拟器时处理卡在 "Waiting for device"

Android 模拟器给出错误 "Resetting for cold boot: emulation engine failed"并退出