Android 来自google plus的用户名返回空值
我已经尝试了所有的可能性Android 来自google plus的用户名返回空值,android,google-api,google-plus,Android,Google Api,Google Plus,我已经尝试了所有的可能性 public void onConnected(Bundle connectionHint) { String personName="Unknown"; if (Plus.PeopleApi.getCurrentPerson(mGoogleApiClient) != null) { Person currentPerson = Plus.PeopleApi.getCurrentPerson(mGoogleApiClient);
public void onConnected(Bundle connectionHint) {
String personName="Unknown";
if (Plus.PeopleApi.getCurrentPerson(mGoogleApiClient) != null) {
Person currentPerson = Plus.PeopleApi.getCurrentPerson(mGoogleApiClient);
personName = currentPerson.getDisplayName();
.........
}
}
我仔细检查了SHA密钥和google服务密钥生成
但是它返回空值。像这样试试,它会工作的
Plus.PeopleApi.loadVisible(mGoogleApiClient, null).setResultCallback(this);
参考上面的链接登录,注销,配置文件信息工作正常 你试过另一个谷歌账户吗?
private void getProfileInformation() {
try {
if (Plus.PeopleApi.getCurrentPerson(mGoogleApiClient) != null) {
Person currentPerson = Plus.PeopleApi.getCurrentPerson(mGoogleApiClient);
String personName = currentPerson.getDisplayName();
String personPhotoUrl = currentPerson.getImage().getUrl();
String email = Plus.AccountApi.getAccountName(mGoogleApiClient);
username.setText(personName);
emailLabel.setText(email);
new LoadProfileImage(image).execute(personPhotoUrl);
// update profile frame with new info about Google Account
// profile
updateProfile(true);
}
} catch (Exception e) {
e.printStackTrace();
}
}