FirebaseFirestore不执行给定查询

时间:2019-06-03 12:38:16

标签: android firebase google-cloud-firestore

enter image description here我正在尝试从文档中导入单个字段值。这里的问题是代码没有打印出来并给出了错误。我也已经从firestore文档中检查了代码。

我也尝试过使用OnSuccessListener,但没有结果。

private FirebaseFirestore db,db1;
Map<String,Object > number=new HashMap<>();


db = FirebaseFirestore.getInstance();

   DocumentReference docRef = db.collection("goals").document(email);
    docRef.get().addOnCompleteListener(new OnCompleteListener<DocumentSnapshot>() {

        @Override
          public void onComplete(@NonNull Task<DocumentSnapshot> task) {
              String TAG="lol";
              System.out.println("IT CAME Here") ;
              if (task.isSuccessful()) {
                  DocumentSnapshot document = task.getResult();
                  if (document.exists()) {
                      Log.d(TAG, "DocumentSnapshot data: " + document.getData());
                       number=document.getData();
                       name = document.getString("number");
                  } else {
                      Log.d(TAG, "No such document");
                  }
              } else {
                  System.out.println("get failed with ");
                  Log.d(TAG, "get failed with ", task.getException());
              }
          }
      });

甚至没有打印else循环中的打印语句。似乎跳过了这段代码

0 个答案:

没有答案