Facebook android sdk登录失败

时间:2014-06-18 09:59:27

标签: android facebook facebook-graph-api

我已使用最新的Android SDK(3.15.0)在 Fragment 上实现了 FB登录按钮

一切正常,对于android> = 4但它不适用于旧版本:

按下登录按钮后,它会系统地转到 CLOSES_LOGIN_FAILED 状态而不会获取Facebook对话框。

代码如下所示:

Session.OpenRequest openRequest = new Session.OpenRequest(this).setCallback(callback);
List<String> readPermissions = Arrays.asList("basic_info", "email", "user_photos");
openRequest.setPermissions(readPermissions);
session.openForRead(openRequest);

回调函数如下:

private Session.StatusCallback callback = new Session.StatusCallback() {
    @Override
    public void call(final Session session, final SessionState state,
    final Exception exception) {    
           onSessionStateChange(session, state, exception);
    }
};

Obvioulsy后跟:

private void onSessionStateChange(final Session session,
    SessionState state, Exception exception) {
        if (state == SessionState.OPENED)
        {
            requestFbUserInfos(session);
        }
        else if (state == SessionState.OPENED_TOKEN_UPDATED) {
                       //
        }
        else if (state == SessionState.CLOSED_LOGIN_FAILED) {
            session.closeAndClearTokenInformation();
        }
        else if (state == SessionState.CLOSED) {
            session.close();
        }
    }

有什么想法吗?

0 个答案:

没有答案