/** Shows GameCenter standard interface for Achievements */
  public void showAchievementsView() {
    // If player is not authenticated, do nothing
    if (!GKLocalPlayer.getLocalPlayer().isAuthenticated()) {
      return;
    }

    // If iOS version is 6 or more we use the new method
    if (getIosVersion() >= IOS_6) {
      GKGameCenterViewController gameCenterView = new GKGameCenterViewController();
      gameCenterView.setGameCenterDelegate(
          new GKGameCenterControllerDelegate.Adapter() {
            @Override
            public void gameCenterViewControllerDidFinish(
                GKGameCenterViewController gameCenterViewController) {
              gameCenterViewController.dismissViewController(true, null);
            }
          });
      gameCenterView.setViewState(
          GKGameCenterViewControllerState.GKGameCenterViewControllerStateAchievements);
      keyWindow.getRootViewController().presentViewController(gameCenterView, true, null);
    } else { // If iOS version is 6 or less we use the deprecated method
      GKAchievementViewController gameCenterView = new GKAchievementViewController();
      gameCenterView.setAchievementDelegate(
          new GKAchievementViewControllerDelegate.Adapter() {
            @Override
            public void achievementViewControllerDidFinish(
                GKAchievementViewController viewController) {
              viewController.dismissViewController(true, null);
            }
          });
      keyWindow.getRootViewController().presentViewController(gameCenterView, true, null);
    }
  }
  /** Shows GameCenter standard interface for Leaderboards */
  public void showLeaderboardsView() {
    // If player is not authenticated, do nothing
    if (!GKLocalPlayer.getLocalPlayer().isAuthenticated()) {
      return;
    }

    // If iOS version is 6 or more we use the new method
    if (getIosVersion() >= IOS_6) {
      GKGameCenterViewController gameCenterView = new GKGameCenterViewController();
      gameCenterView.setGameCenterDelegate(
          new GKGameCenterControllerDelegate.Adapter() {
            @Override
            public void gameCenterViewControllerDidFinish(
                GKGameCenterViewController gameCenterViewController) {
              gameCenterViewController.dismissViewController(true, null);
            }
          });
      gameCenterView.setViewState(
          GKGameCenterViewControllerState.GKGameCenterViewControllerStateLeaderboards);
      gameCenterView.setLeaderboardTimeScope(GKLeaderboardTimeScope.GKLeaderboardTimeScopeAllTime);
      // gameCenterView.setLeaderboardIdentifier("CgkI4OvQqOcSEAIQBg");
      keyWindow.getRootViewController().presentViewController(gameCenterView, true, null);
    } else { // If iOS version is 6 or less we use the deprecated method
      GKLeaderboardViewController gameCenterView = new GKLeaderboardViewController();
      gameCenterView.setTimeScope(GKLeaderboardTimeScope.GKLeaderboardTimeScopeAllTime);
      gameCenterView.setLeaderboardDelegate(
          new GKLeaderboardViewControllerDelegate.Adapter() {
            @Override
            public void leaderboardViewControllerDidFinish(
                GKLeaderboardViewController viewController) {
              viewController.dismissViewController(true, null);
            }
          });
      keyWindow.getRootViewController().presentViewController(gameCenterView, true, null);
    }
  }