Skip to content Skip to sidebar Skip to footer

How To Logout In Facebook From Another Activity?

I am using facebook SDK 4.4.0. i want to logout in facebook from another activity? How can I add logout functionality in another activity ? I want to go to another activity after s

Solution 1:

First initialize the FacebookSdk.sdkInitialize(getApplicationContext()); on your activity then write the below code on button click event:

LoginManager.getInstance().logOut();

It is done!!!

Solution 2:

Make sure to hide the visibility of Facebook's Login Button after SignIN.

Then setOnClickListner on normal Button and use this command :

LoginManager.getInstance().logOut();

and a Toast to confirm the user.

Solution 3:

Try this method

publicstaticvoidLogoutFB(Context context) {
Sessionsession= Session.getActiveSession();
if (session != null) {

    if (!session.isClosed()) {
        session.closeAndClearTokenInformation();
        //clear your preferences if saved
    }
} else {

    session = newSession(context);
    Session.setActiveSession(session);

    session.closeAndClearTokenInformation();
        //clear your preferences if saved
}

}

Post a Comment for "How To Logout In Facebook From Another Activity?"