Halting an activity until I get result from an AlertDialog
<p>Here is my problem - I want to create an activity and a dialog (with text field and OK button). I want to do the following:</p>

<ol>
<li>Show the AlertDialog (on creation of the activity, on clicking a button, or some other actions);</li>
<li>Fill the text in the AlertDialog, and click the OK button;</li>
<li>Continue doing the main thread of the activity;</li>
</ol>

<p>Something like this:</p>

<pre><code>public String getText() {

    String result = null;

    // Showing the new window with the text box and the button, and after
    // the button is clicked to move to the return statement below;

    return result;
}
</code></pre>

<p>I tried using "runOnUiThread" and "AsyncTask", but the actions on the field "result" are done only in the "protected void onPostExecute(Void result)" method, and meanwhile the main program is still executing, without waiting for my input.</p>

<p>Is there anyway this to be done (I am sure it has, because saw such apps) to solve this problem? I know that is really impudent to ask for such help - but is is possible to write some code example, just to see how it is really happening, because more than 3 days, I can' do it. If not please give some suggestions, and will continue trying and trying :)
THANKS A LOT!</p>
