@Override protected String doInBackground(String... arg0) { try { ApplicationSettings.isWeberviceReachable = WebServiceWrapper.Ping(); if (ApplicationSettings.isWeberviceReachable) { forgotPswResponse = WebServiceWrapper.ForgotPassword(edtTxtRecoverEmail.getText().toString()); if (forgotPswResponse == null) { return ApplicationSettings.translationSettings.GetTranslation( "and_msg_noInternetAccess", "No internet access."); } else { if (JSONHelper.getJsonObjectResult( "ForgotPasswordResult", "IsSuccessfull", forgotPswResponse)) { return "SUCCESS"; } else { return "FAILED"; } } } else { return "Couldnot access to server."; } } catch (Exception ex) { PMWF_Log.fnlog(PMWF_Log.ERROR, "editAsyncTask", ex.getMessage()); } return ""; }
@Override protected String doInBackground(String... params) { if (NetworkService.hasInternetConnection(getApplicationContext())) { String userResponse = WebServiceWrapper.CheckUser(editUserEmailAddress.getText().toString().trim()); if (userResponse != null) { msg = JSONHelper.getMessageResult("CheckUserResult", "Message", userResponse); if (JSONHelper.getJsonObjectResult("CheckUserResult", "IsSuccessfull", userResponse)) { return "FAILED"; // user already exist } else { return "SUCCESS"; } } else { return ApplicationSettings.translationSettings.GetTranslation( "and_msg_noInternetAccess", "No internet access"); } } else { return ApplicationSettings.translationSettings.GetTranslation( "and_msg_noInternetAccess", "No internet access"); } }
private void registerUser(String usersInfo) { final String usersInfoFinal = usersInfo; if (NetworkService.hasInternetConnection(getApplicationContext())) { ApplicationSettings.isWeberviceReachable = WebServiceWrapper.Ping(); if (ApplicationSettings.isWeberviceReachable) { new AsyncTask<String, Void, String>() { ProgressDialog dialog; @Override protected void onPreExecute() { super.onPreExecute(); dialog = new ProgressDialog(UsersInformation.this); String message = ApplicationSettings.translationSettings.GetTranslation( "and_msg_registering", "Registering user...."); dialog.setMessage(AlertMessage.setAlertHeaderColor(message, getApplicationContext())); dialog.setCancelable(false); dialog.show(); } @Override protected String doInBackground(String... result) { String pushResponse = WebServiceWrapper.RegisterUser(usersInfoFinal); return pushResponse; } @Override protected void onPostExecute(String result) { super.onPostExecute(result); try { if (dialog != null) { dialog.dismiss(); } } catch (Exception ex) { } try { Log.i("registeruser", result != null ? result : "Null response"); if (result != null) { String msg = JSONHelper.getMessageResult("RegisterUserResult", "Message", result); if (JSONHelper.getJsonObjectValueForRegister("IsSuccessfull", result)) { String message = ApplicationSettings.translationSettings.GetTranslation( "and_lbl_register", "Register"); new AlertShow(UsersInformation.this) .setTitle(AlertMessage.setAlertHeaderColor(message, getApplicationContext())) .setMessage(msg) .setPositiveButton( "OK", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { finish(); } }) .setCancelable(false) .show(); } else { String title = ApplicationSettings.translationSettings.GetTranslation( "and_lbl_register", "Register"); new AlertShow(UsersInformation.this) .setTitle(AlertMessage.setAlertHeaderColor(title, getApplicationContext())) .setMessage(msg) .setPositiveButton( "OK", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { finish(); } }) .setCancelable(false) .show(); } } else { AlertMessage.Alert( ApplicationSettings.translationSettings.GetTranslation( "and_msg_noInternetAccess", "No internet access."), UsersInformation.this); } } catch (Exception ex) { PMWF_Log.fnlog( PMWF_Log.ERROR, "UsersInformation: register onPostExecute()", PMWF_Log.getStringFromStackTrace(ex)); finish(); } } }.execute(); } else { AlertMessage.Alert( ApplicationSettings.translationSettings.GetTranslation( "and_msg_couldnotAccessToServer", "Couldnot access the server."), UsersInformation.this); } } else { AlertMessage.Alert( ApplicationSettings.translationSettings.GetTranslation( "and_msg_noInternetAccess", "No internet access."), UsersInformation.this); } }