Search code examples
androidgoogle-plusgoogle-account

Sigin my app with Google Account in Android


I have learned that there are many ways to sign in app with Google Account. Here are two ways:

  1. Use AccountManager.java , GOOD: can get user's email address and authToken. BAD: can not get user's avatar and nickname.

  2. Use Google+ Api: GOOD: can get user's all info , but email address. BAD: no email address, and the view's style is not matching to my app.

QUESTION:

1 .How can i get avatar and nickname by using only AccountManager ?

  1. Is the Google+ Api's view be changed ? Any documents?

Thanks for any help!


Solution

  • You can get the Email address via the Google+ API. You need to add the appropriate scopes and permission.

    The scopes are

    Scopes.PROFILE
    Scopes.EMAIL
    

    And you need the following permission

    android.permission.GET_ACCOUNTS
    

    Then you can retrieve the Email address with the AccountApi

    Plus.AccountApi.getAccountName(googleApiClient)