Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Logout Facebook Android SDK

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?

like image 568
MikkoP Avatar asked Jun 10 '14 19:06

MikkoP


4 Answers

Starting Facebook SDK 4.0 you need to call

LoginManager.getInstance().logOut();
like image 70
Tarun Avatar answered Nov 01 '22 00:11

Tarun


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?

like image 37
Roemer Avatar answered Nov 01 '22 00:11

Roemer


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.

like image 4
Rob Avatar answered Nov 01 '22 01:11

Rob


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

FacebookSdk.sdkInitialize(getApplicationContext());

And then :

 LoginManager.getInstance().logOut();

 AccessToken.setCurrentAccessToken(null);
like image 1
Nimit Patel Avatar answered Nov 01 '22 01:11

Nimit Patel