Android SDK Connect to the web server on the host

I am creating a web service and an Android application to use it. I do both through Eclipse. When I launch the web server locally, I can connect to the web browser of the host machine at http: // localhost: 8888 / . How can I connect to this from my Android application running on an emulator on the same machine?

+4
source share
2 answers

How can I connect to this from an Android application running on an emulator on the same machine?

If you are linking to your localhost on your system from an Android emulator, you should use http://10.0.2.2:8888/ . Since the Android emulator runs inside a virtual machine (QEMU), so here 127.0.0.1 or localhost will be the emulator’s own feedback address.

Contact: Emulator Network

+8
source

I think you cannot connect through localhost. Try to access it though the IP address. Because the emulator and the machine create a network.

0
source

Source: https://habr.com/ru/post/1341259/


All Articles