基本Firebase Java连接

前端之家收集整理的这篇文章主要介绍了基本Firebase Java连接前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我试图在 Java应用程序中建立与firebase的基本连接,并且使用提供的基本代码我根本无法获得任何响应.

这是我正在使用的代码

package fix;

import com.firebase.client.*;

public class Main {

  public static void main(String args[]) throws Exception {

    String url = "https://----.firebaseIO.com/";
    Firebase dataRef = new Firebase(url);

    dataRef.addListenerForSingleValueEvent(new ValueEventListener() {
         @Override
         public void onDataChange(DataSnapshot snapshot) {
             System.out.println("data");
         }

         @Override
         public void onCancelled() {
             System.err.println("Listener was cancelled");
         }
    });

    System.out.println("hi");
  }
}

图书馆似乎装得很好.有什么建议?

更新

[java] Fri Sep 06 09:54:43 PDT 2013 [DEBUG] ViewManager: Raising events for /.info/authenticated
 [java] Fri Sep 06 09:54:43 PDT 2013 [DEBUG] ViewManager: Doing onDiff with changes: []
 [java] Fri Sep 06 09:54:43 PDT 2013 [DEBUG] ViewManager: Marking queries complete for /.info/authenticated
 [java] Fri Sep 06 09:54:43 PDT 2013 [DEBUG] ViewManager: Marking queries complete for /.info/authenticated
 [java] Fri Sep 06 09:54:43 PDT 2013 [DEBUG] ViewManager: Marking queryMap complete:null
 [java] Fri Sep 06 09:54:43 PDT 2013 [DEBUG] ViewManager: Marking queries complete for /.info/authenticated
 [java] Fri Sep 06 09:54:43 PDT 2013 [DEBUG] ViewManager: Marking queryMap complete:null
 [java] Fri Sep 06 09:54:43 PDT 2013 [DEBUG] ViewManager: Raising events for /.info/connected
 [java] Fri Sep 06 09:54:43 PDT 2013 [DEBUG] ViewManager: Doing onDiff with changes: []
 [java] Fri Sep 06 09:54:43 PDT 2013 [DEBUG] ViewManager: Marking queries complete for /.info/connected
 [java] Fri Sep 06 09:54:43 PDT 2013 [DEBUG] ViewManager: Marking queries complete for /.info/connected
 [java] Fri Sep 06 09:54:43 PDT 2013 [DEBUG] ViewManager: Marking queryMap complete:null
 [java] Fri Sep 06 09:54:43 PDT 2013 [DEBUG] ViewManager: Marking queries complete for /.info/connected
 [java] Fri Sep 06 09:54:43 PDT 2013 [DEBUG] ViewManager: Marking queryMap complete:null
 [java] Fri Sep 06 09:54:43 PDT 2013 [DEBUG] ViewManager: Adding Value Event Listener callback for path: /
 [java] Fri Sep 06 09:54:43 PDT 2013 [DEBUG] PersistentConnection: pc_0 - Listening on / for [{}]
 [java] Fri Sep 06 09:54:43 PDT 2013 [DEBUG] PersistentConnection: pc_0 - Adding listen params: [{}]
 [java] Fri Sep 06 09:54:43 PDT 2013 [DEBUG] EventRaiser: Raising 0 event(s)
 [java] wait
 [java] wait
 [java] wait
 [java] wait

解决方法

Firebase工程师在这里,您可以启用日志记录并发布输出吗?您可以执行以下操作来启用日志
Firebase.getDefaultConfig().setLogLevel(Logger.Level.DEBUG);

另外,你可以添加观察者吗?

dataRef.child(".info/connected");

并记录您从中获得的事件?这将告诉您何时连接或与Firebase断开连接.

编辑:
这是通过电子邮件解决的.这是客户端库中的一个错误,现在已经解决了.您可以从网站下载最新版本:https://www.firebase.com/docs/downloads.html

原文链接:https://www.f2er.com/java/129362.html

猜你在找的Java相关文章