Hussam Daoud
Hussam Daoud

Reputation: 11

google nearby connection access to api

I have a problem with the last update of the google nearby connections API. When I call start Discovery () or start Advertising () before the update I needed to pass a googleApiClient as a parameter.

After the update, I don't need to do this, but I still need to access the api with googleApiClient.

How can I run the sample without using googleApiClient?

  private void startAdvertising() {
  Nearby.getConnections(context).startAdvertising(
          getUserNickname(),
          SERVICE_ID,
          mConnectionLifecycleCallback,
          new AdvertisingOptions(STRATEGY))
      .addOnSuccessListener(
        new OnSuccessListener<Void>() {
          @Override
          public void onSuccess(Void unusedResult) {
            // We're advertising!
          }
        })
      .addOnFailureListener(
        new OnFailureListener() {
          @Override
          public void onFailure(@NonNull Exception e) {
            // We were unable to start advertising.
          }
        });
  }

Upvotes: 1

Views: 440

Answers (2)

Xlythe
Xlythe

Reputation: 2033

Use Nearby.getConnectionsClient(Context), to use the API without making a GoogleApiClient.

Upvotes: 1

Jamol
Jamol

Reputation: 2291

Use Nearby.Connections instead of Nearby.getConnections.

Upvotes: 1

Related Questions