Google+使用Play Services 6.5.87登录(GoogleApiClient) - Android

Bri*_*ier 5 android google-plus google-play-services

在Play Services 6.1.71我使用的是:

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();

但在Google Play Services 6.5.87中,Google建议将PlusClient更改为GoogleApiClient.Builder.但是我无法像以前那样获得用户信息:

mPlusClient.getAccountName() 
Run Code Online (Sandbox Code Playgroud)

要么

mPlusClient.getCurrentPerson()
Run Code Online (Sandbox Code Playgroud)

如何检索用户信息?我认为Google文档已过时.希望您能够帮助我.谢谢.

小智 6

使用GoogleApiClient,而不是PlusClient.样品:

mGoogleApiClient = new GoogleApiClient.Builder(mContext)
            .addConnectionCallbacks(this)
            .addOnConnectionFailedListener(this)
            .addApi(Plus.API)
            .addScope(Plus.SCOPE_PLUS_LOGIN)
            .build();
Run Code Online (Sandbox Code Playgroud)

getAccountName(),请使用Plus.AccountApi.getAccountName(mGoogleApiClient)

getCurrentPerson()使用Plus.PeopleApi.getCurrentPerson(mGoogleApiClient)