title: mGoogleApiClient cannot be achieved in another activity
body: <p>I met a problem in my project.
  I want to use "Google API" to log in in my <em>LoginActivity</em>. And Log out from another Activity(named <em>WelcomeActivity</em>)</p>
  
  <p>LoginActivity:
  (code is <a href="https://github.com/googlesamples/google-services/blob/master/android/signin/app/src/main/java/com/google/samples/quickstart/signin/SignInActivity.java">here</a>)</p>
  
  <pre><code>public class LoginActivity extends AppCompatActivity implements
          GoogleApiClient.OnConnectionFailedListener,
          View.OnClickListener {
  
      // Configuration of Google API - Step 1/3
      private static final String TAG = "LoginActivity";
      private static final int RC_SIGN_IN = 9001;
      public static GoogleApiClient mGoogleApiClient;
      private ProgressDialog mProgressDialog;
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          GoogleAPI();
  
      }
      public void GoogleAPI(){
  
          // Button listeners
          findViewById(R.id.sign_in_button).setOnClickListener(this);
  
          GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
                  .requestEmail()
                  .build();
  
          mGoogleApiClient = new GoogleApiClient.Builder(this)
                  .enableAutoManage(this /* FragmentActivity */, this /* OnConnectionFailedListener */)
                  .addApi(Auth.GOOGLE_SIGN_IN_API, gso)
                  .build();
      }
  
      @Override
      public void onStart() {
          super.onStart();
          ....
      }
  
      // [START onActivityResult]
      @Override
      public void onActivityResult(int requestCode, int resultCode, Intent data) {
          super.onActivityResult(requestCode, resultCode, data);
          // Result returned from launching the Intent from GoogleSignInApi.getSignInIntent(...);
          if (requestCode == RC_SIGN_IN) {
              GoogleSignInResult result = Auth.GoogleSignInApi.getSignInResultFromIntent(data);
              handleSignInResult(result);
          }
      }
      // [END onActivityResult]
  
      // [START handleSignInResult]
      private void handleSignInResult(GoogleSignInResult result) {
  
          if (result.isSuccess()) {
              // Signed in successfully, show authenticated UI.
              CustomApplication app = (CustomApplication)getApplication();
              GoogleSignInAccount acct = result.getSignInAccount();
              Intent i = new Intent(LoginActivity.this, WelcomePage.class);
              i.putExtra("Username", acct.getDisplayName());
              startActivity(i);
          }
      }
      // [END handleSignInResult]
  
      // [START signIn]
      private void signIn() {
          Intent signInIntent = Auth.GoogleSignInApi.getSignInIntent(mGoogleApiClient);
          startActivityForResult(signInIntent, RC_SIGN_IN);
      }
      // [END signIn]
  
      @Override
      public void onConnectionFailed(ConnectionResult connectionResult) {
          ...
      }
  
      private void showProgressDialog() {
         ...
      }
  
      private void hideProgressDialog() {
         ...
      }
  
      @Override
      public void onClick(View v) {
          switch (v.getId()) {
              case R.id.sign_in_button:
                  signIn();
                  break;
              ….
          }
      }
  
  }
  </code></pre>
  
  <p>And I want to use Sign_out Method in my Welcome activity, </p>
  
  <pre><code>private void signOut() {
  //        Auth.GoogleSignInApi.signOut(mGoogleApiClient).setResultCallback(
  //                new ResultCallback&lt;Status&gt;() {
  //                    @Override
  //                    public void onResult(Status status) {
  //                        // [START_EXCLUDE]
  ////                        updateUI(false);
  //                        // [END_EXCLUDE]
  //                    }
  //                });
  //    }
  </code></pre>
  
  <p>In order to solve this problem, i try 2 methods:</p>
  
  <ol>
  <li><p>make mGoogleApiClient as a global variable(extends Application or Singleton), i try it, but failed, in Welcome page, mGoogleApiClient is not null, but error is: <strong>mGoogleApiClient is not connected yet</strong>.</p></li>
  <li><p>i call LoginActivity.getMGoogleApiClient(static variable), but also failed, same error: <strong>mGoogleApiClient is not connected yet</strong>.</p></li>
  </ol>
  
  <p>I already search this problem for days, but nothing useful to solve it, please help me ..</p>