如何实现接受回合制多人游戏邀请的自定义对话框?

How to implement custom dialog for accepting turn based multiplayer game invite?

我想在 onInvitationReceived(Invitation invitation) 回调上实现自定义对话框。它将有 2 个选项 - 'accept' 和 'reject'.

我成功实施了 'reject' 行动。下面的简化代码 -

@Override
public void onInvitationReceived(Invitation invitation) {
    String invitationId = invitation.getInvitationId();

    if (/*code for selecting 'reject' action*/) {
        Games.TurnBasedMultiplayer.declineInvitation(mGoogleApiClient, invitationId);
    }
}

但我如何实施 'accept' 操作? 具体来说,仅来自 Invitation 对象。我需要 TurnBasedMatch 对象才能在受邀玩家结束时开始比赛。

来自 google 开发人员的以下 link 仅列出了向 'accept'(或 'reject')游戏显示默认视图的方式。

https://developers.google.com/games/services/android/turnbasedMultiplayer#handling_invitations

我自己设法解决了这个问题。下面是 'accept' 游戏邀请和获取匹配对象的简化代码 -

PendingResult<TurnBasedMultiplayer.InitiateMatchResult> pendingResult = 
    Games.TurnBasedMultiplayer.acceptInvitation(mGoogleApiClient, invitationId);

pendingResult.setResultCallback(new ResultCallback<TurnBasedMultiplayer.InitiateMatchResult>() {
    @Override
    public void onResult(TurnBasedMultiplayer.InitiateMatchResult result) {
        if (result.getStatus().getStatusCode() == GamesStatusCodes.STATUS_OK) {
            TurnBasedMatch match = result.getMatch();
            // do something with match ...
        }
    }
});