node.js - Firebase change data from server, listen on Android -
i'm playing firebase. updating data in server node.js:
var db = firebase.database() var ref = db.ref("game") ref.update({ "state": "state", "counter": counter })
the data in firebase console updated without problem in android, can't retrieve change. want listen "game" node's changes no luck.
databasereference database = firebasedatabase.getinstance().getreference(); databasereference ref = database.child("game"); ref.addchildeventlistener(new childeventlistener() { @override public void onchildadded(datasnapshot datasnapshot, string s) { log("1"); } @override public void onchildchanged(datasnapshot datasnapshot, string s) { log("2"); } @override public void onchildremoved(datasnapshot datasnapshot) { log("3"); } @override public void onchildmoved(datasnapshot datasnapshot, string s) { log("4"); } @override public void oncancelled(databaseerror databaseerror) { log("5"); } });
there no log in console.
also, valueeventlistener
i'm still not seeing change or error:
databasereference ref = database.child("game"); ref.addvalueeventlistener(new valueeventlistener() { @override public void ondatachange(datasnapshot datasnapshot) { log("1"); } @override public void oncancelled(databaseerror databaseerror) { log("2"); } });
i'm doing wrong. how can listen data changes in firebase?
i 'solved' issue re-logging user. guess bug.
relevant: firebase single value event listener doesn't return