當前位置: 首頁>>代碼示例>>Java>>正文


Java GamesActivityResultCodes.RESULT_LEFT_ROOM屬性代碼示例

本文整理匯總了Java中com.google.android.gms.games.GamesActivityResultCodes.RESULT_LEFT_ROOM屬性的典型用法代碼示例。如果您正苦於以下問題:Java GamesActivityResultCodes.RESULT_LEFT_ROOM屬性的具體用法?Java GamesActivityResultCodes.RESULT_LEFT_ROOM怎麽用?Java GamesActivityResultCodes.RESULT_LEFT_ROOM使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在com.google.android.gms.games.GamesActivityResultCodes的用法示例。


在下文中一共展示了GamesActivityResultCodes.RESULT_LEFT_ROOM屬性的14個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: activityResponseCodeToString

static String activityResponseCodeToString(int respCode) {
    switch (respCode) {
        case Activity.RESULT_OK:
            return "RESULT_OK";
        case Activity.RESULT_CANCELED:
            return "RESULT_CANCELED";
        case GamesActivityResultCodes.RESULT_APP_MISCONFIGURED:
            return "RESULT_APP_MISCONFIGURED";
        case GamesActivityResultCodes.RESULT_LEFT_ROOM:
            return "RESULT_LEFT_ROOM";
        case GamesActivityResultCodes.RESULT_LICENSE_FAILED:
            return "RESULT_LICENSE_FAILED";
        case GamesActivityResultCodes.RESULT_RECONNECT_REQUIRED:
            return "RESULT_RECONNECT_REQUIRED";
        case GamesActivityResultCodes.RESULT_SIGN_IN_FAILED:
            return "SIGN_IN_FAILED";
        default:
            return String.valueOf(respCode);
    }
}
 
開發者ID:AndreFCruz,項目名稱:feup-lpoo-armadillo,代碼行數:20,代碼來源:GameHelperUtils.java

示例2: activityResponseCodeToString

static String activityResponseCodeToString(int respCode)
{
    switch (respCode)
    {
        case Activity.RESULT_OK:
            return "RESULT_OK";
        case Activity.RESULT_CANCELED:
            return "RESULT_CANCELED";
        case GamesActivityResultCodes.RESULT_APP_MISCONFIGURED:
            return "RESULT_APP_MISCONFIGURED";
        case GamesActivityResultCodes.RESULT_LEFT_ROOM:
            return "RESULT_LEFT_ROOM";
        case GamesActivityResultCodes.RESULT_LICENSE_FAILED:
            return "RESULT_LICENSE_FAILED";
        case GamesActivityResultCodes.RESULT_RECONNECT_REQUIRED:
            return "RESULT_RECONNECT_REQUIRED";
        case GamesActivityResultCodes.RESULT_SIGN_IN_FAILED:
            return "SIGN_IN_FAILED";
        default:
            return String.valueOf(respCode);
    }
}
 
開發者ID:overengineering,項目名稱:space-travels-3,代碼行數:22,代碼來源:GameHelperUtils.java

示例3: activityResponseCodeToString

static String activityResponseCodeToString(int respCode) {
    switch (respCode) {
        case Activity.RESULT_OK:
        return "RESULT_OK";
        case Activity.RESULT_CANCELED:
        return "RESULT_CANCELED";
        case GamesActivityResultCodes.RESULT_APP_MISCONFIGURED:
        return "RESULT_APP_MISCONFIGURED";
        case GamesActivityResultCodes.RESULT_LEFT_ROOM:
        return "RESULT_LEFT_ROOM";
        case GamesActivityResultCodes.RESULT_LICENSE_FAILED:
        return "RESULT_LICENSE_FAILED";
        case GamesActivityResultCodes.RESULT_RECONNECT_REQUIRED:
        return "RESULT_RECONNECT_REQUIRED";
        case GamesActivityResultCodes.RESULT_SIGN_IN_FAILED:
        return "SIGN_IN_FAILED";
        default:
        return String.valueOf(respCode);
    }
}
 
開發者ID:ldarren,項目名稱:pico-phonegap-base,代碼行數:20,代碼來源:GmsHelper.java

示例4: activityResponseCodeToString

