0

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}

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.

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

Denoteone
  • 4,043
  • 21
  • 96
  • 150

1 Answers1

1

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.

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.

Martin Foot
  • 3,594
  • 3
  • 28
  • 35
  • But is that why my app is failing. – Denoteone Nov 29 '11 at 19:06
  • normally that doesn't stop a function... it may cause a ANR (application not responding) but it won't stop a function in the middle – vanleeuwenbram Nov 29 '11 at 19:15
  • @Denoteone have a look at [this](http://stackoverflow.com/questions/7489376/warn-activitymanager78-launch-timeout-has-expired-giving-up-wake-lock-wh) and [this](http://stackoverflow.com/questions/4283449/activity-idle-timeout-for-historyrecord) - I would definitely suggest moving the long running processes to another thread. – Martin Foot Nov 29 '11 at 22:15
  • @martin I moved it to a AsyncTask and it is still not getting the whole string from the http request. The file it is reading into a string is a 57KB xml file nothing special. – Denoteone Nov 30 '11 at 02:12
  • @Denoteone I was trying to fix the launch timeout warning in the log, does your function throw any exceptions? Do you have a minimal example / relevant source code available? – Martin Foot Nov 30 '11 at 04:39
  • @martin after testing it looks like logcat is truncating the large string but it is still being read into the app properly. Thanks for your help Checked +1. – Denoteone Nov 30 '11 at 14:11