Email Validation Code in Android
Almost on every login and Sign Up screen, you have to create email field and add email validation on it.
Its a simple code for email validation.
Here you have to call it first doing login or sign up.
public static boolean checkValidEmail(EditText emailEditText,Context _context)
{
if(TextUtils.isEmpty(emailEditText.getText().toString())){
emailEditText.setError(_context.getString(R.string.empty_filed));
emailEditText.requestFocus();
return false;
}
else if(!(emailEditText.getText().toString().contains("@") && emailEditText.getText().toString().contains(".")))
{
emailEditText.setError(_context.getString(R.string.invalid_email));
emailEditText.requestFocus();
return false;
}
return true;
}
0 Comment(s)