Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Facebook Android SDK logout listener

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?

like image 904
Pham Hong Phong Avatar asked May 27 '13 11:05

Pham Hong Phong


People also ask

How do I logout of Facebook SDK on Android?

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.

How did you integrate the Facebook SDK in Android app?

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.


1 Answers

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
            }
        }
    };
like image 110
Aaron Dougherty Avatar answered Sep 19 '22 15:09

Aaron Dougherty