title: Google Play Multiplayer Switching to Game Screen Libgdx
body: <p>I am using Libgdx to manage the screens, updates and rendering.</p>
  
  <p>When I get a RESULT_OK from WAITING_ROOM i start the game screen, the following happens.</p>
  
  <ol>
  <li>in the waiting room, I can see ME who initiated the game room</li>
  <li>I can see the auto matched player who joined the waiting room</li>
  <li>When the MIN players are in the room I get "Prepare to Play" </li>
  <li>The screen is switching to the game screen</li>
  </ol>
  
  <p>Now the issue. </p>
  
  <p>When the new game screen starts one of the players is showing and the other has a blank screen
  Sometimes the blank screen will show on the phone of the player who initiated the game and other times on the phone of the player who joined the room.</p>
  
  <p>What am I doing wrong??</p>
  
  <p>See my code:</p>
  
  <p>ON CREATE</p>
  
  <pre><code>  @Override
     public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
  
      gameActivity = new GameActivity(this, this);
      participants = new Array&lt;Player&gt;();
  
      layout = new RelativeLayout(this);
  
     requestWindowFeature(Window.FEATURE_NO_TITLE);
      getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, 
              WindowManager.LayoutParams.FLAG_FULLSCREEN);
      getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
  
       gameView  = initializeForView(gameActivity);
  
        AdRequest adRequest = new AdRequest.Builder()
          .build();
      adView = new AdView(this);
      adView.setAdSize(AdSize.FULL_BANNER);
      adView.setAdUnitId(AD_UNIT_ID);
      adView.loadAd(adRequest);
  
      RelativeLayout.LayoutParams gameParams = 
              new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT, 
                      RelativeLayout.LayoutParams.WRAP_CONTENT);
        gameParams.addRule(RelativeLayout.CENTER_IN_PARENT);
        gameParams.bottomMargin = 1;
  
     adParams = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT, 
                  RelativeLayout.LayoutParams.WRAP_CONTENT);
                  adParams.addRule(RelativeLayout.ALIGN_PARENT_TOP);
                  adParams.addRule(RelativeLayout.CENTER_IN_PARENT);
  
      layout.addView(gameView, gameParams);
      layout.addView(adView, adParams);
  
      if (mHelper == null) {
          getGameHelper();
      }
  
      mHelper.setup(this);
  
      setContentView(layout);
  
  }
  </code></pre>
  
  <p>STARTING QUICK GAME:</p>
  
  <pre><code>    private void startQuickGame(){
      Log.d(TAG, "StartQuickGame()");
  
      final int MIN_OPPONENTS = 1, MAX_OPPONENTS = 1;
  
      Bundle autoMatch = RoomConfig.createAutoMatchCriteria(MIN_OPPONENTS,
              MAX_OPPONENTS, 0);
       RoomConfig.Builder roomBuilder = RoomConfig.builder(this);
       roomBuilder.setMessageReceivedListener(this);
       roomBuilder.setRoomStatusUpdateListener(this);
       roomBuilder.setAutoMatchCriteria(autoMatch);
  
  
       Games.RealTimeMultiplayer.create(getApiClient(), roomBuilder.build());
  
      //prevent screen from sleeping during players matching
  
       Log.d(TAG, " startQuickGame()" +  "createRoom called");
  
     }
  </code></pre>
  
  <p>ON CREATE ROOM</p>
  
  <pre><code>    @Override
  public void onRoomCreated(int statusCode, Room room) {
  
      Log.d(TAG, "On room created()");
      if(statusCode != GamesClient.STATUS_OK){
          Log.d(TAG, "On room created() ERROR");
          return;
      }
      showWaitingRoom(room);
  
    }
  </code></pre>
  
  <p>ON CONNECTED TO ROOM</p>
  
  <pre><code>   @Override
  public void onConnectedToRoom(Room room) {
       Log.d(TAG, "onConnectedToRoom.");
  
          // get room ID, participants and my ID:
          mRoomId = room.getRoomId();
          mParticipants = room.getParticipants();
          mMyId = room.getParticipantId(Games.Players.getCurrentPlayerId(getApiClient()));
  
  
          // print out the list of participants (for debug purposes)
          Log.d(TAG, "Room ID: " + mRoomId);
          Log.d(TAG, "My ID " + mMyId);
          Log.d(TAG, "&lt;&lt; CONNECTED TO ROOM&gt;&gt;");
  
  }
  </code></pre>
  
  <p>SHOW WAITING ROOM</p>
  
  <pre><code>void showWaitingRoom(Room room) {
      // minimum number of players required for our game
      // For simplicity, we require everyone to join the game before we start it
      // (this is signaled by Integer.MAX_VALUE).
      final int MIN_PLAYERS = Integer.MAX_VALUE;
      Intent i = Games.RealTimeMultiplayer.getWaitingRoomIntent(getApiClient(), room, MIN_PLAYERS);
  
      // show waiting room UI
      startActivityForResult(i, RC_WAITING_ROOM);
  }
  </code></pre>
  
  <p>SWITCHING TO GAME SCREEN</p>
  
  <pre><code>  public void startGame(boolean multiPlayer){
      Log.d(TAG, "startGame()");
      mMultiplayer = multiPlayer;
  
      gameActivity.setScreen(new MultiTest(gameActivity)); //Game Screen Libgdx
  
      Log.d(TAG, "Switched to MultiTest game screen");
  
  }
  </code></pre>