com.google.android.gms.games.multiplayer.Invitation Java Examples

The following examples show how to use com.google.android.gms.games.multiplayer.Invitation. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: GameHelper.java    From ANE-Google-Play-Game-Services with Apache License 2.0 6 votes vote down vote up
/** Called when we successfully obtain a connection to a client. */
@Override
public void onConnected(Bundle connectionHint) {
    debugLog("onConnected: connected!");

    if (connectionHint != null) {
        debugLog("onConnected: connection hint provided. Checking for invite.");
        Invitation inv = connectionHint
                .getParcelable(Multiplayer.EXTRA_INVITATION);
        if (inv != null && inv.getInvitationId() != null) {
            // retrieve and cache the invitation ID
            debugLog("onConnected: connection hint has a room invite!");
            mInvitation = inv;
            debugLog("Invitation ID: " + mInvitation.getInvitationId());
        }

        debugLog("onConnected: connection hint provided. Checking for TBMP game.");
        mTurnBasedMatch = connectionHint
                .getParcelable(Multiplayer.EXTRA_TURN_BASED_MATCH);
    }

    // we're good to go
    succeedSignIn();
}
 
Example #2
Source File: DrawingActivity.java    From 8bitartist with Apache License 2.0 6 votes vote down vote up
@Override
public void onConnected(Bundle bundle) {
    Log.i(TAG, "onConnected: sign-in successful.");

    // This is *NOT* required; if you do not register a handler for
    // invitation events, you will get standard notifications instead.
    // Standard notifications may be preferable behavior in many cases.
    Games.Invitations.registerInvitationListener(mGoogleApiClient, this);

    // Get invitation from Bundle
    if (bundle != null) {
        Invitation invitation = bundle.getParcelable(Multiplayer.EXTRA_INVITATION);
        if (invitation != null) {
            onInvitationReceived(invitation);
        }
    }

    updateViewVisibility();
}
 
Example #3
Source File: GameHelper.java    From google-play-game-services-ane with MIT License 6 votes vote down vote up
/** Called when we successfully obtain a connection to a client. */
@Override
public void onConnected(Bundle connectionHint) {
    debugLog("onConnected: connected!");

    if (connectionHint != null) {
        debugLog("onConnected: connection hint provided. Checking for invite.");
        Invitation inv = connectionHint
                .getParcelable(Multiplayer.EXTRA_INVITATION);
        if (inv != null && inv.getInvitationId() != null) {
            // retrieve and cache the invitation ID
            debugLog("onConnected: connection hint has a room invite!");
            mInvitation = inv;
            debugLog("Invitation ID: " + mInvitation.getInvitationId());
        }

        debugLog("onConnected: connection hint provided. Checking for TBMP game.");
        mTurnBasedMatch = connectionHint.getParcelable(Multiplayer.EXTRA_TURN_BASED_MATCH);
    }

    // we're good to go
    succeedSignIn();
}
 
Example #4
Source File: GameHelper.java    From ColorPhun with Apache License 2.0 5 votes vote down vote up
/** Called when we successfully obtain a connection to a client. */
@Override
public void onConnected(Bundle connectionHint) {
    debugLog("onConnected: connected!");

    if (connectionHint != null) {
        debugLog("onConnected: connection hint provided. Checking for invite.");
        Invitation inv = connectionHint
                .getParcelable(Multiplayer.EXTRA_INVITATION);
        if (inv != null && inv.getInvitationId() != null) {
            // retrieve and cache the invitation ID
            debugLog("onConnected: connection hint has a room invite!");
            mInvitation = inv;
            debugLog("Invitation ID: " + mInvitation.getInvitationId());
        }

        // Do we have any requests pending?
        mRequests = Games.Requests
                .getGameRequestsFromBundle(connectionHint);
        if (!mRequests.isEmpty()) {
            // We have requests in onConnected's connectionHint.
            debugLog("onConnected: connection hint has " + mRequests.size()
                    + " request(s)");
        }

        debugLog("onConnected: connection hint provided. Checking for TBMP game.");
        mTurnBasedMatch = connectionHint
                .getParcelable(Multiplayer.EXTRA_TURN_BASED_MATCH);
    }

    // we're good to go
    succeedSignIn();
}
 
Example #5
Source File: SkeletonActivity.java    From android-basic-samples with Apache License 2.0 5 votes vote down vote up
@Override
public void onInvitationReceived(@NonNull Invitation invitation) {
  Toast.makeText(
      SkeletonActivity.this,
      "An invitation has arrived from "
          + invitation.getInviter().getDisplayName(), Toast.LENGTH_SHORT)
      .show();
}
 
Example #6
Source File: MainActivity.java    From android-basic-samples with Apache License 2.0 5 votes vote down vote up
@Override
public void onInvitationReceived(@NonNull Invitation invitation) {
  // We got an invitation to play a game! So, store it in
  // mIncomingInvitationId
  // and show the popup on the screen.
  mIncomingInvitationId = invitation.getInvitationId();
  ((TextView) findViewById(R.id.incoming_invitation_text)).setText(
      invitation.getInviter().getDisplayName() + " " +
          getString(R.string.is_inviting_you));
  switchToScreen(mCurScreen); // This will show the invitation popup
}
 
Example #7
Source File: MainActivity.java    From android-basic-samples with Apache License 2.0 5 votes vote down vote up
private void handleInvitationInboxResult(int response, Intent data) {
  if (response != Activity.RESULT_OK) {
    Log.w(TAG, "*** invitation inbox UI cancelled, " + response);
    switchToMainScreen();
    return;
  }

  Log.d(TAG, "Invitation inbox UI succeeded.");
  Invitation invitation = data.getExtras().getParcelable(Multiplayer.EXTRA_INVITATION);

  // accept invitation
  if (invitation != null) {
    acceptInviteToRoom(invitation.getInvitationId());
  }
}
 
Example #8
Source File: GameHelper.java    From cordova-google-play-games-services with MIT License 5 votes vote down vote up
/** Called when we successfully obtain a connection to a client. */
@Override
public void onConnected(Bundle connectionHint) {
    debugLog("onConnected: connected!");

    if (connectionHint != null) {
        debugLog("onConnected: connection hint provided. Checking for invite.");
        Invitation inv = connectionHint
                .getParcelable(Multiplayer.EXTRA_INVITATION);
        if (inv != null && inv.getInvitationId() != null) {
            // retrieve and cache the invitation ID
            debugLog("onConnected: connection hint has a room invite!");
            mInvitation = inv;
            debugLog("Invitation ID: " + mInvitation.getInvitationId());
        }

        // Do we have any requests pending?
        mRequests = Games.Requests
                .getGameRequestsFromBundle(connectionHint);
        if (!mRequests.isEmpty()) {
            // We have requests in onConnected's connectionHint.
            debugLog("onConnected: connection hint has " + mRequests.size()
                    + " request(s)");
        }

        debugLog("onConnected: connection hint provided. Checking for TBMP game.");
        mTurnBasedMatch = connectionHint
                .getParcelable(Multiplayer.EXTRA_TURN_BASED_MATCH);
    }

    // we're good to go
    succeedSignIn();
}
 
Example #9
Source File: GameHelper.java    From FlappyCow with MIT License 5 votes vote down vote up
/** Called when we successfully obtain a connection to a client. */
@Override
public void onConnected(Bundle connectionHint) {
    debugLog("onConnected: connected!");

    if (connectionHint != null) {
        debugLog("onConnected: connection hint provided. Checking for invite.");
        Invitation inv = connectionHint
                .getParcelable(Multiplayer.EXTRA_INVITATION);
        if (inv != null && inv.getInvitationId() != null) {
            // retrieve and cache the invitation ID
            debugLog("onConnected: connection hint has a room invite!");
            mInvitation = inv;
            debugLog("Invitation ID: " + mInvitation.getInvitationId());
        }

        // Do we have any requests pending?
        mRequests = Games.Requests
                .getGameRequestsFromBundle(connectionHint);
        if (!mRequests.isEmpty()) {
            // We have requests in onConnected's connectionHint.
            debugLog("onConnected: connection hint has " + mRequests.size()
                    + " request(s)");
        }

        debugLog("onConnected: connection hint provided. Checking for TBMP game.");
        mTurnBasedMatch = connectionHint
                .getParcelable(Multiplayer.EXTRA_TURN_BASED_MATCH);
    }

    // we're good to go
    succeedSignIn();
}
 
Example #10
Source File: GameHelper.java    From tedroid with Apache License 2.0 5 votes vote down vote up
/** Called when we successfully obtain a connection to a client. */
@Override
public void onConnected(Bundle connectionHint) {
    debugLog("onConnected: connected!");

    if (connectionHint != null) {
        debugLog("onConnected: connection hint provided. Checking for invite.");
        Invitation inv = connectionHint
                .getParcelable(Multiplayer.EXTRA_INVITATION);
        if (inv != null && inv.getInvitationId() != null) {
            // retrieve and cache the invitation ID
            debugLog("onConnected: connection hint has a room invite!");
            mInvitation = inv;
            debugLog("Invitation ID: " + mInvitation.getInvitationId());
        }

        // Do we have any requests pending?
        mRequests = Games.Requests
                .getGameRequestsFromBundle(connectionHint);
        if (!mRequests.isEmpty()) {
            // We have requests in onConnected's connectionHint.
            debugLog("onConnected: connection hint has " + mRequests.size()
                    + " request(s)");
        }

        debugLog("onConnected: connection hint provided. Checking for TBMP game.");
        mTurnBasedMatch = connectionHint
                .getParcelable(Multiplayer.EXTRA_TURN_BASED_MATCH);
    }

    // we're good to go
    succeedSignIn();
}
 
Example #11
Source File: GameHelper.java    From Onesearch with MIT License 5 votes vote down vote up
/** Called when we successfully obtain a connection to a client. */
@Override
public void onConnected(Bundle connectionHint) {
    debugLog("onConnected: connected!");

    if (connectionHint != null) {
        debugLog("onConnected: connection hint provided. Checking for invite.");
        Invitation inv = connectionHint
                .getParcelable(Multiplayer.EXTRA_INVITATION);
        if (inv != null && inv.getInvitationId() != null) {
            // retrieve and cache the invitation ID
            debugLog("onConnected: connection hint has a room invite!");
            mInvitation = inv;
            debugLog("Invitation ID: " + mInvitation.getInvitationId());
        }

        // Do we have any requests pending?
        mRequests = Games.Requests
                .getGameRequestsFromBundle(connectionHint);
        if (!mRequests.isEmpty()) {
            // We have requests in onConnected's connectionHint.
            debugLog("onConnected: connection hint has " + mRequests.size()
                    + " request(s)");
        }

        debugLog("onConnected: connection hint provided. Checking for TBMP game.");
        mTurnBasedMatch = connectionHint
                .getParcelable(Multiplayer.EXTRA_TURN_BASED_MATCH);
    }

    // we're good to go
    succeedSignIn();
}
 
Example #12
Source File: GameHelper.java    From io2014-codelabs with Apache License 2.0 5 votes vote down vote up
/** Called when we successfully obtain a connection to a client. */
@Override
public void onConnected(Bundle connectionHint) {
    debugLog("onConnected: connected!");

    if (connectionHint != null) {
        debugLog("onConnected: connection hint provided. Checking for invite.");
        Invitation inv = connectionHint
                .getParcelable(Multiplayer.EXTRA_INVITATION);
        if (inv != null && inv.getInvitationId() != null) {
            // retrieve and cache the invitation ID
            debugLog("onConnected: connection hint has a room invite!");
            mInvitation = inv;
            debugLog("Invitation ID: " + mInvitation.getInvitationId());
        }

        // Do we have any requests pending?
        mRequests = Games.Requests
                .getGameRequestsFromBundle(connectionHint);
        if (!mRequests.isEmpty()) {
            // We have requests in onConnected's connectionHint.
            debugLog("onConnected: connection hint has " + mRequests.size()
                    + " request(s)");
        }

        debugLog("onConnected: connection hint provided. Checking for TBMP game.");
        mTurnBasedMatch = connectionHint
                .getParcelable(Multiplayer.EXTRA_TURN_BASED_MATCH);
    }

    // we're good to go
    succeedSignIn();
}
 
