当前位置: 动力学知识库 > 问答 > 编程问答 >

android - Unity - Google Play Games Services Real Time Multiplayer on close WaitingRoomUI() method?

问题描述:

Is there a method that is executed when the WaitingRoomUI is closed?

Any help is greatly appreciated, thanks.

网友答案:

Since waiting room is being started using startActivityForResult. You need to catch the result in onActivityResult() method of the activity that started the waiting room.

@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);
    }
}

}

You may read the full implementation in the link below. https://developers.google.com/games/services/android/realtimeMultiplayer

分享给朋友:
您可能感兴趣的文章:
随机阅读: