public StringBuilder post(String url) {
HttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new HttpPost(url);
// Add your data (Var name, Var value)
List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(3);
httppost.getParams().setParameter(
CoreProtocolPNames.USE_EXPECT_CONTINUE, Boolean.FALSE);
nameValuePairs.add(new BasicNameValuePair("ageDay", "30"));
nameValuePairs.add(new BasicNameValuePair("ageYear", "1959"));
httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
// Execute HTTP Post Request
HttpResponse response = httpclient.execute(httppost);
// Saves response
String line = "";
StringBuilder result = new StringBuilder();
BufferedReader rd = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));
while ((line = rd.readLine()) != null) {
result.append(line);
}
rd.close();
return result;
}
15+ years of experience in mobile application development which includes Symbian, J2ME, Android and iOS development
0 comments :
Post a Comment