That's a possibility. Or, I might use this function I wrote:
void replaceCurrentTask(android.os.AsyncTask<Void, Void, Long>
newTask){
if (currentTask != null) {
currentTask.cancel(true);
while (!currentTask.isCancelled() &&
currentTask.getStatus()!
=AsyncTask.Status.FINISHED) trytosleep(1);
}
currentTask=newTask;
currentTask.execute();
}
On Sep 10, 4:36 am, Marco Alexander Schmitz
<[email protected]> wrote:
> Hi. How about blocking the ui with some nice waiting dialog? Greetings marco
> Am 10.09.2011 09:39 schrieb "bob" <[email protected]>:
>
>
>
>
>
>
>
> > So, I have a bunch of buttons and each one launches an AsyncTask.
>
> > So, should I keep a variable like this:
>
> > AsyncTask currentTask=null;
>
> > Then should I do
>
> > if (currentTask != null) currentTask.cancel();
>
> > before I launch the new task?
>
> > I only want one task running at a time. Right now, if someone monkeys
> > with the buttons, they get a bunch of tasks running simultaneously
> > with weird UI results.
>
> > --
> > You received this message because you are subscribed to the Google
> > Groups "Android Developers" group.
> > To post to this group, send email to [email protected]
> > To unsubscribe from this group, send email to
> > [email protected]
> > For more options, visit this group at
> >http://groups.google.com/group/android-developers?hl=en
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en