而不是试图覆盖该onclick
方法或更改 Facebook 的库。您可以使用SessionState
来检测是否loginButton
已单击。当SessionState
OPENING 表示该按钮已被单击
private Session.StatusCallback fBcallback = new Session.StatusCallback() {
@Override
public void call(Session session, SessionState state,
Exception exception) {
Session fbSession = session;
Log.e(this.getClass().getName(), "fbSession isNULL "
+ (fbSession == null));
Log.e(this.getClass().getName(),
"fbSession state:" + fbSession.getState() + "");
switch (fbSession.getState()) {
case CLOSED:
Log.e(this.getClass().getName(), "CLOSED");
break;
case CLOSED_LOGIN_FAILED:
Log.e(this.getClass().getName(), "CLOSED LOGIN FAILED");
authButton.setVisibility(View.VISIBLE);
rl.setVisibility(View.GONE);
break;
case CREATED:
Log.e(this.getClass().getName(), "CREATED");
break;
case CREATED_TOKEN_LOADED:
Log.e(this.getClass().getName(), "CREATED TOKEN LOADED");
break;
case OPENED:
Log.e(this.getClass().getName(), "OPENED");
break;
case OPENED_TOKEN_UPDATED:
Log.e(this.getClass().getName(), "OPENED TOKEN UPDATED");
break;
case OPENING:
Log.e(this.getClass().getName(), "OPENING");
authButton.setVisibility(View.GONE);
rl.setVisibility(View.VISIBLE);
break;
}
if (fbSession.isOpened()) {
Log.e(this.getClass().getName(), "fbSession is opened");
getFBUserData();
}
if (fbSession.isClosed()) {
Log.e(this.getClass().getName(), "fbSession is closed, logout");
Token.removeToken(mActivity);
}
}
};