【发布时间】:2025-09-24 19:30:03
【问题描述】:
我有这段代码可以从特定的子集合中获取数据:
db.collection("groups").document(id.get(i)).collection("members")
.get()
.addOnCompleteListener(new OnCompleteListener<QuerySnapshot>() {
@Override
public void onComplete(@NonNull Task<QuerySnapshot> task) {
if (task.isSuccessful()) {
for (QueryDocumentSnapshot document : task.getResult()) {
id.add(document.getId());
Log.e(Tag, document.getId() + " => " + document.getData());
if (task.getResult().isEmpty()) {
Log.d(Tag, "onSuccess: LIST EMPTY");
return;
} else {
// Convert the whole Query Snapshot to a list
// of objects directly! No need to fetch each
// document.
Log.e(Tag, task.getResult() + "");
typeAll = task.getResult().toObjects(GroupMembers.class);
}
}
} else {
Log.e(Tag, "Error getting documents: ", task.getException());
}
但是我需要在通过快照获取所有数据后调用一个方法。如何做到这一点?我应该测试什么?
【问题讨论】:
标签: java android firebase google-cloud-firestore