connection refused when trying to connect to my REST server from android emulator -


consider following android code , please solve problem: there rest server running on laptop..i can access server browser , proper resuts...but want use android emulator running on laptop using 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 emulator when pass url http://www.google.com , got proper response in result when use localhost url(the commented 1 above) got connection refused....

warn/system.err(901): org.apache.http.conn.httphostconnectexception: connection http://localhost:8080 refused warn/system.err(901): caused by: java.net.connectexception: /127.0.0.1:8080 - connection refused 

if run same url on browser works. can tell me why localhost url not working in emulator..?

ankur, had same problem replacing localhost 10.0.2.2 worked me. make sure have added line <uses-permission android:name="android.permission.internet" />

within <manifest> tag in androidmanifest.xml file.

thanks adil , rogerstone responses.

-ajmal


Comments

Popular posts from this blog

c# - SharpSVN - How to get the previous revision? -

c++ - Is it possible to compile a VST on linux? -

url - Querystring manipulation of email Address in PHP -