如何从我的 Android 设备访问我的本地主机? [英] How can I access my localhost from my Android device?

查看:40
本文介绍了如何从我的 Android 设备访问我的本地主机?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以使用 Android 模拟器访问我的笔记本电脑网络服务器,我使用的是 10.0.2.2:portno效果很好.

I'm able to access my laptop web server using the Android emulator, I'm using 10.0.2.2:portno works well.

但是当我连接真正的 Android 手机时,手机浏览器无法连接到笔记本电脑上的同一网络服务器.手机使用 USB 数据线连接到笔记本电脑.如果我运行adb devices 命令,我可以看到我的手机.

But when I connect my real Android phone, the phone browser can't connect to the same web server on my laptop. The phone is connected to the laptop using a USB cable. If I run the adb devices command, I can see my phone.

我错过了什么?

推荐答案

USB 不为移动设备提供网络.

USB doesn't provide network to mobile device.

如果您的台式机和手机都连接到同一个 WiFi(或任何其他本地网络),则使用路由器分配的台式机 IP 地址(不是 localhost而不是 127.0.0.1).

If both your desktop and phone are connected to the same WiFi (or any other local network), then use your desktop IP address assigned by the router (not localhost and not 127.0.0.1).

要找出您桌面的 IP 地址:

To find out the IP address of your desktop:

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