Why is my facebook session still valid after I am logged out?

旧城冷巷雨未停 提交于 2019-12-11 03:48:08

问题


My logout code:

if(fb.isSessionValid()){    
            masyncfb.logout(this, new RequestListener() {
                  @Override
                  public void onComplete(String response, Object state) {
                      Log.d(TAG, "Logging you out: "+response);
                  }

                  @Override
                  public void onIOException(IOException e, Object state) {}

                  @Override
                  public void onFileNotFoundException(FileNotFoundException e,
                        Object state) {}

                  @Override
                  public void onMalformedURLException(MalformedURLException e,
                        Object state) {}

                  @Override
                  public void onFacebookError(FacebookError e, Object state) {}
                });
                      updateButtonImage();                  

        }else{

and my updateButtonImage() method is:

private void updateButtonImage() {
        // TODO Auto-generated method stub
        if(fb.isSessionValid()){
            Toast.makeText(MainActivity.this, "logged in", Toast.LENGTH_LONG).show();
            button.setImageResource(R.drawable.logout);
        }else{
            button.setImageResource(R.drawable.login);
            Toast.makeText(MainActivity.this, "logged out", Toast.LENGTH_LONG).show();
        }
    }

updateButtonImage() method changes the button image from 'Log In' to 'Log Out' after login but doesn't change the button from 'Log Out' to 'Log In' after logout. I am sure that I have successfully logged out from Facebook after clicking the logout button(from logcat). so, that means my session is still valid, although I have successfully logged out from facebook. why? how can i fix the problem? all i need to change button from 'Log Out' to 'Log In'. what should i do?

N.B: i'm using facebook SDK

edited

i think i am trying to change my button before the thread in logout method in AsyncFacebookRunner.java finished its job. if it is true then, how should i wait for the thread to complete its work and then execute my updateButtonImage() method.


回答1:


To get rid of it, I use sessionlogin. With that, it is working fine.



来源:https://stackoverflow.com/questions/13636638/why-is-my-facebook-session-still-valid-after-i-am-logged-out

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!