Android Google Play游戏服务,自动处理结果数据中未包含的玩家信息

Android Google Play游戏服务,自动处理结果数据中未包含的玩家信息,android,google-play-games,Android,Google Play Games,我使用谷歌游戏服务制作了一个简单的示例游戏应用程序 在代码中,我使用GameClient.GetSelectPayerContent方法启动了玩家选择屏幕,就像示例一样 intent = getGamesClient().getSelectPlayersIntent(1, 3); showScreen(Screen.WAITING); startActivityForResult(intent, RC_SELECT_PLAYERS); 玩家选择活动返回结果数据,但它不包括GamesCli

我使用谷歌游戏服务制作了一个简单的示例游戏应用程序

在代码中,我使用GameClient.GetSelectPayerContent方法启动了玩家选择屏幕,就像示例一样

 intent = getGamesClient().getSelectPlayersIntent(1, 3);
 showScreen(Screen.WAITING);
 startActivityForResult(intent, RC_SELECT_PLAYERS);
玩家选择活动返回结果数据,但它不包括GamesClient.EXTRA_玩家、GamesClient.EXTRA_MIN_AUTOMATCH_玩家、GamesClient.EXTRA_MAX_AUTOMATCH_玩家extras,即使我选择了两个自动匹配玩家

当我调试它时,它的额外地图中只包含com.google.android.gms.games.MAX_SELECTION、com.google.android.gms.games.MIN_SELECTION extra

在javadoc for中,结果应该包括所选的玩家信息

我需要为此功能进行一些设置吗

这是我的onActivityResult代码。我只是从样品中复制的

@Override
protected void onActivityResult(int requestCode, int responseCode, Intent data) {
    super.onActivityResult(requestCode, responseCode, data);
    switch (requestCode) {
        case RC_SELECT_PLAYERS:
            // we got the result from the "select players" UI -- ready to create the room
            handleSelectPlayersResult(responseCode, intent);
            break;
        case RC_INVITATION_INBOX:
            // we got the result from the "select invitation" UI (invitation inbox). We're
            // ready to accept the selected invitation:
            handleInvitationInboxResult(responseCode, intent);
            break;
        ... other stuffs


private void handleSelectPlayersResult(int response, Intent data) {
    if (response != Activity.RESULT_OK) {
        Log.w(TAG, "*** select players UI cancelled, " + response);
        showScreen(Screen.MAIN);
        return;
    }

    Log.d(TAG, "Select players UI succeeded.");

    // get the invitee list
    final ArrayList<String> invitees = data.getStringArrayListExtra(GamesClient.EXTRA_PLAYERS);
    if (invitees != null) {
        Log.d(TAG, "Invitee count: " + invitees.size());
    }

    // get the automatch criteria
    Bundle autoMatchCriteria = null;
    int minAutoMatchPlayers = data.getIntExtra(GamesClient.EXTRA_MIN_AUTOMATCH_PLAYERS, 0);
    int maxAutoMatchPlayers = data.getIntExtra(GamesClient.EXTRA_MAX_AUTOMATCH_PLAYERS, 0);
    if (minAutoMatchPlayers > 0 || maxAutoMatchPlayers > 0) {
        autoMatchCriteria = RoomConfig.createAutoMatchCriteria(
                minAutoMatchPlayers, maxAutoMatchPlayers, 0);
        Log.d(TAG, "Automatch criteria: " + autoMatchCriteria);
    }

    // create the room
    Log.d(TAG, "Creating room...");
    RoomConfig.Builder rtmConfigBuilder = RoomConfig.builder(this);
    if (invitees != null) {
        rtmConfigBuilder.addPlayersToInvite(invitees);
    }
    rtmConfigBuilder.setMessageReceivedListener(this);
    rtmConfigBuilder.setRoomStatusUpdateListener(this);
    if (autoMatchCriteria != null) {
        rtmConfigBuilder.setAutoMatchCriteria(autoMatchCriteria);
    }
    showScreen(Screen.WAITING);
    keepScreenOn();
    getGamesClient().createRoom(rtmConfigBuilder.build());
    Log.d(TAG, "Room created, waiting for it to be ready...");
}
使现代化
哎呀,是我的错。我使用了发送意图,而不是接收数据意图。

刚刚检查过,我也跟着这个代码示例,我得到了返回的MinAutoMatchPlayer和MaxAutomatchPlayer。我不认为你的设置会有任何影响,因为信息是在意图中返回的。很有可能,您是否在Rev 11上?@user2346305谢谢您的评论。我使用的是最新版本,Rev 12。非常奇怪,我甚至在api参考中找不到最小选择或最大选择。。。而您启动选择过程的呼叫也是复制/粘贴?Intent Intent=mHelper.getGamesClient.GetSelectPlayerContent1,3;StartActivityForresultint,RC_选择_玩家@user2346305是的,我通过示例代码intent=getGamesClient.getSelectPlayersIntent1,3启动了活动;StartActivityForresultint,RC_选择_玩家;我在api引用中也没有找到最小选择或最大选择。我通过调试器找到了这些值。它们包含在选择活动的结果意图中。