I've succesfully updated my Login code for FB SDK 4.0. Initially, I used this code to logout from Facebook from an external dialog.
if (Global.getActiveSession() != null) {
Session.getActiveSession().closeAndClearTokenInformation();
}
Session.setActiveSession(null);
But with the new FB SDK 4.0, there is no way I use this. I've tried using
LoginManager loginManager = LoginManager.getInstance();
loginManager.logOut();
but got the following error which I cannot explain.
at com.facebook.internal.Validate.sdkInitialized(Validate.java:99)
at com.facebook.login.LoginManager.<init>(LoginManager.java:70)
at com.facebook.login.LoginManager.getInstance(LoginManager.java:81)
at com.ababab.abab_name_changed.common.util.CommonUtils.fbLogout(CommonUtils.java:676)
LoginManager.getInstance().logOut();
Works for me.
I think you'll have to call
FacebookSdk.sdkInitialize(getApplicationContext());
before you ask the LoginManager to logout.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With