【问题标题】:Can not connect to Google+ with new API无法使用新 API 连接到 Google+
【发布时间】:2015-05-22 10:00:35
【问题描述】:

我无法使用 start integrating Google+ into your Android app 连接到 Google+。

它很简单,但是用新的 com.google.android.gms:play-services-plus:7.3.0 类 PlusClient 和 PlusClient.Bulder 无法解决。我需要通过电子邮件获取用户信息,例如:头像的 url 和名字/姓氏。

你能帮帮我吗?

P.S:当我添加到 gradle 依赖项时 com.google.android.gms:play-services:6.1.71 类 PlusClient 可以解决,但我超出了方法的限制。当我只添加 play-services-plus 时,它不起作用

【问题讨论】:

  • 您现在使用的是哪个版本的 google play 服务。
  • 我用的是7.3.0版本
  • 你能告诉我修订号吗?
  • 抱歉,我可以在哪里查看?

标签: android google-api google-plus


【解决方案1】:

PlusClient.Bulder 已从修订号 23 中删除,现在 google play services 修订号为 24。

您可以使用

访问 google plus 登录
     private GoogleApiClient buildGoogleApiClient() {
    // When we build the GoogleApiClient we specify where connected and
    // connection failed callbacks should be returned, which Google APIs our
    // app uses and which OAuth 2.0 scopes our app requests.
    return new GoogleApiClient.Builder(SigninActivity.this).addConnectionCallbacks(this)
            .addOnConnectionFailedListener(this).addApi(Plus.API, Plus.PlusOptions.builder().build())
            .addScope(Plus.SCOPE_PLUS_LOGIN).build();
  }

在你的活动类中调用这个方法并像这样分配 GoogleApiClient 的实例

 GoogleApiClient  mPlusClient = buildGoogleApiClient();

请关注此link 以了解完整流程。

【讨论】:

  • 不幸的是,链接代码不起作用,在 onCreate 初始化之后什么也没发生(
猜你喜欢
  • 2019-12-07
  • 2022-08-10
  • 1970-01-01
  • 1970-01-01
  • 2016-12-08
  • 2015-08-19
  • 1970-01-01
  • 1970-01-01
  • 2012-11-06
相关资源
最近更新 更多