Facebook Android SDK 3.0 callback not called to cancel

I'm trying to update an existing app / frame using the Android Android SDK v3.0, but am stuck on how to authenticate with additional permissions.

The problem is StatusCallback doesn't fire if the user cancels. If I use a regular call Session.openActiveSession

, the callback fires on cancellation, but using new Session.OpenRequest

on the new Session

object does not.

Here's my code:

Session.OpenRequest auth = new Session.OpenRequest(this);

String[] permissions = {"publish_stream", "user_status"};

auth.setPermissions(Arrays.asList(permissions));

auth.setLoginBehavior(SessionLoginBehavior.SSO_WITH_FALLBACK);

auth.setCallback(new Session.StatusCallback() {
    @Override
    public void call(Session session, SessionState state, Exception exception) {
        switch(state) {

            case OPENING:
                System.out.println("OPENING");
                break;              

            case OPENED: // <-- NOT CALLED
                System.out.println("OPENED");
                break;

            case CREATED: // <-- NOT CALLED
                System.out.println("CREATED");
                break;

            case CREATED_TOKEN_LOADED: // <-- NOT CALLED
                System.out.println("CREATED_TOKEN_LOADED");
                break;

            case OPENED_TOKEN_UPDATED: // <-- NOT CALLED
                System.out.println("OPENED_TOKEN_UPDATED");
                break;

            case CLOSED: // <-- NOT CALLED
                System.out.println("CLOSED");
                break;      

            case CLOSED_LOGIN_FAILED: // <-- NOT CALLED
                System.out.println("CLOSED_LOGIN_FAILED");
                break;                          
        }
    }
});

Session session = new Session.Builder(this).setApplicationId("<My APP ID>").build();
session.openForPublish(auth);

      

This creates a view on the device like this:

http://cl.ly/image/0E2C0t2m2b0g

(FB app not installed). If the user clicks on the close button (top left), the callback is NOT triggered.

If I use Session.openActiveSession

in the same scenario a callback is triggered.

Is this a bug or am I doing something wrong?

Thank!

+3


source to share


1 answer


Found the problem. When creating a session manually, you need to set that session as an "active session" on a static session instance:



Session session = new Session.Builder(this).setApplicationId("<My APP ID>").build();
Session.setActiveSession(session); // <-- MUST DO THIS
session.openForPublish(auth);

      

+5


source







All Articles