You can't perform ui related operations in the background thread, so ChangeErrorMsg.setText
must be called in onPostExecute
protected String doInBackground(String... args) {
// getting password from EditTexts
String password = inputPassword.getText().toString();
String newpassword = inputnewPassword.getText().toString();
// Building Parameters
List<NameValuePair> params = new ArrayList<NameValuePair>();
params.add(new BasicNameValuePair("username", username ));
params.add(new BasicNameValuePair("oldpassword", password));
params.add(new BasicNameValuePair("newpassword", newpassword));
// getting JSON string from URL
JSONObject json = jParser.makeHttpRequest(url_change_password, "POST", params);
try {
// Checking for SUCCESS TAG
int success = json.getInt(KEY_SUCCESS);
if (success == 1) {
return "Successsful change";
}
return "Your current password was incorrect.";
} catch (JSONException e) {
e.printStackTrace();
}
return null;
}
/**
* After completing background task Dismiss the progress dialog
* **/
protected void onPostExecute(String file_url) {
// dismiss the dialog once product uupdated
ChangeErrorMsg.setText(file_url);
pDialog.dismiss();
}