How to connect to my http://localhost web server f

2018-12-31 05:18发布

What can I do in Eclipse's Android emulator to connect it to my localhost web server page at http://localhost or http://127.0.0.1?

I've tried it, but the emulator still takes my request like a Google search for localhost or worse it says that it didn't found the page while my web server is normally running.

10条回答
荒废的爱情
2楼-- · 2018-12-31 05:49

Use 10.0.2.2 for default AVD and 10.0.3.2 for .

查看更多
零度萤火
3楼-- · 2018-12-31 05:51

I used 10.0.2.2 successfully on my home machine, but at work, it did not work. After hours of fooling around, I created a new emulator instance using the Android Virtual Device (AVD) manager, and finally the 10.0.2.2 worked.

I don't know what was wrong with the other emulator instance (the platform was the same), but if you find 10.0.2.2 does not work, try creating a new emulator instance.

查看更多
弹指情弦暗扣
4楼-- · 2018-12-31 05:52

The localhost refers to the device on which the code is running, in this case the emulator.

If you want to refer to the computer which is running the Android simulator, use the IP address 10.0.2.2 instead. You can read more from here.

查看更多
何处买醉
5楼-- · 2018-12-31 05:53

Try http://10.0.2.2:8080/ where 8080 is your port number. It worked perfectly. If you just try 10.0.2.2 it won't work. You need to add port number to it. Also if Microsoft IIS has been installed try turning off that feature from control panel (if using any windows os) and then try as given above.

查看更多
旧时光的记忆
6楼-- · 2018-12-31 06:01

according to documentation:

10.0.2.2 - Special alias to your host loopback interface (i.e., 127.0.0.1 on your development machine)

check Emulator Networking for more tricks on emulator networking.

查看更多
裙下三千臣
7楼-- · 2018-12-31 06:07

Another workaround is to get a free domain from no-ip.org and point it to your local ip address. Then, instead of using http://localhost/yourwebservice you can try http://yourdomain.no-ip.org/yourwebservice

查看更多
登录 后发表回答