static String activityResponseCodeToString(int respCode) {
  switch (respCode) {
    case Activity.RESULT_OK:
      return "RESULT_OK";
    case Activity.RESULT_CANCELED:
      return "RESULT_CANCELED";
    case GamesActivityResultCodes.RESULT_APP_MISCONFIGURED:
      return "RESULT_APP_MISCONFIGURED";
    case GamesActivityResultCodes.RESULT_LEFT_ROOM:
      return "RESULT_LEFT_ROOM";
    case GamesActivityResultCodes.RESULT_LICENSE_FAILED:
      return "RESULT_LICENSE_FAILED";
    case GamesActivityResultCodes.RESULT_RECONNECT_REQUIRED:
      return "RESULT_RECONNECT_REQUIRED";
    case GamesActivityResultCodes.RESULT_SIGN_IN_FAILED:
      return "SIGN_IN_FAILED";
    default:
      return String.valueOf(respCode);
  }
}
 
開發者ID:alcacoop,項目名稱:it.alcacoop.fourinaline,代碼行數:20,代碼來源:GameHelperUtils.java

示例5: onActivityResult

@Override
public void onActivityResult(int request, int response, Intent intent) {

    if (request == RC_WAITING_ROOM) {
        if (response == Activity.RESULT_OK) {

            int side;
            if(creatorID.equals(myID)){
                side = 0;
                Toast.makeText(this, "YO EMPIEZO", Toast.LENGTH_SHORT).show();
            }else{
                side = 1;
                Toast.makeText(this, "TU EMPIEZAS", Toast.LENGTH_SHORT).show();
            }

            pong.startOnlineGame(side);
        }
        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(gameHelper.getApiClient(), this, 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(gameHelper.getApiClient(), this, mRoomId);
            getWindow().clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
        }

    }
    else{
        super.onActivityResult(requestCode, response, intent);
        gameHelper.onActivityResult(requestCode, response, intent);
    }
}
 
開發者ID:CODA-Masters,項目名稱:Pong-Tutorial,代碼行數:39,代碼來源:AndroidLauncher.java

示例6: onActivityResult

@Override
public void onActivityResult(int requestCode, int responseCode,
        Intent intent) {
    super.onActivityResult(requestCode, responseCode, intent);

    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;
        case RC_WAITING_ROOM:
            // we got the result from the "waiting room" UI.
            if (responseCode == Activity.RESULT_OK) {
                // ready to start playing
                Log.d(TAG, "Starting game (waiting room returned OK).");
                startGame(true);
            } else if (responseCode == GamesActivityResultCodes.RESULT_LEFT_ROOM) {
                // player indicated that they want to leave the room
                leaveRoom();
            } else if (responseCode == Activity.RESULT_CANCELED) {
                // Dialog was cancelled (user pressed back key, for instance). In our game,
                // this means leaving the room too. In more elaborate games, this could mean
                // something else (like minimizing the waiting room UI).
                leaveRoom();
            }
            break;
        case RC_SIGN_IN:
            Log.d(TAG, "onActivityResult with requestCode == RC_SIGN_IN, responseCode="
                + responseCode + ", intent=" + intent);
            mSignInClicked = false;
            mResolvingConnectionFailure = false;
            if (responseCode == RESULT_OK) {
              mGoogleApiClient.connect();
            } else {
              BaseGameUtils.showActivityResultError(this,requestCode,responseCode, R.string.signin_other_error);
            }
            break;
    }
    super.onActivityResult(requestCode, responseCode, intent);
}
 
開發者ID:ezet,項目名稱:penguins-in-space,代碼行數:45,代碼來源:Example.java

示例7: onActivityResult