Example #13
Source File: GameHelper.java    From io2014-codelabs with Apache License 2.0 5 votes vote down vote up
/** Called when we successfully obtain a connection to a client. */
@Override
public void onConnected(Bundle connectionHint) {
    debugLog("onConnected: connected!");

    if (connectionHint != null) {
        debugLog("onConnected: connection hint provided. Checking for invite.");
        Invitation inv = connectionHint
                .getParcelable(Multiplayer.EXTRA_INVITATION);
        if (inv != null && inv.getInvitationId() != null) {
            // retrieve and cache the invitation ID
            debugLog("onConnected: connection hint has a room invite!");
            mInvitation = inv;
            debugLog("Invitation ID: " + mInvitation.getInvitationId());
        }

        // Do we have any requests pending?
        mRequests = Games.Requests
                .getGameRequestsFromBundle(connectionHint);
        if (!mRequests.isEmpty()) {
            // We have requests in onConnected's connectionHint.
            debugLog("onConnected: connection hint has " + mRequests.size()
                    + " request(s)");
        }

        debugLog("onConnected: connection hint provided. Checking for TBMP game.");
        mTurnBasedMatch = connectionHint
                .getParcelable(Multiplayer.EXTRA_TURN_BASED_MATCH);
    }

    // we're good to go
    succeedSignIn();
}
 
Example #14
Source File: GameHelper.java    From google-play-game-services-ane with MIT License 5 votes vote down vote up
/**
 * Returns the invitation received through an invitation notification.
 * This should be called from your GameHelperListener's
 * @link{GameHelperListener#onSignInSucceeded} method, to check if there's an
 * invitation available. In that case, accept the invitation.
 * @return The invitation, or null if none was received.
 */
public Invitation getInvitation() {
    if (!mGoogleApiClient.isConnected()) {
        Log.w(TAG, "Warning: getInvitation() should only be called when signed in, " +
                "that is, after getting onSignInSuceeded()");
    }
    return mInvitation;
}
 
Example #15
Source File: GameHelper.java    From Asteroid with Apache License 2.0 5 votes vote down vote up
/**
 * Called when we successfully obtain a connection to a client.
 */
@Override
public void onConnected(Bundle connectionHint) {
    debugLog("onConnected: connected!");

    if (connectionHint != null) {
        debugLog("onConnected: connection hint provided. Checking for invite.");
        Invitation inv = connectionHint
                .getParcelable(Multiplayer.EXTRA_INVITATION);
        if (inv != null && inv.getInvitationId() != null) {
            // retrieve and cache the invitation ID
            debugLog("onConnected: connection hint has a room invite!");
            mInvitation = inv;
            debugLog("Invitation ID: " + mInvitation.getInvitationId());
        }

        // Do we have any requests pending?
        mRequests = Games.Requests
                .getGameRequestsFromBundle(connectionHint);
        if (!mRequests.isEmpty()) {
            // We have requests in onConnected's connectionHint.
            debugLog("onConnected: connection hint has " + mRequests.size()
                    + " request(s)");
        }

        debugLog("onConnected: connection hint provided. Checking for TBMP game.");
        mTurnBasedMatch = connectionHint
                .getParcelable(Multiplayer.EXTRA_TURN_BASED_MATCH);
    }

    // we're good to go
    succeedSignIn();
}
 
Example #16
Source File: DrawingActivity.java    From 8bitartist with Apache License 2.0 5 votes vote down vote up
/**
 * Accept an invitation to join an RTMP game
 */
private void acceptInvitation(Invitation invitation) {
    Log.d(TAG, "Got invitation: " + invitation);
    RoomConfig.Builder roomConfigBuilder = RoomConfig.builder(this)
            .setMessageReceivedListener(this)
            .setRoomStatusUpdateListener(this)
            .setInvitationIdToAccept(invitation.getInvitationId());

    Games.RealTimeMultiplayer.join(mGoogleApiClient, roomConfigBuilder.build());
}
 
Example #17
Source File: GameHelper.java    From FixMath with Apache License 2.0 5 votes vote down vote up
/** Called when we successfully obtain a connection to a client. */
@Override
public void onConnected(Bundle connectionHint) {
    debugLog("onConnected: connected!");

    if (connectionHint != null) {
        debugLog("onConnected: connection hint provided. Checking for invite.");
        Invitation inv = connectionHint
                .getParcelable(Multiplayer.EXTRA_INVITATION);
        if (inv != null && inv.getInvitationId() != null) {
            // retrieve and cache the invitation ID
            debugLog("onConnected: connection hint has a room invite!");
            mInvitation = inv;
            debugLog("Invitation ID: " + mInvitation.getInvitationId());
        }

        // Do we have any requests pending?
        mRequests = Games.Requests
                .getGameRequestsFromBundle(connectionHint);
        if (!mRequests.isEmpty()) {
            // We have requests in onConnected's connectionHint.
            debugLog("onConnected: connection hint has " + mRequests.size()
                    + " request(s)");
        }

        debugLog("onConnected: connection hint provided. Checking for TBMP game.");
        mTurnBasedMatch = connectionHint
                .getParcelable(Multiplayer.EXTRA_TURN_BASED_MATCH);
    }

    // we're good to go
    succeedSignIn();
}
 
