我正在通过Udacity课程将Google Sign-In集成到Android应用程序中。我们试图通过onConnected()中的.getCurrentOerson()获取当前用户的详细信息,但.getCurrentOerson()已被弃用。.getCurrentPerson(mGoogleApiClient)在GooglePlayServices中弃用8.4
public class SignInAct extends Activity implements GoogleApiClient.ConnectionCallbacks, GoogleApiClient.OnConnectionFailedListener {
GoogleApiClient mGoogleApiClient;
Button signIn,signOut,revoke;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.signinlay);
mGoogleApiClient = buildApiClient();
}
GoogleApiClient buildApiClient(){
return new GoogleApiClient.Builder(this).
addConnectionCallbacks(this).
addOnConnectionFailedListener(this).
addApi(Plus.API, Plus.PlusOptions.builder().build()).
addScope(new Scope(Scopes.PROFILE)).build();
}
@Override
public void onConnected(Bundle bundle) {
signIn.setEnabled(false);
signOut.setEnabled(true);
revoke.setEnabled(true);
Person currentUser = Plus.PeopleApi.getCurrentPerson(mGoogleApiClient);
}}
现在得到displayName的方法是什么? 谢谢。
谢谢你分享的解决方案,该应用程序正在编译,但它没有登录。请看看这个pastebin [链接](http://pastebin.com/x6WdSeVA),并指导我在哪里我可能会出错。当我点击SignIn按钮时,我总是得到这个输出 - 01-23 18:41:50.914 22617-22617/com.authorwjf D/SignInActivity:handleSignInResult:false。我已经包含了json配置文件,并在我的字符串值xml中添加了oauth客户端id。 – gpd