所以,我有一个Dialog
带有“分享”的按钮。当按钮被按下时,它会调用一个方法来共享用户信息,如果他们已经登录到 Facebook。但是,如果他们没有登录 Facebook,我希望它首先允许用户登录,然后分享他们的信息。这是我尝试在没有 的情况下登录用户LoginButton
:
Session.OpenRequest openRequest = new Session.OpenRequest(GameActivity.this);
StatusCallback callback = new StatusCallback(){
@Override
public void call(Session session, SessionState state, Exception exception) {
Log.d(TAG, "CALL");
if (Session.getActiveSession() != null && Session.getActiveSession().isOpened()){
Log.d(TAG, "sendBrag was called");
sendBrag();
}else{
Log.d(TAG, "session is not opened");
}
if (exception != null){
Log.d(TAG, "caught exception in call method");
}
}
};
openRequest.setCallback(callback);
openRequest.setDefaultAudience(SessionDefaultAudience.FRIENDS);
openRequest.setPermissions(PERMISSIONS);
Session session = new Session(GameActivity.this);
session.openForPublish(openRequest);
Session.setActiveSession(session);
其中,PERMISSIONS
是:
private static final List<String> PERMISSIONS = Arrays.asList("publish_actions");
问题是它永远不会登录!我要么收到一条Toast
消息,说明“检查您的网络连接”(即使我的网络连接正常),要么什么也没发生。但从日志中我可以看出 Session 永远不会打开。总结一下:您如何使用该Session
课程正确登录 Facebook?我在这里想念什么?任何帮助、建议或建议将不胜感激,谢谢!