title: Retrieve context in an abstract, non activity class
body: <p>I'm trying to build my abstract implementation of AsyncTask and I would like to insert a custom ProgressDialog. How can I get the context outside of an Activity Class?</p>
  
  <pre><code>   abstract public class DataPoller extends AsyncTask&lt;Void, Void, Void&gt; {
  
   Context mContext = getApplicationContext();
  
   ProgressDialog dialog = new ProgressDialog(mContext);
  
   @Override
   protected void onPreExecute() {
  
  
  
    dialog.setMessage("Polling data...");
    dialog.show();
  
  
   }
  
  
   @Override
   protected void onPostExecute(Void unused) {
  
    if ( dialog.isShowing() ) {
  
     dialog.dismiss();
  
    }
  
  
   }
  
   @Override
   protected Void doInBackground(Void... params) {
  
    int tmp=0;
  
    for (int ii = 0; ii&lt;1000; ii ++) {
  
     for (int jj = 0; jj&lt;1000; jj ++) {
  
      tmp = ( tmp + 3 ) % 167;     
  
     }
  
    }
    return null;
   }
  </code></pre>
  
  <p>}</p>