I’m quite new to android and try to implement http client to communicate to a REST server.
I’m starting with the Get method but I have some problems using android 2.0 on the emulator.
String url = "http://www.google.fr/search?q=android"
HttpClient client = new DefaultHttpClient(new BasicHttpParams());
HttpGet getMethod = new HttpGet((url));
HttpResponse httpResponse = client.execute(getMethod);
HttpEntity = httpResponse.getEntity());
int length = (int) httpEntity.getContentLength();
=> length is -1 :-(
A look into the logs gives me the UnresolvedHostException.
I searched on google and found several guys having the same problem but who didn’t find any answer.
Is there a particular way to configure the android emulator to have this working ?
Just to precise, I have added the Internet access in the android manifest.
Thanks a lot for your help.
Luc
First, try accessing that page from the Browser application. If that fails, check your firewall or deactivate your proxy server.
Once the Browser can access the page, try getting rid of the
new BasicHttpParams()(it is not needed) and see if that helps. Otherwise, what you have seems OK.