Oscar Moncayo
Oscar Moncayo

Reputation: 188

Get DisplayName from GoogleAccountCredential

I would like to be able to display the display name of the google account. With GoogleAccountCredential I can obtain the email. How can I get the displayName from GoogleAccountCredential (email)?

Upvotes: 1

Views: 359

Answers (1)

Bogdan Kobylynskyi
Bogdan Kobylynskyi

Reputation: 1220

You can use GoogleSignInAccount for that:

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();
}

Upvotes: 1

Related Questions