Facebook上的Andr​​oid SDK 3.0回调不呼吁取消 [英] Facebook Android SDK 3.0 callback not called on cancel

查看:116
本文介绍了Facebook上的Andr​​oid SDK 3.0回调不呼吁取消的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想升级与Facebook的Andr​​oid SDK 3.0的现有应用/框架,但我坚持就如何处理额外的权限进行身份验证。

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.

的问题是,在StatusCallback似乎并不如果用户取消开火。如果我使用就经常调用 Session.openActiveSession 上取消回调火灾,但使用新的 Session.OpenRequest 新鲜会话对象没有。

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.

下面是我的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应用程序未安装)。如果用户点击关闭按钮(左上)回调不会被触发。

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

如果我使用 Session.openActiveSession 在相同的情况下回调被触发。

If I use the Session.openActiveSession in the same scenario the callback IS triggered.

这是一个错误,还是我做错了什么?

Is this a bug, or am I doing something wrong?

谢谢!

推荐答案

发现问题。当手动创建一个会话,必须设置该会话的静态会话实例活动会话:

Found the problem. When creating a session manually, one must set this session as the "active session" on the static Session instance:

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

这篇关于Facebook上的Andr​​oid SDK 3.0回调不呼吁取消的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