gpt4 book ai didi

java - Firestore-检查用户名是否已存在

转载 作者:搜寻专家 更新时间:2023-11-01 09:23:13 26 4
gpt4 key购买 nike

<分区>

我需要 Firestore 方面的帮助。我有一个 AllUsers 数据集合,包含每个用户信息的用户 ID 文档。我想检查用户名是否已经存在;//“该用户名已经存在”。我该怎么做?

` setupBtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {

final String user_name = setupName.getText().toString();

Map<String, Object> commentsMap = new HashMap<>();
commentsMap.put("user_id", user_id);
commentsMap.put("timestamp", FieldValue.serverTimestamp());
commentsMap.put("user_name",user_name);
firebaseFirestore.collection("AllUsers").document(user_id).set(commentsMap).addOnCompleteListener(new OnCompleteListener<Void>() {
@Override
public void onComplete(@NonNull Task<Void> task) {
if(task.isSuccessful()){
Intent asda=new Intent(getApplicationContext(),MainActivity.class);
startActivity(asda);
finish();
}

}
});

`

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