2017-06-28 90 views
0

我一直试图很长一段时间找到很好的答案。 我的问题很简单。Google Play游戏API和范围

访问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)而不添加范围,那么我无法访问

我的游戏只需要显示多人游戏的玩家用户名和playerids。我需要添加范围吗?因为我真的不想在登录时出现同意窗口,因为没有。

谢谢。

回答

0

正如Google Play Docs所述,包括getCurrentAccountName()在内的一些功能需要SCOPE_GAMES。所以如果你想显示你的玩家的用户名,你需要添加范围。 (此外,对于用户名的权限:android.permission.GET_ACCOUNTS是必需的)

+0

谢谢你的回答:) 我得到的用户名与getCurretPlayer()。displayName();它工作正常。所以我想我不需要那个get_accounts权限,但只有范围。 –