我的代码适用于连接和检索用户电子邮件ID:
String account = Plus.AccountApi.getAccountName(mGoogleApiClient);
但是当我尝试获取用户个人资料时,它包含空信息。这是我的代码。
mGoogleApiClient = new GoogleApiClient.Builder(this)
.addConnectionCallbacks(this)
.addOnConnectionFailedListener(this).addApi(Plus.API)
.addScope(Plus.SCOPE_PLUS_PROFILE).build();
@Override
public void onConnected(Bundle arg0) {
account = Plus.AccountApi.getAccountName(mGoogleApiClient);
Plus.PeopleApi.loadVisible(mGoogleApiClient, null)
.setResultCallback(this);
String personName = "Unknown";
if (Plus.PeopleApi.getCurrentPerson(mGoogleApiClient) != null) {
Person currentPerson = Plus.PeopleApi
.getCurrentPerson(mGoogleApiClient);
personName = currentPerson.getDisplayName();
}
}
此处,Plus.PeopleApi.getCurrentPerson(mGoogleApiClient)显示为空。
感谢任何帮助..