Logout Facebook Android SDK

18,575

Solution 1

Can you use closeAndClearTokenInformation() as described here: https://developers.facebook.com/docs/reference/android/current/class/Session/ ?

See also How to programmatically log out from Facebook SDK 3.0 without using Facebook login/logout button?

Solution 2

Starting Facebook SDK 4.0 you need to call

LoginManager.getInstance().logOut();

Solution 3

If you are using facebook SDK 4, you first need to initialize sdk:

FacebookSdk.sdkInitialize(getApplicationContext());

And then just do:

LoginManager.getInstance().logOut();

See here for more details.

Solution 4

If you are using facebook SDK 4, you first need to initialize sdk:

FacebookSdk.sdkInitialize(getApplicationContext());

And then :

 LoginManager.getInstance().logOut();

 AccessToken.setCurrentAccessToken(null);
Share:
18,575
MikkoP
Author by

MikkoP

I'm a student living in Finland, interested in mathematical subjects, programming and computers.

Updated on July 27, 2022

Comments

  • MikkoP
    MikkoP almost 2 years

    I use the LoginButton from the Facebook Android SDK to login to my application. How do I programmatically log out the user from any Activity?

  • MikkoP
    MikkoP almost 10 years
    Thanks Flaxfield! Can you help with the other problem too, if you know something? stackoverflow.com/questions/24149499/…
  • swooby
    swooby almost 9 years
    I am not seeing that this forces the user to re-authenticate. :(
  • Pankaj kumar
    Pankaj kumar almost 9 years
    Always check access token for null before this logout using logingManager.getInstance.logout();