i develop a game project in which i have implemented facebook sdk for posting scores on the wall in facebook. But there is a problem for logout in facebook. I have to logout from facebook in settings page which is different page from where i have to login in facebook. In facebook SDK there is a function logout which requires the context from which i have logged in. I have to store context in shared preference for this. How can i do that?
Asked
Active
Viewed 674 times
0
-
You can pass any context to logout. – Adil Soomro Nov 04 '11 at 13:43
-
no i have tried different context but i cant logout from facebook – user1029750 Nov 04 '11 at 13:49
1 Answers
2
I have done Same thing in my Code Like This... In your Activity Where you have Created object of Facebook make it public static like
public static Facebook mFacebook
and in activity where you want to logout From Facebook use Following Function
private void LogoutFacebook()
{
if(FacebookLoginActivity.mFacebook != null)
{
if (FacebookLoginActivity.mFacebook.isSessionValid())
{
AsyncFacebookRunner asyncRunner = new AsyncFacebookRunner(FacebookLoginActivity.mFacebook);
asyncRunner.logout(AdvanceSetting.this, new LogoutRequestListener());
}
}
}
also add this class where you want to Logout
private class LogoutRequestListener extends BaseRequestListener
{
public void onComplete(String response)
{
SessionEvents.onLogoutFinish();
}
}
Hope it may useful to you..

Miral Dhokiya
- 1,720
- 13
- 26
-
I am also facing same problem after making static still it wont work when phone is switch off and after again switch on then error occurs. – patric_cena Sep 11 '13 at 10:37