Facebook的API时挂起"开放" openActiveSession期间 [英] Facebook api hangs at "Opening" during openActiveSession

查看:112
本文介绍了Facebook的API时挂起"开放" openActiveSession期间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以登录罚款第一次。我有一个选项,用户可以在Android应用程序中禁用的Facebook。当这个被选中的Facebook状态到关闭。当我再次使用该选项,重新登录的API挂在回调函数中打开。

每例子我已经找到了第一个电话的用途

  session.openForRead(新Session.OpenRequest(活动).setCallback(statusCallback));
 

和第二个使用

  Session.openActiveSession(活动,真实,statusCallback);
 

回调函数看起来是这样的:

 私有静态类SessionStatusCallback实现Session.StatusCallback {
    //回调时,会话状态变化
    @覆盖
    公共无效呼叫(会话的会话,SessionState会状态,例外的例外){
        如果(session.isOpened()){
            //使请求/ ME API
            Request.executeMeRequestAsync(会话,新Request.GraphUserCallback(){
                //后与用户对象图形API响应回调
                @覆盖
                公共无效onCompleted(GraphUser用户,响应响应){
                    如果(用户!= NULL){
                        GlobalVars.setUser(user.getName());
                        共享preferences preFS = preferenceManager.getDefaultShared preferences(GlobalVars.getContext());
                        编辑EDITOR = prefs.edit();
                        editor.putBoolean(脸谱,真正的);
                        editor.commit();
                        的System.out.println(脸谱登录);
                    }
                }
            });
        }
        的System.out.println(脸谱会话状态回调+ session.getState()的toString());
    }
}
 

解决方案

我不知道,如果我们有确切的问题,但我的Facebook的会话状态保持开放的 Session.openActiveSession后(活动中,真正的,statusCallback); 。我已经覆盖了 onActivityResult()我的片段中。我所做的解决,这是覆盖在我的活动的方法来代替。

相关答案: http://stackoverflow.com/a/13888652/782870

I can log in fine the first time. And I have an option where the user can disable facebook within the android application. When this is selected the facebook status goes to CLOSED. When I use the option again, to log back in the API hangs at OPENING within the callback function.

Per the examples I've found the first call uses

session.openForRead(new Session.OpenRequest(activity).setCallback(statusCallback));

and the second uses

Session.openActiveSession(activity, true, statusCallback);

The callback function looks like this:

private static class SessionStatusCallback implements 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) {
                        GlobalVars.setUser(user.getName());
                        SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(GlobalVars.getContext());
                        Editor editor = prefs.edit();
                        editor.putBoolean("facebook", true);
                        editor.commit();
                        System.out.println("facebook logged in");
                    }
                }
            });
        }
        System.out.println("facebook session state callback " + session.getState().toString());
    }
}

解决方案

I'm not sure if we have the exact problem, but my facebook's session state retains "OPENING" after the Session.openActiveSession(activity, true, statusCallback);. I had overridden the onActivityResult() inside my fragment. What I did to solve this was to override the method on my Activity instead.

Related answer: http://stackoverflow.com/a/13888652/782870

这篇关于Facebook的API时挂起"开放" openActiveSession期间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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