コード例 #1
0
  /*
   * This method forces the back button to behave properly.
   * It is needed to prevent a crash if the user opens up the
   * game immediately after hitting back
   */
  @Override
  public void onBackPressed() {

    if (!game.isPaused()) {
      game.pause();
    } else {
      game.resume();
    }
  }
コード例 #2
0
 /*
  * This method handles a user pushing the "menu" button
  * available on older and awesome devices.  This game
  * has a unified pause/pause-menu behavior, so we
  * are going to delegate the work to the game for this.
  */
 @Override
 public boolean onCreateOptionsMenu(Menu menu) {
   game.pause();
   return true;
 }
コード例 #3
0
 /*
  * Pause the game if it is not visible for any reason
  * This is called before onStop, and nothing extra needs done in onStop.
  */
 @Override
 protected void onPause() {
   Log.d(LOGGER, "Pausing Activity");
   game.pause();
   super.onPause();
 }