use of com.google.android.gms.auth.api.signin.GoogleSignInResult in project SeriesGuide by UweTrottmann.
the class CloudSetupFragment method onActivityResult.
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == REQUEST_SIGN_IN) {
GoogleSignInResult result = Auth.GoogleSignInApi.getSignInResultFromIntent(data);
handleSignInResult(result);
}
}
use of com.google.android.gms.auth.api.signin.GoogleSignInResult 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.GoogleSignInResult 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.GoogleSignInResult in project easy by MehdiBenmesa.
the class RestApiActivity 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);
handleSignInResult(result);
}
// Handling a user-recoverable auth exception
if (requestCode == RC_RECOVERABLE) {
if (resultCode == RESULT_OK) {
getContacts();
} else {
Toast.makeText(this, R.string.msg_contacts_failed, Toast.LENGTH_SHORT).show();
}
}
}
use of com.google.android.gms.auth.api.signin.GoogleSignInResult in project easy by MehdiBenmesa.
the class RestApiActivity method onStart.
@Override
public void onStart() {
super.onStart();
OptionalPendingResult<GoogleSignInResult> opr = Auth.GoogleSignInApi.silentSignIn(mGoogleApiClient);
if (opr.isDone()) {
// If the user's cached credentials are valid, the OptionalPendingResult will be "done"
// and the GoogleSignInResult will be available instantly.
Log.d(TAG, "Got cached sign-in");
GoogleSignInResult result = opr.get();
handleSignInResult(result);
} else {
// If the user has not previously signed in on this device or the sign-in has expired,
// this asynchronous branch will attempt to sign in the user silently. Cross-device
// single sign-on will occur in this branch.
showProgressDialog();
opr.setResultCallback(new ResultCallback<GoogleSignInResult>() {
@Override
public void onResult(GoogleSignInResult googleSignInResult) {
hideProgressDialog();
handleSignInResult(googleSignInResult);
}
});
}
}
Aggregations