Android SDK Connect to Web Server on Host

后端 未结 2 966
一向
一向 2020-12-30 16:54

I am building a web service, and an android app to utilize it. I am doing both through Eclipse. When I\'m running the web server locally, I can connect from my host machin

相关标签:
2条回答
  • 2020-12-30 17:29

    I think you can not connect through localhost. Try to access it though IP address. Because, emulator and Machine making a network.

    0 讨论(0)
  • 2020-12-30 17:37

    How can I connect to that from my android app running on the emulator on the same machine?

    If you are referring your localhost on your system from the Android emulator then you have to use http://10.0.2.2:8888/. Because Android emulator runs inside a Virtual Machine(QEMU) therefore here 127.0.0.1 or localhost will be emulator's own loopback address.

    Refer: Emulator Networking

    0 讨论(0)
提交回复
热议问题