Skip to content Skip to sidebar Skip to footer

Boolean Returns False When It Is Clearly True

So I have a super simple multiplayer game for my app. And when the game the players play ends, the Boolean gameFinished becomes true. Most of the things that happen in the game fir

Solution 1:

You are comparing a true value with a false. so it returns false. like this:

true.equals(false)

which returns false.

Change your code to this line of code:

if(dataSnapshot.child(currentGameID).child("gameFinished").getValue().equals(false))

to this:

if((Boolean)dataSnapshot.child(currentGameID).child("gameFinished").getValue()) 

Solution 2:

The problem occur because of Boolean "gameFinished" is default initialized as false You need to check getResults() method after your "gameFinished" set as true

Post a Comment for "Boolean Returns False When It Is Clearly True"