@Override
public void onActivityResult(int requestCode, int resultCode, Intent intent) {
    super.onActivityResult(requestCode, resultCode, intent);

    switch (requestCode) {
        case RC_SIGN_IN:
            Task<GoogleSignInAccount> task =
                    GoogleSignIn.getSignedInAccountFromIntent(intent);

            try {
                GoogleSignInAccount account = task.getResult(ApiException.class);
                onConnected(account);
            } catch (ApiException apiException) {
                String message = apiException.getMessage();
                message = getString(R.string.signin_other_error) + " " + "(" + message + ")";

                onDisconnected();

                new AlertDialog.Builder(this)
                        .setTitle(R.string.error_during_signin)
                        .setMessage(message + apiException.toString())
                        .setNeutralButton(android.R.string.ok, null)
                        .show();
            }
            break;
        case RC_SELECT_PLAYERS:
            // we got the result from the "select players" UI -- ready to create the room
            handleSelectPlayersResult(resultCode, 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(resultCode, intent);
            break;
        case RC_WAITING_ROOM:
            // we got the result from the "waiting room" UI.
            if (resultCode == Activity.RESULT_OK) {
                // ready to start playing
                Log.d("ROOM", "Starting game (waiting room returned OK).");
                startGame();
            } else if (resultCode == GamesActivityResultCodes.RESULT_LEFT_ROOM) {
                // player indicated that they want to leave the room

            } else if (resultCode == Activity.RESULT_CANCELED) {
                // Dialog was cancelled (user pressed back key, for instance). In our game,
                // this means leaving the room too. In more elaborate games, this could mean
                // something else (like minimizing the waiting room UI).

            }
            break;
    }

    super.onActivityResult(requestCode, resultCode, intent);

}
 
開發者ID:Augugrumi,項目名稱:SpaceRace,代碼行數:55,代碼來源:AbsRoomActivity.java

示例8: onActivityResult

/**
 * Intent Activity result parser
 * @param request The request of the Intent
 * @param response The response of the Intent
 * @param intent The Intent
 */
public void onActivityResult(int request, int response, Intent intent) {
    switch(request) {
        case RealTimeMultiplayer.RC_SELECT_PLAYERS:
            // Return if the user cancel
            if (response != Activity.RESULT_OK) return;

            // get the invitee list
            Bundle extras = intent.getExtras();
            final ArrayList<String> invitees = intent.getStringArrayListExtra(Games.EXTRA_PLAYER_IDS);

            // Get auto-match criteria
            Bundle autoMatchCriteria = null;
            int minAutoMatchPlayers = intent.getIntExtra(Multiplayer.EXTRA_MIN_AUTOMATCH_PLAYERS, 0);
            int maxAutoMatchPlayers = intent.getIntExtra(Multiplayer.EXTRA_MAX_AUTOMATCH_PLAYERS, 0);

            if (minAutoMatchPlayers > 0) autoMatchCriteria = RoomConfig.createAutoMatchCriteria(minAutoMatchPlayers, maxAutoMatchPlayers, 0);
            else autoMatchCriteria = null;

            // Create the room and specify a variant if appropriate
            RoomConfig.Builder roomConfigBuilder = makeBasicRoomConfigBuilder();
            roomConfigBuilder.addPlayersToInvite(invitees);
            if (autoMatchCriteria != null) roomConfigBuilder.setAutoMatchCriteria(autoMatchCriteria);
            RoomConfig roomConfig = roomConfigBuilder.build();
            Games.RealTimeMultiplayer.create(googleApiClient, roomConfig);

            // Prevent screen from sleeping during handshake
            activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
            break;

        case RealTimeMultiplayer.RC_WAITING_ROOM:
            // we got the result from the "waiting room" UI.
            if (response == Activity.RESULT_OK) {
                // ready to start playing
                Log.d(TAG, "GPGS: Starting game (waiting room returned OK).");
                GodotLib.calldeferred(instanceId, "_on_gpgs_rtm_start_game", new Object[] { });
            } else if (response == GamesActivityResultCodes.RESULT_LEFT_ROOM) {
                // player indicated that they want to leave the room
                leaveRoom();
            } else if (response == Activity.RESULT_CANCELED) {
                // Dialog was cancelled (user pressed back key, for instance). In our game,
                // this means leaving the room too. In more elaborate games, this could mean
                // something else (like minimizing the waiting room UI).
                leaveRoom();
            }
            break;

        case RealTimeMultiplayer.RC_INVITATION_INBOX:
            // we got the result from the "select invitation" UI (invitation inbox). We're
            // ready to accept the selected invitation:
            handleInvitationInboxResult(response, intent);
            break;
    }
}
 
開發者ID:kloder-games,項目名稱:godot-gpgs,代碼行數:59,代碼來源:RealTimeMultiplayer.java

示例9: onActivityResult

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data)
{
	Gdx.app.log("multi","RequestCode: "+requestCode+"  - ResultCode: "+resultCode);
	switch (requestCode){
		case REQUEST_CODE_WAITING_ROOM:
			// Obtenemos el resultado que coincide con el de la petición
			if (resultCode == Activity.RESULT_OK) {
				// Empezamos el juego multijugador
				multiplayerState = MultiplayerState.STARTMULTIPLAYER;
			} else if (resultCode == GamesActivityResultCodes.RESULT_LEFT_ROOM) {
				// Un jugador se va
				leaveRoom();
				multiplayerState = MultiplayerState.CANCEL;
			} else if (resultCode == Activity.RESULT_CANCELED) {
				// El jugador cancela la partida, esto para nosotros se transforma en una
				// solicitud de abandono de habitación
				leaveRoom();
				multiplayerState = MultiplayerState.CANCEL;
			}
			break;
		case REQUEST_CODE_SELECT_PLAYERS:
			if (resultCode == Activity.RESULT_OK) {
				multiplayerState = MultiplayerState.WAITING;
				// Obtenemos la lista de usuarios a los que hemos invitado
				final ArrayList<String> invitees = data.getStringArrayListExtra(Games.EXTRA_PLAYER_IDS);

				// Iniciamos nuestro criterio de auto de emparejamiento
				Bundle autoMatchCriteria = null;
				// Información obtenida desde la ventana de invitación
				int minAutoMatchPlayers = data.getIntExtra(Multiplayer.EXTRA_MIN_AUTOMATCH_PLAYERS, 0);
				int maxAutoMatchPlayers = data.getIntExtra(Multiplayer.EXTRA_MAX_AUTOMATCH_PLAYERS, 0);

				if (minAutoMatchPlayers > 0 || maxAutoMatchPlayers > 0) {
					autoMatchCriteria = RoomConfig.createAutoMatchCriteria(
							minAutoMatchPlayers, maxAutoMatchPlayers, 0);
				}

				// Creamos la configuración de la habitación
				RoomConfig.Builder rtmConfigBuilder = RoomConfig.builder(new RoomUpdate(this));
				rtmConfigBuilder.addPlayersToInvite(invitees);
				rtmConfigBuilder.setMessageReceivedListener(new MessageReceived(this));
				rtmConfigBuilder.setRoomStatusUpdateListener(new RoomStatusUpdate(this));

				if (autoMatchCriteria != null) {
					rtmConfigBuilder.setAutoMatchCriteria(autoMatchCriteria);
				}
				// Reseteamos las propiedades del multijugador por si acaso
				resetMultiplayerProperties();

				// Creamos la sala multijugador con esta configuración de la habitación
				Games.RealTimeMultiplayer.create(_gameHelper.getApiClient(), rtmConfigBuilder.build());
			}else{
				multiplayerState = MultiplayerState.CANCEL;
			}
			break;
		case REQUEST_CODE_INVITATION_INBOX:
			if (resultCode == Activity.RESULT_OK) {
				multiplayerState = MultiplayerState.WAITING;
				// Obtenemos la invitación desde la ventana correspondiente
				Invitation inv = data.getExtras().getParcelable(Multiplayer.EXTRA_INVITATION);

				// Iniciamos el proceso de aceptación de la invitación

				// Creamos la configuración de la habitación
				RoomConfig.Builder roomConfigBuilder = RoomConfig.builder(new RoomUpdate(this));
				roomConfigBuilder.setInvitationIdToAccept(inv.getInvitationId())
						.setMessageReceivedListener(new MessageReceived(this))
						.setRoomStatusUpdateListener(new RoomStatusUpdate(this));

				// Nos unimos a la habitación correspondiente con nuesta ID de invitación
				Games.RealTimeMultiplayer.join(_gameHelper.getApiClient(), roomConfigBuilder.build());
			}else{
				multiplayerState = MultiplayerState.CANCEL;
			}
			break;
	}
	super.onActivityResult(requestCode, resultCode, data);
	_gameHelper.onActivityResult(requestCode, resultCode, data);
}
 
