5
我(想我)跟着Facebook教程,但我無法正常工作。我試圖通過FB登錄,然後獲取有關用戶的信息。我有:Android Facebook SDK - session.isOpened()總是返回false
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() {
// callback after Graph API response with user object
@Override
public void onCompleted(GraphUser user, Response response) {
m_user = user;
System.out.println("Hello " + user.getName());
}
});
}
}
然後:
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);
}
}
但似乎 「真棒」 從不打印( 「好」 打印)eventhough我設法登錄到FB。 或者我不明白session.isOpened()
是什麼意思?