Code example for PlusClient

Methods: clearDefaultAccountconnectdisconnectisConnected

0
 
    /** 
     * Sign out of the app. 
     */ 
    public void signOut() { 
        if (mPlusClient.isConnected()) {
            mPlusClient.clearDefaultAccount();
        } 
         
        if (mIsConnecting || mPlusClient.isConnected()) {
            mPlusClient.disconnect();
            resetAfterSignOut(); 
        } 
    } 
     
    /** 
     * 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();