我一直在尝试将Facebook登录名与Android集成,但发生了登录Facebook,但是在onActivityResult中没有收到回调。我已经遵循了这一点: Facebook Login CallbackManager FacebookCallback not called? 但是,我的问题仍然没有解决。这是一个代码段:
@Override
protected FragmentPresenter getFragmentPresenter() {
return presenter;
}
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
callbackManager.onActivityResult(requestCode, resultCode, data);
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View view = inflater.inflate(getLayoutId(), container, false);
setHasOptionsMenu(true);
view.setClickable(true);
setupView(view);
//FacebookSdk.sdkInitialize(FacebookSdk.getApplicationContext());
FacebookSdk.sdkInitialize(getContext());
callbackManager = CallbackManager.Factory.create();
loginFacebook.setReadPermissions(Arrays.asList(EMAIL));
loginFacebook.setFragment(this);
loginFacebook.registerCallback(callbackManager, new FacebookCallback<LoginResult>() {
@Override
public void onSuccess(LoginResult loginResult) {
getActivity().setResult(RESULT_OK);
getActivity().finish();
}
@Override
public void onCancel() {
getActivity().setResult(RESULT_CANCELED);
getActivity().finish();
}
@Override
public void onError(FacebookException exception) {
//Handle Exception
}
});
return view;
}
请帮助我。