0

这是我更新状态的代码:

new Session(context);
Session.setActiveSession(session);
Session.openActiveSession(context);
Log.e("session after setted",Session.getActiveSession().toString());

Request request = Request.newMeRequest(Session.getActiveSession(), new Request.GraphUserCallback() {
@Override
public void onCompleted(GraphUser user, Response response) {
    // If the response is successful
       if (Session.getActiveSession().isOpened()) {
            if (user != null) {
                session = Session.getActiveSession();
            postFromAlarm();
                Log.e("user","not null");
            }else{
            postFromAlarm();
            Log.e("user","null");
        }
        }  else{
        postFromAlarm();
        Log.e("not open session",Session.getActiveSession().toString());
        Log.e("session","not open");
        }
     }   
}); 
Log.e("request session",request.getSession().toString());
Request.executeBatchAsync(request);

Log.e("session after setted",Session.getActiveSession().toString()); 正在显示一个良好且健康的会话,可用于发布。因为在logcat中显示会话打开了,accesstoken好,app_id也好。

但是当我尝试发布时使用此会话,在该onComplete()方法中执行了这些行:

Log.e("not open session",Session.getActiveSession().toString()); Log.e("session","not open");

它表明:

{Session state:CLOSED, token:null, appId:***************** }

怎么了?我试过没有new Session(context),但得到了相同的结果。我该怎么办?

4

1 回答 1

0

首次使用创建会话时保存会话

SessionStore.save(mFacebook, getBaseContext());

并在同一用户执行发布操作时恢复会话

SessionStore.restore(mFacebook, getBaseContext());

mFacebook你的Facebook对象引用在哪里

于 2013-02-03T07:57:49.203 回答