Android I';我正在尝试从firestore、collection聊天室(Id是两个用户的电子邮件)获取与我聊天的用户,但值为0 chatCollection.addSnapshotListener(getActivity(),new EventListe

Android I';我正在尝试从firestore、collection聊天室(Id是两个用户的电子邮件)获取与我聊天的用户,但值为0 chatCollection.addSnapshotListener(getActivity(),new EventListe,android,google-cloud-firestore,Android,Google Cloud Firestore,I';我正在尝试从firestore、collection聊天室(Id是两个用户的电子邮件)获取与我聊天的用户,但值为0 chatCollection.addSnapshotListener(getActivity(),new EventListener()){ @凌驾 public void onEvent(@Nullable QuerySnapshot值,@Nullable FirebaseFirestoreException错误){ if(错误!=null){ Log.d(标记“E

I';我正在尝试从firestore、collection聊天室(Id是两个用户的电子邮件)获取与我聊天的用户,但值为0 chatCollection.addSnapshotListener(getActivity(),new EventListener()){ @凌驾 public void onEvent(@Nullable QuerySnapshot值,@Nullable FirebaseFirestoreException错误){ if(错误!=null){ Log.d(标记“Error:+Error.getMessage()); 返回; } for(QueryDocumentSnapshot文档快照:值){ String id=documentSnapshot.getId(); //这里我想获取文档id,但上面的值是0 } } });
此代码中的哪些内容没有按您期望的方式工作?如果你感兴趣,在这里你可以找到一个关于如何创建一个完整的和功能性的。
  chatCollection.addSnapshotListener(getActivity(), new EventListener<QuerySnapshot>() {
            @Override
            public void onEvent(@Nullable QuerySnapshot value, @Nullable FirebaseFirestoreException error) {
                if(error!=null){
                    Log.d(TAG,"Error:"+error.getMessage());
                    return;
                }
                for(QueryDocumentSnapshot documentSnapshot:value){
                    String id=documentSnapshot.getId();
                    //Here I want to get the document id but the value above is 0
                }
            }
        });