android - Google+ 使用 Play 服务登录 6.5.87 (GoogleApiClient) - Android

标签 android google-plus google-play-services

我在 Play Services 6.1.71 中使用:

mPlusClient = new PlusClient.Builder(this,this,this).setActions("http://schemas.google.com/AddActivity", "http://schemas.google.com/BuyActivity") .setScopes(Scopes.PLUS_LOGIN, Scopes.PROFILE).build();

但在 Google Play Services 6.5.87 中,Google 建议改为将 PlusClient 更改为 GoogleApiClient.Builder。但是我无法像以前那样获取用户信息:

mPlusClient.getAccountName() 

mPlusClient.getCurrentPerson()

如何检索用户信息?我认为 Google 文档已过时。 希望您能够帮助我。谢谢。

最佳答案

使用 GoogleApiClient,而不是 PlusClient。示例:

mGoogleApiClient = new GoogleApiClient.Builder(mContext)
            .addConnectionCallbacks(this)
            .addOnConnectionFailedListener(this)
            .addApi(Plus.API)
            .addScope(Plus.SCOPE_PLUS_LOGIN)
            .build();

getAccountName() 使用Plus.AccountApi.getAccountName(mGoogleApiClient)

getCurrentPerson() 使用 Plus.PeopleApi.getCurrentPerson(mGoogleApiClient)

关于android - Google+ 使用 Play 服务登录 6.5.87 (GoogleApiClient) - Android,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27472435/

相关文章:

android - 蓝牙低功耗: transmitWindowSize: can it be controlled?

android - FLAG_SECURE 不适用于 libgdx 的 AndroidApplication

android - Android Web 应用程序中的 Google Analytics 在 4.0 或更高版本中不起作用

google-api - Google Calendar Javascript API列出了所有日历中的所有事件

java - Google 登录中的致命异常(Fantom 错误)

admob - 在CoCos2dx中如何同时使用admob和google play服务

android - 在 Android 中使用注册 ID 从 GCM 注销设备

Android Play 服务 FusedLocatioAPI getLastLocation 因 SecurityException 而崩溃

android - 创建新项目时没有构建目标

c# - Google+ API plus.me