Google Play Game Service - Get a Match List

I am working on a TurnBased Game using the Google Play Game Service. Now I would like to list all the games that you participate in DrawerMenu, so you can easily enter the games, as well as see what games you are in ...

My question is: how can I get these Games, as well as how to get them so that I can re-enter them on click?

I hope I can make my problem clear :) Thank you!

+3
source share
3 answers

Here is how I did it:

static final int[] statusesToLoad = new int[]{
            TurnBasedMatch.MATCH_TURN_STATUS_INVITED,
            TurnBasedMatch.MATCH_TURN_STATUS_MY_TURN,
            TurnBasedMatch.MATCH_TURN_STATUS_THEIR_TURN,
            TurnBasedMatch.MATCH_TURN_STATUS_COMPLETE};

PendingResult<TurnBasedMultiplayer.LoadMatchesResult> loadMathesResult = Games.TurnBasedMultiplayer.loadMatchesByStatus(mGoogleApiClient, statusesToLoad);
loadMathesResult.setResultCallback(new loadMatchesCallback());

And then in the callback you can get data buffers for all active games in which you participate, and all the invitations you received:

    private class loadMatchesCallback implements ResultCallback<TurnBasedMultiplayer.LoadMatchesResult>{

        @Override
        public void onResult(TurnBasedMultiplayer.LoadMatchesResult loadMatchesResult) {
            LoadMatchesResponse response = loadMatchesResult.getMatches();
            TurnBasedMatchBuffer myTurnMatches = response.getMyTurnMatches();
            TurnBasedMatchBuffer theirTurnMatches = response.getTheirTurnMatches();
            TurnBasedMatchBuffer completedMatches = response.getCompletedMatches();
            InvitationBuffer invitations = response.getInvitations();
            }
        }
    }

, ArrayList, , Google , release() . , .

+2

:

Games.TurnBasedMultiplayer.getInboxIntent(GoogleApiClient apiClient);

Intent, , .

, . , .

0

iOS : , , , GPGTurnBasedUserMatchStatusInvited .

GPGTurnBasedModel *turnModel = [GPGManager sharedInstance].applicationModel.turnBased;
    NSArray *invited = [turnModel matchesForUserMatchStatus:GPGTurnBasedUserMatchStatusInvited];

, , , .

0

All Articles