I use the form of execute that takes two parameters, the request
object and a request handler, like this:
HttpGet get = new HttpGet(URL);
try {
String response = mClient.execute(get, new BasicResponseHandler(), c);
JSONObject respJSO = new JSONObject(response);
Log.d(TAG, "Credentials: " + respJSO.toString(2));
} catch ... Any errors with the response go here see
BasicResponseHandler
I've found this to be much easier to deal with. I don't know about
speed though. It's probably doing the same stuff under the covers. At
least I don't have to deal with it.
On Dec 31, 1:52 pm, SizzlingSkizzorsProgrammer <[email protected]>
wrote:
> What is the best (fastest and most efficient) method of doing an HTTP
> Request?
>
> Currently I use:
>
> DefaultHttpClient httpclient= new DefaultHttpClient();
>
> HttpPost httpost = new HttpPost(uri);
>
> httpost.setEntity(new UrlEncodedFormEntity(nvps, HTTP.UTF_8));
>
> HttpResponse response = httpclient.execute(httpost);
> HttpEntity entity = response.getEntity();
> String sResponse = EntityUtils.toString(entity);
>
> if (close == true)
> {
> httpclient.getConnectionManager().shutdown();
> }
>
> if (entity != null)
> {
> entity.consumeContent();
> }
>
> return sResponse;
>
> It works fine, but it's quite slow...any way to make it faster?
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en