Facebook SDK - 如何正确覆盖 onActivityResult()?

Facebook SDK - how to override onActivityResult() correctly?

我有一个简单的 Activity,我想在其中获取有关 Facebook 用户的一些信息:

public class FacebookActivity extends Activity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        setContentView(R.layout.facebook_layout);

        // start Facebook Login
        Session.openActiveSession(this, true, new Session.StatusCallback() {

            // callback when session changes state
            public void call(Session session, SessionState state, Exception exception) {
                if (session.isOpened()) {
                    Request.executeMeRequestAsync(session, new Request.
                            GraphUserCallback() {

                        // callback after Graph API response with user object
                        @Override
                        public void onCompleted(GraphUser user, Response response) {
                            if (user != null) {
                                Log.i("facebook_id", user.getId());
                                Log.i("facebook_name", user.getName());
                            }
                        }
                    });
                }
            }

        });
    }
}

但是如果 onActivityResult() 方法没有被覆盖,那么 onCompleted() 方法就不会被调用。所以,我的问题是如何在我的情况下正确制作它?

谢谢。

尝试一下

@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);

    Session.getActiveSession().onActivityResult(this, requestCode,
            resultCode, data);
}