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.
An IllegalStateException is a runtime exception in Java that is thrown to indicate that a method has been invoked at the wrong time. This exception is used to signal that a method is called at an illegal or inappropriate time. For example, once a thread has been started, it is not allowed to restart the same thread again.
In the above example if we call start () method only once on thread t then we will not get any java.lang.IllegalStateException because we are not calling the start () method after the starting of thread (i.e we are not calling the start () method at an illegal or an inappropriate time.) Writing code in comment?
Whether the exception is checked or unchecked every exception occurs at run time only if there is no chance of occurring any exception at compile time. IllegalStateException is the child class of RuntimeException and hence it is an unchecked exception.
Are you running on UI thread? Wrap your code withrunOnUiThread
like this
Facebook SDK mentions that async calls must be done from UI thread
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With