After spending days trying to figure this out, I couldn't come up with anything that worked. Using my code, it shows me the permission form which I accept and log in but it doesn't get to the onSuccess, onError or onCancel. Anytime I click the button, it just doesn't do anything. And no errors on the LogCat. I don't know where i'm going wrong.
fb = (Button) findViewById(R.id.fb_button);
fb.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
LoginManager.getInstance().logInWithReadPermissions(LoginActivity.this,permissionNeeds);
callbackManager = CallbackManager.Factory.create();
LoginManager.getInstance().registerCallback(callbackManager,new FacebookCallback<LoginResult>() {
@Override
public void onSuccess(LoginResult loginResult) {
Log.d("kkkkkk","kkllkl");
}
@Override
public void onCancel() {
Log.d("kkkkkk","kkllkl2");
}
@Override
public void onError(FacebookException error) {
Log.d("kkkkkk","kkllkl4");
}
});
}
});
The FacebookSdk.sdkInitialize(this.getApplicationContext());
is initialized after the super.onCreate(savedInstanceState);
I finally figured it out. I changed the code a bit from the initial code to this:
and then in the button's on click listener, i just had to make the call for the login.
also don't forget to add the onActivityResult. I made the mistake also.