我尝试在注册时使用firebase自动生成的ID来设置片段,但它向我显示了null或如何获取ID ????
documentReference=FirebaseFirestore.getInstance().collection("users").document();
if (task.getResult().size() == 0) {
//Toast.makeText(SignUpActivity.this, "Username not exists", Toast.LENGTH_SHORT).show();
reference.document(email).set(map).addOnCompleteListener(new OnCompleteListener<Void>() {
@Override
public void onComplete(@NonNull Task<Void> task) {
if (task.isSuccessful()){
mProgress.dismiss();
Intent homeActivity=new Intent(SignUpActivity.this, MainActivity.class);
homeActivity.putExtra("userid",email);
homeActivity.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
startActivity(homeActivity);
Toast.makeText(SignUpActivity.this, "Register sucessfully", Toast.LENGTH_SHORT).show();
}
else {
Toast.makeText(SignUpActivity.this, ""+task.getException().getLocalizedMessage(), Toast.LENGTH_SHORT).show();
}
告诉我零点。