Example #18
Source File: GameHelper.java    From Trivia-Knowledge with Apache License 2.0 5 votes vote down vote up
/** Called when we successfully obtain a connection to a client. */
@Override
public void onConnected(Bundle connectionHint) {
    debugLog("onConnected: connected!");

    if (connectionHint != null) {
        debugLog("onConnected: connection hint provided. Checking for invite.");
        Invitation inv = connectionHint
                .getParcelable(Multiplayer.EXTRA_INVITATION);
        if (inv != null && inv.getInvitationId() != null) {
            // retrieve and cache the invitation ID
            debugLog("onConnected: connection hint has a room invite!");
            mInvitation = inv;
            debugLog("Invitation ID: " + mInvitation.getInvitationId());
        }

        // Do we have any requests pending?
        mRequests = Games.Requests
                .getGameRequestsFromBundle(connectionHint);
        if (!mRequests.isEmpty()) {
            // We have requests in onConnected's connectionHint.
            debugLog("onConnected: connection hint has " + mRequests.size()
                    + " request(s)");
        }

        debugLog("onConnected: connection hint provided. Checking for TBMP game.");
        mTurnBasedMatch = connectionHint
                .getParcelable(Multiplayer.EXTRA_TURN_BASED_MATCH);
    }

    // we're good to go
    succeedSignIn();
}
 
Example #19
Source File: RealTimeMultiplayer.java    From godot-gpgs with MIT License 5 votes vote down vote up
private void handleInvitationInboxResult(int response, Intent data) {
    if (response != Activity.RESULT_OK) {
        Log.w(TAG, "*** invitation inbox UI cancelled, " + response);
        GodotLib.calldeferred(instanceId, "_on_gpgs_rtm_invitation_cancelled", new Object[] { });
        return;
    }

    Log.d(TAG, "GPGS: Invitation inbox UI succeeded.");
    Invitation inv = data.getExtras().getParcelable(Multiplayer.EXTRA_INVITATION);

    // accept invitation
    acceptInviteToRoom(inv.getInvitationId());
}
 
Example #20
Source File: RealTimeMultiplayer.java    From godot-gpgs with MIT License 5 votes vote down vote up
@Override
public void onInvitationReceived(Invitation invitation) {
    // We got an invitation to play a game! So, store it in
    // mIncomingInvitationId
    // and show the popup on the screen.
    incomingInvitationId = invitation.getInvitationId();
    Log.e(TAG, "GPGS: Invitation received " + incomingInvitationId);
    GodotLib.calldeferred(instanceId, "_on_gpgs_rtm_invitation_received", new Object[] { });
}
 
Example #21
Source File: GameHelper.java    From dice-heroes with GNU General Public License v3.0 5 votes vote down vote up
/** Called when we successfully obtain a connection to a client. */
@Override
public void onConnected(Bundle connectionHint) {
    debugLog("onConnected: connected!");

    if (connectionHint != null) {
        debugLog("onConnected: connection hint provided. Checking for invite.");
        Invitation inv = connectionHint
                .getParcelable(Multiplayer.EXTRA_INVITATION);
        if (inv != null && inv.getInvitationId() != null) {
            // retrieve and cache the invitation ID
            debugLog("onConnected: connection hint has a room invite!");
            mInvitation = inv;
            debugLog("Invitation ID: " + mInvitation.getInvitationId());
        }

        // Do we have any requests pending?
        mRequests = Games.Requests
                .getGameRequestsFromBundle(connectionHint);
        if (!mRequests.isEmpty()) {
            // We have requests in onConnected's connectionHint.
            debugLog("onConnected: connection hint has " + mRequests.size()
                    + " request(s)");
        }

        debugLog("onConnected: connection hint provided. Checking for TBMP game.");
        mTurnBasedMatch = connectionHint
                .getParcelable(Multiplayer.EXTRA_TURN_BASED_MATCH);
    }

    // we're good to go
    succeedSignIn();
}
 
Example #22
Source File: GameHelper.java    From martianrun with Apache License 2.0 5 votes vote down vote up
/**
 * Called when we successfully obtain a connection to a client.
 */
