Sorry I got confused, you want removeDialog(), not dismissDialog(). The latter only closes the dialog but it is still known as a managed dialog. removeDialog() on the other hand tells the Activity to forget about the dialog *and* to dismiss it.
On Wed, Mar 4, 2009 at 10:53 AM, Nmix <[email protected]> wrote: > > Just to finish this off, here is what I've learned now that I have it > working properly. > > First, dismissDialog() in onDestroy() does not dismiss the dialog. I > have to do it in onSaveInstanceState(). If I do it in onDestroy() and > I try to recreate it in onCreate() with showDialog() -- after > recreating the dynamic data it needs -- I get two dialog windows: one > that's broken (empty dynamic data) and one that's good. > > Second, if I do nothing at all, onPrepareDialog() is not called on the > active dialog after the config change. So simply recreating the data > it needs does nothing. I just displays the empty dialog. > > It all works perfectly when I do a dismissDialog() in > onSaveInstanceState(), save the dialog id in the bundle, pull it back > out in onCreate(), then create the data and call showDialog(). I > suppose it all makes some sort of sense although I do wish it were > more intuitive (and simpler). > > Romain, Marco, thanks for the feedback. > > On Mar 4, 12:13 pm, Nmix <[email protected]> wrote: >> Ugh. I already use onCreateDialog() and onPrepareDialog() since that >> is how I deal with making the content dynamic. I figured dismissing >> it (ok, I agree that's not quite a best practice), would be simplest, >> especially since in the context of the app it is very unlikely that >> the user would change config while it is showing. >> >> I'll try dismissing in onDestroy(). I hadn't done that since I wasn't >> sure that it'd be called on a config change. >> >> It also seems from your comment that onCreateDialog() and >> onPrepareDialog() do get called again sometime after onCreate(). If >> true, I hadn't realized that. I may look into that later and see if I >> can refresh those dialogs. >> >> Thanks. >> >> On Mar 4, 11:42 am, Romain Guy <[email protected]> wrote: >> >> > If you want to call dismissDialog(int) you need to use managed >> > dialogs. You will need to look at the javadoc for showDialog(int), >> > onCreateDialog() and onPrepareDialog(). The API Demos also show how to >> > use managed dialogs. >> >> > If you are already using these APIs, onCreate() is not the right >> > placae to dismiss the dialog since it doesn't exist yet. You would >> > have to do this in onDestroy() for instance. Note that dismissing the >> > dialog on configuration change goes against the purpose of managed >> > dialogs :) >> >> > On Wed, Mar 4, 2009 at 8:37 AM, Nmix <[email protected]> wrote: >> >> > > Flipping between landscape and portrait is causing me a problem with >> > > dialogs that are active at the time of config change. The dialogs >> > > survive (which I think is good), but I have the problem that some of >> > > my dialogs contain dynamic content which would need to be refreshed in >> > > the dialog views. All that content disappears from the dialog views >> > > after the config change. >> >> > > I thought it would be easier to do a dismissDialog() on restoration in >> > > onCreate(), letting the user press the button that shows the dialog. >> > > I successfully save and recover the dialog id, but when I attempt to >> > > dismissDialog(id) I get an IllegalArgumentException: no dialog with id >> > > 1 was ever shown via Activity$showDialog. >> >> > > Ok, so that doesn't work, and I still have that messed up dialog up on >> > > the screen that I want to get rid of. How can I do that? Are there >> > > any other reasonable alternatives? Thanks. >> >> > -- >> > Romain Guy >> > Android framework engineer >> > [email protected] >> >> > Note: please don't send private questions to me, as I don't have time >> > to provide private support. All such questions should be posted on >> > public forums, where I and others can see and answer them > > > -- Romain Guy Android framework engineer [email protected] Note: please don't send private questions to me, as I don't have time to provide private support. 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 [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 -~----------~----~----~----~------~----~------~--~---

