views:

119

answers:

2

I'm on Android 1.5, and my code is like this:

HttpPost httpPost = new HttpPost(url);
HttpEntity entity = new UrlEncodedFormEntity(params, HTTP.UTF_8);
httpPost.setEntity(entity);

HttpResponse response = httpClient.execute(httpPost);
HttpEntity respEntity = response.getEntity();
String result = EntityUtils.toString(respEntity, DEFAULT_CHARSET);

After successfully executed these codes, the result is a stripped string. I've tried using browser to test the url+param, it works fine and got all data.

What's wrong with this code? Is there any parameters I need to specified?

A: 

Try using the ResponseHandler pattern instead and see if that gives you better results.

CommonsWare
A: 

This works:

HttpResponse response=httpclient.execute(httppost);
BufferedReader reader = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));
Moons