Facebook SDK LoginButton

时间:2015-08-21 12:32:03

标签: facebook facebook-login facebook-sdk-4.0

下午好, 我在这里有问题。 我设法得到了sdk facebook并且可以看到要登录的图标,只是当我点击它时出现错误。这个哈希键是正确的,它可能是什么?

private LoginButton loginButton;
private CallbackManager mCallbackManager;


@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    FacebookSdk.sdkInitialize(getApplicationContext());
    mCallbackManager = CallbackManager.Factory.create();

    setContentView(R.layout.gondola);
    loginButton = (LoginButton)findViewById(R.id.login_button);
    loginButton.setReadPermissions("user_friends");

    loginButton.registerCallback(mCallbackManager, new FacebookCallback<LoginResult>() {
        @Override
        public void onSuccess(LoginResult loginResult) {
            AccessToken accessToken = loginResult.getAccessToken();
            Profile profile = Profile.getCurrentProfile();

            Toast.makeText(getApplicationContext(), "LogIN",
                    Toast.LENGTH_SHORT).show();
        }

        @Override
        public void onCancel() {
            Toast.makeText(getApplicationContext(), "ERRO1",
                    Toast.LENGTH_SHORT).show();
        }

        @Override
        public void onError(FacebookException exception) {
            Toast.makeText(getApplicationContext(), "ERRO2",
                    Toast.LENGTH_SHORT).show();
        }
    });

}

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

0 个答案:

没有答案