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.
The virtual device is emulating my Droid X (API 2.2). I'm not looking for answers o开发者_高级运维n 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
As noted therein:
"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."
So you'll need to use the server's public IP (as opposed to it's local network IP).
you dont need to do so much thing.
Just use your machine's ip to achieve this.
Suppose your machine(server) ip is 192.168.1.1
Then from your application just use http://192.168.1.1/your_appliction/webpage
If you want to access http://localhost/
just use http://10.0.2.2/
To enable/toggle Wi-fi you need to go the Dev Tools
option. That should do.
精彩评论