How to add a logout callback for facebook sdk in android

后端 未结 3 1933
春和景丽
春和景丽 2021-01-04 06:13

I have integrated Facebook sdk in my android app. As described in the manual I added the login callback for facebook. But I have to change the UI if the user logs out from f

3条回答
  •  既然无缘
    2021-01-04 06:37

    there are 2 possible ways:

    1) you need to overwrite in on create AccessTokenTracker like this:

    accessTokenTracker = new AccessTokenTracker() {
                @Override
                protected void onCurrentAccessTokenChanged(AccessToken oldAccessToken,
                                                           AccessToken currentAccessToken) {
                        if (currentAccessToken == null) {
                            //write your code here what to do when user logout
                        } 
                    }
                }
    

    2) You can call LoginManager.logOut() to log out the user

    hope this will help you :)

提交回复
热议问题