Reputation: 924
my app using android facebook sdk 3.0,after login getting some response,after that i need to signout from facebook clicking on button.
How to log-out from the session in facebook pls help
Upvotes: 8
Views: 9163
Reputation: 1943
This method will help you to logout from facebook programmatically in android
/**
* Logout From Facebook
*/
public static void callFacebookLogout(Context context) {
Session session = Session.getActiveSession();
if (session != null) {
if (!session.isClosed()) {
session.closeAndClearTokenInformation();
//clear your preferences if saved
}
} else {
session = new Session(context);
Session.setActiveSession(session);
session.closeAndClearTokenInformation();
//clear your preferences if saved
}
}
Upvotes: 7
Reputation: 680
You should do something like this.
if (Session.getActiveSession() != null) {
Session.getActiveSession().closeAndClearTokenInformation();
}
Session.setActiveSession(null);
Also if you store the user token in some other way you should clear that too.
Upvotes: 26