Take a look at this method:
private boolean ensureOpenSession() {
if (Session.getActiveSession() == null || !Session.getActiveSession().isOpened())
{
Session.openActiveSession(this, true, new Session.StatusCallback() {
@Override
public void call(Session session, SessionState state, Exception exception)
{
onSessionStateChanged(session, state, exception);
}
});
return false;
}
else
{
onSessionStateChanged(Session.getActiveSession(), Session.getActiveSession().getState(), null);
}
return true;
}
and will have to create the onSessionStateChanged
method:
private void onSessionStateChanged(Session session, SessionState state, Exception exception)
{}
In which you can specify what happens when Session state changes.