AsyncTask onPostExecute isnt' getting called
<p>I'm trying to implement a basic login screen for an android app.  The flow is as follows:<br>
1) User enters login information and hits submit<br>
2) A <code>LoginRequest</code> which extends <code>AsyncTask</code> is created and executed.<br>
3) The <code>doInBackground</code> will fire some http calls to validate the user credentials<br>
4) The <code>onPostExecute</code> should be getting called to set the <code>loginResults</code><br>
5) Ui thread sees the login results and continues accordingly.</p>

<p>I'm been simplifying the code to get to the root issue but haven't had any luck so far.  Here is the simplified code that still repros the issue.</p>

<p>Inside my activity:</p>

<pre><code>private void tryLogin(String email, String password)
{
    this.showProgress(true);
    LoginHelper loginHelper = new LoginHelper();
    LoginResult result = loginHelper.tryLogin(email, password);
    this.showProgress(false);
}
</code></pre>

<p>This gets called from my submit buttons on click listener.</p>

<p>Inside LoginHelper:</p>

<pre><code>TestClass test = new TestClass();
public LoginResult tryLogin(String mobileNumber, String password, int deviceId)
{
    String loginUrl = "...";
    new LoginRequest(test).execute(loginUrl);

    while (test.result == null)
    {
        try {
            Thread.sleep(1000);
        }
        catch (Exception e)
        {
            //...
        }
    }
    return test.result;
}
</code></pre>

<p>This will execute the AsyncTask and wait for the result being continuing. </p>

<p>LoginRequest:</p>

<pre><code>public class LoginRequest extends AsyncTask&lt;String, Void, LoginResult&gt;
    TestClass test;

    public LoginRequest(TestClass test)
    {
        this.test = test;
    }
    @Override
    protected LoginResult doInBackground(String... params) {

        LoginResult ret = null;
        ret = new LoginResult(1,"test");
        return ret;
    }

    @Override
    protected void onPostExecute(LoginResult result) {
         this.test.result = result;
    }
}
</code></pre>

<p>I run this through the debugger with breakpoints inside the <code>doInBackground</code> and <code>onPostExecute</code>.  The <code>doInBackground</code> executes correctly and returns the <code>LoginResult</code> value, but the <code>onPostExecute</code> breakpoint never gets hit, and my code will wait in the while loop in <code>LoginHelper</code>.</p>