gpt4 book ai didi

android - 为什么 GoogleApiClient 的 blockingConnect 方法返回 ConnectionResult.CANCELED?

转载 作者:太空狗 更新时间:2023-10-29 14:09:27 25 4
gpt4 key购买 nike

为什么 GoogleApiClient 的 blockingConnect 方法返回 ConnectionResult.CANCELED 而在同一调用期间我从 OnConnectionFailedListener 获得 ConnectionResult.SIGN_IN_REQUIRED?

我认为 blockingConnect 方法应该返回与 OnConnectionFailedListener.onConnectionFailed 中相同的 ConnetionResult。

这是 GoogleApiClient 中的错误吗?

下面是一个示例代码(应该在后台线程中执行)。

 GoogleApiClient googleApiClient = new GoogleApiClient.Builder(LoginActivity.this)
.addApi(Plus.API)
.addScope(Plus.SCOPE_PLUS_LOGIN)
.addOnConnectionFailedListener(new GoogleApiClient.OnConnectionFailedListener() {
@Override
public void onConnectionFailed(ConnectionResult connectionResult) {

}
})
.build();
ConnectionResult connectionResult = googleApiClient.blockingConnect(30, TimeUnit.SECONDS);

我正在使用“com.google.android.gms:play-services-plus:7.3.0”

最佳答案

我也遇到过这个问题。到目前为止,这是我想通的。当您在构建 GoogleApiClient 时明确设置帐户名时,blockingConnect 方法会返回 SUCCESS。否则它返回取消。但是,正如 nLL 在评论中提到的那样,blockingConnect 在较早的 Play Services 版本中返回 SIGN_IN_REQUIRED,特别是 6.5.87 版本,因此您可以尝试使用此版本。

关于android - 为什么 GoogleApiClient 的 blockingConnect 方法返回 ConnectionResult.CANCELED?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30166843/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com