title: AsyncTask in other class error in android java
body: <p>hi im trying to use asynctask in other class but when i call it it doesn't work </p>
  
  <p>here is my code</p>
  
  <pre><code>package com.examplee.test;
  
      import android.app.Activity;
      import android.app.ProgressDialog;
      import android.content.Context;
      import android.os.AsyncTask;
      import android.widget.Toast;
  
      public class test extends Activity {
  
          public static void main(String[] args) {
  
              new ProgressTask(test.this).execute();  // THIS IS ERROR CANNOT USE THIS IN STATIC CONTEXT and when i change static thing class doesn't work anymore
  
  
          }
  
          private class ProgressTask extends AsyncTask&lt;String, Void, Boolean&gt; {
              private ProgressDialog dialog;
  
              public ProgressTask(test mainActivity) {
                  context = mainActivity;
                  dialog = new ProgressDialog(context);
              }
  
              private Context context;
  
              protected void onPreExecute() {
                  this.dialog.setMessage("Please Wait For Some Time...");
                  this.dialog.setCancelable(false);
                  this.dialog.setTitle("Please Wait...");
                  this.dialog.setIcon(R.drawable.ic_launcher);
                  this.dialog.show();
              }
  
                  @Override
              protected void onPostExecute(final Boolean success) {
  
                      if (dialog.isShowing()) {
                      dialog.dismiss();
                  }
  
                      if (success) {
                          Toast.makeText(context, "Done", Toast.LENGTH_LONG).show();
                      } else {
                          Toast.makeText(context, "Some Error", Toast.LENGTH_LONG).show();
                      }
  
              }
  
              protected Boolean doInBackground(final String... args) {
  
                  // My Work i have to perform
  
                  return null; 
  
  
                }
          }
  
      }
  </code></pre>
  
  <p>can anybody correct this code ?
  even i try changing everything on progresstask.execute ,nothing is working :(</p>
  
  <p>i would appreciate if anybody could take time and help me sort it out :)</p>
  
  <p>this line is what i needed to stay in class to </p>
  
  <p><strong>public static void main(String[] args)</strong></p>