Game over not functioning correctly?

Currently I have a simple shooting game where sprites fly across the screen and when they are pressed it will increment the users score by one. The issue is that I want to have it so I have declared a boolean for gameover, when the game starts this will be initialised as false and will be declared as true when the timer runs out. The code I have currently has it so that gameover is set to true when the timer runs out but for some reason instead of that it defaults to true instead of waiting for the timer to run out. Any idea why this is?

/* Member (state) fields   */
private GameLoopThread gameLoopThread;
private Paint paint; //Reference a paint object 
/** The drawable to use as the background of the animation canvas */
private Bitmap mBackgroundImage;
private Sprite sprite;
private int hitCount;
/* For the countdown timer */
private long  startTime ;           //Timer to count down from
private final long interval = 1 * 1000;     //1 sec interval
private CountDownTimer countDownTimer;  //Reference to class
private boolean timerRunning = false;
private String displayTime;         //To display time on the screen
private boolean gameOver;
private int highscore = 0;
/* Countdown Timer - private class */
private class MyCountDownTimer extends CountDownTimer {

  public MyCountDownTimer(long startTime, long interval) {
        super(startTime, interval);
  public void onFinish() {
        displayTime = "Times Over!";
        timerRunning = false;
        gameOver = true;
        if (hitCount > highscore) {
            highscore= hitCount;


 public void update(){
    //if (gameOver = true){ 


I might be wrong, but this gameOver = true which appears here commented, would create that kind of behaviour. You are using an assignation (=) instead of an equality verification (==).

In this case, you should write if (gameOver == true) {, or rather simply: if (gameOver) {.

Other that that, I don’t know what your mistake could be, as the default value for a boolean primitive variable is indeed false.

Here’s a little test I did to make sure of my assumptions. I ran:

public class Test {

    public static boolean x;

    public static void main(String[] args) {
        if (x = true)


And obtained the output: