facebook,android java.lang.IllegalStateException:无法执行任务:该任务已经在运行 [英] facebook, android java.lang.IllegalStateException: Cannot execute task: the task is already running

查看:291
本文介绍了facebook,android java.lang.IllegalStateException:无法执行任务:该任务已经在运行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

登录后,我可以进行FB查询。几分钟后(玩游戏)Facebook请求失败例外:

  java.lang.IllegalStateException:无法执行任务:任务已经运行

当我打电话

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

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

请求请求=新请求(会话,我/ apprequests,null,
null ,new Request.Callback(){....});
RequestAsyncTask status = request.executeAsync();

在登录后立即调用相同的调用,它们工作。
我有一个测试应用程序,但是在实际应用程序登录后的几分钟后,它不起作用。

解决方案

是哟你在UI线程上运行?使用 runOnUiThread



包装代码,如这个



Facebook SDK 提到,异步调用必须从UI线程完成


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.

解决方案

Are you running on UI thread? Wrap your code withrunOnUiThread

like this

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

这篇关于facebook,android java.lang.IllegalStateException:无法执行任务:该任务已经在运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