title: Android Facebook Login Works, but Endlessly Stuck on Login Screen
body: <p>I have a Facebook login on my Android app, and it successfully logs you in, but once logged in, it stays on the Login Button screen. In other words, after tapping the "Login to Facebook" button and logging in with your account, you're stuck in an endless loop of logging in. I'm not getting any errors on output, so my attempts to debug so far have been unsuccessful...some help would be appreciated.</p>
  
  <pre><code> private CallbackManager callbackManager;
      private static final int SIGN_IN_REQUEST_CODE = 1;
      private FirebaseListAdapter&lt;ChatMessage&gt; adapter;
      private TextView info;
      private LoginButton loginButton;
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
  
          final View mainActivity = getLayoutInflater().inflate(R.layout.activity_main, null);
          View loginButtonLayout = getLayoutInflater().inflate(R.layout.login_button, null);
          setContentView(mainActivity);
          Firebase.setAndroidContext(this);
          //If there is no account associated with user, follow this loop
          if (FirebaseAuth.getInstance().getCurrentUser() == null) {
              FacebookSdk.sdkInitialize(getApplicationContext());
              FacebookSdk.setApplicationId(getResources().getString(R.string.facebook_app_id));
              setContentView(loginButtonLayout);
              callbackManager = CallbackManager.Factory.create();
              info = (TextView)findViewById(R.id.info);
              loginButton = (LoginButton) loginButtonLayout.findViewById(R.id.login_button);
              loginButton.registerCallback(callbackManager, new FacebookCallback&lt;LoginResult&gt;() {
                  @Override
                  public void onSuccess(LoginResult loginResult) {
                      // Start sign in/sign up activity
                      setContentView(mainActivity);
                      startActivityForResult(
                              AuthUI.getInstance()
                                      .createSignInIntentBuilder()
                                      .build(),
                              SIGN_IN_REQUEST_CODE
                      );
                  }
  
                  @Override
                  public void onCancel() {
                      Toast.makeText(MainActivity.this,
                              "We couldn't sign you in. Please try again later.",
                              Toast.LENGTH_LONG)
                              .show();
                  }
  
                  @Override
                  public void onError(FacebookException e) {
                      Toast.makeText(MainActivity.this,
                              "We couldn't sign you in. Please try again later.",
                              Toast.LENGTH_LONG)
                              .show();
                  }
              });
  
          } else {
              // User is already signed in. Therefore, display a welcome message
          }
  </code></pre>