I'm begginer in coding and I don't know how to solve this bug. I'm creating an app and in the login class the app stop working when fields are wmpty and pressing login button. Please help me with this
This is the code:
binding.submitBtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
String email, pass;
email = binding.emailBox.getText().toString();
pass = binding.passwordBox.getText().toString();
dialog.show();
auth.signInWithEmailAndPassword(email, pass).addOnCompleteListener(new OnCompleteListener<AuthResult>() {
@Override
public void onComplete(@NonNull Task<AuthResult> task) {
dialog.dismiss();
if(task.isSuccessful()){
startActivity(new Intent(LoginActivity.this, MainActivity.class));
finish();
} else {
Toast.makeText(LoginActivity.this, task.getException().getLocalizedMessage(), Toast.LENGTH_SHORT).show();
}
}
});
}
});