Google Play游戏回合制多人通知

时间:2019-05-04 06:47:08

标签: android google-play-games multiplayer

我正在使用内置的Google Play用户界面来处理Android Google Turn-Based Multiplayer游戏的配对,并且在提供的通知中存在两个问题。

Google-Play notification

  1. “ with”一词和对手的名字之间存在文本间距问题。在这种情况下为“ garguno”。
  2. 在此通知上单击“忽略”将游戏从您的活动游戏列表中完全删除。在这种情况下,我还没有找到恢复游戏的方法。

我想弄清楚如何解决这两个问题,但是我很难找到有关基于回合的通知如何工作和/或如何自定义其功能的文档。感谢任何帮助。

here提供的文档确实描述了dismissInvitation()与dismissMatch()的功能,但是这些代码都不在我自己的应用程序中,因为我只是使用内置的UI来处理匹配项,即(来自链接1):

@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) {   super.onActivityResult(requestCode, resultCode, data);   if (requestCode == RC_SELECT_PLAYERS) {
    if (resultCode != Activity.RESULT_OK) {
      // Canceled or other unrecoverable error.
      return;
    }
    ArrayList<String> invitees = data.getStringArrayListExtra(Games.EXTRA_PLAYER_IDS);

    // Get automatch criteria
    Bundle autoMatchCriteria = null;
    int minAutoPlayers = data.getIntExtra(Multiplayer.EXTRA_MIN_AUTOMATCH_PLAYERS, 0);
    int maxAutoPlayers = data.getIntExtra(Multiplayer.EXTRA_MAX_AUTOMATCH_PLAYERS, 0);

    TurnBasedMatchConfig.Builder builder = TurnBasedMatchConfig.builder()
        .addInvitedPlayers(invitees);
    if (minAutoPlayers > 0) {
      builder.setAutoMatchCriteria(
          RoomConfig.createAutoMatchCriteria(minAutoPlayers, maxAutoPlayers, 0));
    }
    Games.getTurnBasedMultiplayerClient(this, GoogleSignIn.getLastSignedInAccount(this))
        .createMatch(builder.build()).addOnCompleteListener(new OnCompleteListener<TurnBasedMatch>() {
      @Override
      public void onComplete(@NonNull Task<TurnBasedMatch> task) {
        if (task.isSuccessful()) {
          TurnBasedMatch match = task.getResult();
          if (match.getData() == null) {
            // First turn, initialize the game data.
            // (You need to implement this).
            initializeGameData(match);
          }

          // Show the turn UI.
          // (Game specific logic)
          showTurnUI(match);
        } else {
          // There was an error. Show the error.
          int status = CommonStatusCodes.DEVELOPER_ERROR;
          Exception exception = task.getException();
          if (exception instanceof ApiException) {
            ApiException apiException = (ApiException) exception;
            status = apiException.getStatusCode();
          }
          handleError(status, exception);
        }
      }
    });   } }

0 个答案:

没有答案