Android Firebase Sign In With Email And Password
I have an android app and a Firebase database. The login I've set is with email and password. It works great, but when I try and login with blank email and password the app crashes
Solution 1:
This would help you :)
finalStringEmail= email.getText().toString();
finalStringPassword= password.getText().toString();
if(!TextUtils.isEmpty(Email) && !TextUtils.isEmpty(Password)) {
mAuth.signInWithEmailAndPassword(email, password).addOnCompleteListener(CustomerLoginActivty.this, newOnCompleteListener<AuthResult>() {
@OverridepublicvoidonComplete(@NonNull Task<AuthResult> task) {
if (!task.isSuccessful()) {
Toast.makeText(ThisActivity.this, "sign in error", Toast.LENGTH_SHORT).show();
} else
mAuth.addAuthStateListener(firebaseAuthListener);
}
});
break;
}
Solution 2:
Both parameters email and password should not be either null or empty. So if you need to log with blank spaces, make sure you validate the fields and not send a null or an empty to the method signInWithEmailAndPassword
Post a Comment for "Android Firebase Sign In With Email And Password"