i'm using facbook sdk in my application. when i logged in my application via facebook sdk, everything work perfectly, but when i open Facebook App and logout from Facebook App, my app still logged on. so how do i add a listener to listen logout event from Facebook SDK?
Logout from Facebook from custom button clicklogOut(); You should also remove First name, last name, email-id etc. details from SharedPreferences if you stored it. After Facebook you will need to integrate Google login in shortly.
To use the Facebook SDK in an Android Studio project, add the SDK as a build dependency and import the SDK. Go to Android Studio | New Project | Minimum SDK. Select API 15: Android 4.0. 3 (IceCreamSandwich) or higher and create your new project.
This is an old questions, but I wanted to update with an answer.
In Facebook API 4.0 (As that is current as of writing) You can use an AccessTokenTracker.
AccessTokenTracker accessTokenTracker = new AccessTokenTracker() {
@Override
protected void onCurrentAccessTokenChanged(AccessToken accessToken, AccessToken accessToken2) {
Log.d(TAG, "onCurrentAccessTokenChanged()");
if (accessToken == null) {
// Log in Logic
} else if (accessToken2 == null) {
// Log out logic
}
}
};
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