facebook, android java.lang.IllegalStateException:

2020-03-01 17:11发布

After login I can I can make FB queries. After few minutes (played game) Facebook requests fail exception:

java.lang.IllegalStateException: Cannot execute task: the task is already running

It fails when I call

        Request.executeMeRequestAsync(Session.getActiveSession(),
                new Request.GraphUserCallback() {...

        Request.executeGraphPathRequestAsync(Session.getActiveSession(),
                "me/apprequests", new Request.Callback() {...

        Request request = new Request(session, "me/apprequests", null,
                    null, new Request.Callback() { .... } );
        RequestAsyncTask status = request.executeAsync();

Same calls are called immediately after login and they work. I have a test app where it works. But in real app after few minutes after login it does not work.

2条回答
仙女界的扛把子
2楼-- · 2020-03-01 17:53

You can use Request.toHttpConnection(request) instead of request.executeAsync()

查看更多
劫难
3楼-- · 2020-03-01 18:11

Are you running on UI thread? Wrap your code withrunOnUiThread

like this

Facebook SDK mentions that async calls must be done from UI thread

查看更多
登录 后发表回答