java - 如何修复此 Android Firebase“客户端离线”错误
问题描述
我正在尝试将我的 android 应用程序连接到 Firebase。但它显示“无法获取文档,因为客户端离线”应用程序运行时吐司。我看到了启动画面,但我得到了 toast 并且没有导航到第一个活动。
private void loadData() {
catList.clear();
firestore.collection("QuizApp").document("Categories").get().addOnSuccessListener(new OnSuccessListener<DocumentSnapshot>() {
@Override
public void onSuccess(DocumentSnapshot documentSnapshot) {
if(documentSnapshot.exists()){
long count = (long)documentSnapshot.get("COUNT");
for(int i=1; i<=count; i++){
String catName = documentSnapshot.getString("CAT"+ String.valueOf(i));
catList.add(catName);
}
final Intent anim_int = new Intent(SplashScreen.this,MainActivity.class);
startActivity(anim_int);
SplashScreen.this.finish();
}else{
Toast.makeText(SplashScreen.this,"No any categories",Toast.LENGTH_SHORT).show();
finish();
}
}
})
.addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception e) {
Toast.makeText(SplashScreen.this,e.getMessage(),Toast.LENGTH_SHORT).show();
}
});
}
解决方案
推荐阅读
- html - 从
- android - 在函数注释中引用具有视图绑定的 xml 元素
- quickfix - 如何在 TradeCaptureReport 中正确设置组?
- javascript - HTML-CSS 到页面顶部和底部按钮
- ios - 将航点任务上传到 Phantom 4 时出错
- javascript - 我可以在 for 循环中使用 if 语句吗
- python - 在 Python 上实现深度搜索策略时出错
- r - 通过 cumsum 获取数字序列
- ckeditor - CKEditor 4从word粘贴时将换行符转换为段落
- javascript - Vue.js 组件未显示在 Swal.fire html 中