Doronz
Doronz

Reputation: 704

Differentiate between multiple Google APIs calling onConnected

So I have an app that uses both the google+ api to allow users to sign in, as well as the cast api to allow users to cast content to a chromecast.

However, both APIs use the same connection callbacks.

What is the best practice for differentiating between which API should be notified of the connection callback?

For example, onConnected() is called when the user succesfully signs in. But it is also called when the connection to the chromecast has been established. How do I differentiate between the two scenarios?

Edit: So I found this info from Google:

Note that the contents of the connectionHint Bundle are defined by the specific services. Please see the documentation of the specific implementation of GoogleApiClient you are using for more information.

However, I cannot find the documentation that describes the connectionHint contents for different APIs.

Edit2: Could I just create a separate API client for each API?

Upvotes: 0

Views: 324

Answers (1)

Ali Naddaf
Ali Naddaf

Reputation: 19084

The easiest approach is to use multiple clients, one for each API and then attach separate callbacks to them to be able to distinguish them.

Upvotes: 1

Related Questions