App close when use async method
<p>I'm writting an application which has to contact a webservice. 
It's working.
But, now I have to use the async task. I have to fill a list of category.
I can't figure what's the problem.</p>

<p>The async class : </p>

<pre><code>private class CallCategory extends AsyncTask&lt;List&lt;Category&gt;,Void,List&lt;Category&gt;&gt;{
        private ProgressDialog dialog;


        protected void onPreExecute() {
            this.dialog = ProgressDialog.show(getApplicationContext(), "Calling", "Time Service...", true);
        }

        protected void onPostExecute() {
            this.dialog.cancel();
        }

        @Override
        protected List&lt;Category&gt; doInBackground(List&lt;Category&gt;... params) {
            return ServerCall.GetCategory();
        }


    }
</code></pre>

<p>The call : </p>

<pre><code>    CallCategory cc = new CallCategory();
    _ListCategory = new ArrayList&lt;Category&gt;();
    cc.execute();
</code></pre>

<p>GetCategory fonction : </p>

<pre><code>public static List&lt;Category&gt; GetCategory (){
    List&lt;Category&gt; categories = null;
    try{

        String url =  "http://188.130.40.103/api/"+"Category";
        RestClient client = new RestClient(url);

        //Call
        client.Execute(RequestMethod.GET);

        if(client.getResponseCode() == 200){

        //Get the response
        String response = client.getResponse();

        //build list of categories
        Type listType = new TypeToken&lt;ArrayList&lt;Category&gt;&gt;() {
    }.getType();

     categories = new Gson().fromJson(response, listType);
    }

    }
    catch (Exception e) {
        Log.i("Error", e.toString());
    }
    return categories;
}
</code></pre>

<p>StackTrace :</p>

<pre><code> 06-29 12:58:57.746: W/dalvikvm(3087): threadid=3: thread exiting with
     uncaught exception (group=0x4001b188) 06-29 12:58:57.746:
     E/AndroidRuntime(3087): Uncaught handler: thread main exiting due to
     uncaught exception 06-29 12:58:57.786: E/AndroidRuntime(3087):
     java.lang.RuntimeException: Unable to start activity
     ComponentInfo{ApPicture.Android/ApPicture.Android.ApPictureActivity}:
     android.view.WindowManager$BadTokenException: Unable to add window --
     token null is not for an application 06-29 12:58:57.786:
     E/AndroidRuntime(3087):    at
     android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2496)
     06-29 12:58:57.786: E/AndroidRuntime(3087):    at
     android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2512)
     06-29 12:58:57.786: E/AndroidRuntime(3087):    at
     android.app.ActivityThread.access$2200(ActivityThread.java:119) 06-29
     12:58:57.786: E/AndroidRuntime(3087):  at
     android.app.ActivityThread$H.handleMessage(ActivityThread.java:1863)
     06-29 12:58:57.786: E/AndroidRuntime(3087):    at
     android.os.Handler.dispatchMessage(Handler.java:99) 06-29
     12:58:57.786: E/AndroidRuntime(3087):  at
     android.os.Looper.loop(Looper.java:123) 06-29 12:58:57.786:
     E/AndroidRuntime(3087):    at
     android.app.ActivityThread.main(ActivityThread.java:4363) 06-29
     12:58:57.786: E/AndroidRuntime(3087):  at
     java.lang.reflect.Method.invokeNative(Native Method) 06-29
     12:58:57.786: E/AndroidRuntime(3087):  at
     java.lang.reflect.Method.invoke(Method.java:521) 06-29 12:58:57.786:
     E/AndroidRuntime(3087):    at
     com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
     06-29 12:58:57.786: E/AndroidRuntime(3087):    at
     com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618) 06-29
     12:58:57.786: E/AndroidRuntime(3087):  at
     dalvik.system.NativeStart.main(Native Method) 06-29 12:58:57.786:
     E/AndroidRuntime(3087): Caused by:
     android.view.WindowManager$BadTokenException: Unable to add window --
     token null is not for an application 06-29 12:58:57.786:
     E/AndroidRuntime(3087):    at
     android.view.ViewRoot.setView(ViewRoot.java:472) 06-29 12:58:57.786:
     E/AndroidRuntime(3087):    at
     android.view.WindowManagerImpl.addView(WindowManagerImpl.java:177)
     06-29 12:58:57.786: E/AndroidRuntime(3087):    at
     android.view.WindowManagerImpl.addView(WindowManagerImpl.java:91)
     06-29 12:58:57.786: E/AndroidRuntime(3087):    at
     android.app.Dialog.show(Dialog.java:239) 06-29 12:58:57.786:
     E/AndroidRuntime(3087):    at
     android.app.ProgressDialog.show(ProgressDialog.java:107) 06-29
     12:58:57.786: E/AndroidRuntime(3087):  at
     android.app.ProgressDialog.show(ProgressDialog.java:90) 06-29
     12:58:57.786: E/AndroidRuntime(3087):  at
     ApPicture.Android.ApPictureActivity$CallCategory.onPreExecute(ApPictureActivity.java:406)
     06-29 12:58:57.786: E/AndroidRuntime(3087):    at
     android.os.AsyncTask.execute(AsyncTask.java:391) 06-29 12:58:57.786:
     E/AndroidRuntime(3087):    at
     ApPicture.Android.ApPictureActivity.LoadCategory(ApPictureActivity.java:291)
     06-29 12:58:57.786: E/AndroidRuntime(3087):    at
     ApPicture.Android.ApPictureActivity.onCreate(ApPictureActivity.java:108)
     06-29 12:58:57.786: E/AndroidRuntime(3087):    at
     android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
     06-29 12:58:57.786: E/AndroidRuntime(3087):    at
     android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2459)
     06-29 12:58:57.786: E/AndroidRuntime(3087):    ... 11 more
</code></pre>

<p>Regards.</p>
