简体   繁体   中英

is there callback methods for logout facebook button in android?

I want to perform some task when user clicked logout button and at the time if the user is logged out perform some task(say to open another activity)

CallbackManager mCallbackManager = CallbackManager.Factory.create();

FacebookCallback<LoginResult> mCallback = new FacebookCallback<LoginResult>() {
            @Override
            public void onSuccess(LoginResult loginResult) {
//                AccessToken accessToken = loginResult.getAccessToken();
//                Boolean value = accessToken.isExpired();
                Profile profile = Profile.getCurrentProfile();

                if (profile != null) {
                    String userId = profile.getId();
                    String userName = profile.getName();

                    Log.d("userId", userId);
                    Log.d(TAG, "name : " + userName);

//                    sessionManager.createLoginSessionViaApp(userId, userName);
//                    disableTheAppSignInRegisterButtonsIfLoggedin();
                }

            }

            @Override
            public void onCancel() {
                Log.d(TAG, "status cancel");
            }

            @Override
            public void onError(FacebookException e) {
                Log.d(TAG, "status error login");
            }
        };
        fbLoginButton.setReadPermissions("user_friends");
        fbLoginButton.registerCallback(mCallbackManager, mCallback);

I've done this so far for login

You can use the AccessTokenTracker to track logouts. It will call onCurrentAccessTokenChanged, and the currentAccessToken will be null if the user has logged out.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM