【发布时间】:2018-08-04 06:50:43
【问题描述】:
我收到Null Object Reference,当我退出时应用程序崩溃。
代码:
//Get Comments Count
firebaseFirestore.collection("Posts/" + postId + "/Comments").addSnapshotListener(new EventListener<QuerySnapshot>() {
@Override
public void onEvent(QuerySnapshot documentSnapshots, FirebaseFirestoreException e) {
if (!documentSnapshots.isEmpty())
{
int count = documentSnapshots.size();
holder.updateCommentsCount(count);
}
else if(documentSnapshots.isEmpty())
{
holder.updateCommentsCount(0);
}
}
});
错误:
尝试在空对象引用上调用虚拟方法“boolean com.google.firebase.firestore.QuerySnapshot.isEmpty()”
【问题讨论】:
-
请添加您的数据库结构。
标签: java android firebase google-cloud-firestore