onPostExecute Looper AsyncTask
<p>My Android application allows users to update their Facebook status from a Fragment. I've implemented the following AsyncTask so they can log in:</p>

<pre><code>    public class updateFacebookTask extends AsyncTask&lt;String, Void, Boolean&gt; {
    protected Boolean doInBackground(final String... message) {
        Log.i(TAG, "Async UFT");

        myFResult = false;

            Looper.prepare();   

            if (loginAndPostToWall()) {
                Log.i(TAG, "loginAndPostToWall Returned: " + myFResult);

                myFResult = true;

            } else {
                Log.i(TAG, "loginAndPostToWall Returned: " + myFResult);

                myFResult = false;
            }


            //Looper.loop();


        return myFResult;
    }

    @Override
    protected void onPreExecute() {
        super.onPreExecute();

        Log.i(TAG, "UFT - oPrE");

    }
    @Override
    protected void onPostExecute(Boolean myFResult) {
        super.onPostExecute(myFResult);

        if (myFResult) {
            Log.i(TAG, "UFT oPE - Success: " + myFResult);


        } else {
            Log.w(TAG, "UFT oPE - fail: " + myFResult);

        }
    }
</code></pre>

<p>The AsyncTask uses the method loginAndPostToWall() as below, Which implements a DialogListener as part of the Facebook sdk:</p>

<pre><code>public boolean loginAndPostToWall() {

    myFResult = false;

    facebook.authorize(getActivity(), PERMISSIONS,
            Facebook.FORCE_DIALOG_AUTH, new DialogListener() {

                public void onComplete(Bundle values) {
                    Log.i(TAG, "LoginDialog Complete - Success");


                    myFResult = true;


                }

                public void onFacebookError(FacebookError error) {
                    Log.w(TAG,
                            "onFacebookError - Authentication with Facebook failed");


                    myFResult = false;

                }

                public void onError(DialogError error) {
                    Log.w(TAG,
                            "onError - Authentication with Facebook failed");
                    looper = false;
                    Log.i(TAG, "looper " + looper);

                    myFResult = false;

                }

                public void onCancel() {
                    Log.w(TAG,
                            "onCancel - Authentication with Facebook cancelled");


                    myFResult = false;

                }
            });


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

<p>I have two problems that I really need help with please:</p>

<ol>
<li><p>LogInAndPostToWall immediately returns myFResult as false. What I want it to do is wait until the login by webView has returned onComplete (or an error) from the DialogListener. How can I get it to return myFResult at that point and not before?</p></li>
<li><p>If I include Looper.loop(); onPostExecute is never called. If I don't include Looper.prepare(); I get an error saying I can't create a handler without it. Am I supposed to call quit() somewhere?</p></li>
</ol>

<p>I've been stuck on this for two days (!) and have read many, many SO posts - I've tried using runnables and logging which threads everything is running on etc, but no joy. </p>

<p>Thanks in advance for saving me...  </p>
