How can I let the Android emulator talk to the local host?

I am running an Android application on an emulator. This application is trying to download an html file using the webview api.

I also have a simple HTTP server running on the same computer in the directory where I want to execute the request using the following python command:

python -m SimpleHTTPServer 800

However, I could not access this link through the application or browser on the emulator:

HTTP: // local: 800 / demo.html

Please let me know if I missed something.

+6
python android android-emulator webview
source share
4 answers

Use the address 10.0.2.2 instead of localhost.

+16
source share

localhost is a short acronym to say β€œanything” to talk to yourself. So, you are telling the emulator to look for a web server running in the emulator.

Instead of trying to connect to the local host, find the IP address for your computer and use it instead.

0
source share

In fact, localhost refers to the emulator directory itself.

Use your system IP address to access the link

0
source share

The best solution is not to use the emulator at all. Its slow and full of mistakes. Ask your employer to buy a device or two.

-2
source share

All Articles