@Override
public void onConnected(Bundle connectionHint) {
    debugLog("onConnected: connected!");

    if (connectionHint != null) {
        debugLog("onConnected: connection hint provided. Checking for invite.");
        Invitation inv = connectionHint
                .getParcelable(Multiplayer.EXTRA_INVITATION);
        if (inv != null && inv.getInvitationId() != null) {
            // retrieve and cache the invitation ID
            debugLog("onConnected: connection hint has a room invite!");
            mInvitation = inv;
            debugLog("Invitation ID: " + mInvitation.getInvitationId());
        }

        // Do we have any requests pending?
        mRequests = Games.Requests
                .getGameRequestsFromBundle(connectionHint);
        if (!mRequests.isEmpty()) {
            // We have requests in onConnected's connectionHint.
            debugLog("onConnected: connection hint has " + mRequests.size()
                    + " request(s)");
        }

        debugLog("onConnected: connection hint provided. Checking for TBMP game.");
        mTurnBasedMatch = connectionHint
                .getParcelable(Multiplayer.EXTRA_TURN_BASED_MATCH);
    }

    // we're good to go
    succeedSignIn();
}
 
Example #23
Source File: GameServicesHelper.java    From dice-heroes with GNU General Public License v3.0 5 votes vote down vote up
@Override public void onSignInSucceeded() {
    achievements = new GoogleAchievements(activity, helper.getApiClient());
    cloudSave = new GoogleCloudSave(activity, helper.getApiClient());
    multiplayer = new GameServicesMultiplayer(activity, helper.getApiClient(), helper.getInvitation());
    Games.Invitations
        .loadInvitations(helper.getApiClient())
        .setResultCallback(new ResultCallback<Invitations.LoadInvitationsResult>() {
            @Override public void onResult(final Invitations.LoadInvitationsResult result) {
                if (multiplayer == null) return;
                multiplayer.loadInvitations(result.getInvitations());
            }
        });
    invitationListenerRegistered = true;
    Games.Invitations.registerInvitationListener(helper.getApiClient(), new OnInvitationReceivedListener() {
        @Override public void onInvitationReceived(final Invitation invitation) {
            if (multiplayer == null) return;
            multiplayer.onInvitationReceived(invitation);
        }

        @Override public void onInvitationRemoved(final String s) {
            if (multiplayer == null) return;
            multiplayer.onInvitationRemoved(s);
        }
    });
    Gdx.app.postRunnable(new Runnable() {
        @Override public void run() {
            dispatcher.setState(ServicesState.CONNECTED);
        }
    });
}
 
Example #24
Source File: MainActivity.java    From android-basic-samples with Apache License 2.0 4 votes vote down vote up
private void onConnected(GoogleSignInAccount googleSignInAccount) {
  Log.d(TAG, "onConnected(): connected to Google APIs");
  if (mSignedInAccount != googleSignInAccount) {

    mSignedInAccount = googleSignInAccount;

    // update the clients
    mRealTimeMultiplayerClient = Games.getRealTimeMultiplayerClient(this, googleSignInAccount);
    mInvitationsClient = Games.getInvitationsClient(MainActivity.this, googleSignInAccount);

    // get the playerId from the PlayersClient
    PlayersClient playersClient = Games.getPlayersClient(this, googleSignInAccount);
    playersClient.getCurrentPlayer()
        .addOnSuccessListener(new OnSuccessListener<Player>() {
          @Override
          public void onSuccess(Player player) {
            mPlayerId = player.getPlayerId();

            switchToMainScreen();
          }
        })
        .addOnFailureListener(createFailureListener("There was a problem getting the player id!"));
  }

  // register listener so we are notified if we receive an invitation to play
  // while we are in the game
  mInvitationsClient.registerInvitationCallback(mInvitationCallback);

  // get the invitation from the connection hint
  // Retrieve the TurnBasedMatch from the connectionHint
  GamesClient gamesClient = Games.getGamesClient(MainActivity.this, googleSignInAccount);
  gamesClient.getActivationHint()
      .addOnSuccessListener(new OnSuccessListener<Bundle>() {
        @Override
        public void onSuccess(Bundle hint) {
          if (hint != null) {
            Invitation invitation =
                hint.getParcelable(Multiplayer.EXTRA_INVITATION);

            if (invitation != null && invitation.getInvitationId() != null) {
              // retrieve and cache the invitation ID
              Log.d(TAG, "onConnected: connection hint has a room invite!");
              acceptInviteToRoom(invitation.getInvitationId());
            }
          }
        }
      })
      .addOnFailureListener(createFailureListener("There was a problem getting the activation hint!"));
}
 
