title: Asynctask and onclicklistener android 2.3.3 versus 3.2
body: <p>On my nexus One (android 2.3.3) the following program behaves differently from my xoom (android 3.2):</p>
  
  <pre><code>public class TestOnclickWithAsyncTask extends Activity {
  
  private int mClicked = 0;
  
  private final static String TAG = "TestOnclickWithAsyncTask";
  
  @Override
  public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState); 
  
      setContentView(R.layout.main);
      RelativeLayout relativeLayout= (RelativeLayout) findViewById(R.id.img_control_panel);
  
      final Button button = new Button(this);
  
      button.setOnClickListener(new View.OnClickListener() {
          public void onClick(View v) {
              mClicked++;
              Log.i (TAG, "Clicked "+ mClicked + " times");
          }
      });
  
      relativeLayout.addView(button);
  
  
      new LongTask().execute();
  
  }
  
  private class LongTask extends AsyncTask&lt;Void , Void, Void&gt; {
      private ProgressDialog dialog;
  
        protected void onPreExecute() {
        dialog = new  ProgressDialog(TestOnclickWithAsyncTask.this);
        dialog.setMessage("Waiting ");
        dialog.setIndeterminate(true); 
        dialog.setCancelable(true); 
        try {
            dialog.show();
        } catch (Exception e){}
        }
  
          protected Void doInBackground(Void... notused) {
                  try {
                      Thread.sleep (30000);
                  } catch (InterruptedException e) {
                      e.printStackTrace();
                  }//do long task
              return null;
          }
  
  
          protected void onPostExecute(Void unusedg) { 
              dialog.dismiss();
              Log.i (TAG,"Long task finished");
          }
  
  }
  
  }
  </code></pre>
  
  <p>On my Nexus I can't press the button while the asynctask is running (desired behavior):</p>
  
  <pre><code>09-26 00:45:34.361: INFO/TestOnclickWithAsyncTask(3803): Long task finished
  09-26 00:45:36.463: INFO/TestOnclickWithAsyncTask(3803): Clicked 1 times
  09-26 00:45:36.814: INFO/TestOnclickWithAsyncTask(3803): Clicked 2 times
  09-26 00:45:37.975: INFO/TestOnclickWithAsyncTask(3803): Clicked 3 times
  09-26 00:45:38.435: INFO/TestOnclickWithAsyncTask(3803): Clicked 4 times
  </code></pre>
  
  <p>On my xoom I can just press the button and the progress indicator disappears.</p>
  
  <pre><code>09-26 00:49:05.440: INFO/TestOnclickWithAsyncTask(5887): Clicked 1 times
  09-26 00:49:06.230: INFO/TestOnclickWithAsyncTask(5887): Clicked 2 times
  09-26 00:49:06.580: INFO/TestOnclickWithAsyncTask(5887): Clicked 3 times
  09-26 00:49:06.840: INFO/TestOnclickWithAsyncTask(5887): Clicked 4 times
  09-26 00:49:08.170: INFO/TestOnclickWithAsyncTask(5887): Clicked 5 times
  09-26 00:49:08.560: INFO/TestOnclickWithAsyncTask(5887): Clicked 6 times
  09-26 00:49:30.960: INFO/TestOnclickWithAsyncTask(5887): Long task finished 
  09-26 00:49:32.800: INFO/TestOnclickWithAsyncTask(5887): Clicked 7 times
  09-26 00:49:33.810: INFO/TestOnclickWithAsyncTask(5887): Clicked 8 times
  </code></pre>
  
  <p>Why does this differ? And more importantly how can I prevent the xoom from canceling the progress dialog?</p>