title: How to properly sign out of Facebook on Android with Firebase?
body: <p>So I figured out how to properly signout with Google. Cool. Now, what about Facebook?</p>
  
  <p>When I get an error signing in to Facebook, such as an error indicating I already have a Firebase account with the same credentials but a different social provider, I get the "Log out of facebook" button. <strong>To be more clear:</strong></p>
  
  <p>I try logging into Facebook, then I get an error (<em>this isn't my problem!</em>), but the problem is, Facebook's button is now on "Log out". When it should <strong>still</strong> be <strong><em>"Sign In With Facebook"</em></strong>. I know why this is happening; it's because the error is with <strong>Firebase</strong> and Facebook thinks I'm signed in.</p>
  
  <p><strong>But the real question is</strong>, how do I properly sign out of Facebook? <code>FirebaseAuth.getInstance().signout()</code> doesn't seem to logout of <strong>Facebook</strong> itself.</p>
  
  <p>Here's my current <code>logout()</code> method:</p>
  
  <pre><code>static void logOut(final Context context) {
      new SweetAlertDialog(context, SweetAlertDialog.WARNING_TYPE)
          .showCancelButton(true)
          .setTitleText(context.getString(R.string.areYouSure))
          .setContentText(context.getString(R.string.logoutMSG))
          .setCancelText(context.getString(android.R.string.no))
          .setCancelClickListener(new SweetAlertDialog.OnSweetClickListener() {
              @Override
              public void onClick(SweetAlertDialog sweetAlertDialog) {
                  sweetAlertDialog.dismiss();
              }
          })
          .setConfirmText(context.getString(R.string.yes))
          .setConfirmClickListener(new SweetAlertDialog.OnSweetClickListener() {
              @Override
              public void onClick(final SweetAlertDialog sweetAlertDialog) {
                  //region Google
                  GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
                      .requestIdToken(context.getString(R.string.default_web_client_id))
                      .requestEmail()
                      .build();
                  final GoogleApiClient mGoogleApiClient = new GoogleApiClient.Builder(context)
                      .enableAutoManage((FragmentActivity) context, new GoogleApiClient.OnConnectionFailedListener() {
                          @Override
                          public void onConnectionFailed(@NonNull ConnectionResult connectionResult) {
                              FirebaseCrash.log(connectionResult.getErrorMessage());
                              Toast.makeText(context, context.getString(R.string.error), Toast.LENGTH_SHORT).show();
                          }
                      })
                      .addApi(Auth.GOOGLE_SIGN_IN_API, gso)
                      .build();
                  mGoogleApiClient.registerConnectionCallbacks(new GoogleApiClient.ConnectionCallbacks() {@
                      Override
                      public void onConnected(@Nullable Bundle bundle) {
  
                          FirebaseAuth.getInstance().signOut();
                          if (mGoogleApiClient.isConnected()) {
                              Auth.GoogleSignInApi.signOut(mGoogleApiClient).setResultCallback(new ResultCallback &lt; Status &gt; () {@
                                  Override
                                  public void onResult(@NonNull Status status) {
                                      if (status.isSuccess()) {
                                          FirebaseAuth.getInstance().signOut();
                                          sweetAlertDialog.dismiss();
                                          Log.d(TAG, "User Logged out");
                                          Intent intent = new Intent(context, SignUp.class);
                                          context.startActivity(intent);
                                          ((FragmentActivity) context).finish();
                                      } else
                                          Toast.makeText(context, context.getString(R.string.error), Toast.LENGTH_SHORT).show();
                                  }
                              });
                          }
                      }
  
                      @
                      Override
                      public void onConnectionSuspended(int i) {
                          Log.e(TAG, "Google API Client Connection Suspended");
                      }
                  });
                  //endregion
              }
          }).show();
  }
  </code></pre>