client(android) - server(java) communication - local ip address
i am trying to built a client- server communication using RESTful.The client is an android application while the server is a java application. When i call the URL: http://localhost:8888 through my browser i can see the result(it works fine). As i read, using this URL in my client as the endpoint it doesn't work because the localhost is the (emulated)phone. But when i use the local ip of my computer, through the browser i get the message "The connection has timed out" and through the client i can't take any result too. What is wrong with it. What ip I开发者_JS百科 have to use in order to have access to my server? Thank you!
127.0.0.1 points back to the android. If you want localhost, give 10.0.2.2 a try.
Here is a little more about the android networking interface:
http://developer.android.com/guide/developing/devices/emulator.html#emulatornetworking
It also has a list of network address spaces.
精彩评论