Reputation: 497
I have an application which has some background processes, like downloading an XML from a server and parsing it, and I am performing these tasks in Threads.
The problem comes when sometimes a thread does not get CPU time for long time, it could be anytime between 15 minutes to some hours, and then the thread starts behaving properly.
How should I handle this?
Upvotes: 1
Views: 222
Reputation: 27004
My experience with AsyncTask is not very good, and it will terrible with very long operations like 15 min (you will have problems such as UI interaction, limits, etc.)
I recommend you create a service instead (IntentService is easy to work with) that will broadcast it reult when it is finished.
Upvotes: 0
Reputation: 30855
use the AsyncTask class for this.
in this you can perform to fetching or processing in background and until the background process was not complete the another method of this class was not execute
check this links for tutorial and guidlines
http://www.vogella.de/articles/AndroidPerformance/article.html
http://developer.android.com/reference/android/os/AsyncTask.html
Upvotes: 3