Code example for PlusClient

Methods: connect, isConnected, revokeAccessAndDisconnect

0
     
    /** 
     * Revoke the access token and completely disconnect from the app. 
     */ 
    public void disconnect(OnAccessRevokedListener listener) {
        if (mPlusClient.isConnected()) {
            mPlusClient.clearDefaultAccount();
        } 
 
        mPlusClient.revokeAccessAndDisconnect(listener);
        resetAfterSignOut(); 
    } 
     
    /** 
     * Reset variables to prepare to connect again. 
     */ 
    private void resetAfterSignOut() { 
        // Reconnect to get a new mPlusClient. 
        mLastConnectionResult = null;
        // Cancel sign in. 
        mRequestCode = INVALID_REQUEST_CODE;
 
        // Reconnect to fetch the sign-in (account chooser) intent from the plus client. 
        mPlusClient.connect();
    } 
     
 
    public boolean isAuthenticated() { 
        return mPlusClient != null && mPlusClient.isConnected();