AsyncTask never finishes when other tasks are running

Posted by rebeccamaher on Stack Overflow See other posts from Stack Overflow or by rebeccamaher
Published on 2011-02-07T15:22:15Z Indexed on 2011/02/07 15:25 UTC
Read the original article Hit count: 165

Filed under:
|
|

In my app, I show a menu screen immediately to the user and then use an AsyncTask to load some data from disk. Loading takes about 3 seconds if that's all the app had to do. When the user hits a menu option and the data hasn't loaded yet, a "Please wait, loading" screen appears.

I have two problems:

  • I recently added ads to my app and have found this is making my app hang sometimes because the AsyncTask never finishes loading. What seems to be happening is that the ad banner (I'm using admob and this happens when adsense ads are shown which admob do occasionally) is using resources by playing a simple animation and the AsyncTask never gets a chance to finish.

  • I want to play a simple looping animation (e.g. making a view rotate) on my menu screen and this makes the AsyncTask take about 5 times longer to finish which renders the background loading pointless.

How can I avoid situations where my background data never finishes loading or has such a low priority it takes a long time?

I can't seem to find a way to increase the priority of an AsyncTask.

© Stack Overflow or respective owner

Related posts about java

Related posts about android