Beispiel #1
0
  /** Quit game activity */
  public void quitGame() {
    // Clear data from GameSettings
    GameSettings.setGameId(-1);
    GameSettings.setGameName(null);
    GameSettings.setGameToken(null);
    GameSettings.setCanBreakWall(false);
    GameSettings.setTimeLimit(-1);
    GameSettings.setLastPlayTime((System.currentTimeMillis() - startTime) / 1000);

    if (countdown != null) {
      countdown.removeCallbacks(countdownRunnable);
      countdownRunnable = null;
      countdown = null;
    }

    // Start Lobby activity while destroying RoomActivity and HostActivity
    Intent intent = new Intent(this, LobbyActivity.class);
    intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
    startActivity(intent);

    // Pause the socket
    Log.d("Socket", "quitting socket");
    connection.pause();

    // Close the GameActivity
    finish();
  }
Beispiel #2
0
  @Override
  public void onDestroy() {
    super.onDestroy();

    if (gameEventHandler != null) gameEventHandler.stop();

    // Stop the socket
    Log.d("Socket", "quitting socket");
    connection.pause();
  }