Create a separate AsyncTask subclass for each different task that needs to be done.
It is bad Java design to create one large AsyncTask subclass that handles everything in your app. That would mean you'd have to create a large 'doInBackground' method (being able to handle all cases), possibly create a large 'onPostExecute' as well, etc, and riddle your code with 'if' statements or large 'switch' statements. In the end, all your AsyncTask instances/objects, regardless which subclass they actually are, are run on one 'global' system queue and 'global' pool of threads. They all share it. For executing a particular AsyncTask instance/object: You can execute an AsyncTask instance/object only once (i.e. call 'execute' on the object only once). --- Anton. On Tuesday, November 13, 2012 4:44:16 AM UTC-5, Albertus Kruger wrote: > > Hi, > > I am new to Android programming. I would like to know if it is better to > have seperate AsyncTasks for every screen on your application or is it > better to have one AsynTask class that handles all processing from > different screens on my application ? > > I have looked at stackoverflow but its still not clear to me. I'm thinking > one class might be a lot of overhead and making seperate AsyncTasks for > every screen of my application will be good for performance. > > Thanks for any advice. > Albertus > -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en