Hi I am very new for android and in my app I have Validations for Change password page.
That means the Password must contain minimum 8 characters at least 1 Alphabet
try following Code
//*****************************************************************
public static boolean isValidPassword(final String password) {
Pattern pattern;
Matcher matcher;
final String PASSWORD_PATTERN = "^(?=.*[0-9])(?=.*[A-Z])(?=.*[@#$%^&+=!])(?=\\S+$).{4,}$";
pattern = Pattern.compile(PASSWORD_PATTERN);
matcher = pattern.matcher(password);
return matcher.matches();
}
And change your code to this
if(newPassword.getText().toString().length()<8 &&!isValidPassword(newPassword.getText().toString())){
System.out.println("Not Valid");
}else{
System.out.println("Valid");
}