Question

I am using the google play games service in my android app and I am trying to load all turn based matches with the status: TurnBasedMatch.MATCH_TURN_STATUS_MY_TURN

public class TurnBasedMulti  implements 
    OnInvitationReceivedListener, OnTurnBasedMatchUpdateReceivedListener, OnTurnBasedMatchesLoadedListener{

    private GoogleApiClient googleApiClient;

    public TurnBasedMulti(){
        googleApiClient = new GoogleApiClient.Builder(this)
           .addApi(Games.API)
           .build();

        googleApiClient.connect();
    }

    public void loadMatches(){
        Log.i("TBM", "load matches async");
        Games.TurnBasedMultiplayer.loadMatchesByStatus(googleApiClient, TurnBasedMatch.MATCH_TURN_STATUS_MY_TURN);
    }

    @Override
    public void onConnected(Bundle arg0) {
        Log.i("googleApiClient", "connected");
        Games.TurnBasedMultiplayer.registerMatchUpdateListener(googleApiClient, this);
    }

    @Override
    public void onTurnBasedMatchesLoaded(int statusCode, LoadMatchesResponse response) {
        Log.i("TBM", "matches loaded");
        TurnBasedMatchBuffer matchBuffer = response.getMyTurnMatches();
        matchBuffer.close();

        response.getCompletedMatches().close();
        response.getTheirTurnMatches().close();
        response.getInvitations().close();
        response.close();
    }

}

LogCat Output:

03-15 21:16:04.594: I/googleApiClient(6066): connected
03-15 21:16:04.666: I/TBM(6066): load matches async
03-15 21:16:18.366: E/DataBuffer(6066): Internal data leak within a DataBuffer object detected!  Be sure to explicitly call close() on all DataBuffer extending objects when you are done with them. (com.google.android.gms.games.multiplayer.turnbased.TurnBasedMatchBuffer@a69f2d40)

onTurnBasedMatchesLoaded is never called. What am I doing wrong?

Was it helpful?

Solution

You have to register the ResultCallback

 Games.TurnBasedMultiplayer.loadMatchesByStatus(googleApiClient, TurnBasedMatch.MATCH_TURN_STATUS_MY_TURN).setResultCallback(
        new ResultCallback<TurnBasedMultiplayer.LoadMatchesResult>()
        {
          @Override
          public void onResult(LoadMatchesResult result)
          {

          }
        });
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top