Using facebook SDK on Android gives “User logged in as different Facebook user.” error

后端 未结 5 1028
Happy的楠姐
Happy的楠姐 2021-01-31 15:02

I\'m upgrading my use of the Facebook SDK to the latest version. The following code is prety much lifted line by line from Facebook\'s own examples, which can be found here: htt

5条回答
  •  既然无缘
    2021-01-31 15:05

    If you want to log in with the user that is now logged in on the Facebook app and you still have a token valid for a previous user, you can detect the error and log out in your FacebookCallback like this:

        @Override
        public void onError(FacebookException e) {
            if (e instanceof FacebookAuthorizationException) {
                if (AccessToken.getCurrentAccessToken() != null) {
                    LoginManager.getInstance().logOut();
                }
            }
        }
    

    Then you can log in again using the LoginManager.

提交回复
热议问题