从Google Play服务获取用户ID?

问题描述:

在使用Google Play服务时,有什么方法可以让特定用户获得Google Play ID(数字,字符串,任何内容)?从Google Play服务获取用户ID?

对于Google Play游戏服务,您可以使用:

String playerId = Games.Players.getCurrentPlayerId(getApiClient()); 
+0

我明白了,但谢谢。这可能对未来的其他人有所帮助。 – Agamemnus 2015-01-12 20:40:57

+6

@Pygmalion它是独一无二的,并且是不变的?它可以用来在线保存玩家的进度吗? – 2016-05-20 16:56:58

这取决于您尝试访问的服务。 下面是相关类Player对谷歌玩游戏: https://developer.android.com/reference/com/google/android/gms/games/Player.html

及相关类People从谷歌加: https://developer.android.com/reference/com/google/android/gms/plus/model/people/package-summary.html

最后,还有AdvertisingIdClient对于谷歌移动广告平台: https://developer.android.com/reference/com/google/android/gms/ads/identifier/AdvertisingIdClient.html

+0

是的,我不想问用户G +的权限。我只想要用户ID。我不知道如何去这个“球员”类。 – Agamemnus 2014-10-16 21:05:31

+0

'com.google.android.gms.games.Player' 这是正确的第一个链接。 – Sam12345 2014-10-16 21:10:27

+0

那么只需导入它就是了?我得到用户的ID?我需要做其他事吗? – Agamemnus 2014-10-16 21:49:35