On Thu, Mar 11, 2010 at 1:40 PM, Achanta <krishna.acha...@gmail.com> wrote:
> Yes I am trying to redesign it to use AsyncTask. One reason why I did > not take this approach is that I just wanted a plain thread that sits > and logs user events that are occurring throughout my app and it made > more sense to just start that thread when the app starts and shut it > down when the app closes. I had a handler which grabs the logs and > puts them in db and the thread just sits there and logs them to > server. > For this model, manage the thread through a separate static singleton, have clients tell it when they are using it (in onCreate() or whatever) and when they are done (in onDestroy() or whatever), and have that class take care of stopping the thread when there are no more clients. Also please be careful about what this thread is doing. An application should be careful to be doing very little work any time it is not in the foreground, or it will be consuming battery... and has a good chance of showing up high up in the battery meter as it eats the user's battery. -- Dianne Hackborn Android framework engineer hack...@android.com Note: please don't send private questions to me, as I don't have time to provide private support, and so won't reply to such e-mails. All such questions should be posted on public forums, where I and others can see and answer them. -- 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