android - 未解决对 Firestore 侦听器上的任务结果数据的引用
问题描述
我有这种方法尝试从 Firestore 中检索文档,但由于某种原因,我收到一个错误:task.result.data 中的“未解析的引用:数据”,我可能错过了什么?
import android.util.Log
import com.google.firebase.firestore.FirebaseFirestore
val db = FirebaseFirestore.getInstance()
val docRef = db.collection("Cocab").document("Keys").collection("allkeys")
// do something
docRef.get().addOnCompleteListener { task ->
if (task.isSuccessful) {
val document = task.result
if (document != null) {
Log.d("mate", "DocumentSnapshot data: " + task.result.data)
} else {
Log.d("mate", "No such document")
}
} else {
Log.d("mate", "get failed with ", task.exception)
}
}
.addOnFailureListener { exception ->
Log.d("mate", "get failed with ", exception)
}
解决方案
推荐阅读
- multithreading - Fortran OpenMP 函数没有提高速度,增加线程数超过 2
- python - Python绘制极坐标方程
- python - 如何按色调/图例组用百分比注释条形图
- php - 卡在雄辩的查询和子查询中
- postgresql - 为什么 PostgreSQL 会改变查询计划?
- javascript - 如何使用JS在DOM中根据值(0/ 1)显示按钮
- android - 应用程序在将编辑保存到 pdf 文件 android 11 时崩溃
- excel - 即使 MS Access 应用程序打开,也可以运行 VBA 代码
- python - matplotlib:用一小组颜色绘制插值数据
- .htaccess - 通过 htaccess 重写动态 URL