(如何)android虚拟设备可以使用本地计算机的互联网吗?

(How) Can an android virtual device use the local computer#39;s internet?((如何)android虚拟设备可以使用本地计算机的互联网吗?)

本文介绍了(如何)android虚拟设备可以使用本地计算机的互联网吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的计算机所在的网络上运行着一台服务器.有没有办法让虚拟设备使用同一个网络并访问服务器?虚拟设备不允许我切换 wifi(可能是因为它没有).我认为正确的唯一选项是:

I have a server running on the network my computer is on. Is there a way to allow the virtual device to use this same network and access the server? The virtual device won't let me toggle the wifi (probably because it doesn't have one). The only options I see that look right are:

无线和网络设置"-->移动网络"-->接入点名称".

"Wireless & network settings" --> "Mobile networks" --> "Access point names".

我不确定在所有这些字段中填写什么.如果有人有使用本地计算机互联网所需的所有字段的示例,我将不胜感激.

I'm not sure what to fill into all these fields though. If someone has an example of all the fields that are necessary to use the local computers internet, I'd appreciate it.

虚拟设备正在模拟我的 Droid X (API 2.2).我不是在寻找有关如何与服务器通信的答案,而是上网,可能是一个简单的测试来验证我是否在线(现在我只是使用 ConnectivityManager 来检查)

The virtual device is emulating my Droid X (API 2.2). I'm not looking for answers on how to communicate with the server but to get on the net and possibly a simple test to verify I'm on (right now I'm just using the ConnectivityManager to check)

推荐答案

https://developer.android.com/studio/run/emulator-networking.html

如其中所述:

"模拟器的每个实例都运行在虚拟路由器/防火墙后面将其与您的服务隔离开来的服务开发机器的网络界面和设置,并从互联网.模拟设备不能查看您的开发机器或其他网络上的模拟器实例.相反,它只看到它是通过以太网连接到一个路由器/防火墙."

"Each instance of the emulator runs behind a virtual router/firewall service that isolates it from your development machine's network interfaces and settings and from the internet. An emulated device can not see your development machine or other emulator instances on the network. Instead, it sees only that it is connected through Ethernet to a router/firewall."

因此您需要使用服务器的公共 IP(而不是本地网络 IP).

So you'll need to use the server's public IP (as opposed to it's local network IP).

这篇关于(如何)android虚拟设备可以使用本地计算机的互联网吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本文标题为:(如何)android虚拟设备可以使用本地计算机的互联网吗?

基础教程推荐