0

How do I show dialog here? And end the game and go back to main activity after clicking ok from the dialog?

I am using Android Studio 2.2 on Ubuntu 16.04.

for (int i = 0; i < enemyCount; i++) {
    broccolis[i].update(player.getSpeed());

    if (Rect.intersects(player.getDetectCollision(), broccolis[i].getDetectCollision())){
        //need to show dialog and change activity here...
    }
}

I'm new to Android programming and Java so please keep that in mind.

ekad
  • 14,436
  • 26
  • 44
  • 46
Henyl95
  • 17
  • 1

1 Answers1

0

For a dialog you can use one of these answers. I think there are a lot of good examples.

To start an activity you can do it like this:

    Intent var = new Intent(this, yourActivity.class);
    startActivity(var);
Community
  • 1
  • 1
Paul
  • 823
  • 1
  • 11
  • 18