I'm trying to upgrade an existing app/framework with Facebook Android SDK v3.0 but am stuck on how to authenticate with extra permissions.
The problem is that the StatusCallback does not seem to fire if the user cancels. If I use the regular call to Session.openActiveSession
the callback fires on cancel, but using a new Session.OpenRequest
on fresh 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 produces a view on the device like this:
http://cl.ly/image/0E2C0t2m2b0g
(FB app is not installed). If the user clicks the close button (top left) the callback is NOT triggered.
If I use the Session.openActiveSession
in the same scenario the callback IS triggered.
Is this a bug, or am I doing something wrong?
Thanks!