開發者ID:SpaceGame-ETSII,項目名稱:spacegame,代碼行數:80,代碼來源:AndroidLauncher.java

示例10: onActivityResult

@Override
public void onActivityResult(int request, int response, Intent data) {
	if (spinnerUtils.isSpinnerVisible()) spinnerUtils.hideSpinner();
	switch (request) {
		case REQUEST_INVITE:
			if (response != Activity.RESULT_OK) return;

			// get the invitee list
			ArrayList<String> invitees = data.getStringArrayListExtra(Games.EXTRA_PLAYER_IDS);

			// get auto-match criteria
			int minAutoMatchPlayers = data.getIntExtra(Multiplayer.EXTRA_MIN_AUTOMATCH_PLAYERS, 0);
			int maxAutoMatchPlayers = data.getIntExtra(Multiplayer.EXTRA_MAX_AUTOMATCH_PLAYERS, 0);

			connectionManager.invitePlayers(invitees, minAutoMatchPlayers, maxAutoMatchPlayers);
			break;

		case REQUEST_WAITING_ROOM:
			if (response == Activity.RESULT_OK) {
				Timber.d("all players connected, starting game ...");
				actionListener.onGameStarted();
				return;
			}

			if (response == Activity.RESULT_CANCELED || response == GamesActivityResultCodes.RESULT_LEFT_ROOM) {
				Timber.d("leaving room ...");
				connectionManager.leaveRoom();
			}
			break;

		case REQUEST_VIEW_INVITATIONS:
			// canceled
			if (response != Activity.RESULT_OK) return;

			// get and accept the selected invitation
			Bundle extras = data.getExtras();
			Invitation invitation = extras.getParcelable(Multiplayer.EXTRA_INVITATION);
			connectionManager.acceptInvitation(invitation);
			break;

		case REQUEST_LEADERBOARD:
			// nothing to do
			break;
	}
}
 
