You can't call .dismiss() after onDestroy() of an activity. In the case of an orientation switch, the previous activity will be destroyed and a new instance created; after the previous instance is destroyed, its window and all windows it created are removed from the window manager, and the next instance will need to take care of re-adding them.
If you are using managed dialogs, most of the work to deal with this should be done for you, you just need to make sure that you don't do anything with an old dialog after the onDestroy() call. The easiest way to do this is probably to have the main thread handle all of the dialogs, create a Handler on that thread that is NOT an inner class of the Activity, but just has a pointer to the current Activity, and clear that pointer in onDestroy() and set in in onCreate(). Now when another thread wants to dismiss the dialog, it can send a message requesting this from the handler, and the handler simply grabs the Activity pointer and if non-null, gets the Dialog pointer from it and dismisses it if there is one. On Mon, Dec 15, 2008 at 8:44 AM, Al Sutton <a...@funkyandroid.com> wrote: > > A code snippet which prevents an "java.lang.IllegalArgumentException: > View not attached to window manager" being thrown when .dismiss() is > called on a progress dialogue box which is on screen when the device > changes orientation. > > Thanks, > > Al. > > -- > ====== > Funky Android Limited is registered in England & Wales with the > company number 6741909. The registered head office is Kemp House, > 152-160 City Road, London, EC1V 2NX, UK. > > The views expressed in this email are those of the author and not > necessarily those of Funky Android Limited, it's associates, or it's > subsidiaries. > > > > > -- 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. 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 -~----------~----~----~----~------~----~------~--~---