Re: [android-developers] AsyncTask, back button and cancel(boolean)

2010-08-16 Thread Filip Havlicek
Thanks for the suggestion Agus, will certainly consider this approach as well. By the way, I stumbled upon another interesting matter. If AsyncTask has ProgressDialog and it's cancel button (BUTTON_NEGATIVE) is implemented with a listener that calls cancel(boolean), the onCancelled() method is

[android-developers] AsyncTask, back button and cancel(boolean)

2010-08-15 Thread Filip Havlicek
Hi folks, I'm just wondering what happens to running AsyncTask when the back button is pressed. Doesn't seem to invoke onCancelled or onPostExecute in my AsyncTask. The second thing is I thought that when cancel(true) is invoked inside doInBackground, the onCancelled method should be called, but

Re: [android-developers] AsyncTask, back button and cancel(boolean)

2010-08-15 Thread Mark Murphy
On Sun, Aug 15, 2010 at 5:37 PM, Filip Havlicek havlicek.fi...@gmail.com wrote: I'm just wondering what happens to running AsyncTask when the back button is pressed. Nothing happens to your AsyncTask when the BACK button is pressed. Doesn't seem to invoke onCancelled or onPostExecute in my

Re: [android-developers] AsyncTask, back button and cancel(boolean)

2010-08-15 Thread Sebastián Treu
On Sun, Aug 15, 2010 at 7:43 PM, Mark Murphy mmur...@commonsware.com wrote: On Sun, Aug 15, 2010 at 5:37 PM, Filip Havlicek havlicek.fi...@gmail.com wrote: I'm just wondering what happens to running AsyncTask when the back button is pressed. Nothing happens to your AsyncTask when the BACK

Re: [android-developers] AsyncTask, back button and cancel(boolean)

2010-08-15 Thread Filip Havlicek
Hi Mark, thanks for your swift reply. I thought my AsyncTask got destroyed somehow, but from your response it seems like just my ProgressDialog got dismissed. Is there a way I can prevent that? I want the computation in AsyncTask to be done before user can interact with the UI again. And second

Re: [android-developers] AsyncTask, back button and cancel(boolean)

2010-08-15 Thread Mark Murphy
On Sun, Aug 15, 2010 at 6:03 PM, Sebastián Treu sebastian.t...@gmail.com wrote: Doesn't seem to invoke onCancelled or onPostExecute in my AsyncTask. Correct. Bear in mind that AsyncTask does not have to be used by an Activity. It could be used by a Service, for example. This is right? I

Re: [android-developers] AsyncTask, back button and cancel(boolean)

2010-08-15 Thread Mark Murphy
On Sun, Aug 15, 2010 at 6:13 PM, Filip Havlicek havlicek.fi...@gmail.com wrote: thanks for your swift reply. I thought my AsyncTask got destroyed somehow, but from your response it seems like just my ProgressDialog got dismissed. Is there a way I can prevent that? Prevent what? I want the

Re: [android-developers] AsyncTask, back button and cancel(boolean)

2010-08-15 Thread Filip Havlicek
The UI works without the results, although I'm worried about other scenarios. The AsyncTask takes let's say 30 seconds to complete, it's invoked in first tab and the results are displayed in second and third tab. If user dismisses the ProgressDialog, he can of course navigate to second or third

Re: [android-developers] AsyncTask, back button and cancel(boolean)

2010-08-15 Thread Mark Murphy
On Sun, Aug 15, 2010 at 6:32 PM, Filip Havlicek havlicek.fi...@gmail.com wrote: The AsyncTask takes let's say 30 seconds to complete, it's invoked in first tab and the results are displayed in second and third tab. If user dismisses the ProgressDialog, he can of course navigate to second or

Re: [android-developers] AsyncTask, back button and cancel(boolean)

2010-08-15 Thread Filip Havlicek
Oh. AFAIK, the ProgressDialog itself handles its BACK button. Call setCancelable() on the ProgressDialog to adjust its behavior. Oh, actually overlooked this one while reading the documentation, my bad. Yes, that did the trick I wanted, thanks a lot for your help. The discussion about AsyncTask

Re: [android-developers] AsyncTask, back button and cancel(boolean)

2010-08-15 Thread Agus
You might want to try using BroadcastReceivers for that scenario. AsyncTask fires off an intent signaling that operation has been completed with the information on how to obtain the data or include the data in the intent. And have each tab activity register a common receiver to handle the intent.