I am able to log in using helper classes from BaseGameUtils: https://github.com/playgameservices/android-basic-samples/tree/master/BasicSamples/libraries/BaseGameUtils/src/main/java/com/google/example/games/basegameutils
How can I get the ID of the player just logged in?
gameHelper.setConnectOnStart(false);
gameHelper.setMaxAutoSignInAttempts(0);
gameHelper.setup(gameHelperListener);
final GameHelper.GameHelperListener gameHelperListener = new GameHelper.GameHelperListener() {
@Override
public void onSignInFailed() {
}
@Override
public void onSignInSucceeded() {
// I want to get the player ID here
}
};
Login code:
try {
runOnUiThread(new Runnable() {
@Override
public void run() {
gameHelper.beginUserInitiatedSignIn();
}
});
} catch (Exception e) {
}
This question was answered here: Get a user ID from Google Play Services?
Here is the solution:
String playerId = Games.Players.getCurrentPlayerId(getApiClient());