问题
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.
回答1:
Are you running on UI thread? Wrap your code withrunOnUiThread
like this
Facebook SDK mentions that async calls must be done from UI thread
回答2:
You can use Request.toHttpConnection(request) instead of request.executeAsync()
来源:https://stackoverflow.com/questions/15556015/facebook-android-java-lang-illegalstateexception-cannot-execute-task-the-task