如何在 Android 模拟器中连接 localhost? [英] How do you connect localhost in the Android emulator?

查看:40
本文介绍了如何在 Android 模拟器中连接 localhost?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 localhost 中创建了一个 php 脚本,我正在将它与 httpClient 连接,但我遇到了问题.

I have made a php script inside localhost and I am connecting that with httpClient but I am getting a problem.

请告诉我如何从模拟器连接到 localhost 的 php 文件?

Please tell me how can I connect to a php file at localhost from the emulator?

推荐答案

使用10.0.2.2访问你的实际机器.

如您所知,当您使用模拟器时,localhost (127.0.0.1) 指的是设备自己的环回服务,而不是您机器上的环回服务你可以期待.

Use 10.0.2.2 to access your actual machine.

As you've learned, when you use the emulator, localhost (127.0.0.1) refers to the device's own loopback service, not the one on your machine as you may expect.

您可以使用 10.0.2.2 来访问您的实际机器,它是为帮助开发而设置的别名.

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

这篇关于如何在 Android 模拟器中连接 localhost?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