AlertDialog is this a bug?
<p>My app creates an AlertDialog in which a user enters the name to save. When a user clicks the save button, the onClickListener will check for duplicated name. If the name already exists, another dialog box will pop up to alert the user that existing data will be replaced. The user then have a choice to cancel and go back to change to a new name or go ahead and have the data replace.<br>
When the second dialog appears, I expect the first dialog box is still visible until I call dismiss. However, the first AlertDialog disappeared before the second AlertDialog appears. That is dismiss will automatically be called when a button is clicked. Is this a bug or by design?<br>
I wrote the test case below which I checked on 3 devices: Nexus S android 4.0, HTC Rezound android 2.3 and Motorola Droid Bionic android 2.3.  </p>

<p><strong>Layout</strong></p>

<pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
     android:layout_width="fill_parent"
     android:layout_height="fill_parent"
     android:orientation="vertical" &gt;

    &lt;TextView 
        android:id="@+id/message"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:text="Some message will be here"
    /&gt;

    &lt;Button
        android:id="@+id/show_btn"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content" 
        android:text="Show"
    /&gt;

&lt;/LinearLayout&gt;
</code></pre>

<p><strong>Code</strong></p>

<pre><code>public class AlertDialogBug extends Activity 
{
    static final int DIALOG_ALERT_ID = 1;
    AlertDialog alertDlg;  
    TextView message;

    @Override
    public void onCreate(Bundle savedInstanceState) 
    {
        super.onCreate(savedInstanceState);

        setContentView(R.layout.main);

        message = (TextView) findViewById(R.id.message);
        Button showButton = (Button) findViewById(R.id.show_btn);
        showButton.setOnClickListener(new OnClickListener()
        {
            @Override
            public void onClick(View v)
            {
                showDialog(DIALOG_ALERT_ID);
            }   
         });
     }

    private AlertDialog createAlertDialog()
    {
        AlertDialog.Builder builder = new AlertDialog.Builder(this);
        builder.setTitle("Bug?");

        builder.setPositiveButton("OK", new DialogInterface.OnClickListener()
        {

            @Override
            public void onClick(DialogInterface dialog, int which)
            {
                // No dismiss, cancel, finish, or removeDialog,
                // but the dialog will disappear when this button is clicked.
            }

          });

         alertDlg = builder.create();
         alertDlg.setOnDismissListener(new OnDismissListener()
         {

             @Override
             public void onDismiss(DialogInterface dialog)
             {
                message.setText("onDismiss was called");
             }

          });

          return alertDlg;
    }

    @Override
    protected Dialog onCreateDialog(int id)
    {
        switch (id)
        {
            case DIALOG_ALERT_ID:
                return createAlertDialog();

            default:
                return super.onCreateDialog(id);
        }       
    } 

} 
</code></pre>

<p>I originally wrote the save dialog box as an activity with android:theme="@android:style/Theme.Dialog". The UI looks fine on the Nexus S and Rezound but look terrible on the Droid Bionic (the edit box and button only occupied half of the width, the other half is blank).</p>
