Android GPGS Java API中能否获取profileSettings.profileVisible字段?
Hey there, I’ve run into this exact scenario before when working with Google Play Games Services (GPGS) on Android—super frustrating that the Web API exposes the profileVisible field in the profileSettings object, but the official Android/Java SDK doesn’t include it directly in the Player class! Let’s go through the most practical solutions to get this info without building a fully manual API integration:
1. Reuse Existing Auth to Call the GPGS REST API
Since your users are already logged in via GPGS, you can leverage their existing authentication to fetch the profile settings via the Web API, no extra login required:
- First, get the current player’s ID using the SDK:
String playerId = Games.getPlayersClient(context).getCurrentPlayer().getId(); - Next, retrieve a valid auth token from the existing
GoogleSignInAccount(you should have this from your login flow):GoogleSignInAccount account = GoogleSignIn.getLastSignedInAccount(context); String idToken = account.getIdToken(); - Then, make a simple GET request to the GPGS Players endpoint:
GET https://www.googleapis.com/games/v1/players/{playerId} Headers: Authorization: Bearer {idToken} - Parse the JSON response to extract
profileSettings.profileVisible—this boolean value tells you if the user has enabled global leaderboard visibility.
This method is reliable because it uses the same auth context your app already has, so users won’t see any extra permission prompts.
2. Fallback: Indirect Check via Leaderboard Data
If you want to avoid making an extra API call, you can use an indirect approach after submitting a score:
- After successfully submitting a leaderboard entry, wait a few seconds (to allow GPGS to process the score), then fetch the user’s own leaderboard rank using
Games.getLeaderboardsClient(context).loadPlayerCenteredLeaderboardScore(...). - If the result doesn’t return the user’s score (or returns an invalid rank), you can show your prompt explaining that their score won’t appear on global leaderboards, possibly due to their profile visibility settings.
Note: This method isn’t 100% foolproof—network delays or temporary GPGS issues could lead to false positives, so it’s best used as a backup if the REST API approach isn’t feasible.
Why No Native SDK Support?
Unfortunately, Google hasn’t exposed the profileVisible field in the Android SDK’s Player class as of now. The Web API has more granular profile settings access, which is why we have to use these workarounds.
内容的提问来源于stack exchange,提问作者Luan Nico

