9

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.

Max
  • 6,286
  • 5
  • 44
  • 86

2 Answers2

20

Are you running on UI thread? Wrap your code withrunOnUiThread

like this

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

Community
  • 1
  • 1
Tema
  • 1,338
  • 13
  • 27
4

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