title: logout GoogleApiClient from another activity
body: <p>I want build app with google account API. I done login with google tutorial and it work good but i try to logout account from another activity and it works too but method "onStart" in class LoginActivity.java login account back when i comment "onStart" its ok but when i try login again it login for account which was logged. For pass googleApiClient object to another activity i used singleton. Can you help me?</p>
  
  <p>Code: </p>
  
  <pre><code>public void onStart() {
          super.onStart();
  
          OptionalPendingResult&lt;GoogleSignInResult&gt; opr = Auth.GoogleSignInApi.silentSignIn(mGoogleApiClient);
          if (opr.isDone()) {
              Log.d(TAG, "Got cached sign-in");
              GoogleSignInResult result = opr.get();
              handleSignInResult(result);
          } else {
              showProgressDialog();
              opr.setResultCallback(new ResultCallback&lt;GoogleSignInResult&gt;() {
                  @Override
                  public void onResult(GoogleSignInResult googleSignInResult) {
                      hideProgressDialog();
                      handleSignInResult(googleSignInResult);
                  }
              });
          }
      }
  </code></pre>
  
  <p>HomeActivity.java:</p>
  
  <pre><code>public class HomeActivity extends AppCompatActivity implements View.OnClickListener {
      private GoogleApiClient mGoogleApiClient;// = state.getmGoogleApiClient();
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_home);
  
          GlobalState state = ((GlobalState) getApplicationContext()); 
          mGoogleApiClient = state.getmGoogleApiClient();
  
          findViewById(R.id.sign_out_button).setOnClickListener(this);
      }
  
      private void signOut(){
          Auth.GoogleSignInApi.signOut(mGoogleApiClient).setResultCallback(
                  new ResultCallback&lt;Status&gt;() {
                      @Override
                      public void onResult(Status status) {
                          GlobalState state = ((GlobalState) getApplicationContext()); 
                          state.setmGoogleApiClient(mGoogleApiClient);
                          Intent login = new Intent(getApplicationContext(), LoginActivity.class);
                          login.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
                          startActivity(login);
                          finish();
                      }
                  });
      }
  
  
  
      @Override
      public void onClick(View v) {
          switch(v.getId()){
              case R.id.sign_out_button:
                  signOut();
                  break;
          }
      }
  </code></pre>