here is my code for updating status:
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());
is showing a good and healthy session, which can be used for posting. because in logcat, it is showing that the session is open, accesstoken is good, app_id is also good.
but using this session when i am trying to post, in the onComplete() method, executed these lines:
Log.e("not open session",Session.getActiveSession().toString());
Log.e("session","not open");
and it is showing that:
{Session state:CLOSED, token:null, appId:***************** }
what is wrong? i have tried without new Session(context), but getting the same result. what should i do?
save the session when you create it for first time using
and also restore the session when same user performs post operation
where
mFacebookis yourFacebookobject reference