Code example for PlusClient

Methods: clearDefaultAccount, connect, disconnect, isConnected, isConnecting

0
 
    /** 
     * Sign out of the app. 
     */ 
    public void signOut() { 
        if (mPlusClient.isConnected()) {
            mPlusClient.clearDefaultAccount();
        } 
 
        if (mPlusClient.isConnecting() || mPlusClient.isConnected()) {
            mPlusClient.disconnect();
            // 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. 
            connectPlusClient(); 
        } 
    } 
 
    /** 
     * Revoke access to the current app. 
     */ 
    public void revokeAccessAndDisconnect() { 
        if (mPlusClient.isConnected()) {
            mPlusClient.revokeAccessAndDisconnect(this);
        } 
    } 
 
    /** 
     * Attempts to connect the client to Google Play services if the client isn't already connected, 
     * and isn't in the process of being connected. 
     */ 
    private void connectPlusClient() { 
        if (!mPlusClient.isConnecting() && !mPlusClient.isConnected()) {
            mPlusClient.connect();
        } 
    } 
}