mardi 7 avril 2015

Android Facebook SDK 4 login - no callbacks being called

Vote count:


I'm implementing facebook sdk 4.0 login/logout flow in an app and having trouble with the callbacks. The implementation takes place in a custom class (i.e. it neither implements activity nor fragment) but it receives a reference to its parent activity when it initializes. Here is the code in the constructor:

private CallbackManager callbackManager;

public void login(Activity parentActivity) {

callbackManager = CallbackManager.Factory.create();
final List<String> READ_PERMISSIONS = Collections.singletonList("some_permission_that_I_need");

LoginManager.getInstance().registerCallback(callbackManager, new FacebookCallback<LoginResult>() {
public void onSuccess(LoginResult loginResult) {

Log.d("Facebook", "onSuccess with " + loginResult.getAccessToken().toString());


public void onCancel() {
Log.d("Facebook", "onCancel");

public void onError(FacebookException error) {
Log.d("Facebook", "onError");

AccessTokenTracker accessTokenTracker = new AccessTokenTracker() {
protected void onCurrentAccessTokenChanged(AccessToken oldAccessToken, AccessToken newAccessToken) {

Log.d("Facebook","access token tracker");



if (AccessToken.getCurrentAccessToken() == null) {

Log.d("Facebook", "Accesstoken was null");

LoginManager.getInstance().logInWithReadPermissions(parentActivity, READ_PERMISSIONS);



I can see in the logs that the accesstoken was null and that therefore the method loginWithReadPermissions is being called.. but after that nothing. None of the callback methods are being called for the login flow. I tried moving the callback definition to the parent activity but I still get nothing back after calling loginWithReadPermissions. What am I missing here?

asked 53 secs ago



Android Facebook SDK 4 login - no callbacks being called

Aucun commentaire:

Enregistrer un commentaire