that demo is not calling showDialog() in onCreate until you click on a button. in my case, i'm doing it automatically based on some condition.
On Mar 29, 7:43 pm, Dianne Hackborn <[email protected]> wrote: > Here is an API demo showing how to do this: > > http://developer.android.com/resources/samples/ApiDemos/src/com/examp... > > It doesn't have the behavior you describe, so I wonder if there is something > else going on in your code? > > > > > > > > > > On Tue, Mar 29, 2011 at 10:58 AM, sdphil <[email protected]> wrote: > > okay, this is officially driving me crazy. > > > I have an Activity and in onCreate() if some condition is true, I want > > to pop up a dialog and inform the user. > > > public void onCreate() { > > .... > > .... > > if (condition is true) > > showDialog(42); > > .... > > } > > > And I put in the appropriate code in onCreateDialog and > > onPrepareDialog - no problem, everything is working fine. > > > The issue is if I change screen orientation, it destroys the activity > > and re-creates it. Fine. But in doing that, it goes into onCreate > > and calls showDialog(42) again, which causes onCreateDialog and > > onPrepareDialog to be called again. Then it seems like the underlying > > system is trying to remember that I had a dialog up when i did the > > screen orientation so it calls onCreateDialog and onPrepareDialog a > > second time! I can save an instance of the dialog id in > > onSaveInstanceState() and restore it in onRestoreInstanceState(), but > > it seems like onRestoreInstanceState() doesn't get called until > > *after* onCreate is called, which means, it's going to make that call > > to showDialog(42) again. What's the best place to show dialogs after > > an activity has come up such that screen orientation changes won't > > cause multiple onCreateDialogs/onPrepareDialog calls to be made? > > > -- > > 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 > > -- > Dianne Hackborn > Android framework engineer > [email protected] > > Note: please don't send private questions to me, as I don't have time to > provide private support, and so won't reply to such e-mails. 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

