Sign in to Google+ with Play Services 6.5.87 (GoogleApiClient) - Android

In Play Services 6.1.71, I used:

mPlusClient = new PlusClient.Builder(this,this,this).setActions("http://schemas.google.com/AddActivity", "http://schemas.google.com/BuyActivity").setScopes(Scopes.PLUS_LOGIN, Scopes.PROFILE).build();

But in Google Play Services 6.5.87, Google suggests changing PlusClient to GoogleApiClient.Builder instead. But I can’t get the user information as before:

 mPlusClient.getAccountName() 

or

 mPlusClient.getCurrentPerson() 

How can I get user information? I think the Google documentation is out of date. I hope you help me. Thanks.

+5
source share
2 answers

Use GoogleApiClient , not PlusClient . Example:

 mGoogleApiClient = new GoogleApiClient.Builder(mContext) .addConnectionCallbacks(this) .addOnConnectionFailedListener(this) .addApi(Plus.API) .addScope(Plus.SCOPE_PLUS_LOGIN) .build(); 

To getAccountName () use Plus.AccountApi.getAccountName (mGoogleApiClient)

In getCurrentPerson () use Plus.PeopleApi.getCurrentPerson (mGoogleApiClient)

+6
source

A very nice example of how to implement a login using GoogleApiClient ... Since this is a complete tutorial, I do not copy it here.

0
source

Source: https://habr.com/ru/post/1209018/


All Articles