Example #25
Source File: GameHelper.java    From tedroid with Apache License 2.0 3 votes vote down vote up
/**
 * Returns the invitation received through an invitation notification. This
 * should be called from your GameHelperListener's
 *
 * @link{GameHelperListener#onSignInSucceeded method, to check if there's an
 *                                            invitation available. In that
 *                                            case, accept the invitation.
 * @return The invitation, or null if none was received.
 */
public Invitation getInvitation() {
    if (!mGoogleApiClient.isConnected()) {
        Log.w(TAG,
                "Warning: getInvitation() should only be called when signed in, "
                        + "that is, after getting onSignInSuceeded()");
    }
    return mInvitation;
}
 
Example #26
Source File: GameHelper.java    From ANE-Google-Play-Game-Services with Apache License 2.0 3 votes vote down vote up
/**
 * Returns the invitation received through an invitation notification. This
 * should be called from your GameHelperListener's
 *
 * @link{GameHelperListener#onSignInSucceeded method, to check if there's an
 *                                            invitation available. In that
 *                                            case, accept the invitation.
 * @return The invitation, or null if none was received.
 */
public Invitation getInvitation() {
    if (!mGoogleApiClient.isConnected()) {
        Log.w(TAG,
                "Warning: getInvitation() should only be called when signed in, "
                        + "that is, after getting onSignInSuceeded()");
    }
    return mInvitation;
}
 
Example #27
Source File: GameHelper.java    From Trivia-Knowledge with Apache License 2.0 3 votes vote down vote up
/**
 * Returns the invitation received through an invitation notification. This
 * should be called from your GameHelperListener's
 *
 * @link{GameHelperListener#onSignInSucceeded method, to check if there's an
 *                                            invitation available. In that
 *                                            case, accept the invitation.
 * @return The invitation, or null if none was received.
 */
public Invitation getInvitation() {
    if (!mGoogleApiClient.isConnected()) {
        Log.w(TAG,
                "Warning: getInvitation() should only be called when signed in, "
                        + "that is, after getting onSignInSuceeded()");
    }
    return mInvitation;
}
 
Example #28
Source File: GameHelper.java    From cordova-google-play-games-services with MIT License 3 votes vote down vote up
/**
 * Returns the invitation received through an invitation notification. This
 * should be called from your GameHelperListener's
 *
 * @link{GameHelperListener#onSignInSucceeded method, to check if there's an
 *                                            invitation available. In that
 *                                            case, accept the invitation.
 * @return The invitation, or null if none was received.
 */
public Invitation getInvitation() {
    if (!mGoogleApiClient.isConnected()) {
        Log.w(TAG,
                "Warning: getInvitation() should only be called when signed in, "
                        + "that is, after getting onSignInSuceeded()");
    }
    return mInvitation;
}
 
Example #29
Source File: GameHelper.java    From FlappyCow with MIT License 3 votes vote down vote up
/**
 * Returns the invitation received through an invitation notification. This
 * should be called from your GameHelperListener's
 *
 * @link{GameHelperListener#onSignInSucceeded method, to check if there's an
 *                                            invitation available. In that
 *                                            case, accept the invitation.
 * @return The invitation, or null if none was received.
 */
public Invitation getInvitation() {
    if (!mGoogleApiClient.isConnected()) {
        Log.w(TAG,
                "Warning: getInvitation() should only be called when signed in, "
                        + "that is, after getting onSignInSuceeded()");
    }
    return mInvitation;
}
 
Example #30
Source File: GameHelper.java    From dice-heroes with GNU General Public License v3.0 3 votes vote down vote up
/**
 * Returns the invitation received through an invitation notification. This
 * should be called from your GameHelperListener's
 *
 * @link{GameHelperListener#onSignInSucceeded method, to check if there's an
 *                                            invitation available. In that
 *                                            case, accept the invitation.
 * @return The invitation, or null if none was received.
 */
public Invitation getInvitation() {
    if (!mGoogleApiClient.isConnected()) {
        Log.w(TAG,
                "Warning: getInvitation() should only be called when signed in, "
                        + "that is, after getting onSignInSuceeded()");
    }
    return mInvitation;
}