gpt4 book ai didi

android - 生成父 UID 以使用 google auth android studio firebase 进行注册

转载 作者:行者123 更新时间:2023-12-04 10:24:33 24 4
gpt4 key购买 nike

关闭。这个问题需要details or clarity .它目前不接受答案。












想改善这个问题吗?通过 editing this post 添加详细信息并澄清问题.

去年关闭。




Improve this question




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

我搜索了模型,但没有成功,如果有人可以帮助我,我将不胜感激

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

模型

public class User implements Serializable {
private String user;
private String email;
private String photoUrl;
private String uid;
private String money;
private String cassinotime;
private String cassinoprofit;

public String getCassinotime() {
return cassinotime;
}

public void setCassinotime(String cassinotime) {
this.cassinotime = cassinotime;
}

public String getCassinoprofit() {
return cassinoprofit;
}

public void setCassinoprofit(String cassinoprofit) {
this.cassinoprofit = cassinoprofit;
}

public User(String user, String email, String photoUrl, String uid, String money) {
this.user = user;
this.email = email;
this.photoUrl = photoUrl;
this.uid = uid;
this.money = money;
}

public User() {
}

public User(String user, String email, String photoUrl, String uid) {

this.user = user;
this.email = email;
this.photoUrl = photoUrl;
this.uid = uid;
}

public String getMoney() {
return money;
}

public void setMoney(String money) {
this.money = money;
}

public String getUser() {

return user;
}

public void setUser(String user) {
this.user = user;
}

public String getEmail() {
return email;
}

public void setEmail(String email) {
this.email = email;
}

public String getPhotoUrl() {
return photoUrl;
}

public void setPhotoUrl(String photoUrl) {
this.photoUrl = photoUrl;
}

public String getUid() {
return uid;
}

public void setUid(String uid) {
this.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();
}
}
});

最佳答案

                       val ref = database.push().key
mapinfoinstance.id = ref!!
database.child(ref).setValue(mapinfoinstance)

'mapinfoinstance' 是我的类的一个实例。

我想你想要这样:
enter image description here

关于android - 生成父 UID 以使用 google auth android studio firebase 进行注册,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60681192/

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