@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if (requestCode == RC_SIGN_IN) { // The Task returned from this call is always completed, no need to attach // a listener. Task<GoogleSignInAccount> task = GoogleSignIn.getSignedInAccountFromIntent(data); handleSignInResult(task); } }
@Override public void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if (requestCode == RC_SIGN_IN) { Task<GoogleSignInAccount> task = GoogleSignIn.getSignedInAccountFromIntent(data); handleSignInResult(task); } }
@Override public void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if (requestCode == RC_SIGN_IN) { Task<GoogleSignInAccount> task = GoogleSignIn.getSignedInAccountFromIntent(data); try { GoogleSignInAccount account = task.getResult(ApiException.class); firebaseAuthWithGoogle(account); } catch (ApiException e) { Log.w(TAG, e.getMessage()); Toast.makeText(this, "Google Sign In failed. Please try again.", Toast.LENGTH_SHORT).show(); } } }
@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) { Task<GoogleSignInAccount> task = GoogleSignIn.getSignedInAccountFromIntent(data); try { // Google Sign In was successful, authenticate with Firebase GoogleSignInAccount account = task.getResult(ApiException.class); if(account != null) { firebaseAuthWithGoogle(account); } } catch (ApiException e) { Toast.makeText(this, e.getLocalizedMessage(), Toast.LENGTH_SHORT).show(); } } }
Task<GoogleSignInAccount> task = GoogleSignIn.getSignedInAccountFromIntent(data); task.addOnSuccessListener( new OnSuccessListener<GoogleSignInAccount>() {
@Override public void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); showProgressDialog(Constants.PLEASE_WAIT); // Result returned from launching the Intent from GoogleSignInApi.getSignInIntent(...); if (requestCode == 11) { Task<GoogleSignInAccount> task = GoogleSignIn.getSignedInAccountFromIntent(data); try { // Google Sign In was successful, authenticate with Firebase account = task.getResult(ApiException.class); hideProgressDialog(); signup(mMifosSavingProductId); } catch (Exception e) { // Google Sign In failed, update UI appropriately DebugUtil.log(Constants.GOOGLE_SIGN_IN_FAILED, e.getMessage()); Toaster.showToast(this, Constants.GOOGLE_SIGN_IN_FAILED); hideProgressDialog(); signup(mMifosSavingProductId); } } }