예제 #1
0
  /** Call this method from your Activity's onStart(). */
  public void onStart(Activity act) {
    mActivity = act;
    mAppContext = act.getApplicationContext();

    debugLog("onStart");
    assertConfigured("onStart");

    if (mConnectOnStart) {
      if (mGoogleApiClient.isConnected()) {
        Log.w(TAG, "GameHelper: client was already connected on onStart()");
      } else {
        debugLog("Connecting client.");
        mConnecting = true;
        mGoogleApiClient.connect();
      }
    } else {
      debugLog("Not attempting to connect becase mConnectOnStart=false");
      debugLog("Instead, reporting a sign-in failure.");
      mHandler.postDelayed(
          new Runnable() {
            @Override
            public void run() {
              notifyListener(false);
            }
          },
          1000);
    }
  }
예제 #2
0
  /** Call this method from your Activity's onStop(). */
  public void onStop() {
    debugLog("onStop");
    assertConfigured("onStop");
    if (mGoogleApiClient.isConnected()) {
      debugLog("Disconnecting client due to onStop");
      mGoogleApiClient.disconnect();
    } else {
      debugLog("Client already disconnected when we got onStop.");
    }
    mConnecting = false;
    mExpectingResolution = false;

    // let go of the Activity reference
    mActivity = null;
  }