I am using the official facebook SDK for Android and I am facing some issues regarding session management. Specifically, I don’t know how to test whether the session is still valid or not.
First I initialize and authorize a connexion to facebook:
Facebook facebook = new Facebook(context.getString(R.string.facebook_app_id));
facebook.authorize(...); // Works ok
Then, I want to disconnect the user:
facebook.logout(context);
But once I have done that, the following still returns true:
facebook.isSessionValid();
Why does it return true?
Anything I’m doing wrong?
Thanks!
Maybe you encountered an older bug. Is your Facebook SDK up to date?
According to the source, logout calls
setAccessToken(null);. And if the token is null,isSessionValid()should return false. Here is it’s code for reference:The getter/setter doesn’t do any null-checks either, so the call in logout() should have the desired effect.