consider the following Android code and please solve my problem: There is a REST server on my laptop. I can access this server from my browser and get the correct settings ... but now I want to use it from my Android emulator, which also works on my laptop using the following code.
// String URL = "http://localhost:8080/server/rest/user/1"; String URL = "http://www.google.com"; HttpClient httpclient = new DefaultHttpClient(); HttpGet request = new HttpGet(URL); HttpResponse result = httpclient.execute(request);
in the emulator, when I pass the URL as http://www.google.com , I got the correct answer as a result, but when I use my localhost URL (comment one above), I received a communication failure ....
WARN/System.err(901): org.apache.http.conn.HttpHostConnectException: Connection to http://localhost:8080 refused WARN/System.err(901): Caused by: java.net.ConnectException: /127.0.0.1:8080 - Connection refused
if i run the same url in my browser, it works. can you tell me why localhost url is not working in emulator.?
Ankur source share