title: Calling a Static Method with AsyncTask/ProgressDialog of a class
body: <p>So I'm relatively new to Android (and Java). I've made a class which has your usual <code>AsyncTask</code> with a ProgressDialog in a <code>static</code> method because I want to call it from multiple Activities.</p>
  
  <pre><code>public class SomeClass {
  
      // Some other methods, etc.
  
      public static void SomeFunction(final Context context, String FilePath) {
          new AsyncTask&lt;Void, Void, Void&gt;() {
              private ProgressDialog dialog;
  
              protected void onPreExecute() {
                  dialog = ProgressDialog.show(context, "", "Loading...", true); 
              }
  
              protected Void doInBackground(Void... unused) { 
                  for (int i=0; i&lt;15000; i++) 
                      System.out.println("Gatorade me, Bitch: " + i);
  
              return null;
              }
  
              protected void onPostExecute(Void unused) { 
                  dialog.dismiss();
              }
  
          }.execute();  
      }
  
  }
  </code></pre>
  
  <p>The problem is that the statement 
  <code>dialog = ProgressDialog.show(context, "", "Loading...", true);</code>
  in the <code>onPreExecute()</code> section of the <code>AsyncTask</code> gives error. The code runs fine without it.</p>
  
  <p>So what can I do to solve this issue without creating a new java class file for AsyncTask. I know that works but I just want to make one file for this entire class so I can use it in multiple programs. </p>
  
  <p>Thanks for your help!</p>