Thanks a lot for your input!

On 5 Aug., 16:32, Jef <[email protected]> wrote:
> In my application, I display two dialogs. For each, I have a
> getXXXDialogMessage() method which formulates the message (based on
> the current state of the app) and returns a string. Then, in both
> onCreateDialog and onPrepareDialog, I call
> dialog.setMessage(getXXXDialogMessage()).
>
> I'll have to check my logcat to see what happens if a rotate happens
> while one of these dialogs is displayed, I haven't tested that yet.

As you are using onCreateDialog/onPrepareDialog, you should not get a
window leak.
This happens only if you display dialogs by using AlertDialog.show(),
and forget to dismiss the dialog in onDestroy().

On 5 Aug., 16:38, TreKing <[email protected]> wrote:
> No - only onCreateDialog does. onPrepareDialog also passes you the Dialog
> it's preparing ... otherwise it would be rather useless.

Yes, you are right. But I can only use the id to setup the dialog (and
member variables of the activity, which is problematic).

> Store the number of files somewhere in the activity, and in onPrepareDialog,
> which, again, gives you the Dialog, call dialog.setMessage("Number of file:
> " + numberOfFiles);

If the data is stored in a member variable, the data will be lost when
I turn the device (as the activity is destroyed and recreated).
I would have to use onRetainNonInstanceState or onSaveInstanceState to
pass that data to the new activity. But that would blow up
my code more than I would like.

> Where does it say these functions are called asynchronously? Anything
> dealing with any UI elements (like a Dialog) is pretty much guaranteed to be
> running on the UI thread.

The function Activity.showDialog does not immediately call
onPrepareDialog, but onPrepareDialog is called later on the UI
thread.
In between those two calls, the UI thread could potentially change the
member variables holding the dialog data (for example due to a second
dialog that gets shown).
But maybe I'm nit-picking here, so please forget that comment :)

Andreas

-- 
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

Reply via email to