hasan
hasan

Reputation: 24205

Sign out the user

Here in the code sample provided by Google the connect method is called directly after the disconnect method.

@Override
public void onClick(View view) {
  if (view.getId() == R.id.sign_out_button) {
    if (mGoogleApiClient.isConnected()) {
      Plus.AccountApi.clearDefaultAccount(mGoogleApiClient);
      mGoogleApiClient.disconnect();
      mGoogleApiClient.connect();
    }
  }
}

This code snippets as discribed should be used to sign user out of Google+. why they reconnect again?

Is that code sample wrong? if not what is the explanation and what the connect method really do if not sign in?!

Upvotes: 0

Views: 91

Answers (2)

Ojonugwa Jude Ochalifu
Ojonugwa Jude Ochalifu

Reputation: 27237

The accepted answer is, wrong. It is not a mistake. When you signout from Google plus, you are presented with the option of choosing another or same account again. That's why mGoogleApiClient.connect() is called again after you've disconnected.It doesn't automatically sign you back in, it just asks for you to choose an account to resign in with.

Upvotes: 0

planet260
planet260

Reputation: 1454

Because you are immediately connecting it after disconnecting

mGoogleApiClient.disconnect();
mGoogleApiClient.connect(); #Remove this part

It's a mistake in their site.

Upvotes: 1

Related Questions