Lilian Sorlanski
Lilian Sorlanski

Reputation: 435

Is it still necessary to call GoogleApiClient connect() and disconnect()?

I know that GoogleApiClient is deprecated and the new class that should be used is GoogleSignInClient, as explained by Paresh Mayani in this answer. However, when I used GoogleApiClient in the back, in my MainActivity I was always calling:

googleApiClient.connect();

In the onStart() and:

googleApiClient.disconnect();

In the onStop().

Is this still required?

Upvotes: 3

Views: 441

Answers (1)

Salman Khakwani
Salman Khakwani

Reputation: 6714

Both GoogleApiClient and GoogleSignInClient are different. Since you are using GoogleSignInClient, it is not necessary to connect/disconnect GoogleApiClient

Also for reference:

GoogleApiClient is used with a variety of static methods. Some of these methods require that GoogleApiClient be connected, some will queue up calls before GoogleApiClient is connected; check the specific API documentation to determine whether you need to be connected.

This is the demonstration of how GoogleAPIClient works internally This is the demonstration of how GoogleAPIClient works internally

Reference link: https://developers.google.com/android/reference/com/google/android/gms/common/api/GoogleApiClient

As recommended by the Google APIs for Android documentation, please migrate to GoogleApi. Following is the migration link:

Migration Link: https://developers.google.com/android/reference/com/google/android/gms/common/api/GoogleApi

I hope this helps.

Upvotes: 1

Related Questions