This question is an exact duplicate:
public class RegistrationActivity extends Activity { boolean number; boolean name; boolean Email; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_registration); } public void BackToLogin(View view) { Intent BackToLogin = new Intent(RegistrationActivity.this, LoginActivity.class); startActivity(BackToLogin); } private boolean CheckPhoneNumber() { TextView hint = (TextView)findViewById(R.id.NumberTextView); EditText checkPhoneNumber = (EditText)findViewById(R.id.Number); String phoneNumber = checkPhoneNumber.getText().toString(); if (phoneNumber.length()<8 || phoneNumber.length()>20) { hint.setText("You enter wrong phone number. Try again"); checkPhoneNumber.setText(""); return number = false; } else { return number = true; } } private boolean CheckEmail() { TextView Hint = (TextView)findViewById(R.id.EmailTextView); EditText checkEmail = (EditText)findViewById(R.id.Email); String email = checkEmail.getText().toString(); if (email.matches("@") & email.matches(".")) { Email = true; return Email; } else { Email = false; Hint.setText("You enter wrong E-mail. It must contains symbol '@' and '.'"); return Email; } } private boolean CheckName() { TextView Hint = (TextView)findViewById(R.id.NameTextView); EditText checkName = (EditText)findViewById(R.id.Name); String Name = checkName.getText().toString(); if (Name.length()<3) { Hint.setText("Your name must contains more than 3 symbols"); name = false; return name; } else { name = true; return name; } } public void GiftActivity(View view) { TextView Hint = (TextView)findViewById(R.id.Hint); if (name == false && Email == false && number == false) { Hint.setText("You enter something wrong. Please, check again."); } else { Intent GiftActivity = new Intent(RegistrationActivity.this, GiftHomeActivity.class); startActivity(GiftActivity); } }