When you use Activity.showDialog() you are telling the parent activity to manage the dialog that you create.
>From the API docs ( http://developer.android.com/intl/fr/reference/android/app/Activity.html#showDialog(int) ): "A call to onCreateDialog(int) will be made with the same id the first time this is called for a given id. From thereafter, the dialog will be automatically saved and restored." When you rotate the phone, your parent activity is closed and re-created. The showDialog() method tells the activity to automatically re-create the AlertDialog as well. When you use AlertDialog.show(), you are effectively managing the dialog yourself. This means that when the activity is closed and re-created, you would have to make sure the dialog is dismissed and displayed correspondingly; otherwise the activity *may* be destroyed before the dialog has chance to close, and the internal reference to it will be flagged as leaked. On Fri, Jan 8, 2010 at 5:15 PM, Michael Dorin <[email protected]> wrote: > When creating an AlertDialog...I have noticed in some cases, if you > invoke .show directly, you > get a leaked dialog error when you rotate the phone. > In other cases you don't. > > If you don't call .show and use showDialog from the activity you don't > see the leaked dialogs. > Are there some cases when you can use .show? > > Or is it just dumb luck if you don't see a problem? > > -Mike > > -- > You received this message because you are subscribed to the Google > Groups "Android Beginners" group. > > NEW! Try asking and tagging your question on Stack Overflow at > http://stackoverflow.com/questions/tagged/android > > To unsubscribe from this group, send email to > [email protected] > For more options, visit this group at > http://groups.google.com/group/android-beginners?hl=en > >
-- You received this message because you are subscribed to the Google Groups "Android Beginners" group. NEW! Try asking and tagging your question on Stack Overflow at http://stackoverflow.com/questions/tagged/android To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-beginners?hl=en

