googleworkspace / android-samples

Android samples for Google Workspace APIs
Apache License 2.0
635 stars 410 forks source link

blockingConnect always returns CANCELED Connection result #33

Closed QuickBrownFoxy closed 9 years ago

QuickBrownFoxy commented 9 years ago

ConnectionResult connectionResult = mGoogleApiClientBlocking.blockingConnect(WAITTM, TimeUnit.MILLISECONDS);

is always CANCELED I have just tested with version 24 too

QuickBrownFoxy commented 9 years ago

Simply run below to test

private void blockingTest() { final HandlerThread bcThread = new HandlerThread("blockingConnectThread"); bcThread.start(); final Handler bcHandler = new Handler(bcThread.getLooper());

    final HandlerThread cbThread = new HandlerThread("callbackThread");
    cbThread.start();
    final Handler cbHandler = new Handler(cbThread.getLooper());

    final GoogleApiClient apiClient = new GoogleApiClient.Builder(this)
            .addApi(Drive.API)
            .addScope(Drive.SCOPE_FILE)
            .setHandler(cbHandler)
            .build();

    bcHandler.post(new Runnable() {
        @Override
        public void run() {
              ConnectionResult connectionResult = apiClient.blockingConnect();
            if (connectionResult.isSuccess()) {
                Log.e("TAG", "apiClient connectionResult was successful. Return client");

            } else {    

                Log.e("TAG","resolveIssue connectionResult error code was : "+ connectionResult.getErrorCode() + " hasRes: " + connectionResult.hasResolution());
            }

        }
    });
}
kroikie commented 9 years ago

Is it necessary to use a handler to connect here? Either way I'd suggest not using the same callback to handle callbacks (setHandler) and connecting GoogleApiClient.

QuickBrownFoxy commented 9 years ago

It wasn't that, there was a known issue with google play services and has been fixed with the latest release'

kroikie commented 9 years ago

Thanks for the update @nolovelust