Sign In Register

How can we help you today?

Start a new topic

Android Integration with Google Play signin

Im stuck on how to integrate gamesparks into my libgdx game with google play authentication. Ive gone thru the setup and the authentication tutorials on the gamesparks website.  My onCreate and onStart code looks like this: 

	protected void onCreate (Bundle savedInstanceState) {
		AndroidApplicationConfiguration config = new AndroidApplicationConfiguration();
		config.hideStatusBar = true;
		config.useImmersiveMode = true;

		//Create the client used to sign in to Google services
		mGoogleSignInClient = GoogleSignIn.getClient(this,
				new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_GAMES_SIGN_IN)

		//Gamesparks stuff
		GSAndroidPlatform.initialise(this, "Y350111e9EVD", "onfWeN5kCAuB4sgljZvz2ck34tJJsFu9", "device", false, true);

		game = new RoboSmash(this);

		initialize(game, config);

	protected void onStart() {

  When the game is initialized a call to log in via google play game services is called.  That code looks like this when it connects:

private void onConnected(final GoogleSignInAccount googleSignInAccount) {
		Log.d(TAG, "onConnected(): connected to Google APIs");

		GamesClient gamesClient = Games.getGamesClient(AndroidLauncher.this, googleSignInAccount);
		gamesClient.setGravityForPopups(Gravity.TOP | Gravity.CENTER_HORIZONTAL);

		mPlayersClient = Games.getPlayersClient(this, googleSignInAccount);

		// Set the greeting appropriately on main menu
				.addOnCompleteListener(new OnCompleteListener<Player>() {
					public void onComplete(@NonNull Task<Player> task) {
						String displayName;
						if (task.isSuccessful()) {
							user = new User();
							game.user = user;
									.setAccessToken(googleSignInAccount.getIdToken()).send(new GSEventConsumer<GSResponseBuilder.AuthenticationResponse>() {
								public void onEvent(AuthenticationResponse authenticationResponse) {
									Log.d("GameSparks", "New Player:" + authenticationResponse.getNewPlayer());
						} else {
							Exception e = task.getException();
							handleException(e, getString(R.string.players_exception));
							displayName = "???";

 This runs but starts up like this and have to hit the back button to proceed to my game.


Is this normal behavior and if so I want it to create a new player if player doesnt exist

Login to post a comment