Android - Facebook SDK - 邮件权限

时间:2014-05-02 09:06:22

标签: android facebook-graph-api

我想向我的应用添加邮件权限。

我见过很多帖子,但没有人真正符合我的问题...

  • 我不使用facebook登录按钮
  • 我使用以下代码:

    Session.openActiveSession(InscriptionConnexionActivity.this, true, new Session.StatusCallback() {
    
    // callback when session changes state
    @Override
    public void call(Session session, SessionState state, Exception exception) {
    
        if (session.isOpened()) {
    
            // make request to the /me API
            Request.executeMeRequestAsync(session, new Request.GraphUserCallback() {
    
                // callback after Graph API response with user object
                @Override
                public void onCompleted(GraphUser user, Response response) {
    
                    if (user != null) {
    
                        System.out.println(user.getName() + " : connected");
                        register_facebook(session.getAccessToken());
                    }
                }
            });
        }
    } });
    

拥有邮件权限需要做什么?在此先感谢:)

1 个答案:

答案 0 :(得分:1)

尝试以下代码: -

Session session = Session.getActiveSession();
if (session == null) {
    session = new Session(this);
    Session.setActiveSession(session);
}
if (!session.isOpened() && !session.isClosed())) {
    session.openForRead(new Session.OpenRequest(this)
      .setPermissions(Arrays.asList("basic_info","email"))
      .setCallback(statusCallback));
}

见下面的链接

Facebook SDK 3.7 for Android request email permission