gpt4 book ai didi

android - 无法解析 'updateUI' firebase

转载 作者:塔克拉玛干 更新时间:2023-11-02 22:07:40 26 4
gpt4 key购买 nike

我正在尝试通过 firebase 使用电子邮件和密码对用户进行身份验证。但它显示无法解析 updateUI(user)。这是代码的这一部分。

public void OnContinue(View view) {
if(hasClickedCountinueOnce){
EditText emailTextBox = (EditText)findViewById(R.id.email);
String user = userNAAME.getText().toString();
String passwordText = password.getText().toString();
String email = emailTextBox.getText().toString();
//todo manage new account here
if(!user.isEmpty() && !passwordText.isEmpty() ){
mAuth.createUserWithEmailAndPassword(email, passwordText)
.addOnCompleteListener(this, new OnCompleteListener<AuthResult>() {
@Override
public void onComplete(@NonNull Task<AuthResult> task) {
if (task.isSuccessful()) {
// Sign in success, update UI with the signed-in user's information
Log.d("SignInFailed", "createUserWithEmail:success");
FirebaseUser user = mAuth.getCurrentUser();
updateUI(user);
} else {
// If sign in fails, display a message to the user.
Log.w("SignInFailed", "createUserWithEmail:failure", task.getException());
Toast.makeText(SignUP.this, "Authentication failed.",
Toast.LENGTH_SHORT).show();
updateUI(null);
}
}
});
}
}
}

最佳答案

代码来自Firebase Quickstart-Android项目。这就是它的作用。你可以实现类似的东西:

   private void updateUI(FirebaseUser user) {
hideProgressDialog();
if (user != null) {
mStatusTextView.setText(getString(R.string.google_status_fmt, user.getEmail()));
mDetailTextView.setText(getString(R.string.firebase_status_fmt, user.getUid()));

findViewById(R.id.sign_in_button).setVisibility(View.GONE);
findViewById(R.id.sign_out_and_disconnect).setVisibility(View.VISIBLE);
} else {
mStatusTextView.setText(R.string.signed_out);
mDetailTextView.setText(null);

findViewById(R.id.sign_in_button).setVisibility(View.VISIBLE);
findViewById(R.id.sign_out_and_disconnect).setVisibility(View.GONE);
}
}

关于android - 无法解析 'updateUI' firebase,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44491418/

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