samedi 18 avril 2015

Why absolutely nothing happens after calling onActivityResult() on the CallbackManager using the Facebook Login Button?

I've been trying to figure out how to solve this but was unsuccessful.


The problem here is after clicking the login button, it loads the Facebook Activity normally, and when it finishes, my activity receives the activity result and notifies the CallbackManager (all as described in the docs).


Unfortunately nothing happens from this point, no method from the registered FacebookCallback is executed, and not even a line is logged to inform of an error.


Here are the involved files:



public class LoginActivity extends Activity

CallbackManager callbackManager;
LoginButton loginFacebook;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
FacebookSdk.sdkInitialize(this);

setContentView(R.layout.activity_login);


...


callbackManager = CallbackManager.Factory.create();
loginFacebook = (LoginButton) findViewById(R.id.login_button);
loginFacebook.setReadPermissions("public_profile","email");
loginFacebook.registerCallback(callbackManager, new FacebookCallback<LoginResult>() {

@Override
public void onSuccess(LoginResult loginResult) {
...
(This is never executed)
}

@Override
public void onCancel() {
...
(Not executed)
}

@Override
public void onError(FacebookException e) {
...
(Not executed either)
}
});

}



@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
callbackManager.onActivityResult(resultCode, resultCode, data);
super.onActivityResult(requestCode, resultCode, data);
}


...


}


And activity_login.xml includes the button like this



<com.facebook.login.widget.LoginButton
android:id="@+id/login_button"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center_horizontal"/>


I also added the APP ID in my android manifest file



<meta-data android:name="com.facebook.sdk.ApplicationId" android:value="@string/facebook_app_id" />


As well as the android app key in the facebook application.


Hope figures out a solution for this, thank you very much.


Aucun commentaire:

Enregistrer un commentaire