title: Couple questions about how to implement turn by turn based games in google game service
body: <p>I have a couple questions of how to implement google game services in my app.
  First of all, after I checked that the user is signed in and the client is connected, I launch </p>
  
  <pre><code>Intent intent = Games.TurnBasedMultiplayer.getSelectOpponentsIntent(mGoogleApiClient, 1, 1, true);
  startActivityForResult(intent, RC_SELECT_PLAYERS);
  </code></pre>
  
  <p>To show the user a dialog where they can select the opponent. 
  After I get the result from the activity I execute this code</p>
  
  <pre><code>if (request == RC_SELECT_PLAYERS) {
              Log.e(LOG_TAG, "Got RC_SELECT_PLAYERS result intent");
  
              if (response != Activity.RESULT_OK) {
                  // user canceled
                  return;
              }
  
              // Get the invitee list.
              final ArrayList&lt;String&gt; invitees = data.getStringArrayListExtra(Games.EXTRA_PLAYER_IDS);
  
              // Get auto-match criteria.
              Bundle autoMatchCriteria;
              int minAutoMatchPlayers = data.getIntExtra(Multiplayer.EXTRA_MIN_AUTOMATCH_PLAYERS, 0);
              int maxAutoMatchPlayers = data.getIntExtra(Multiplayer.EXTRA_MAX_AUTOMATCH_PLAYERS, 0);
  
              if (minAutoMatchPlayers &gt; 0) {
                  autoMatchCriteria = RoomConfig.createAutoMatchCriteria(minAutoMatchPlayers, maxAutoMatchPlayers, 0);
              } else {
                  autoMatchCriteria = null;
              }
  
              TurnBasedMatchConfig turnBasedMatchConfig = TurnBasedMatchConfig.builder()
                      .addInvitedPlayers(invitees)
                      .setAutoMatchCriteria(autoMatchCriteria)
                      .build();
  
              // Create and start the match.
              Games.TurnBasedMultiplayer
                      .createMatch(mGoogleApiClient, turnBasedMatchConfig)
                      .setResultCallback(new MatchInitiatedCallback());
          }
  </code></pre>
  
  <p>To initiate the match. The problem is, the opponent I challenged doesn't get any notification where he is asked to join the game. So when the user gets a notification to join a game, how can I catch this notification and show the user the appropriate content? Which intent result should I look for? </p>
  
  <p>In my MatchInitiatedCallback I check which turn it is now:</p>
  
  <pre><code>public class MatchInitiatedCallback implements ResultCallback&lt;TurnBasedMultiplayer.InitiateMatchResult&gt; {
      private static final String LOG_TAG = "MatchInitiatedCallback";
  
      @Override
      public void onResult(TurnBasedMultiplayer.InitiateMatchResult result) {
          // Check if the status code is not success.
          Status status = result.getStatus();
  
          if (!status.isSuccess()) {
              Log.e(LOG_TAG, "showError() " + status.toString());
              //showError(status.getStatusCode());
              return;
          }
  
          TurnBasedMatch match = result.getMatch();
  
          // If this player is not the first player in this match, continue.
          if (match.getData() != null) {
              Log.e(LOG_TAG, "Not my turn");
              //showTurnUI(match);
              return;
          }
  
          // Otherwise, this is the first player. Initialize the game state.
          //initGame(match);
          Log.e(LOG_TAG, "initGame()");
  
          // Let the player take the first turn
          //showTurnUI(match);
          Log.e(LOG_TAG, "showTurnGui()");
      }
  }
  </code></pre>
  
  <p>But this code gets executed even before my opponent selects to join.
  Shouldn't he first be able to accept or decline the game?
  Can someone please tell me if I'm doing this properly or if this is supposed to be like this? If not, how should it be implemented correctly?</p>
  
  <p>EDIT: I took all this code from the documentation. It does show some code samples of how to implement things, but not of how the code all comes together and the order in which things should be executed, or how to handle notifications and such.</p>