TextEdit Text Input Issues in my game
<p>I am working on an Android game and am currently trying to get text input working. I want to prompt the player to enter his or her name and have that name added to the high score list.</p>

<p>I am trying to do that through EditText which I can get to work if I put my code in the onCreate method, but not if I call it from my game loop.</p>

<p>The method I am currently using:</p>

<pre><code>public static void getInput(Context context)
{
    final AlertDialog.Builder alert = new AlertDialog.Builder(context);
    final EditText input = new EditText(context);

    alert.setView(input);
    alert.setPositiveButton("Ok", new DialogInterface.OnClickListener() 
    {
        public void onClick(DialogInterface dialog, int whichButton) 
        {
            String value = input.getText().toString().trim();
        }
    });

    alert.setNegativeButton("Cancel",
            new DialogInterface.OnClickListener() 
            {
                public void onClick(DialogInterface dialog, int whichButton) {
                    dialog.cancel();
                }
            });
    alert.show();
}
</code></pre>

<p>If I call this from my gameloop the game crashes and I get the error:</p>

<pre><code>01-26 06:33:21.413: ERROR/AndroidRuntime(6960): java.lang.RuntimeException: Can't create handler inside thread that has not called Looper.prepare()
</code></pre>

<p>I tried calling Looper.prepare() and then Looper.loop(), and that opened up the text input box, but when I closed the box my game just sat on a black screen and did not respond.</p>

<p>So, my question is: what am I doing wrong, and is there an easier way to get text input? My game is based off the LunarLander example, so I am using SurfaceView.</p>

<p>Any help or suggestions will be appreciated. Thank you :)</p>
