I'm using Google+ sign in on my application, and followed the reference such as the Getting Started and Google+ Sign-in for Android.
So the situation is the following:
I have one LoginActivity and a MainActivity, both extend on BaseActivity (so they can share the instance of GoogleApiClient, and the necessary interfaces implementations) and when I sign in, the LoginActivity does the following:
public void onConnected(Bundle connectionHint) {
super.onConnected(connectionHint);
mSignInClicked = false;
launchMain();
}
private void launchMain() {
Intent i = new Intent(this, MainActivity.class);
startActivity(i);
finish();
}
And the MainActivity will launch, great!
But when I want to sign out from the MainActivity I do the following:
protected static GoogleApiClient mGoogleApiClient;
public void signOut() {
if (mGoogleApiClient.isConnected()) {
Plus.AccountApi.clearDefaultAccount(mGoogleApiClient);
mGoogleApiClient.disconnect();
mGoogleApiClient.connect();
Intent i = new Intent(getApplicationContext(),LoginActivity.class);
i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK| Intent.FLAG_ACTIVITY_CLEAR_TASK);
startActivity(i);
}
}
The mGoogleApiClient.isConnected() check is always false, and I'm never able to disconnect.
Besides that I'm confused why should I do the connect right after the disconnect.