4

Why blockingConnect method of GoogleApiClient returns ConnectionResult.CANCELED while during the same call I get ConnectionResult.SIGN_IN_REQUIRED from OnConnectionFailedListener?

I think that blockingConnect method should return the same ConnetionResult as in the OnConnectionFailedListener.onConnectionFailed.

Is this is a bug in GoogleApiClient?

Below is a sample code (should be executed in background thread).

 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);

I'm using 'com.google.android.gms:play-services-plus:7.3.0'

Kamil
  • 336
  • 1
  • 7
  • I have same issue. I believe this is a bug with Play services, 2 version below has no issues – nLL May 12 '15 at 10:09

1 Answers1

1

Had this problem as well. This is what I`ve figured out so far. blockingConnect method returns SUCCESS, when you explicitly set the account name when you build your GoogleApiClient. Otherwise it returns CANCELED. However, as nLL mentioned in the comment, blockingConnect returns SIGN_IN_REQUIRED in earlier Play Services versions, version 6.5.87 in particular, so you can try using this version.

matdev
  • 4,115
  • 6
  • 35
  • 56