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.