Initialization of variable
private GoogleApiClient mGoogleApiClient;
You must have to Write this Code in onCreate() method of all that when u put signout button.
mGoogleApiClient = new GoogleApiClient.Builder(this)
.enableAutoManage(this /* FragmentActivity */, this /* OnConnectionFailedListener */)
.addApi(Auth.GOOGLE_SIGN_IN_API)
.build();
Put below code on signout button.
Auth.GoogleSignInApi.signOut(mGoogleApiClient).setResultCallback(
new ResultCallback<Status>() {
@Override
public void onResult(Status status) {
FirebaseAuth.getInstance().signOut();
Intent i1 = new Intent(MainActivity.this, GoogleSignInActivity.class);
startActivity(i1);
Toast.makeText(MainActivity.this, "Logout Successfully!", Toast.LENGTH_SHORT).show();
}
});