2015-12-27 188 views

回答

1

由於等候室正在使用startActivityForResult啓動。您需要在啓動候車室的活動的onActivityResult()方法中捕獲結果。

@Override 
public void onActivityResult(int request, int response, Intent intent)  { 
    if (request == RC_WAITING_ROOM) { 
     if (response == Activity.RESULT_OK) { 
      // (start game) 
     } 
     else if (response == Activity.RESULT_CANCELED) { 
     // Waiting room was dismissed with the back button. The meaning of this 
     // action is up to the game. You may choose to leave the room and cancel the 
     // match, or do something else like minimize the waiting room and 
     // continue to connect in the background. 

     // in this example, we take the simple approach and just leave the room: 
     Games.RealTimeMultiplayer.leave(mGoogleApiClient, null, mRoomId); 
     getWindow().clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); 
    } 
    else if (response == GamesActivityResultCodes.RESULT_LEFT_ROOM) { 
     // player wants to leave the room. 
     Games.RealTimeMultiplayer.leave(mGoogleApiClient, null, mRoomId); 
     getWindow().clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); 
    } 
} 

}

你可以閱讀下面鏈接中全面推行。 https://developers.google.com/games/services/android/realtimeMultiplayer

相關問題