I’m using Facebook’s SDK for Android (latest version as of today). The code that is for authentication is the following:
prefs = PreferenceManager.getDefaultSharedPreferences(this);
facebook = new Facebook(FACEBOOK_APP_ID);
String fbAccessToken = prefs.getString("fb_access_token", null);
long fbAccessExpires = prefs.getLong("fb_access_expires", 0);
if (fbAccessToken != null) {
facebook.setAccessToken(fbAccessToken);
}
if (fbAccessExpires != 0) {
facebook.setAccessExpires(fbAccessExpires);
}
if (!facebook.isSessionValid()) {
facebook.authorize(this, new String[] { "friends_birthday" }, new DialogListener() {
public void onComplete(Bundle values) {
SharedPreferences.Editor prefEditor = prefs.edit();
prefEditor.putString("fb_access_token", facebook.getAccessToken());
prefEditor.putLong("fb_access_expires", facebook.getAccessExpires());
prefEditor.commit();
// do some graph requests
}
public void onFacebookError(FacebookError error) {
}
public void onError(DialogError e) {
}
public void onCancel() {
}
});
}
else {
// do some graph requests
}
Unfortunately, the Facebook app opens upon that request and shows “Loading …”. A few seconds later, it just disappears without any result.
In LogCat, I can then read the following exception:
12-11 21:04:34.597: E/System(29584): Uncaught exception thrown by finalizer
12-11 21:04:34.613: E/System(29584): java.lang.IllegalStateException: Binder has been finalized!
12-11 21:04:34.613: E/System(29584): at android.os.BinderProxy.transact(Native Method)
12-11 21:04:34.613: E/System(29584): at android.database.BulkCursorProxy.close(BulkCursorNative.java:288)
12-11 21:04:34.613: E/System(29584): at android.database.BulkCursorToCursorAdaptor.close(BulkCursorToCursorAdaptor.java:133)
12-11 21:04:34.613: E/System(29584): at android.database.CursorWrapper.close(CursorWrapper.java:49)
12-11 21:04:34.613: E/System(29584): at android.content.ContentResolver$CursorWrapperInner.close(ContentResolver.java:1591)
12-11 21:04:34.613: E/System(29584): at android.content.ContentResolver$CursorWrapperInner.finalize(ContentResolver.java:1604)
12-11 21:04:34.613: E/System(29584): at java.lang.Daemons$FinalizerDaemon.doFinalize(Daemons.java:182)
12-11 21:04:34.613: E/System(29584): at java.lang.Daemons$FinalizerDaemon.run(Daemons.java:168)
12-11 21:04:34.613: E/System(29584): at java.lang.Thread.run(Thread.java:856)
Is this a common problem with Facebook SDK? I don’t think so, haven’t found anything about that. What causes this problem?
You should ensure you are using the final version of the SDK 3.0 (which we just released), available at https://developers.facebook.com/android
Also make sure you have Java 1.6 and a clean project/workspace.
I’d advise you to use the contemporary patterns for Session handling and login, as described in the documentation on that site.