我在以编程方式登录时遇到问题,登录后,当我希望用户发布某些内容时,当我检查 isOpened() 的活动会话时,它返回 false,所以我无法发出任何请求......
这是登录代码:
public void login()
{
Session session = Session.getActiveSession();
if (session == null)
{
session = new Session.Builder(ResourceManager.getInstance().getMainActivity()).build();
Session.setActiveSession(session);
}
if (!session.isOpened())
{
Session.OpenRequest openRequest = new Session.OpenRequest(ResourceManager.getInstance().getMainActivity());
openRequest.setPermissions(PERMISSIONS);
openRequest.setLoginBehavior(SessionLoginBehavior.SSO_WITH_FALLBACK);
session.openForPublish(openRequest);
}
}
这是我检查是否可以使用会话的代码:
public void post()
{
Session session = Session.getActiveSession();
if (session != null)
{
// This returns always false, so it never goes in...
if (session.isOpened())
{
postStatus(String pStatus);
}
}
}