I'm having a problem with one specific device (my main device which is galaxy s7)
as described here : Firebase addValueEventListener not being triggered
the addvalueeventlistener won't trigger and as suggested i checked if i have connection using this :
https://firebase.google.com/docs/database/android/offline-capabilities#section-connection-state
and i'm actually not connected
the problem is that one the developing device it's working great and on other it's not.
what am i missing here ?
this is the code:
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
localCountryDB = ((GlobalState) this.getApplication()).getCountry();
mAuth = FirebaseAuth.getInstance();
mFirebaseDatabase = FirebaseDatabase.getInstance();
myRef = mFirebaseDatabase.getReference().child(localCountryDB);
FirebaseUser user = mAuth.getCurrentUser();
if (mAuth.getCurrentUser()!=null)
userID = user.getUid();
DatabaseReference connectedRef = FirebaseDatabase.getInstance().getReference(".info/connected");
connectedRef.addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot snapshot) {
boolean connected = snapshot.getValue(Boolean.class);
if (connected) {
System.out.println("connected");
} else {
System.out.println("not connected");
}
}
@Override
public void onCancelled(DatabaseError error) {
System.err.println("Listener was cancelled");
}
});
valueEventListener = myRef.addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
getUserData(dataSnapshot);
}
@Override
public void onCancelled(DatabaseError databaseError) {
String Hello;
Hello="a";
}
});