Not logout the facebook session
I have created one face book integrate application.when i login & logout
my application which is login and logged out correctly.And if i login the
facebook and close the application and then open that application click
the logout which is logout correctly.My problem is when i login the
application and then again run the application from my eclipse ide at that
time i am trying to logout this one show error.thanks...
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mAsyncRunner = new AsyncFacebookRunner(facebook);
facebook = new Facebook(APP_ID);
sharePref = getPreferences(MODE_PRIVATE);
facebook.setAccessToken(sharePref.getString(ACCESS_TOKEN, null));
facebook.setAccessExpires(sharePref.getLong(EXPIRE_SESSION, 0));
buttonLogin.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
loginToFacebook();
}
});
buttonLogout.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
logoutFacebook();
}
});
}
public void loginToFacebook() {
if (!facebook.isSessionValid()) {
facebook.authorize(this, PERMISSIONS, Facebook.FORCE_DIALOG_AUTH,
new DialogListener() {
@Override
public void onFacebookError(FacebookError e) {
}
@Override
public void onError(DialogError e) {
}
@Override
public void onComplete(Bundle values) {
SharedPreferences.Editor editor =
sharePref.edit();
editor.putString(ACCESS_TOKEN,
facebook.getAccessToken());
editor.putLong(EXPIRE_SESSION,
facebook.getAccessExpires());
editor.commit();
}
@Override
public void onCancel() {
}
});
} else {
Toast.makeText(getApplicationContext(), "You Already Login",
Toast.LENGTH_SHORT).show();
}
}
protected void logoutFacebook() {
if (facebook.isSessionValid()) {
mAsyncRunner.logout(this,
new RequestListener() {
@Override
public void onComplete(String response, Object
state) {
Log.d("Logout from Facebook", response);
if (Boolean.parseBoolean(response) == true) {
Log.e("Logout from Facebook", "Great");
}
}
@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) {
}
});
} else {
Toast.makeText(getApplicationContext(), "Login First",
Toast.LENGTH_SHORT).show();
}
}
I got this type of error:
E/AndroidRuntime( 6331): FATAL EXCEPTION: Thread-264
E/AndroidRuntime( 6331): java.lang.IllegalArgumentException: Invalid
context argument E/AndroidRuntime( 6331): at
android.webkit.CookieSyncManager.createInstance(CookieSyncManager.java:86)
E/AndroidRuntime( 6331): at
com.facebook.internal.Utility.clearCookiesForDomain(Utility.java:261)
E/AndroidRuntime( 6331): at
com.facebook.internal.Utility.clearFacebookCookies(Utility.java:285)
E/AndroidRuntime( 6331): at
com.facebook.Session.closeAndClearTokenInformation(Session.java:593)
E/AndroidRuntime( 6331): at
com.facebook.android.Facebook.logoutImpl(Facebook.java:698)
E/AndroidRuntime( 6331): at
com.facebook.android.AsyncFacebookRunner$1.run(AsyncFacebookRunner.java:89)
W/ActivityManager( 1202): Force finishing activity
com.facebook.androidhive/.AndroidFacebookConnectActivity W/WindowManager(
1202): Failure taking screenshot for (246x437) to layer 21020 W/Trace (
6331): Unexpected value from nativeGetEnabledTags: 0 W/Trace ( 1202):
Unexpected value from nativeGetEnabledTags: 0 W/Trace ( 1202): Unexpected
value from nativeGetEnabledTags: 0 W/Trace ( 1202): Unexpected value from
nativeGetEnabledTags: 0 W/Trace ( 6239): Unexpected value from
nativeGetEnabledTags: 0 W/Trace ( 1202): Unexpected value from
nativeGetEnabledTags: 0 W/Trace ( 1202): Unexpected value from
nativeGetEnabledTags: 0 W/Trace ( 1202): Unexpected value from
nativeGetEnabledTags: 0 W/Trace ( 6331): Unexpected value from
nativeGetEnabledTags: 0 W/Trace ( 1202): Unexpected value from
nativeGetEnabledTags: 0 W/Trace ( 6239): Unexpected value from
nativeGetEnabledTags: 0 W/Trace ( 6239): Unexpected value from
nativeGetEnabledTags: 0 W/Trace ( 6239): Unexpected value from
nativeGetEnabledTags: 0 W/Trace ( 6239): Unexpected value from
nativeGetEnabledTags: 0 W/Trace ( 1202): Unexpected value from
nativeGetEnabledTags: 0 W/Trace ( 1202): Unexpected value from
nativeGetEnabledTags: 0 E/SurfaceFlinger( 786): ro.sf.lcd_density must be
defined as a build property W/Trace ( 6239): Unexpected value from
nativeGetEnabledTags: 0 W/Trace ( 6239): Unexpected value from
nativeGetEnabledTags: 0 W/Trace ( 6239): Unexpected value from
nativeGetEnabledTags: 0 W/Trace ( 1202): Unexpected value from
nativeGetEnabledTags: 0 W/Trace ( 6239): Unexpected value from
nativeGetEnabledTags: 0 W/Trace ( 1202): Unexpected value from
nativeGetEnabledTags: 0 W/Trace ( 6331): Unexpected value from
nativeGetEnabledTags: 0 W/Trace ( 1202): Unexpected value from
nativeGetEnabledTags: 0 W/Trace ( 1202): Unexpected value from
nativeGetEnabledTags: 0 W/Trace ( 1202): Unexpected value from
nativeGetEnabledTags: 0 W/Trace ( 1202): Unexpected value from
nativeGetEnabledTags: 0 W/Trace ( 6239): Unexpected value from
nativeGetEnabledTags: 0 W/Trace ( 1202): Unexpected value from
nativeGetEnabledTags: 0 W/Trace ( 1202): Unexpected value from
nativeGetEnabledTags: 0
No comments:
Post a Comment