问题
Here is how I implemented callback mechanism for FB login button:
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
FacebookSdk.sdkInitialize(getApplicationContext());
AppEventsLogger.activateApp(this);
setContentView(R.layout.activity_main);
loginButton = (LoginButton)findViewById(R.id.login_button);
callbackManager = CallbackManager.Factory.create();
loginButton.registerCallback(callbackManager, new FacebookCallback<LoginResult>() {
@Override
public void onSuccess(LoginResult loginResult) {
Log.d("FB onSuccess 1", "");
}
@Override
public void onCancel() {
Log.d("FB onCancel 1", "");
}
@Override
public void onError(FacebookException e) {
Log.d("FB onError 1", "");
}
});
}
When pressing button a spinner appear, starts, but the confirmation screen does not appear, and no log messages are filled into Activity Monitor. What is the problem?
回答1:
Try Adding this in your Activity :
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
callbackManager.onActivityResult(requestCode, resultCode, data);
}
来源:https://stackoverflow.com/questions/39266772/pressing-facebook-login-button-does-nothing