@Override public void onStart() { super.onStart(); OptionalPendingResult<GoogleSignInResult> opr = Auth.GoogleSignInApi.silentSignIn(mGoogleApiClient); if (opr.isDone()) { Log.d(TAG, "Got cached sign-in"); /* GoogleSignInResult result = opr.get(); handleSignInResult(result);*/ Intent dashbIntent = new Intent(this, ProfileActivity.class); dashbIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK); startActivity(dashbIntent); } 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); } });*/ } }
@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); } }); } }
@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); handleSignInResult(result); } }
@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 == SIGN_IN_RESULT) { GoogleSignInResult result = Auth.GoogleSignInApi.getSignInResultFromIntent(data); handleSignInResult(result); } }
public void signout(View v) { Auth.GoogleSignInApi.signOut(mGoogleApiClient) .setResultCallback( new ResultCallback<Status>() { @Override public void onResult(Status status) { updateUI(false); } }); }
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if (requestCode == RC_SIGN_IN) { GoogleSignInResult result = Auth.GoogleSignInApi.getSignInResultFromIntent(data); handleSignInResult(result); succ(); } else { callbackManager.onActivityResult(requestCode, resultCode, data); } }
private void signOut() { Auth.GoogleSignInApi.signOut(mGoogleApiClient) .setResultCallback( new ResultCallback<Status>() { @Override public void onResult(Status status) { showSnackBar(getString(R.string.signed_out)); showSignInButton(true); showShortenBox(false); } }); }
private void signOutUser() { Auth.GoogleSignInApi.signOut(mGoogleApiClient) .setResultCallback( new ResultCallback<Status>() { @Override public void onResult(Status status) { // [START_EXCLUDE] // updateUI(false); // [END_EXCLUDE] } }); btnSignIn.setVisibility(View.VISIBLE); }
private void revokeAccess() { // Firebase sign out mAuth.signOut(); // Google revoke access Auth.GoogleSignInApi.revokeAccess(mGoogleApiClient) .setResultCallback( new ResultCallback<Status>() { @Override public void onResult(@NonNull Status status) { updateUI(null); } }); }
@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()) { showSnackBar( String.format(getString(R.string.signed_in), result.getSignInAccount().getEmail())); } else { } handleSignInResult(result); } }
@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); } else { // Toast.makeText(this, "An Error Occured, Check your Network Connection // Settings",Toast.LENGTH_SHORT).show(); // btEnter.setVisibility(View.GONE); // btnSignIn.setVisibility(View.VISIBLE); } }
@Override public void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if (requestCode == RC_GOOGLE_SIGN_IN) { GoogleSignInResult result = Auth.GoogleSignInApi.getSignInResultFromIntent(data); if (result.isSuccess()) { GoogleSignInAccount account = result.getSignInAccount(); firebaseAuthWithGoogle(account); } else { Toast.makeText(SignInActivity.this, R.string.erro_google_sign_in, Toast.LENGTH_SHORT) .show(); } } }
// [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); handleSignInResult(result); } if (requestCode == REQUEST_ENABLE_BT) { // Make sure the request was successful if (resultCode != RESULT_OK) { finish(); } else { try_silent_signin(); } } }
// [START signIn] private void signIn() { ConnectivityManager cm = (ConnectivityManager) this.getSystemService(Context.CONNECTIVITY_SERVICE); Intent signInIntent = Auth.GoogleSignInApi.getSignInIntent(mGoogleApiClient); NetworkInfo activeNetwork = cm.getActiveNetworkInfo(); boolean isConnected = activeNetwork != null && activeNetwork.isConnectedOrConnecting(); if (!isConnected) { AlertDialog.Builder builder = new AlertDialog.Builder(this); builder .setMessage( "No Internet Connectivity detected! Check your Internet Connectivity settings") .setCancelable(false) .setPositiveButton( "Check Settings", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { startActivity(new Intent(Settings.ACTION_SETTINGS)); } }) .setNegativeButton( "Quit", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { finish(); } }); AlertDialog alert = builder.create(); alert.show(); return; } else startActivityForResult(signInIntent, RC_SIGN_IN); btnSignIn.setVisibility(View.GONE); /* btEnter.setVisibility(View.VISIBLE); btEnter.setIndeterminateProgressMode(true); btEnter.setProgress(50);*/ showpDialog(); Toast.makeText(this, "Signing In", Toast.LENGTH_SHORT).show(); }
// [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] } } }
/** * *********************************************************************************************** * Method: logout Description: Logs out the user from their current session and starts * MainSignInActivity. Also disconnects the mGoogleApiClient if connected and provider is Google * Parameters: N/A Returned: N/A * ********************************************************************************************** */ protected void logout() { /* Logout if mProvider is not null */ if (mProvider != null) { // unauthorize the firebase user mFirebaseRef.unauth(); bUsingOffline = true; if (mProvider.equals(Constants.GOOGLE_PROVIDER)) { /* Logout from Google+ */ Auth.GoogleSignInApi.signOut(mGoogleApiClient) .setResultCallback( new ResultCallback<Status>() { @Override public void onResult(Status status) { // nothing } }); } } }
@Override public void onResume() { super.onResume(); OptionalPendingResult<GoogleSignInResult> opr = Auth.GoogleSignInApi.silentSignIn(mGoogleApiClient); if (opr.isDone()) { GoogleSignInResult result = opr.get(); handleSignInResult(result); showShortenBox(true); showSignInButton(false); } else { opr.setResultCallback( new ResultCallback<GoogleSignInResult>() { @Override public void onResult(GoogleSignInResult googleSignInResult) { showSignInButton(true); showShortenBox(false); } }); } }
// retrieves the intent from RegisterActivity @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); // send this to the facebook button callbackManager.onActivityResult(requestCode, resultCode, data); if (requestCode == REQUEST_REGISTER) { if (resultCode == RESULT_OK) { String name = data.getStringExtra("Name"); Log.d("this just kicked in", ""); // TODO: Implement successful register logic here // By default we just finish the Activity and log them in automatically // this.finish(); HashMap<String, String> user = session.getRegistrationDetails(); _emailText.setText(user.get(SessionManager.KEY_EMAIL)); _passwordText.setText(user.get(SessionManager.KEY_PASSWORD)); session.clearRegistrationDetails(); login(); } } else if (requestCode == RC_SIGN_IN) { GoogleSignInResult result = Auth.GoogleSignInApi.getSignInResultFromIntent(data); handleSignInResult(result); } }
public void googleSignIn() { isGoogleLogin = true; Intent signInIntent = Auth.GoogleSignInApi.getSignInIntent(mGoogleApiClient); startActivityForResult(signInIntent, RC_SIGN_IN); }
// [START signIn] private void signIn() { Intent signInIntent = Auth.GoogleSignInApi.getSignInIntent(mGoogleApiClient); startActivityForResult(signInIntent, RC_SIGN_IN); }