为什么任务无法成功进行Firebase身份验证

时间:2019-04-12 15:11:54

标签: android firebase firebase-authentication

我尝试使用Firebase登录。我对这些代码进行了编码,但是当我在应用程序上登录时,我从!task.isSuccessful接收了我的代码。我基本上如何解决这个问题?我是android studio的新手。

当我单击“登录”按钮调用此功能时,我认为这部分代码可能不正确

private void createAccount(){
    String email=userEmail.getText().toString();
    String password=userPassword.getText().toString();
    mAuth.createUserWithEmailAndPassword(email,password).
            addOnCompleteListener(this, new OnCompleteListener<AuthResult>() {
        @Override
        public void onComplete(@NonNull Task<AuthResult> task) {
        //when Authentication is successful
            if (task.isSuccessful()){  
Log.d(TAG,"createUserWithEmail:onComplete"+task.isSuccessful());
                Toast.makeText(SignInActivity.this,"Registration was 
provided",Toast.LENGTH_SHORT).show();
                Intent signIn= new 
Intent(SignInActivity.this,UserMainActivity.class);
                startActivity(signIn);
            }//when Authentication is failed
             else {
                Toast.makeText(SignInActivity.
                        this,"Registration is unsuccessful! Please try 
again...",Toast.LENGTH_SHORT).show();
            }

        }
    });
}

0 个答案:

没有答案