Skip to content

Instantly share code, notes, and snippets.

@benhaxe
Created November 23, 2017 12:23
Show Gist options
  • Save benhaxe/1bb4de7cbf5b7f00cacd3895f4aeb0ad to your computer and use it in GitHub Desktop.
Save benhaxe/1bb4de7cbf5b7f00cacd3895f4aeb0ad to your computer and use it in GitHub Desktop.
Still on firebase database, this codes checks for the state of a user in the firebase real tile database state.
DatabaseReferene connectRef = FirebaseDatabase.getInstance().getReference(".info/connected");
connectRef.addValueEventListener(new ValueEventListener() {
@override
public void onDataCHanged(DataSnapshot dataSnapshot){
boolean isConnected = dataSnapshot.getValue(Boolean.class);
if(connected){
System.out.println("Your are now connected");
}else{
System.out.println("Your are disconnected");
}
}
@override
public void onCanclled(DatabseError error){
System.out.println("Database error" + error.getMessage);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment