Spidy
Spidy

Reputation: 40002

(How) Can an android virtual device use the local computer's internet?

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 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)

Edit access point GUI

Upvotes: 12

Views: 37537

Answers (3)

Chris Cashwell
Chris Cashwell

Reputation: 22859

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).

Upvotes: 10

Simon
Simon

Reputation: 11

To enable/toggle Wi-fi you need to go the Dev Tools option. That should do.

Upvotes: 1

Tanmay Mandal
Tanmay Mandal

Reputation: 40168

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/

Upvotes: 9

Related Questions