title: Progress dialog in AsyncTask do not show up
body: <p>I know there was similiar problem to this, but I still haven't found an answer. The problem is that progress dialog for this long operation won't show up, but still process is being done. I think there is problem with the context, but dunno how to solve this. </p>
  
  <pre><code>public class MainActivity extends Activity {
  
  Utilities uti = new Utilities();
  SharedPreferences prefs = null;
  private ContactServiceActivity contactService;
  ProgressDialog mProgressDialog;
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
  
      contactService = new ContactServiceActivity(getApplicationContext());
  
      doFirstRun();
  
      Intent i = new Intent(getBaseContext(), ContactListActivity.class);
      startActivity(i);
  }
  
  private void doFirstRun() {
      SharedPreferences settings = getSharedPreferences("pl.stxnext.stxcontactsync", MODE_PRIVATE);
      if (settings.getBoolean("isFirstRun", true)) {
  
          new firstRunTask().execute();
  
          SharedPreferences.Editor editor = settings.edit();
          editor.putBoolean("isFirstRun", false);
          editor.commit();
      }
  }
  
  private class firstRunTask extends AsyncTask&lt;Void, Void, Void&gt; {
  
      @Override
      protected void onPreExecute() {
          super.onPreExecute();
          mProgressDialog = new ProgressDialog(MainActivity.this);
          mProgressDialog.setTitle("Trwa synchronizacja danych");
          mProgressDialog.setMessage("Może to zająć chwilę, proszę czekać.");
          mProgressDialog.setIndeterminate(false);
          mProgressDialog.show();
      }
  
      @Override
      protected Void doInBackground(Void... params) {
          contactService.getAssetsAtFirstRun();
          return null;
      }
  
      @Override
      protected void onPostExecute(Void result) {
          mProgressDialog.dismiss();
          uti.showToast(getBaseContext(), "Zapisano kontakty.");
      }
  }
  </code></pre>
  
  <p>}</p>