Question Detail

How can i get check Email ID is valid formatted or Not Android?

6 years ago Views 1636 Visit Post Reply

How can I check that user is entering right Email ID? Is there any email id Formate checker how can check the pattern of Email ID?


Thread Reply

Anonymous

- 6 years ago

if you don't want to set accurate Email Address Checker you can use this.

private boolean isEmailValid(String email) {
    //TODO: Replace this with your own logic
    return email.contains("@");
}
Correct Answer

Hemant Sharma

- 6 years ago

public final static boolean isvalidEmailID(CharSequence email) {
    if (email == null || email.toString().isEmpty()) {
        return false;
    } else {
        return android.util.Patterns.EMAIL_ADDRESS.matcher(email).matches();
    }
}
Correct Answer

Hemant Sharma

- 6 years ago

public final static boolean isvalidEmailID(CharSequence email) {
    if (email == null || email.toString().isEmpty()) {
        return false;
    } else {
        return android.util.Patterns.EMAIL_ADDRESS.matcher(email).matches();
    }
}