从 GoogleAccountCredential 获取 DisplayName

Get DisplayName from GoogleAccountCredential

我希望能够显示 google 帐户的显示名称。 使用 GoogleAccountCredential 我可以获得电子邮件。 如何从 GoogleAccountCredential(电子邮件)获取显示名称?

你可以使用 GoogleSignInAccount

OptionalPendingResult<GoogleSignInResult> opr = Auth.GoogleSignInApi.silentSignIn(mGoogleApiClient);
if (opr.isDone()) {
    GoogleSignInResult signInResult = opr.get();
    GoogleSignInAccount account = result.getSignInAccount();
    String displayName = account.getDisplayName();
    String givenName = account.getGivenName();
    String familyName = account.getFamilyName();
}