Created
November 23, 2017 12:23
-
-
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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