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

4

为什么GoogleApiClient的blockingConnect方法在同一次调用中返回ConnectionResult.CANCELED,而我从OnConnectionFailedListener中获取到ConnectionResult.SIGN_IN_REQUIRED?

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

这是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'


我有同样的问题。我相信这是Play服务的一个错误,2个版本之前没有问题。 - nLL
1个回答

1

我也遇到了这个问题。目前我已经找到的解决方案如下。 当你在构建GoogleApiClient时显式设置帐户名称时,blockingConnect方法返回SUCCESS。否则,它返回CANCELED。但是,正如nLL在评论中提到的那样,早期Play服务版本(特别是6.5.87版本)中,blockingConnect返回SIGN_IN_REQUIRED,因此您可以尝试使用此版本。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接