Title: Facebook Android login, stuck on one account, even after logout
Tags: android;facebook;oauth;oauth-2.0
Question: I am trying to implement facebook login with my android app. Unfortunately, even after signing out. The app seems permanently stuck on one test account.
How do I get it to sign in to a different account?
The following is the code that I have implemented in MainActivity.java and activity_main.xml
package com.example.www.facebook;
import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.widget.Toast;
import com.facebook.AccessToken;
import com.facebook.CallbackManager;
import com.facebook.FacebookCallback;
import com.facebook.FacebookException;
import com.facebook.login.LoginResult;
import com.facebook.login.widget.LoginButton;
public class MainActivity extends AppCompatActivity
public LoginButton loginButton;
public CallbackManager callbackManager;
@Override
protected void onCreate(Bundle savedInstanceState)
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
callbackManager = CallbackManager.Factory.create();
loginButton = (LoginButton) findViewById(R.id.login_button);
loginButton.registerCallback(callbackManager, new FacebookCallback<LoginResult&gt;()
{
@Override
public void onSuccess(LoginResult loginResult)
{
// App code
}
@Override
public void onCancel()
{
// App code
}
@Override
public void onError(FacebookException exception)
{
// App code
}
});
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data)
super.onActivityResult(requestCode, resultCode, data);
callbackManager.onActivityResult(requestCode, resultCode, data);
And here we have the layout file
<?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
<android.support.constraint.ConstraintLayout xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;
xmlns:app=&quot;http://schemas.android.com/apk/res-auto&quot;
xmlns:tools=&quot;http://schemas.android.com/tools&quot;
android:layout_width=&quot;match_parent&quot;
android:layout_height=&quot;match_parent&quot;
tools:context=&quot;com.example.www.facebook.MainActivity&quot;&gt;
<com.facebook.login.widget.LoginButton
android:id=&quot;@+id/login_button&quot;
android:layout_width=&quot;wrap_content&quot;
android:layout_height=&quot;wrap_content&quot;
android:layout_gravity=&quot;center_horizontal&quot;
android:layout_marginTop=&quot;30dp&quot;
android:layout_marginBottom=&quot;30dp&quot; /&gt;
</android.support.constraint.ConstraintLayout&gt;
Comment: @sasikumar I don't understand what you are saying.

Comment: @sasikumar I can't log out.

Comment: different account can you able to login in first time?

Comment: apart from  test account  other account login or not?



{'source': 'StackExchangeDataset', 'subset': 'stackoverflow.com', 'metadata': {'AnswerCount': 0, 'CommentCount': 4, 'ContentLicense': 'CC BY-SA 3.0', 'CreationDate': '2017:00:05/21/17', 'FavoriteCount': None, 'PostTypeId': 1, 'Tags': '<android><facebook><oauth><oauth-2.0>', 'Title': 'Facebook Android login, stuck on one account, even after logout', 'ViewCount': 178, 'id': 44093389, 'user_AboutMe': '<p>“Before long, billions of people around the world were working and playing in the OASIS every day. Some of them met, fell in love, and got married without ever setting foot on the same continent. The lines of distinction between a person’s real identity and that of their avatar began to blur. It was the dawn of new era, one where most of the human race now spent all of their free time inside a video game.”</p>\n<p><a href="https://rebrand.ly/sr2aj4g" rel="nofollow noreferrer">– Ernest Cline, Ready Player One (2011)</a></p>\n', 'user_AccountId': 4709931.0, 'user_DisplayName': 'AlanSTACK', 'user_Reputation': 5009.0, 'user_Views': 831.0, 'user_id': 3810748.0}}