Android Dialog does not wait for TextInput and OK Clicked
<p>In Activity "A", i override the onCreateDialog to create a dialogbox with EditText
In Activity "A"'s onCreate, i call a method which invokes showDialog, then i spawn another activity B using an intent.</p>

<p>I expect the user to enter something in the EditText and then press Ok, then the Intent should be launched!!.,
but what happens is, The dialog box pops up, and the new activity is fired by the Intent.</p>

<p>basically, the code does not wait on OnClickListener for the dialogBox. Is it bebcause DialogBox does not stop the main UI thread?? why is it like this., and what do i need to do to get this behavior of waiting until the user enters something in the dialog box and press Ok to proceed further.</p>

<p>Code template</p>

<pre><code>@Override
protected Dialog onCreateDialog(int id) {
    switch(id) {            
    case DIALOG_TEXT_ENTRY:

        LayoutInflater factory = LayoutInflater.from(this);
        final View textEntryView = factory.inflate(R.layout.alert_dialog, null);

        return new AlertDialog.Builder(ExampleActivityy.this)
            .setTitle(R.string.name_title_string)
            .setView(textEntryView)
            .setPositiveButton(R.string.ok_string, new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int whichButton) {

                    /* User clicked OK so do some stuff */
                }
            })
            .setNegativeButton(R.string.cancel_string, new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int whichButton) {

                    /* User clicked cancel so do some stuff */
                }
            })
            .create();

           .../...
           .../...
           ...// further down inside onCreate
@Override
public void onCreate(Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);
    this.mTitleRightImageButton.setOnClickListener(new OnClickListener() {

        public void onClick(View v) {
            Intent spawnEmptyIntent = new Intent(Intent.ACTION_INSERT, getIntent().getData());
            showDialog(DIALOG_TEXT_ENTRY); /// UI does not wait here
            onCreateNewList(); // and proceed further to this section
            Log.w(TAG, "Intent action string is " + getIntent().getDataString());
            startActivity(spawnEmptyListIntent); // and launches this activity.
        }
</code></pre>
