6

I am using this guide on setting up facebook login for Android. I have my app configured with keyhashes, etc. However, when I click the login with facebook button in my app, None of the callbacks run and no stack trace is logged.

    FacebookSdk.sdkInitialize(getApplicationContext());
    mCallbackManager = CallbackManager.Factory.create();
    mFacebookLoginButton = (LoginButton)findViewById(R.id.login_button);
    mFacebookLoginButton.registerCallback(mCallbackManager, new FacebookCallback<LoginResult>() {
        @Override
        public void onSuccess(LoginResult loginResult) {
            Log.e("Login Success", loginResult.getAccessToken().getToken());
            Log.e("Login Success", "hello");
        }

        @Override
        public void onCancel() {
           Log.e("Login Canceled", "Canceled Facebook Login");
        }

        @Override
        public void onError(FacebookException exception) {
            Log.e("Login Error", exception.getMessage());
        }
    });

I would expect SOMETHING to be logged when clicking the button. But nothing hapen except for normal logcat stuff, like:

04-12 13:13:21.759    4813-4813/com.example.myapp I/ActivityManager﹕ Timeline: Activity_idle id: android.os.BinderProxy@43e6de80 time:4181940
04-12 13:13:22.629    4813-4813/com.example.myapp I/ViewRootImpl﹕ ViewRoot's Touch Event : ACTION_DOWN
04-12 13:13:22.699    4813-4813/com.example.myapp I/ViewRootImpl﹕ ViewRoot's Touch Event : ACTION_UP
04-12 13:13:22.719    4813-4813/com.example.myapp I/ActivityManager﹕ Timeline: Activity_launch_request com.example.myapp time:4182907
04-12 13:13:22.829    4813-4813/com.example.myapp I/ActivityManager﹕ Timeline: Activity_idle id: android.os.BinderProxy@43ded488 time:4183019
04-12 13:13:23.329    4813-4813/com.example.myapp I/ActivityManager﹕ Timeline: Activity_idle id: android.os.BinderProxy@43e6de80 time:4183519

Any idea why none of the callbacks are running?

1

1 Answer 1

28

Silly mistake, I was missing the onActivityResult method:

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.