private void prepareConfirmationEmail(final LewaUser user) {

    final EditText email = new EditText(getApplicationContext());
    email.setTag("email-input");
    email.setHint(getString(R.string.label_email_address));
    email.setInputType(InputType.TYPE_TEXT_VARIATION_EMAIL_ADDRESS);
    String newEmailAddress = email.getEditableText().toString().toLowerCase().trim();
    if (newEmailAddress.equals("")) newEmailAddress = user.getEmailAddressNew();
    if (!newEmailAddress.equals("") && !newEmailAddress.equals(user.getEmailAddressNew())) {
      user.setEmailAddress(newEmailAddress);
      user.setEmailAddressNew(newEmailAddress);
    }
    final ProgressDialog resendVerificationProgressDialog =
        ProgressDialog.show(
            LewaLoginActivity.this,
            getString(R.string.label_email_verification),
            String.format(
                "%s: %s",
                getString(R.string.dialog_resend_verification_email), user.getEmailAddress()),
            true,
            true,
            new OnCancelListener() {
              @Override
              public void onCancel(DialogInterface dialog) {
                dialog.dismiss();
              }
            });
    Thread thread =
        new Thread(
            new Runnable() {
              @Override
              public void run() {
                Looper.prepare();
                lewaAuthService.resendActivationEmail(
                    new SendConfirmEmailHandler(resendVerificationProgressDialog), user);
              }
            });
    thread.start();
  }
  private void resendConfirmationEmail(String error) {

    final LewaUser user = LewaUser.getInstance(getApplicationContext());
    final EditText email = new EditText(getApplicationContext());
    email.setTag("email-input");
    email.setHint(getString(R.string.label_email_address));
    email.setInputType(InputType.TYPE_TEXT_VARIATION_EMAIL_ADDRESS);
    email.setText(user.getEmailAddressNew());
    if (!error.equals("")) {
      email.setError(error);
    }
    this.emailViewId = email.getId();
    AlertDialog.Builder alert = new AlertDialog.Builder(this);
    alert.setTitle(getString(R.string.label_email_verification));
    alert.setMessage(getString(R.string.dialog_resend_verification_email));
    alert.setView(email);
    alert.setCancelable(true);
    alert.setPositiveButton(
        getString(R.string.label_ok),
        new DialogInterface.OnClickListener() {
          public void onClick(DialogInterface dialog, int whichButton) {
            email.invalidate();
            dialog.cancel();
            String emailAddress = email.getEditableText().toString().trim().toLowerCase();
            String emailDomain = LewaUtils.validateEmail(emailAddress, true);
            Message message = Message.obtain();
            if (emailDomain != "") {
              user.setEmailAddress(emailAddress);
              message.what = USER_INPUT_VALID;
            } else {
              message.what = USER_INPUT_INVALID;
            }
            confirmEmailHandler.sendMessageDelayed(message, 1500);
          }
        });
    alert.show();
  }