private boolean checkPhoneNumber() { EditText checkingPhoneNumber = (EditText)findViewById(R.id.Number); String phoneNumber = checkingPhoneNumber.getText().toString(); if (phoneNumber.length()<8 || phoneNumber.length()>20) { return false; } else { return true; } } private boolean checkEmail() { EditText checkingEmail = (EditText)findViewById(R.id.Email); String email = checkingEmail.getText().toString(); if (email.matches("@") & email.matches(".")) { Email = true; return true; } else { Email = false; return false; } } private boolean checkName() { EditText checkingName = (EditText)findViewById(R.id.Name); String Name = checkingName.getText().toString(); if (Name.length()<3) { name = false; return false; } else { name = true; return true; } } public void onClick(View v){ TextView Hint = (TextView)findViewById(R.id.Hint); if (checkPhoneNumber() == true || checkName() == true || checkEmail() == true) { Intent giftActivity = new Intent(RegistrationActivity.this, GiftHomeActivity.class); startActivity(giftActivity); .... Verification does not work. When entering any values, the next activity will still start.
onClickto launch an activity it is enough to fulfill any condition, and not all at once, as you probably want. Secondly,String.matcheschecks that the entire string matches the regular order, i.e. The only validemailyou have is "@". Third, writeif ( выражение ) { return true; } else {return false;}if ( выражение ) { return true; } else {return false;}not necessary, you can justreturn выражение;, equality testвыражение == truealso superfluous. - zRrr 5:09