01.
public
String getHttpPost(String url,List<NameValuePair> params) {
02.
StringBuilder str =
new
StringBuilder();
03.
HttpClient client =
new
DefaultHttpClient();
04.
HttpPost httpPost =
new
HttpPost(url);
05.
06.
try
{
07.
httpPost.setEntity(
new
UrlEncodedFormEntity(params));
08.
HttpResponse response = client.execute(httpPost);
09.
StatusLine statusLine = response.getStatusLine();
10.
int
statusCode = statusLine.getStatusCode();
11.
if
(statusCode ==
200
) {
12.
HttpEntity entity = response.getEntity();
13.
InputStream content = entity.getContent();
14.
BufferedReader reader =
new
BufferedReader(
new
InputStreamReader(content));
15.
String line;
16.
while
((line = reader.readLine()) !=
null
) {
17.
str.append(line);
18.
}
19.
}
else
{
20.
Log.e(
"Log"
,
"Failed to download result.."
);
21.
}
22.
}
catch
(ClientProtocolException e) {
23.
e.printStackTrace();
24.
}
catch
(IOException e) {
25.
e.printStackTrace();
26.
}
27.
return
str.toString();
28.
}