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

查看:427
本文介绍了如何在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天全站免登陆