Android Facebook请求耗时太长

时间:2013-07-13 05:11:33

标签: android facebook facebook-graph-api

所以我基本上从Facebook API教程中复制/粘贴了这段代码,但是当我运行它时,调用onCompleted()可能需要超过60(!)秒,这显然是完全不可接受的。我已经花了不到10秒钟几次,但这是非常罕见的;大部分时间至少需要30秒。这不受我本地帧率的影响吗?我正在加载纹理并渲染一个加载屏幕,而这个请求正在等待,这会导致渲染中出现一些波动,但我不认为这会影响到这一点。我也尝试过模拟器以及多个不同的手机,但都有同样的问题。如果有人有任何想法或建议,请帮助!

 Session.openActiveSession( this, true, new Session.StatusCallback() {
        @Override
        public void call(Session session, SessionState state, Exception exception)
        {
            if( session != null && session.isOpened() )
            {
                // make request to the /me API
                Request request = Request.newMeRequest( session,
                        new Request.GraphUserCallback() {
                            // callback after Graph API response with user object

                            @Override
                            public void onCompleted(GraphUser user, Response response)
                            {
                                 // sometimes over 60 seconds to get here!
                            }
                        }
                        );
                Request.executeBatchAsync(request);
            }
        }
    });

1 个答案:

答案 0 :(得分:0)

你可以试试这个......

Session.openActiveSession( this, true, new Session.StatusCallback() {
        @Override
        public void call(Session session, SessionState state, Exception exception)
        {
            if( session != null && session.isOpened() )
            {
                // make request to the /me API
                Request request = Request.executeMeRequest( session,
                        new Request.GraphUserCallback() {
                            // callback after Graph API response with user object

                            @Override
                            public void onCompleted(GraphUser user, Response response)
                            {}
                        });
            }
        }
    });