use of com.google.android.gms.auth.api.signin.GoogleSignInAccount in project SeriesGuide by UweTrottmann.
the class HexagonTools method checkSignInState.
private void checkSignInState() {
if (credential.getSelectedAccount() != null && !isTimeForSignInStateCheck()) {
Timber.d("%s: just checked state, skip", ACTION_SILENT_SIGN_IN);
}
lastSignInCheck = SystemClock.elapsedRealtime();
if (googleApiClient == null) {
googleApiClient = new GoogleApiClient.Builder(app).addApi(Auth.GOOGLE_SIGN_IN_API, getGoogleSignInOptions()).build();
}
android.accounts.Account account = null;
ConnectionResult connectionResult = googleApiClient.blockingConnect();
if (connectionResult.isSuccess()) {
OptionalPendingResult<GoogleSignInResult> pendingResult = Auth.GoogleSignInApi.silentSignIn(googleApiClient);
GoogleSignInResult result = pendingResult.await();
if (result.isSuccess()) {
GoogleSignInAccount signInAccount = result.getSignInAccount();
if (signInAccount != null) {
Timber.i("%s: successful", ACTION_SILENT_SIGN_IN);
account = signInAccount.getAccount();
credential.setSelectedAccount(account);
} else {
trackSignInFailure(ACTION_SILENT_SIGN_IN, "GoogleSignInAccount is null");
}
} else {
trackSignInFailure(ACTION_SILENT_SIGN_IN, result.getStatus());
}
googleApiClient.disconnect();
} else {
trackSignInFailure(ACTION_SILENT_SIGN_IN, connectionResult);
}
boolean shouldFixAccount = account == null;
PreferenceManager.getDefaultSharedPreferences(app).edit().putBoolean(HexagonSettings.KEY_SHOULD_VALIDATE_ACCOUNT, shouldFixAccount).apply();
}
use of com.google.android.gms.auth.api.signin.GoogleSignInAccount in project RSAndroidApp by RailwayStations.
the class SignInActivity method onActivityResult.
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
// Result returned from launching the Intent from GoogleSignInApi.getSignInIntent(...);
if (requestCode == RC_SIGN_IN) {
GoogleSignInResult result = Auth.GoogleSignInApi.getSignInResultFromIntent(data);
if (result.isSuccess()) {
// Google Sign In was successful, authenticate with Firebase
GoogleSignInAccount account = result.getSignInAccount();
firebaseAuthWithGoogle(account);
} else {
// Google Sign In failed
Log.e(TAG, "Google Sign In failed.");
}
}
}
use of com.google.android.gms.auth.api.signin.GoogleSignInAccount in project google-services by googlesamples.
the class RestApiActivity method handleSignInResult.
private void handleSignInResult(GoogleSignInResult result) {
Log.d(TAG, "handleSignInResult:" + result.isSuccess());
if (result.isSuccess()) {
// Get the account from the sign in result
GoogleSignInAccount account = result.getSignInAccount();
// Signed in successfully, show authenticated UI.
mStatusTextView.setText(getString(R.string.signed_in_fmt, account.getDisplayName()));
updateUI(true);
// Store the account from the result
mAccount = account.getAccount();
// Asynchronously access the People API for the account
getContacts();
} else {
// Clear the local account
mAccount = null;
// Signed out, show unauthenticated UI.
updateUI(false);
}
}
use of com.google.android.gms.auth.api.signin.GoogleSignInAccount in project quickstart-android by firebase.
the class GoogleSignInActivity method onActivityResult.
// [END on_stop_remove_listener]
// [START onactivityresult]
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
// Result returned from launching the Intent from GoogleSignInApi.getSignInIntent(...);
if (requestCode == RC_SIGN_IN) {
GoogleSignInResult result = Auth.GoogleSignInApi.getSignInResultFromIntent(data);
if (result.isSuccess()) {
// Google Sign In was successful, authenticate with Firebase
GoogleSignInAccount account = result.getSignInAccount();
firebaseAuthWithGoogle(account);
} else {
// Google Sign In failed, update UI appropriately
// [START_EXCLUDE]
updateUI(null);
// [END_EXCLUDE]
}
}
}
use of com.google.android.gms.auth.api.signin.GoogleSignInAccount in project UniPool by divya21raj.
the class LoginActivity method handleSignInResult.
private void handleSignInResult(Task<GoogleSignInAccount> completedTask) {
try {
GoogleSignInAccount account = completedTask.getResult(ApiException.class);
firebaseAuthWithGoogle(account);
// Signed in successfully, show authenticated UI.
} catch (ApiException e) {
// The ApiException status code indicates the detailed failure reason.
// Please refer to the GoogleSignInStatusCodes class reference for more information.
Log.w(TAG, "signInResult:failed code=" + e.getStatusCode());
Toast.makeText(getApplicationContext(), "Ok", Toast.LENGTH_SHORT).show();
updateUI(null);
}
}
Aggregations