我正在使用 Cocos2dX 我在一个名为 login 的自定义类中有一个方法,该方法由一些本机代码通过 JNI 调用,这意味着告诉 Facebook 登录并显示 UI。但是,当我退出 Facebook 时,它没有显示任何内容。
班级
public class AndroidFacebook {
protected static Activity activity = null;
protected static Context context = null;
protected AndroidFacebook() {
// Exists only to defeat instantiation.
}
public static void init(Activity activity) {
AndroidFacebook.activity = activity;
AndroidFacebook.context = activity.getApplicationContext();
}
@SuppressLint("ShowToast")
public static void login() {
Session.StatusCallback callback = new Session.StatusCallback() {
public void call(Session session, SessionState state, Exception exception) {
}
};
Session session = Session.getActiveSession();
if (session == null) {
session = new Session(AndroidFacebook.activity);
Session.setActiveSession(session);
}
if (!session.isOpened() && !session.isClosed()) {
session.openForRead(new Session.OpenRequest(AndroidFacebook.activity)
.setPermissions(Arrays.asList("basic_info"))
.setCallback(callback));
} else {
Session.openActiveSession(AndroidFacebook.activity, true, callback);
}
}
}