Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

(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

like image 570
Spidy Avatar asked Mar 07 '11 19:03

Spidy


2 Answers

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

like image 188
Chris Cashwell Avatar answered Oct 30 '22 09:10

Chris Cashwell


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/

like image 42
Tanmay Mandal Avatar answered Oct 30 '22 09:10

Tanmay Mandal