gpt4 book ai didi

java - 错误: incompatible types: > cannot be converted to OnCompleteListenererro

转载 作者:行者123 更新时间:2023-12-02 01:05:55 24 4
gpt4 key购买 nike

下面是代码。我在编码方面没有太多经验。希望你能帮助我!非常感谢=)

我的错误是:

error: incompatible types: > cannot be converted to OnCompleteListener

 //Register new User
auth.createUserWithEmailAndPassword(edtEmail.getText().toString(),edtPassword.getText().toString())
.addOnCompleteListener(new OnSuccessListener<AuthResult>() {

@Override
public void onSuccess(AuthResult authResult) {
//Save user to db
User user = new User();
user.setEmail(edtEmail.getText().toString());
user.setName(edtName.getText().toString());
user.setPhone(edtPhone.getText().toString());
user.setPassword(edtPassword.getText().toString());

//User email to key
users.child(user.getEmail())
.setValue(user)
.addOnSuccessListener(new OnSuccessListener<Void>(){
@Override
public void onSuccess(Void aVoid) {
Snackbar.make(rootLayout, "Register successful !!! ", Snackbar.LENGTH_SHORT)
.show();
}

}).addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception e) {
Snackbar.make(rootLayout,"Failed "+e.getMessage(),Snackbar.LENGTH_SHORT)
.show();
}
})
}
})
.addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception e) {
Snackbar.make(rootLayout,"Failed "+e.getMessage(),Snackbar.LENGTH_SHORT)
.show();
}
});
}

});

最佳答案

正如堆栈跟踪建议使用 addOnSuccessListener 而不是 addOnCompleteListener 所示,如下所示:

auth.createUserWithEmailAndPassword(edtEmail.getText().toString(),edtPassword.getText().toString())
.addOnSuccessListener(new OnSuccessListener<AuthResult>() {

@Override
public void onSuccess(AuthResult authResult) {
//Save user to db
....
}
})
.addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception e) {
....
}
});

关于java - 错误: incompatible types: <anonymous OnSuccessListener<AuthResult>> cannot be converted to OnCompleteListener<AuthResult>erro,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60071452/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com