Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android facebook sdk 3.0 logout not working?

I'm using facebook sdk 3.0 to login my application. login working fine. once i logout my application it's not happening.

my logout code:

Facebook mFb=new Facebook("xxxxxxxx");
mFb.logout(this);

give me some idea to do this.

like image 403
Jeeva123 Avatar asked Dec 21 '22 10:12

Jeeva123


2 Answers

I have been facing same problem finally i found this fix

public void logout()
{
    Session session = Session.getActiveSession();
    if (session != null) {
        session.closeAndClearTokenInformation();
    }
    else
    {
        Session session2 = Session.openActiveSession((Activity)context, false, null);
        if(session2 != null)
            session2.closeAndClearTokenInformation();
    }
    Session.setActiveSession(null);

}

I do not know whats going inside but i guess we will have to create new session if it is not found and clear token information for it. It worked for me. hope it will help.

like image 168
Mufazzal Avatar answered Jan 07 '23 17:01

Mufazzal


Try this:

if( mFb.isSessionValid() ) {                                  
    mFb.logout(getApplicationContext());
    SessionStore.clear(getApplicationContext());
}
like image 36
Android_coder Avatar answered Jan 07 '23 16:01

Android_coder