I have an activity for user to login with facebook. I used facebook-android-sdk v4.0.0. But login callback is not triggered when user click on login button. After showing progress bar, start previous activity automatically without showing any error on log instead of triggering login callback.
In SignUpActivity,
private CallbackManager callbackManager;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_sign_up);
callbackManager = CallbackManager.Factory.create();
LoginButton loginButton = (LoginButton) findViewById(R.id.login_btn);
loginButton.setReadPermissions(Arrays.asList("user_friends", "email"));
loginButton.registerCallback(callbackManager, new FacebookCallback<LoginResult>() {
@Override
public void onSuccess(LoginResult loginResult) {
Log.i("Login : ", "Success");
}
@Override
public void onCancel() {
Log.i("Login : ", "Cancel");
}
@Override
public void onError(FacebookException e) {
Log.e("Login Error : ", e.getMessage() + "");
}
});
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
callbackManager.onActivityResult(requestCode, resultCode, data);
}
I also added meta-data element to application element and the FacebookActivity to the manifest. Moreover, finished initializing facebook SDK in Application :
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
FacebookSdk.sdkInitialize(getApplicationContext());
}
What's wrong with my code ? Thanks for any suggestion !!
Edit
I found myself what's wrong with my code. I start SignUpActivity with no_history flag. After I remove that flag, everything is okay now.