0

My menu has a game button and a close button the close button closes the app but if I run the game and proceed to the results activity, and return to the main menu via the back button. The close button the opens the results activity.

Results Activity:

@Override
public void onBackPressed() {
    startActivity(new Intent(EndGame.this, Main.class));
}

Main Menu Button Close

buttonExit.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            //Closes the APP
            Main.this.finish();
        }
    });
Seatter
  • 408
  • 1
  • 9
  • 19

1 Answers1

0

Change

@Override
public void onBackPressed() {
    startActivity(new Intent(EndGame.this, Main.class));
}

to:

@Override
public void onBackPressed() {
    finish();
    startActivity(new Intent(EndGame.this, Main.class));
}
egfconnor
  • 2,637
  • 1
  • 26
  • 44