I (I think) followed Facebook, but I can't get it to work correctly. I try to log in via FB and then get user information. I have:
private Session.StatusCallback statusCallback = new Session.StatusCallback() {
@Override
public void call(Session session, SessionState state, Exception exception) {
System.out.println("GOOD");
if (session.isOpened()) {
System.out.println("AWESOME");
Request.executeMeRequestAsync(session, new Request.GraphUserCallback() {
@Override
public void onCompleted(GraphUser user, Response response) {
m_user = user;
System.out.println("Hello " + user.getName());
}
});
}
}
And then:
public void onBtnFacebookClick(final View v) {
Session session = Session.getActiveSession();
if (session == null) {
session = new Session(this);
Session.setActiveSession(session);
if (session.getState().equals(SessionState.CREATED_TOKEN_LOADED)) {
session.openForRead(new Session.OpenRequest(this).setCallback(statusCallback));
}
}
if (!session.isOpened() && !session.isClosed()) {
session.openForRead(new Session.OpenRequest(this).setCallback(statusCallback));
} else {
Session.openActiveSession(this, true, statusCallback);
}
}
But it seems that “AWESOME” never prints (“GOOD” prints), although I managed to get into FB. Or maybe I do not understand what it means session.isOpened()?
source
share