单击时,Facebook登录按钮未运行回调

时间:2015-04-12 17:19:37

标签: android facebook facebook-login

我正在使用this guide设置Android的Facebook登录信息。我的应用程序配置了keyhashes等。但是,当我在我的应用程序中单击登录时使用facebook按钮时,没有回调运行且没有记录堆栈跟踪。

    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());
        }
    });

我希望在点击按钮时记录SOMETHING。但除了正常的logcat之外,没什么好处,比如:

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

知道为什么没有回调正在运行?

1 个答案:

答案 0 :(得分:27)

愚蠢的错误,我错过了onActivityResult方法:

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