I have an activity that has two EditText boxes, one email and one plain text. I want to check that the email box is not empty and also that is matches an email pattern before allowing the user to move on. The pattern matcher part works, but the empty string part doesn't.

I validate as the user enters data, and then set the two buttons to the be clickable or not according to whether the email is correct. However, if the box is empty, it allows the user to press the button when it shouldn't. When there is text in the box, it does the correct thing of only letting the user press the button when the email pattern has been matched. 

My after text changed method:

```
        public void afterTextChanged(Editable s) {
            // TODO Auto-generated method stub
            String enteredEmail = email.getText().toString();

            if (validateEmail(enteredEmail) == true) {
                image1.setImageResource(R.drawable.greentick);
                play.setClickable(true);
                play.setFocusable(true);
                existingUser.setClickable(true);
                existingUser.setFocusable(true);
            }

            else {
                System.out.println("Invalid");
                image1.setImageResource(R.drawable.redcross);
                play.setClickable(false);
                play.setFocusable(false);
                existingUser.setClickable(false);
                existingUser.setFocusable(false);
            }
        }

```

And my validateEmail() method:

```
public boolean validateEmail(String email) {

    boolean validated = false;
    if (android.util.Patterns.EMAIL_ADDRESS.matcher(email).matches() && (! email.equals("")) ) {
        validated = true;           
    }

    else {
        validated = false;
    }   
    return validated;
}

```