Check if a string is a valid Email address by using android.util.Patterns.EMAIL_ADDRESS - Android android.util

Android examples for android.util:Patterns

Description

Check if a string is a valid Email address by using android.util.Patterns.EMAIL_ADDRESS

Demo Code


public class Main{

    public static boolean isEmail(String str) {
        if (str == null)
            return false;

        return android.util.Patterns.EMAIL_ADDRESS.matcher(str.trim())
                .matches();/*  w  w w. ja va 2s  .c  o  m*/
    }

}

Related Tutorials