android Messagebox
<p>android Messagebox doesn't show because of <strong>finish</strong> call, how to make this function wait for ok and then close</p>

<pre><code>public void msbox(String str,String str2)
{
    AlertDialog.Builder dlgAlert  = new AlertDialog.Builder(this);                      
    dlgAlert.setMessage(str2);
    dlgAlert.setTitle(str);              
    dlgAlert.setPositiveButton("OK", null);
    dlgAlert.setCancelable(true);
    dlgAlert.create().show();
    finish(); 
}
</code></pre>

<p>should be like this</p>

<pre><code>public void msbox(String str,String str2)
{
    AlertDialog.Builder dlgAlert  = new AlertDialog.Builder(this);                      
    dlgAlert.setTitle(str); 
    dlgAlert.setMessage(str2); 
    dlgAlert.setPositiveButton("OK",new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int whichButton) {
             finish(); 
        }
   });
    dlgAlert.setCancelable(true);
    dlgAlert.create().show();
}
</code></pre>
