0

I am trying to restore user session inside my application. For that I call :

Session.openActiveSessionFromCache(ctx);

Most of the time it works fine. But sometimes I get :

java.lang.UnsupportedOperationException: Session: an attempt was made to open an already opened session.

Edit :

I've add this check :

    Session activeSession = Session.getActiveSession();
    if (activeSession!=null && activeSession.isOpened()){
        return activeSession;
    }
    activeSession = Session.openActiveSessionFromCache(ctx);

and it did not help

Does anybody have a hint how to tackle that problem?

thanks

4

2 回答 2

2

作为

openActiveSessionFromCache

工作方式如下:“创建一个新会话,如果令牌缓存可用,则打开会话并使其处于活动状态,无需任何用户交互”。

所以最好在调用 openActiveSessionFromCache 之前检查会话是否打开。您可以使用

已打开()

于 2013-07-11T19:44:32.347 回答
1

当 facebook 会话未处于打开状态时使用这行代码。

private Session.StatusCallback callback = new Session.StatusCallback() {
    @Override
    public void call(Session session, SessionState state, Exception exception) {
        if (!state.isClosed()) {
            Session.openActiveSessionFromCache(ctx);
        }
    }
};
于 2013-07-13T20:53:17.097 回答