I am trying to authenticate users with email and password through firebase. But it shows can not resolve updateUI(user). Here's this part of the code.
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);
}
}
});
}
}
}
If I am getting your problem rightly with the limited code that u shared above, the function call "updateUI" refred here (https://firebase.google.com/docs/auth/android/password-auth) is the call/function you have to write on your own to update ur UI elements, and as @BobSnyder mentioned here's the link to a reference code (https://github.com/firebase/quickstart-android/blob/master/auth/app/src/main/java/com/google/firebase/quickstart/auth/EmailPasswordActivity.java#L209)
The code is from the Firebase Quickstart-Android project. This is what it does. You can implement something similar:
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);
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With