use of com.google.android.gms.auth.api.signin.GoogleSignInAccount in project google-services by googlesamples.
the class SignInActivityWithDrive method handleSignInResult.
// [END onActivityResult]
// [START handleSignInResult]
private void handleSignInResult(GoogleSignInResult result) {
Log.d(TAG, "handleSignInResult:" + result.isSuccess());
if (result.isSuccess()) {
// Signed in successfully, show authenticated UI.
GoogleSignInAccount acct = result.getSignInAccount();
mStatusTextView.setText(getString(R.string.signed_in_fmt, acct.getDisplayName()));
updateUI(true);
} else {
// Signed out, show unauthenticated UI.
updateUI(false);
}
}
use of com.google.android.gms.auth.api.signin.GoogleSignInAccount in project iosched by google.
the class SwitchUserActivity method handleSignInResult.
/**
* Update active account and inform calling task of result completion.
* Invoked after after the GoogleSignInApi login process completes (which is itself invoked
* in SignOutCallback).
*
* <p>In the event the user cancels login, the last known user is restored.
*
* @param result User data from GoogleSignInApi
*/
private void handleSignInResult(final GoogleSignInResult result) {
if (result.isSuccess()) {
final GoogleSignInAccount newUser = result.getSignInAccount();
if (newUser != null) {
AccountUtils.setActiveAccount(this, newUser.getEmail());
LOGI(TAG, "Switched to user: " + newUser);
setResult(Activity.RESULT_OK);
}
} else {
// Login failed, revert to previous user to simulate spinner behavior
LOGI(TAG, "Account switch aborted, re-enabling previous user: " + mPreviousUser);
AccountUtils.setActiveAccount(this, mPreviousUser);
setResult(Activity.RESULT_CANCELED);
}
finish();
}
use of com.google.android.gms.auth.api.signin.GoogleSignInAccount in project iosched by google.
the class AccountFragment method handleSignInResult.
private void handleSignInResult(final GoogleSignInResult result) {
Log.d(TAG, "handleSignInResult:" + result.isSuccess());
if (result.isSuccess()) {
// Signed in successfully, show authenticated UI.
final GoogleSignInAccount acct = result.getSignInAccount();
if (acct != null) {
AccountUtils.setActiveAccount(getContext(), acct.getEmail());
doNext();
}
}
}
use of com.google.android.gms.auth.api.signin.GoogleSignInAccount in project Android by Tracman-org.
the class LoginActivity method handleGoogleSignInResult.
private void handleGoogleSignInResult(GoogleSignInResult result) {
//Log.d(TAG, "handleSignInResult:" + result.isSuccess());
if (result.isSuccess()) {
// Signed in successfully
GoogleSignInAccount acct = result.getSignInAccount();
try {
// Build request
Request request = new Request.Builder().url(SERVER_ADDRESS + "login/app/google?id_token=" + acct.getIdToken()).build();
// Send to server
authenticateWithTracmanServer(request);
} catch (Exception e) {
//Log.e(TAG, "Error sending ID token to backend.", e);
}
} else {
//Log.e(TAG, "Failed to log in: "+result.getStatus().getStatusCode());
if (result.getStatus().getStatusCode() != 4) {
showError(R.string.google_connection_error);
}
}
}
use of com.google.android.gms.auth.api.signin.GoogleSignInAccount in project coins-android by bubelov.
the class SignInActivity method handleSignInResult.
private void handleSignInResult(GoogleSignInResult result) {
if (result.isSuccess()) {
GoogleSignInAccount account = result.getSignInAccount();
new AuthWithGoogleTask(account.getIdToken()).execute();
}
}
Aggregations