我正在使用 Facebook 的 Android SDK(截至今天的最新版本)。用于身份验证的代码如下:
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
}
不幸的是,Facebook 应用程序会根据该请求打开并显示“正在加载...”。几秒钟后,它就消失了,没有任何结果。
在 LogCat 中,我可以读取以下异常:
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)
这是 Facebook SDK 的常见问题吗?我不这么认为,还没有找到任何关于它的东西。是什么导致了这个问题?