我有GoogleAccountCredential对象,可以收到用户的电子邮件。但是,我需要获取他的displayName和头像图标的url。帮你做这个吗?
我通过此代码获得的GoogleAccountCredential对象:
credential = GoogleAccountCredential.usingOAuth2(this, Collections.singleton(CalendarScopes.CALENDAR));
它需要我获取谷歌日历。
答案 0 :(得分:1)
private void getProfileInformation() {
try {
if (Plus.PeopleApi.getCurrentPerson(mGoogleApiClient) != null) {
Person currentPerson = Plus.PeopleApi
.getCurrentPerson(mGoogleApiClient);
String personName = currentPerson.getDisplayName().replace(" ", "%20");
String personPhotoUrl = currentPerson.getImage().getUrl();
// String personGooglePlusProfile = currentPerson.getUrl();
// int gender = currentPerson.getGender();
String email = Plus.AccountApi.getAccountName(mGoogleApiClient);
// Log.i("personName", ""+personName);
} else {
Toast.makeText(getApplicationContext(),
"Person information is null", Toast.LENGTH_LONG).show();
}
} catch (Exception e) {
e.printStackTrace();
}
}