title: Android: Cancel Async Task
body: <p>I use an async task to upload an image and get some results.</p>
  <p>While uploading the image I see a progress dialog, written in onPreExecute() method like this:</p>
  <pre><code>    protected void onPreExecute() { 
           uploadingDialog = new ProgressDialog(MyActivity.this); 
           uploadingDialog.setMessage(&quot;uploading&quot;); 
           uploadingDialog.setCancelable(true);
           uploadingDialog.show();
      }
  </code></pre>
  <p>Ok when I press the back button, obviously the dialog disappears because of the setCancelable(true).</p>
  <p>But (obviously) the async task doesn't stop.</p>
  <p>So how can I fix this? I want to cancel both dialog and async task when I press the back button. Any ideas?</p>