l如何检索用户的个人资料名称信息,例如姓名,电子邮件和个人资料照片?

时间:2019-09-10 11:45:22

标签: java android firebase firebase-realtime-database firebase-authentication

redirectToCheckout

UserInformation类:

private void firebaseAuthWithGoogle(GoogleSignInAccount acct) {
    Log.d(TAG, "firebaseAuthWithGoogle:" + acct.getId());

    AuthCredential credential = GoogleAuthProvider.getCredential(acct.getIdToken(), null);
    mAuth.signInWithCredential(credential)
            .addOnCompleteListener(this, new OnCompleteListener<AuthResult>() {
                @Override
                public void onComplete(@NonNull Task<AuthResult> task) {
                    if (task.isSuccessful()) {

                        String currentUserID = mAuth.getCurrentUser().getUid();
                        DataRef.child("Users").child(currentUserID).child("Name").setValue(name);
                        DataRef.child("Users").child(currentUserID).child("Email").setValue(email);

                        // Sign in success, update UI with the signed-in user's information
                        Log.d(TAG, "signInWithCredential:success");
                        FirebaseUser user = mAuth.getCurrentUser();
                        updateUI();
                    } else {
                        // If sign in fails, display a message to the user.
                        Log.w(TAG, "signInWithCredential:failure", task.getException());
                        // Toast.makeText(MainActivity.this, task.getException().getLocalizedMessage(), Toast.LENGTH_SHORT).show();
                    }

                    // ...
                }
            });

2 个答案:

答案 0 :(得分:1)

首先分配Firebase用户。

FirebaseUser firebaseUser = mAuth.getCurrentUser();

将保留用户的数据。

有多种方法可以检索当前用户数据

String userEmail = firebaseUser.getEmail();
String uid = firebaseUser.getDisplayName();
String photouri = String.ValueOf(firebaseUser.getPhotoUrl());

答案 1 :(得分:0)

'password: "something"'.replace(/(?<=password[ :]+)[^\n,]+/i, '*****') 中,您需要添加:

task.isSuccessful(){