我正在使用 android-simple-facebook 库实现 Facebook 登录。
它在 Eclipse 示例中运行良好,但在我的 JNI 应用程序中它崩溃并出现以下错误:
java.lang.UnsupportedOperationException: Session: an attempt was made to open an already opened session.
at com.facebook.Session.open(Session.java:985)
at com.facebook.Session.openForPublish(Session.java:423)
at com.sromku.simple.fb.SessionManager.openSession(SessionManager.java:237)
at com.sromku.simple.fb.SessionManager.reopenSession(SessionManager.java:332)
at com.sromku.simple.fb.SessionManager.isLogin(SessionManager.java:123)
at com.sromku.simple.fb.SessionManager.login(SessionManager.java:57)
at com.sromku.simple.fb.SimpleFacebook.login(SimpleFacebook.java:171)
at com.js.helpers.FBHelper$2.run(FBHelper.java:109)
at android.os.Handler.handleCallback(Handler.java:730)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:5103)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:525)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
at dalvik.system.NativeStart.main(Native Method)
我的登录实现非常严格:
public static void login() {
final OnLoginListener onLoginListener = new OnLoginListener() {
@Override
public void onFail(String reason) {
Log.w(TAG, "onLoginListener failed: " + reason);
}
@Override
public void onException(Throwable throwable) {
Log.e(TAG, "OnLoginListener exception: ", throwable);
}
@Override
public void onThinking() {
// show progress bar or something to the user while login is happening
Log.i(TAG, "onLoginListener in progress...");
}
@Override
public void onLogin() {
// change the state of the button or do whatever you want
Log.i(TAG, "Logged in");
loginCB();
}
@Override
public void onNotAcceptingPermissions(Permission.Type type) {
Log.i(TAG, "onLoginListener NotAcceptingPermissions: " + type);
}
};
mSimpleFacebook.login(onLoginListener);
Log.i(TAG, "FBHelper.login");
}
loginCB是我的原生回调函数。
最烦人的问题是浮动,应用程序有时可能会登录,但大多是崩溃。
我将不胜感激任何帮助!