開發者ID:FauDroids,項目名稱:TeamBlocks,代碼行數:45,代碼來源:MenuFragment.java

示例11: onActivityResult

@Override
public void onActivityResult(int request, int response, Intent data) {
    super.onActivityResult(request, response, data);
    Log.i(TAG, "onActivityResult: code = " + request + ", response = " + response);

    // Coming back from resolving a sign-in request
    if (request == RC_SIGN_IN) {
        mSignInClicked = false;
        mResolvingConnectionFailure = false;
        if (response == RESULT_OK) {
            mGoogleApiClient.connect();
        } else {
            BaseGameUtils.showActivityResultError(this, request, response,
                    R.string.sign_in_failed);
        }
    }

    // Coming back from a RealTime Multiplayer waiting room
    if (request == RC_WAITING_ROOM) {
        dismissSpinner();

        Room room = data.getParcelableExtra(Multiplayer.EXTRA_ROOM);
        if (response == RESULT_OK) {
            Log.d(TAG, "Waiting Room: Success");
            mRoom = room;
            startMatch();
        } else if (response == RESULT_CANCELED) {
            Log.d(TAG, "Waiting Room: Canceled");
            leaveRoom();
        } else if (response == GamesActivityResultCodes.RESULT_LEFT_ROOM) {
            Log.d(TAG, "Waiting Room: Left Room");
            leaveRoom();
        } else if (response == GamesActivityResultCodes.RESULT_INVALID_ROOM) {
            Log.d(TAG, "Waiting Room: Invalid Room");
            leaveRoom();
        }
    }

    // We are coming back from the player selection UI, in preparation to start a match.
    if (request == RC_SELECT_PLAYERS) {
        if (response != Activity.RESULT_OK) {
            // user canceled
            Log.d(TAG, "onActivityResult: user canceled player selection.");
            return;
        }

        // Create a basic room configuration
        RoomConfig.Builder roomConfigBuilder = RoomConfig.builder(this)
                .setMessageReceivedListener(this)
                .setRoomStatusUpdateListener(this);

        // Set the auto match criteria
        int minAutoMatchPlayers = data.getIntExtra(Multiplayer.EXTRA_MIN_AUTOMATCH_PLAYERS, 0);
        int maxAutoMatchPlayers = data.getIntExtra(Multiplayer.EXTRA_MAX_AUTOMATCH_PLAYERS, 0);
        if (minAutoMatchPlayers > 0 || maxAutoMatchPlayers > 0) {
            Bundle autoMatchCriteria = RoomConfig.createAutoMatchCriteria(
                    minAutoMatchPlayers, maxAutoMatchPlayers, 0);
            roomConfigBuilder.setAutoMatchCriteria(autoMatchCriteria);
        }

        // Set the invitees
        final ArrayList<String> invitees = data.getStringArrayListExtra(Games.EXTRA_PLAYER_IDS);
        if (invitees != null && invitees.size() > 0) {
            roomConfigBuilder.addPlayersToInvite(invitees);
        }

        // Build the room and start the match
        showSpinner();
        Games.RealTimeMultiplayer.create(mGoogleApiClient, roomConfigBuilder.build());
    }
}
 
開發者ID:playgameservices,項目名稱:8bitartist,代碼行數:71,代碼來源:DrawingActivity.java

示例12: onActivityResult

