저는 Firebase를 사용하고 있으며 "createUserWithEmailAndPassword"라고 불리는 사용자 계정을 만드는 방법을 사용하고 있습니다.createUserWithEmailAndPassword 메서드의 예외를 재정의하는 방법은 무엇입니까?
Firebase references에서이 메소드 중 하나가 암호가 6 자 미만일 때 호출되는 "FirebaseAuthWeakPasswordException"이라는 것을 발견했습니다.
나는이 예외를 잡아 내 자신의 단어와 함께 사용자에게 을 메시지를 보여주고 싶어하지만 난 & 캐치를 시도와 방법을 포장 할 때이 오류를 얻을 : "예외 'com.google.firebase.auth.FirebaseAuthWeakPasswordException을 '해당 try 블록 "에서 throw되지 않습니다. 잠시 동안이 문제를 해결하려했지만 행운이 없었습니다. 여기에 코드 조각이, 당신이 내 그림을 도울 수 있기를 바랍니다 : 당신은 당신이 올바른 오류 코드 또는 예외를 얻을 수없는 이유 어떤 FailureListener을 추가하지 않은
mAuth.createUserWithEmailAndPassword(email, pass)
.addOnCompleteListener(this, new OnCompleteListener<AuthResult>() {
@Override
public void onComplete(@NonNull Task<AuthResult> task) {
// Log.d(TAG, "createUserWithEmail:onComplete:" + task.isSuccessful());
// If sign in fails, display a message to the user. If sign in succeeds
// the auth state listener will be notified and logic to handle the
// signed in user can be handled in the listener.
if(task.isSuccessful())
{
Toast.makeText(getApplicationContext(),"Account has created!",Toast.LENGTH_SHORT).show();
}
if (!task.isSuccessful()) {
Toast.makeText(getApplicationContext(), "failed!",
Toast.LENGTH_SHORT).show();
}
}
});
너무 감사합니다! 이제 작동 중입니다. 그리고 나는 단지 "e instanceof"를 각 질문에 대한 참조 링크 인 FirebaseAuthWeakPasswordException, FirebaseAuthInvalidCredentialsException 및 FirebaseAuthUserCollisionException과 같은 가능한 예외로 변경합니다. – zb22
다행 :). 행운을 빕니다. –