Java Code Examples for com.google.android.gms.auth.api.signin.GoogleSignInAccount#getEmail()

The following examples show how to use com.google.android.gms.auth.api.signin.GoogleSignInAccount#getEmail() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Utils.java    From PretendYoureXyzzyAndroid with GNU General Public License v3.0 6 votes vote down vote up
@NonNull
public static String getAccountName(@NonNull GoogleSignInAccount account) {
    String name = account.getDisplayName();
    if (name == null || name.isEmpty()) {
        name = account.getGivenName();
        if (name == null || name.isEmpty()) {
            name = account.getEmail();
            if (name == null || name.isEmpty()) {
                name = account.getId();
                if (name == null || name.isEmpty()) name = "<unknown>";
            }
        }
    }

    return name;
}
 
Example 2
Source File: GoogleLoginHiddenActivity.java    From SocialLoginManager with Apache License 2.0 6 votes vote down vote up
private void handleSignInResult(GoogleSignInResult result) {
  if (result.isSuccess()) {
    GoogleSignInAccount acct = result.getSignInAccount();
    SocialUser user = new SocialUser();
    user.userId = acct.getId();
    user.accessToken = acct.getIdToken();
    user.photoUrl = acct.getPhotoUrl() != null ? acct.getPhotoUrl().toString() : "";
    SocialUser.Profile profile = new SocialUser.Profile();
    profile.email = acct.getEmail();
    profile.name = acct.getDisplayName();
    user.profile = profile;
    SocialLoginManager.getInstance(this).onLoginSuccess(user);
  } else {
    Throwable throwable = new Throwable(result.getStatus().getStatusMessage());
    SocialLoginManager.getInstance(this).onLoginError(throwable);
  }

  finish();
}
 
Example 3
Source File: AndroidGoogleAccount.java    From QtAndroidTools with MIT License 5 votes vote down vote up
private boolean loadSignedInAccountInfo(final GoogleSignInAccount SignedInAccount)
{
    if(SignedInAccount != null)
    {
        AccountInfo SignedInAccountInfo = new AccountInfo();
        final Uri PhotoUrl = SignedInAccount.getPhotoUrl();

        SignedInAccountInfo.id = SignedInAccount.getId();
        SignedInAccountInfo.displayName = SignedInAccount.getDisplayName();
        SignedInAccountInfo.email = SignedInAccount.getEmail();
        SignedInAccountInfo.familyName = SignedInAccount.getFamilyName();
        SignedInAccountInfo.givenName = SignedInAccount.getGivenName();

        if(PhotoUrl != null)
        {
            DownloadAccountPhotoTask DownloadAccountPhoto = new DownloadAccountPhotoTask(SignedInAccountInfo);
            DownloadAccountPhoto.execute(PhotoUrl.toString());
        }
        else
        {
            SignedInAccountInfo.photo = null;
            updateSignedInAccountInfo(SignedInAccountInfo);
        }

        return true;
    }

    return false;
}
 
Example 4
Source File: RxAccount.java    From RxSocialAuth with Apache License 2.0 5 votes vote down vote up
public RxAccount(GoogleSignInAccount gsa) {
    this.id = gsa.getId();
    this.accessToken = gsa.getIdToken();
    this.email = gsa.getEmail();
    this.firstname = gsa.getGivenName();
    this.lastname = gsa.getFamilyName();
    this.displayName = gsa.getDisplayName();
    this.photoUri = gsa.getPhotoUrl();
    this.provider = IdentityProviders.GOOGLE;
}
 
Example 5
Source File: LoginActivity.java    From aptoide-client with GNU General Public License v2.0 5 votes vote down vote up
public void handleSignInResult(GoogleSignInResult result) {
    Log.d(TAG, "GoogleSignInResult. status: " + result.getStatus());
    final GoogleSignInAccount account;
    if (result.isSuccess() && (account = result.getSignInAccount()) != null) {
        final String userName = account.getEmail();
        final String token = account.getServerAuthCode();
        final String name = account.getDisplayName();
        submit(Mode.GOOGLE, userName, token, name);
    } else {
        Toast.makeText(Aptoide.getContext(), R.string.error_occured, Toast.LENGTH_SHORT).show();
    }
}
 
Example 6
Source File: HomeActivity.java    From Movie-Check with Apache License 2.0 5 votes vote down vote up
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    if (requestCode == RC_SIGN_IN) {
        GoogleSignInResult result = Auth.GoogleSignInApi.getSignInResultFromIntent(data);
        if (result.isSuccess()) {
            GoogleSignInAccount googleSignInAccount = result.getSignInAccount();
            User user = new User(googleSignInAccount.getId(), googleSignInAccount.getDisplayName(),
                    googleSignInAccount.getEmail(), googleSignInAccount.getPhotoUrl().toString());
            presenter.login(user);
        }
    }
}