AsynTask Using Post Request
private class submit_webservice extends AsyncTask<Void, Void, Void> {
@Override
protected void onPreExecute() {
super.onPreExecute();
prgDialog = new ProgressDialog(getActivity());
prgDialog.setMessage("Please Wait...");
prgDialog.setCancelable(false);
}
@Override
protected Void doInBackground(Void... params) {
List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(2);
nameValuePairs.add(new BasicNameValuePair("user_id",
UserProfile.login_user_id));
nameValuePairs
.add(new BasicNameValuePair("name", UserProfile.name));
nameValuePairs.add(new BasicNameValuePair("email",
UserProfile.email));
nameValuePairs.add(new BasicNameValuePair("dob", UserProfile.dob));
nameValuePairs.add(new BasicNameValuePair("address",
UserProfile.address));
nameValuePairs.add(new BasicNameValuePair("state",
UserProfile.state_id));
vkposts(nameValuePairs);
return null;
}
@Override
protected void onPostExecute(Void result) {
// TODO Auto-generated method stub
super.onPostExecute(result);
if (prgDialog.isShowing()) {
prgDialog.dismiss();
}
}
}
public void vkposts(List nameValuesPair) {
HttpClient httpClient = new DefaultHttpClient();
HttpPost httpPost = new HttpPost(
"http://www.crazzybazaar.com/userwesv/user-profile.php");
try {
httpPost.setEntity(new UrlEncodedFormEntity(nameValuesPair));
// getting response
HttpResponse httpResponse = httpClient.execute(httpPost);
response = EntityUtils.toString(httpResponse.getEntity());
} catch (IOException e) {
}
}