Email validation in Android

In Android email validation is an important thing, if the user is entered an invalid email id then we need to show some alert messages to the user. This will be required in most of the Android application with uses some thing with email id. here i am writing some code to do this, 
  1. public static boolean isEmailAddress(EditText editText, boolean required)  
  2. {  
  3.     String EMAIL_REGEX = "^[_A-Za-z0-9-\\+]+(\\.[_A-Za-z0-9-]+)*@[A-Za-z0-9-]+(\\.[A-Za-z0-9]+)*(\\.[A-Za-z]{2,})$";  
  4.     return isValid(editText, EMAIL_REGEX, EMAIL_MSG, required);  
  5. }  
  6. public static boolean isValid(EditText editText, String regex, String errMsg, boolean required)  
  7. {  
  8.     String text = editText.getText().toString().trim();  
  9.     // clearing the error, if it was previously set by some other values  
  10.     editText.setError(null);  
  11.     // text required and editText is blank, so return false  
  12.     if (required && !hasText(editText)) return false;  
  13.     // pattern doesn't match so returning false  
  14.     if (required && !Pattern.matches(regex, text))   
  15.     {  
  16.         editText.setError(errMsg);  
  17.         return false;  
  18.     };  
  19.     return true;  
  20. }  
  21. public static boolean hasText(EditText editText)  
  22. {  
  23.     String text = editText.getText().toString().trim();  
  24.     editText.setError(null);  
  25.     // length 0 means there is no text  
  26.     if (text.length() == 0)   
  27.     {  
  28.         editText.setError(REQUIRED_MSG);  
  29.         return false;  
  30.     }  
  31.     return true;  
  32. }  

This will return false if the entered email id is invalid otherwise true.