首页 > 解决方案 > 如何修复此 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();
                }
            });
}

标签: javaandroidfirebasegoogle-cloud-firestore

解决方案


推荐阅读