我一直试图在很长一段时间内找到一个很好的答案。 我的问题很简单。
访问Google Play游戏API时,Google建议我们不要求不必要的范围。
在this post,中,在没有同意屏幕的情况下访问API的好方法就是这样:
// This way you won’t get a consent screen
GoogleApiClient gac = new GoogleApiClient.Builder(this, this, this)
.addApi(Games.API)
.build();
// This way you won’t get a consent screen
在Play Game Services Guide中,他们举了这个例子
// Create the Google Api Client with access to the Play Games services
mGoogleApiClient = new GoogleApiClient.Builder(this)
.addConnectionCallbacks(this)
.addOnConnectionFailedListener(this)
.addApi(Games.API).addScope(Games.SCOPE_GAMES)
// add other APIs and scopes here as needed
.build();
所以我的问题是关于" addScope(Games.SCOPE_GAMES)"。添加时,用户会获得年龄范围,游戏玩家个人资料的同意屏幕以及我不记得的内容。
它是为了什么?两者有什么区别? 如果我只是不使用,只需使用addApi(Games.API)而不添加范围,我将无法访问。
我的游戏只需要显示多人游戏的玩家用户名和玩家。我需要addScope吗?因为我不想在登录时出现同意窗口,一无所获。
谢谢。
答案 0 :(得分:0)
正如Google Play Docs所述,包含getCurrentAccountName()
在内的多项功能都需要SCOPE_GAMES
。因此,如果您想显示您的球员用户名,则需要添加范围。 (此外,对于用户名,权限:android.permission.GET_ACCOUNTS
是必需的)