Android async task not loading
<p>I am using the following code </p>

<pre><code>class AddTask extends AsyncTask&lt;Void, Void, Void&gt;
     {      
        ProgressDialog dialog;
    protected void onPreExecute() 
    {      
     dialog = new ProgressDialog(getApplicationContext());         
    dialog.setMessage("Loading"); 
    dialog.setIndeterminate(true);         
    dialog.setCancelable(false);      
    dialog.show();

      }     
     protected Void doInBackground(Void... unused) 
    {     

//task
return(null);  


    }     

      protected void onPostExecute(Void unused)
     {     
        dialog.dismiss();    
     }  

     }
</code></pre>

<p>I am calling it from here</p>

<pre><code>public void onCreate(Bundle savedInstanceState) 
    {
        super.onCreate(savedInstanceState);
        new AddTask.execute();
}
</code></pre>

<p>Logcat</p>

<p>03-29 18:16:06.434: E/AndroidRuntime(1246): Caused by: android.view.WindowManager$BadTokenException: Unable to add window -- token null is not for an application</p>
