Accessing Google Account Id /username via Android

后端 未结 7 2279
夕颜
夕颜 2020-11-28 02:11

How do you access the user\'s Google Account Id / username in code? I am building an application that will call a web service to store data and I want to identify the ident

7条回答
  •  清歌不尽
    2020-11-28 02:26

    Retrieve profile information for a signed-in user Use the GoogleSignInResult.getSignInAccount method to request profile information for the currently signed in user. You can call the getSignInAccount method after the sign-in intent succeeds.

    GoogleSignInResult result = 
    Auth.GoogleSignInApi.getSignInResultFromIntent(data);
    GoogleSignInAccount acct = result.getSignInAccount();
    String personName = acct.getDisplayName();
    String personGivenName = acct.getGivenName();
    String personFamilyName = acct.getFamilyName();
    String personEmail = acct.getEmail();
    String personId = acct.getId();
    Uri personPhoto = acct.getPhotoUrl();
    

提交回复
热议问题