Android的 - 功能未完成 [英] Android - Function is not completing

查看:142
本文介绍了Android的 - 功能未完成的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图让使用HTTP调用的字符串。我注意到,在大文件我没有阅读完所有的文件之前停止,给我这个错误,然后用脚本的其余部分将继续。

I'm trying to get a string using a http call. I am noticing that in large files I am not reading all of the file before it stops and gives me this error and then continues with the rest of the script.

11-29 11:26:18.417: WARN/ActivityManager(59): Launch timeout has expired, giving up wake lock!
11-29 11:26:18.556: WARN/ActivityManager(59): Activity idle timeout for HistoryRecord{45059000 com.MeetingManager/.MeetingManager}

我觉得像的getXML功能正在长和应用程序恰到好处一起code的下一行,它使用从一个没有完成previous功能不完整的字符串移动。当然,这是使我的应用程序废话了。

I feel like the getXML function is taking to long and the app just moves right along to the next line of code which uses the incomplete string from the previous function that did not finish. Of course this is making my app crap out.

我如何给我的功能更多的时间?

How do I give my function more time?

以下是在两个函数调用。如果需要从这些调用更多信息只是让我知道。

Below are the two function calls. If you need more info from these calls just let me know.

字符串XML = XMLfunctions.getXML(项目);
    文档的DOC = XMLfunctions.XMLfromString(XML);

String xml = XMLfunctions.getXML(items); Document doc = XMLfunctions.XMLfromString(xml);

推荐答案

它看起来像你调用你的应用程序的onCreate或者阻止主应用程序线程onResume方法里面一个长期运行的功能。这不是一个好主意,因为这意味着你的用户将无法看到信息,如果应用程序需要很长的时间来启动 - 他们可能会认为什么都没发生并退出

It looks like you're calling a long running function inside your application's onCreate or onResume methods which is blocking the main application thread. This isn't a good idea as it means your users won't be able to see information if the app takes a long time to start up - they might think nothing is happening and quit.

看一看并移动任何长时间运行的操作成像一个 AsyncTask的或一个的发了处理程序。看看这里获取更多信息。

Have a look at this and move any long running operations into something like an ASyncTask or a Thread with a Handler. Have a look here for more information.

这篇关于Android的 - 功能未完成的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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