Login callback does not start using facebook-android-sdk 4

I have activity for user login on facebook. I used facebook-android-sdk v4.0.0. But the login callback does not start when the login button is pressed. After the progress bar is displayed, automatically start the previous activity without showing any errors in the log, instead of starting the 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 a metadata element to the application element and FacebookActivity to the manifest. In addition, the initialization of the Facebook SDK in the application has been completed:

 @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); FacebookSdk.sdkInitialize(getApplicationContext()); } 

What happened to my code? Thanks for any suggestion!

Edit

I found what is wrong with my code. I am running SignUpActivity with the no_history flag. After I remove this flag, now everything is in order.

+6
source share

Source: https://habr.com/ru/post/987187/


All Articles