views:

41

answers:

1

I'm trying to authenticate to a web server from an android class with the org.apache.http.HttpClient.

How can I do this? The code for my connection is:

HttpClient httpClient = new DefaultHttpClient();
HttpGet httpGet = new HttpGet("url");

HttpResponse response = null;

try {
    response = httpClient.execute(httpGet);
} catch (ClientProtocolException e) {
   ...
} catch (IOException e) {
   ...
}
Log.i("httptest", response.getStatusLine().toString());
HttpEntity entity = response.getEntity();

Edit

I want to do a basic authentication with username and password

+1  A: 

Documentation for HttpClient can be found at the HttpClient site.

You don't say what sort of authentication you are trying to use, so it is impossible to give you concrete answers. Here are some tutorials that may match your needs.

CommonsWare