src/com/closedcircles/client/activities/LoginActivity.java
/* onConnected is called when our Activity successfully connects to Google
     * Play services.  onConnected indicates that an account was selected on the
     * device, that the selected account has granted any requested permissions to
     * our app and that we were able to establish a service connection to Google
     * Play services.
     */
onConnected is called when our Activity successfully connects to Google
Play services.  onConnected indicates that an account was selected on the
device, that the selected account has granted any requested permissions to
our app and that we were able to establish a service connection to Google
Play services.
onConnected is called when our Activity successfully connects to Google Play services . onConnected indicates that an account was selected on the device that the selected account has granted any requested permissions to our app and that we were able to establish a service connection to Google Play services .
@Override
    public void onConnected(Bundle connectionHint) {
        Log.i(TAG, "onConnected");
        mSignInProgress = STATE_DEFAULT;
        if ( mSignOut) {
            SignOut();
            mSignOut = false;
            return;
        }
        mSignInButton.setEnabled(false);
        Toast.makeText(this, "User is connected!", Toast.LENGTH_LONG).show();
        AsyncTask<Void, Void, String> task = new AsyncTask<Void, Void, String>() {
            @Override
            protected String doInBackground(Void... params) {
                String token = null;
                try {
                    token = GoogleAuthUtil.getToken(LoginActivity.this,
                            Plus.AccountApi.getAccountName(mGoogleApiClient),
                            GOOGLE_AUTH_SCOPES);
                } catch (IOException transientEx) {
                    Log.e(TAG, transientEx.toString());
                } catch (UserRecoverableAuthException e) {
                    if ( mFirstTimeAuth ){
                        Log.e(TAG, e.toString());
                        Intent recover = e.getIntent();
                        startActivityForResult(recover, REQUEST_CODE_TOKEN_AUTH);
                        mFirstTimeAuth = false;
                    }
                    else
                        return token;
                } catch (GoogleAuthException authEx) {
                    Log.e(TAG, authEx.toString());
                }
                return token;
            }
            @Override
            protected void onPostExecute(String token) {
                if ( token != null ){
                    Log.i(TAG, "Access token retrieved");
                    WebConnectionManager.get().doAuth(token, AUTH_TYPE_GOOGLE);
                    Intent i = new Intent(LoginActivity.this, CirclesActivity.class);
                    i.putExtra(INTENT_AUTHORIZED, true);
                    startActivity(i);
                }
            }
        };
        task.execute();
    }
@ Override public void onConnected ( Bundle connectionHint ) { Log . i ( TAG , "onConnected" ) ; mSignInProgress = STATE_DEFAULT ; if ( mSignOut ) { SignOut ( ) ; mSignOut = false ; return ; } mSignInButton . setEnabled ( false ) ; Toast . makeText ( this , "User is connected!" , Toast . LENGTH_LONG ) . show ( ) ; AsyncTask < Void , Void , String > task = new AsyncTask < Void , Void , String > ( ) { @ Override protected String doInBackground ( Void ... params ) { String token = null ; try { token = GoogleAuthUtil . getToken ( LoginActivity . this , Plus . AccountApi . getAccountName ( mGoogleApiClient ) , GOOGLE_AUTH_SCOPES ) ; } catch ( IOException transientEx ) { Log . e ( TAG , transientEx . toString ( ) ) ; } catch ( UserRecoverableAuthException e ) { if ( mFirstTimeAuth ) { Log . e ( TAG , e . toString ( ) ) ; Intent recover = e . getIntent ( ) ; startActivityForResult ( recover , REQUEST_CODE_TOKEN_AUTH ) ; mFirstTimeAuth = false ; } else return token ; } catch ( GoogleAuthException authEx ) { Log . e ( TAG , authEx . toString ( ) ) ; } return token ; } @ Override protected void onPostExecute ( String token ) { if ( token != null ) { Log . i ( TAG , "Access token retrieved" ) ; WebConnectionManager . get ( ) . doAuth ( token , AUTH_TYPE_GOOGLE ) ; Intent i = new Intent ( LoginActivity . this , CirclesActivity . class ) ; i . putExtra ( INTENT_AUTHORIZED , true ) ; startActivity ( i ) ; } } } ; task . execute ( ) ; }
onConnected is called when our Activity successfully connects to Google
 Play services.
onConnected is called when our Activity successfully connects to Google Play services .
// Reaching onConnected means we consider the user signed in. // Indicate that the sign in process is complete. // Update the user interface to reflect that the user is signed in. // We've resolved any connection errors. // Network or server error, try later // Recover (with e.getIntent()) // The call is not ever expected to succeed // assuming you have already verified that // Google Play services is installed.