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 called whether the argument is true or false AND the AsyncTask itself gets destroyed. 2010/8/16 Agus <[email protected]> > 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. > > On Sun, Aug 15, 2010 at 3:32 PM, Filip Havlicek > <[email protected]> wrote: > > 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 tab. But > if > > the tab is displayed when AsyncTask completes, the results aren't > displayed > > unless there is some refresh of the tab activity (ie onResume or > onCreate). > > Is there a way to "asynchronously" update the tab's content upon > AsyncTask's > > completion? For example using Intents? (I'm still not confident about > using > > these in some larger scale than startActivity/startActivityForResult). > > (About the first question, I thought about preventing the ProgressDialog > > being dismissed by user pressing BACK button.) > > 2010/8/16 Mark Murphy <[email protected]> > >> > >> On Sun, Aug 15, 2010 at 6:13 PM, Filip Havlicek > >> <[email protected]> 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 computation in AsyncTask to be > >> > done before user can interact with the UI again. > >> > >> Personally, I would recommend you design a UI that works both with and > >> without the results of the "computation". > >> > >> > And second question, can I override the back button somehow so I could > >> > catch > >> > the call in my AsyncTask and cancel it? > >> > >> onBackPressed() (Android 2.x) and onKeyDown (Android 1.x) can be used > >> to intercept the BACK button. That being said, you should consider > >> whether you really should be implementing onPause() or onStop() > >> instead, since there are more scenarios than merely the BACK button > >> (e.g., HOME button). > >> > >> -- > >> Mark Murphy (a Commons Guy) > >> http://commonsware.com | http://github.com/commonsguy > >> http://commonsware.com/blog | http://twitter.com/commonsguy > >> > >> _The Busy Coder's Guide to Android Development_ Version 3.1 Available! > >> > >> -- > >> 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]<android-developers%[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]<android-developers%[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]<android-developers%[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

