2

请我有以下代码,

其中 loginButton 是 Facebook 登录按钮。

    loginButton.setReadPermissions(Arrays.asList("user_events"));
    loginButton.setUserInfoChangedCallback(new LoginButton.UserInfoChangedCallback() {
                @Override
                public void onUserInfoFetched(GraphUser user) {
                    MainActivity.this.user = user;
                    //pb.setVisibility(View.VISIBLE);
                    myApp.user = user;
                    eventi.clear();
                    myApp.eventiCompleti.clear();

                    if (user != null) {
                        String srt = "";
                        getEvents chn = new getEvents();

                    //OTHRE STUFF
                    foo...foo

现在问题如下。

我需要在按下 Facebook LoginButton 时进行拦截,以执行其他操作

但是如果我设置

  loginButton.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            // DO SOME OTHER STUFF
        }
    });

然后

 @Override
 public void onUserInfoFetched(GraphUser user)

不调用回调...

请问我该如何解决这个问题?

4

1 回答 1

1

我在会话生命周期的另一个时刻实现了请求的方法调用:

 private void onSessionStateChange(Session session, SessionState state,
        Exception exception) {
    if (isResumed) {
        FragmentManager manager = getSupportFragmentManager();
        int backStackSize = manager.getBackStackEntryCount();
        for (int i = 0; i < backStackSize; i++) {
            manager.popBackStack();
        }
        // check for the OPENED state instead of session.isOpened() since
        // for the
        // OPENED_TOKEN_UPDATED state, the selection fragment should already
        // be showing.
        if (state.equals(SessionState.OPENED)) {
            // showFragment(SELECTION, false);
            pb.setVisibility(View.VISIBLE);// <-- HERE IS THE METHOD I WANTED TO CALL
        } else if (state.isClosed()) {

        }
    }
}
于 2013-07-03T14:19:12.273 回答