我有以下关于 Facebook 登录按钮的 onclick:
fblogin.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
Session session = Session.getActiveSession();
if (session == null) {
Session.openActiveSession(LogIn.this, true,
statusCallback);
} else if (!session.isOpened()) {
session.openForRead(new Session.OpenRequest(
LogIn.this).setCallback(statusCallback)
.setPermissions(permissions)
);
}
}
});
然后点击以下注销:
private OnClickListener OnClick_logout = new OnClickListener() {
public void onClick(View v) {
SharedPreferences settings = getSharedPreferences(PREFS_NAME, 0);
SharedPreferences.Editor editor = settings.edit();
editor.putBoolean("loggedIn", false);
editor.putString("email", "");
editor.putString("password", "");
editor.commit();
db.clearLists();
db.clearProducts();
Intent intent = new Intent(v.getContext(), Splash.class);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP );
v.getContext().startActivity(intent);
}
};
目前这不会注销 facebook,这意味着当用户返回登录活动并尝试单击 fblogin 按钮时没有任何反应。
我需要在我的注销 onclick 中添加什么以实际注销 facebook,以便用户可以再次按下 fblogin 按钮并再次登录。
我尝试添加到注销按钮:
Session.getActiveSession().closeAndClearTokenInformation();
但是,当我返回登录屏幕并单击登录按钮时,我得到:
10-30 10:51:14.776: E/AndroidRuntime(18964): java.lang.UnsupportedOperationException: Session: an attempt was made to open an already opened session.