On Wed, Jun 23, 2010 at 8:02 AM, Surfer <[email protected]> wrote: > Hi, built a simple app that displays an alertDialog with two buttons. > The problem is it's not getting dismissed when i change orientation. > After change i get a leak warning on debugger and the dialog appears > twice(pressing back hides the first dialog, only a second back > dismisses it completely). Any ideas? >
OnCreate makes dialog #1 which is managed by the activity. So far so good. You rotate, forcing onCreate to get called again which creates a new dialog, #2. Meanwhile dialog #1 is being managed for you and is being re-shown. Now you have 2 dialogs. Since they have the same ID, the second is probably overriding the first in the Activity's management system causing a leak of the first. Simple fix: check if you Bundle is null in onCreate. If it is, you're a fresh start and can show a dialog for the first time. If it's not, you're being recreated and your managed dialog will show on it's own, so you don't have to do anything. ------------------------------------------------------------------------------------------------- TreKing - Chicago transit tracking app for Android-powered devices http://sites.google.com/site/rezmobileapps/treking -- 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

