AndroidStudio 添加 Firebase 选项



AndroidStudio4.2 以停止更新,默认存在firebase连接
创建 Firebase 项目 添加到 Android 项目中
准备好 google 账号
打开 Firebase

进入控制台

选择项目名称

继续

选择默认账户或者创建

稍等片刻

完成

根据提示在Android项目中添加各个SDK

使用 Cloud Storage的话需要添加SDK到应用
dependencies {
// Import the BoM for the Firebase platform
implementation platform('com.google.firebase:firebase-bom:28.1.0')
// Declare the dependency for the Cloud Storage library
// When using the BoM, you don't specify versions in Firebase library dependencies
implementation 'com.google.firebase:firebase-storage-ktx'
}
删除 Firebase 项目
点击设置

选择项目设置
翻到最底部

删除项目。

在 CloudFireStore中添加 元数据





将 Storage中的数据链接添加到元数据中



com.google.firebase.firestore.Query类
A Query which you can read or listen to.
您可以阅读或收听的查询。
You can also construct refined Query objects by adding filters and ordering.
您还可以通过添加过滤器和排序来构造精细的Query对象。
get方法
Executes the query and returns the results as a QuerySnapshot.
执行查询并以QuerySnapshot的形式返回结果。
public Task<QuerySnapshot> get ()
返回值
将返回的结果解析为Query
com.google.firebase.firestore.QuerySnapshot类
A QuerySnapshot contains the results of a query.
quersnapshot查询结果。
It can contain zero or more DocumentSnapshot objects.
它可以包含零个或多个DocumentSnapshot对象。
toObjects方法
Returns the contents of the documents in the QuerySnapshot, converted to the provided class, as a list.
以列表的形式返回QuerySnapshot中文档的内容,并转换为提供的类。
public List<T> toObjects (Class<T> clazz)
参数
The POJO type used to convert the documents in the list.
用来转换列表中文档的POJO类型。