示例#1
0
  /**
   * Performs setup on this GameHelper object. Call this from the onCreate() method of your
   * Activity. This will create the clients and do a few other initialization tasks. Next,
   * call @link{#onStart} from the onStart() method of your Activity.
   *
   * @param listener The listener to be notified of sign-in events.
   */
  public void setup(GameHelperListener listener) {
    if (mSetupDone) {
      String error = "GameHelper: you cannot call GameHelper.setup() more than once!";
      logError(error);
      throw new IllegalStateException(error);
    }
    mListener = listener;
    debugLog("Setup: requested clients: " + mRequestedClients);

    if (mGoogleApiClientBuilder == null) {
      // we don't have a builder yet, so create one
      createApiClientBuilder();
    }

    mGoogleApiClient = mGoogleApiClientBuilder.build();
    mGoogleApiClientBuilder = null;
    mSetupDone = true;
  }