Right way to dismiss a Dialog
<p>I am trying to use a managed dialog. I noticed that after the first time I display it, subsequent creations don't actually make a new instance of the dialog, they just seem to reuse the first one.</p>

<p>If I want to stop that, and get a brand new instance on every call, is this the right way to do it?:</p>

<pre><code>@Override
protected Dialog onCreateDialog(int id) {
    switch (id) {
        case MY_DIALOG_ID:
            MyDlg dlg = new MyDlg(this);
            dlg.setOnDismissListener(new OnDismissListener() {
                public void onDismiss(DialogInterface dialog) {
                    removeDialog(MY_DIALOG_ID);
                }
            });
            return dlg;
    }
    return null;
}
</code></pre>

<p>so I guess the removeDialog() call does the trick, but my onDismiss() handler should be called in every instance of the dialog being killed, right (like Dialog.cancel(), Dialog.dismiss(), hitting the back key)?</p>

<p>Thanks</p>