@Override
public void onActivityResult(int requestCode, int responseCode,
                             Intent intent) {
    super.onActivityResult(requestCode, responseCode, intent);

    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;
        case RC_WAITING_ROOM:
            // we got the result from the "waiting room" UI.
            if (responseCode == Activity.RESULT_OK) {
                // ready to start playing
                Log.d(LOG_TAG, "Starting game (waiting room returned OK).");
                multiplayerConnected = true;
                switchToGame();
            } else if (responseCode == GamesActivityResultCodes.RESULT_LEFT_ROOM) {
                // player indicated that they want to leave the room
                leaveRoom();
                switchToMainActivity();
            }
            else if (responseCode == Activity.RESULT_CANCELED) {
                // Dialog was cancelled (user pressed back key, for instance)
                leaveRoom();
                switchToMainActivity();
            }
            else {
                unableToCreateRoom();
            }

            break;
        case RC_SIGN_IN:
            Log.d(LOG_TAG, "onActivityResult with requestCode == RC_SIGN_IN, responseCode="
                    + responseCode + ", intent=" + intent);
            mSignInClicked = false;
            mResolvingConnectionFailure = false;
            if (responseCode == RESULT_OK) {
                mGoogleApiClient.connect();
            }
            break;
    }
    super.onActivityResult(requestCode, responseCode, intent);
}
 
開發者ID:TylerCarberry,項目名稱:2048-Battles,代碼行數:49,代碼來源:MultiplayerActivity.java

示例13: onActivityResult

@Override
public void onActivityResult(int requestCode, int resultCode, Intent intent) {

  if (requestCode == RC_SIGN_IN) {

    Task<GoogleSignInAccount> task =
        GoogleSignIn.getSignedInAccountFromIntent(intent);

    try {
      GoogleSignInAccount account = task.getResult(ApiException.class);
      onConnected(account);
    } catch (ApiException apiException) {
      String message = apiException.getMessage();
      if (message == null || message.isEmpty()) {
        message = getString(R.string.signin_other_error);
      }

      onDisconnected();

      new AlertDialog.Builder(this)
          .setMessage(message)
          .setNeutralButton(android.R.string.ok, null)
          .show();
    }
  } else if (requestCode == RC_SELECT_PLAYERS) {
    // we got the result from the "select players" UI -- ready to create the room
    handleSelectPlayersResult(resultCode, intent);

  } else if (requestCode == RC_INVITATION_INBOX) {
    // we got the result from the "select invitation" UI (invitation inbox). We're
    // ready to accept the selected invitation:
    handleInvitationInboxResult(resultCode, intent);

  } else if (requestCode == RC_WAITING_ROOM) {
    // we got the result from the "waiting room" UI.
    if (resultCode == Activity.RESULT_OK) {
      // ready to start playing
      Log.d(TAG, "Starting game (waiting room returned OK).");
      startGame(true);
    } else if (resultCode == GamesActivityResultCodes.RESULT_LEFT_ROOM) {
      // player indicated that they want to leave the room
      leaveRoom();
    } else if (resultCode == Activity.RESULT_CANCELED) {
      // Dialog was cancelled (user pressed back key, for instance). In our game,
      // this means leaving the room too. In more elaborate games, this could mean
      // something else (like minimizing the waiting room UI).
      leaveRoom();
    }
  }
  super.onActivityResult(requestCode, resultCode, intent);
}
 
開發者ID:playgameservices,項目名稱:android-basic-samples,代碼行數:51,代碼來源:MainActivity.java

示例14: 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, data);
            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, data);
            break;
        case RC_WAITING_ROOM:
            // ignore result if we dismissed the waiting room from code:
            if (mWaitRoomDismissedFromCode) break;

            // we got the result from the "waiting room" UI.
            if (responseCode == Activity.RESULT_OK) {
                // player wants to start playing
                Log.d(TAG, "Starting game because user requested via waiting room UI.");

                // let other players know we're starting.
                broadcastStart();

                // start the game!
                startGame(GameMode.MULTI);
            } else if (responseCode == GamesActivityResultCodes.RESULT_LEFT_ROOM) {
                // player actively indicated that they want to leave the room
                leaveRoom();
            } else if (responseCode == Activity.RESULT_CANCELED) {
                /* Dialog was cancelled (user pressed back key, for
                 * instance). In our game, this means leaving the room too. In more
                 * elaborate games,this could mean something else (like minimizing the
                 * waiting room UI but continue in the handshake process). */
                leaveRoom();
            }

            break;
    }
}
 
開發者ID:kingori,項目名稱:ihatecolor_and,代碼行數:41,代碼來源:MainActivity.java


注:本文中的com.google.android.gms.games.GamesActivityResultCodes.RESULT_LEFT_ROOM屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。