生成用于向google auth android studio firebase注册的父UID

生成用于向google auth android studio firebase注册的父UID,android,firebase,firebase-realtime-database,Android,Firebase,Firebase Realtime Database,我需要帮助如何使用用户模型。创建帐户而不是使用电子邮件生成父节点时。将主节点设为uid。我尝试了一些修改,但没有成功。有人可以帮助我。该帐户由google auth创建,它希望生成一个主uid节点,而不是电子邮件 我寻找模型,但我没有成功,如果有人能帮助我,我将非常感激 我仍然需要电子邮件,但不是作为主节点。对于主节点,我需要模型中已经存在的uid,但我无法进行此更改:( 模型 谷歌创建帐户代码 private void firebaseAuthWithGoogle(final Goo

我需要帮助如何使用用户模型。创建帐户而不是使用电子邮件生成父节点时。将主节点设为uid。我尝试了一些修改,但没有成功。有人可以帮助我。该帐户由google auth创建,它希望生成一个主uid节点,而不是电子邮件


我寻找模型,但我没有成功,如果有人能帮助我,我将非常感激


我仍然需要电子邮件,但不是作为主节点。对于主节点,我需要模型中已经存在的uid,但我无法进行此更改:(


模型


谷歌创建帐户代码

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

                            User user = new User(


                            );
                            String photoUrl = null;
                            if (account.getPhotoUrl() != null) {
                                user.setPhotoUrl(account.getPhotoUrl().toString());
                            }

                            user.setEmail(account.getEmail());
                            user.setUser(account.getDisplayName());
                            user.setUid(mAuth.getCurrentUser().getUid());
                            user.setMoney(money);
                            user.setCassinotime(cassinotime);
                            user.setCassinoprofit(cassinoprofit);

                            FirebaseUtils.getUserRef(account.getEmail())
                                    .setValue(user, new DatabaseReference.CompletionListener() {
                                        @Override
                                        public void onComplete(DatabaseError databaseError, DatabaseReference databaseReference) {
                                            mFirebaseUser = mAuth.getCurrentUser();
                                            finish();
                                        }
                                    });
                        } else {
                            dismissProgressDialog();
                        }
                    }
                });
private void firebaseAuthWithGoogle(最终谷歌签名帐户){
AuthCredential credential=GoogleAuthProvider.getCredential(account.getIdToken(),null);
mAuth.SIGNWITH凭证(凭证)
.addOnCompleteListener(这是新的OnCompleteListener(){
@凌驾
未完成的公共void(@NonNull任务){
if(task.issusccessful()){
用户=新用户(
);
字符串photoUrl=null;
if(account.getPhotoUrl()!=null){
user.setPhotoUrl(account.getPhotoUrl().toString());
}
user.setEmail(account.getEmail());
user.setUser(account.getDisplayName());
user.setUid(mAuth.getCurrentUser().getUid());
user.setMoney(money);
user.setCassinotime(cassinotime);
user.setCassinoprofit(cassinoprofit);
FirebaseUtils.getUserRef(account.getEmail())
.setValue(用户,新数据库引用.CompletionListener(){
@凌驾
public void onComplete(DatabaseError DatabaseError,DatabaseReference DatabaseReference){
mFirebaseUser=mAuth.getCurrentUser();
完成();
}
});
}否则{
dismissProgressDialog();
}
}
});
“MapInfo实例”是我的类的实例

我想你想要这样: 解决方案

FirebaseUtils.getUserRef(account.getEmail())
                                    .setValue(user,

                       val ref = database.push().key
                        mapinfoinstance.id = ref!!
                        database.child(ref).setValue(mapinfoinstance)
FirebaseUtils.getUserRef(account.getEmail())
                                    .setValue(user,
 FirebaseDatabase.getInstance().getReference("users")
                                        .child(FirebaseAuth.getInstance().getCurrentUser().getUid())
                                        .setValue(user)