Code example for PlusClient

Methods: clearDefaultAccount, connect, disconnect, isConnected, isConnecting

0
	 
	/** 
	 * Sign out of the app. 
	 */ 
	public void signOut() { 
		if (plusClient.isConnected()) {
			plusClient.clearDefaultAccount();
		} 
		 
		if (plusClient.isConnecting() || plusClient.isConnected()) {
			plusClient.disconnect();
			// Reconnect to get a new mPlusClient. 
			lastConnectionResult = null;
			// Cancel sign in. 
			requestCode = 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 (plusClient.isConnected()) {
			plusClient.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 (!plusClient.isConnecting() && !plusClient.isConnected()) {
			plusClient.connect();
		} 
	} 
}