How to execute AsyncTask from callback method?
<p>I have a code:</p>

<pre><code>private void submitExec() {

    if (SQLiteDbWrapper.getInstance().getBookCount()==0) {

        Toast.makeText(this, "A list of books is empty", Toast.LENGTH_LONG).show();
        return;
    }

    SQLiteDbWrapper.getInstance().makeFacebook(this, this.getApplicationContext());
    if (SQLiteDbWrapper.getInstance().getConnector().getFacebook().isSessionValid()) {
        new SubmitClass().execute();
    }
    else {

        SessionEvents.AuthListener listener = new SessionEvents.AuthListener() {

            @Override
            public void onAuthSucceed() {
                MyBookDroidActivity.this.executeSubmitClass();
            }

            @Override
            public void onAuthFail(String error) {

            }
        };
        SessionEvents.addAuthListener(listener);
        SQLiteDbWrapper.getInstance().getConnector().login();
    }
}

private void executeSubmitClass() {

    new SubmitClass().execute();
}
</code></pre>

<p>This code authorize by Facebook and execute AsyncTask. But I get Runtime error always:</p>

<pre><code>12-13 21:58:41.513: E/AndroidRuntime(31961): Uncaught handler: thread Thread-25 exiting due to uncaught exception
12-13 21:58:41.523: E/AndroidRuntime(31961): java.lang.RuntimeException: Can't create handler inside thread that has not called Looper.prepare()
12-13 21:58:41.523: E/AndroidRuntime(31961):    at android.os.Handler.&lt;init&gt;(Handler.java:121)
12-13 21:58:41.523: E/AndroidRuntime(31961):    at android.app.Dialog.&lt;init&gt;(Dialog.java:105)
12-13 21:58:41.523: E/AndroidRuntime(31961):    at android.app.AlertDialog.&lt;init&gt;(AlertDialog.java:63)
12-13 21:58:41.523: E/AndroidRuntime(31961):    at android.app.ProgressDialog.&lt;init&gt;(ProgressDialog.java:80)
12-13 21:58:41.523: E/AndroidRuntime(31961):    at android.app.ProgressDialog.&lt;init&gt;(ProgressDialog.java:76)
12-13 21:58:41.523: E/AndroidRuntime(31961):    at com.nda.mybookdroid.MyBookDroidActivity$SubmitClass.onPreExecute(MyBookDroidActivity.java:115)
12-13 21:58:41.523: E/AndroidRuntime(31961):    at android.os.AsyncTask.execute(AsyncTask.java:391)
12-13 21:58:41.523: E/AndroidRuntime(31961):    at com.nda.mybookdroid.MyBookDroidActivity.executeSubmitClass(MyBookDroidActivity.java:101)
12-13 21:58:41.523: E/AndroidRuntime(31961):    at com.nda.mybookdroid.MyBookDroidActivity.access$0(MyBookDroidActivity.java:99)
12-13 21:58:41.523: E/AndroidRuntime(31961):    at com.nda.mybookdroid.MyBookDroidActivity$1.onAuthSucceed(MyBookDroidActivity.java:86)
12-13 21:58:41.523: E/AndroidRuntime(31961):    at com.nda.facebook.SessionEvents.onLoginSuccess(SessionEvents.java:78)
12-13 21:58:41.523: E/AndroidRuntime(31961):    at com.nda.facebook.FacebookConnector$IDRequestListener.onComplete(FacebookConnector.java:141)
12-13 21:58:41.523: E/AndroidRuntime(31961):    at com.facebook.android.AsyncFacebookRunner$2.run(AsyncFacebookRunner.java:254)
12-13 22:01:47.193: E/AndroidRuntime(32216): Uncaught handler: thread Thread-32 exiting due to uncaught exception
12-13 22:01:47.203: E/AndroidRuntime(32216): java.lang.RuntimeException: Can't create handler inside thread that has not called Looper.prepare()
12-13 22:01:47.203: E/AndroidRuntime(32216):    at android.os.Handler.&lt;init&gt;(Handler.java:121)
12-13 22:01:47.203: E/AndroidRuntime(32216):    at android.app.Dialog.&lt;init&gt;(Dialog.java:105)
12-13 22:01:47.203: E/AndroidRuntime(32216):    at android.app.AlertDialog.&lt;init&gt;(AlertDialog.java:63)
12-13 22:01:47.203: E/AndroidRuntime(32216):    at android.app.ProgressDialog.&lt;init&gt;(ProgressDialog.java:80)
12-13 22:01:47.203: E/AndroidRuntime(32216):    at android.app.ProgressDialog.&lt;init&gt;(ProgressDialog.java:76)
12-13 22:01:47.203: E/AndroidRuntime(32216):    at com.nda.mybookdroid.MyBookDroidActivity$SubmitClass.onPreExecute(MyBookDroidActivity.java:115)
12-13 22:01:47.203: E/AndroidRuntime(32216):    at android.os.AsyncTask.execute(AsyncTask.java:391)
12-13 22:01:47.203: E/AndroidRuntime(32216):    at com.nda.mybookdroid.MyBookDroidActivity.executeSubmitClass(MyBookDroidActivity.java:101)
12-13 22:01:47.203: E/AndroidRuntime(32216):    at com.nda.mybookdroid.MyBookDroidActivity.access$0(MyBookDroidActivity.java:99)
12-13 22:01:47.203: E/AndroidRuntime(32216):    at com.nda.mybookdroid.MyBookDroidActivity$1.onAuthSucceed(MyBookDroidActivity.java:86)
12-13 22:01:47.203: E/AndroidRuntime(32216):    at com.nda.facebook.SessionEvents.onLoginSuccess(SessionEvents.java:78)
12-13 22:01:47.203: E/AndroidRuntime(32216):    at com.nda.facebook.FacebookConnector$IDRequestListener.onComplete(FacebookConnector.java:141)
12-13 22:01:47.203: E/AndroidRuntime(32216):    at com.facebook.android.AsyncFacebookRunner$2.run(AsyncFacebookRunner.java:254)
</code></pre>

<p>I try to execute Looper.prepare(), but in this case application freeze always. How should I execute AsyncTask? Thank you. </p>
