title: AsyncTask crash when scroll event
body: <p>I have a problem AsyncTask in android listview is not really a problem when running normally, so the condition when the user scrolls page down to next page when asyntask running, the direct application of force closed.</p>
  
  <p>I've tried all the conditions as :</p>
  
  <pre><code>if (AsyncTask.Status.RUNNING == null) {
      / / My code do in backgroud here
  }
  
  if (backgroundtask.getStatus! = STATUS.RUNNING) {
      / / My code do in backgroud here
  }
  </code></pre>
  
  <p>Always failed...</p>
  
  <pre><code>public abstract View getAmazingView(int position, View convertView,
              ViewGroup parent);
  
  
  public final View getView(int position, View convertView, ViewGroup parent) {
          View res = getAmazingView(position, convertView, parent);
  
          if (position == getCount() - 1 &amp;&amp; automaticNextPageLoading) {
              onNextPageRequested(page + 1);
          }
  
          final int section = getSectionForPosition(position);
          boolean displaySectionHeaders = (getPositionForSection(section) ==  position);
  
          bindSectionHeader(res, position, displaySectionHeaders);
  
          return res;
      }
  
  
  protected void onNextPageRequested(int page) {
  
              backgroundTask = new AsyncTask&lt;Integer, Void, List&lt;Bola&gt;&gt;() {
                  protected List&lt;Bola&gt; doInBackground(
                          Integer... params) {
                      int page = params[0];
                      return Adapter.getRows(page);
                  }
  
                  protected void onPostExecute(
                          List&lt;Bola&gt; result) {
                      if (isCancelled()){
                          backgroundTask.cancel(true);                        
                      }
  
                      list.addAll(result);
                      nextPage();
                      notifyDataSetChanged();
  
                      if (result.size() &gt; 0) {
                          // still have more pages
                          notifyMayHaveMorePages();
                      } else {
                          notifyNoMorePages();
                      }
                  };
              }.execute(page);
          }
  </code></pre>
  
  <p>How that can be run with the AsyncTask running condition, and user use scrolls down event?</p>
  
  <p><strong>======= UPDATE MY LOG =======</strong></p>
  
  <pre><code>11-02 23:22:42.330: ERROR/AndroidRuntime(25830): FATAL EXCEPTION: main
  11-02 23:22:42.330: ERROR/AndroidRuntime(25830): java.lang.IllegalStateException: The content of the adapter has changed but ListView did not receive a notification. Make sure the content of your adapter is not modified from a background thread, but only from the UI thread. [in ListView(2131034281, class com.dhika.bola.application.ui.ListUtils) with Adapter(class android.widget.HeaderViewListAdapter)]
  11-02 23:22:42.330: ERROR/AndroidRuntime(25830):     at android.widget.ListView.layoutChildren(ListView.java:1548)
  11-02 23:22:42.330: ERROR/AndroidRuntime(25830):     at android.widget.AbsListView.onTouchEvent(AbsListView.java:3490)
  11-02 23:22:42.330: ERROR/AndroidRuntime(25830):     at com.dhika.bola.application.ui.ListUtils.onTouchEvent(ListUtils.java:445)
  11-02 23:22:42.330: ERROR/AndroidRuntime(25830):     at android.view.View.dispatchTouchEvent(View.java:7262)
  11-02 23:22:42.330: ERROR/AndroidRuntime(25830):     at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2235)
  11-02 23:22:42.330: ERROR/AndroidRuntime(25830):     at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1932)
  11-02 23:22:42.330: ERROR/AndroidRuntime(25830):     at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2241)
  11-02 23:22:42.330: ERROR/AndroidRuntime(25830):     at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1946)
  11-02 23:22:42.330: ERROR/AndroidRuntime(25830):     at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2241)
  11-02 23:22:42.330: ERROR/AndroidRuntime(25830):     at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1946)
  11-02 23:22:42.330: ERROR/AndroidRuntime(25830):     at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2241)
  11-02 23:22:42.330: ERROR/AndroidRuntime(25830):     at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1946)
  11-02 23:22:42.330: ERROR/AndroidRuntime(25830):     at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2241)
  11-02 23:22:42.330: ERROR/AndroidRuntime(25830):     at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1946)
  11-02 23:22:42.330: ERROR/AndroidRuntime(25830):     at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2241)
  11-02 23:22:42.330: ERROR/AndroidRuntime(25830):     at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1946)
  11-02 23:22:42.330: ERROR/AndroidRuntime(25830):     at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:1968)
  11-02 23:22:42.330: ERROR/AndroidRuntime(25830):     at com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1420)
  11-02 23:22:42.330: ERROR/AndroidRuntime(25830):     at android.app.Activity.dispatchTouchEvent(Activity.java:2428)
  11-02 23:22:42.330: ERROR/AndroidRuntime(25830):     at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:1916)
  11-02 23:22:42.330: ERROR/AndroidRuntime(25830):     at android.view.View.dispatchPointerEvent(View.java:7442)
  11-02 23:22:42.330: ERROR/AndroidRuntime(25830):     at android.view.ViewRootImpl.deliverPointerEvent(ViewRootImpl.java:3610)
  11-02 23:22:42.330: ERROR/AndroidRuntime(25830):     at android.view.ViewRootImpl.deliverInputEvent(ViewRootImpl.java:3538)
  11-02 23:22:42.330: ERROR/AndroidRuntime(25830):     at android.view.ViewRootImpl.doProcessInputEvents(ViewRootImpl.java:4790)
  11-02 23:22:42.330: ERROR/AndroidRuntime(25830):     at android.view.ViewRootImpl.enqueueInputEvent(ViewRootImpl.java:4750)
  11-02 23:22:42.330: ERROR/AndroidRuntime(25830):     at android.view.ViewRootImpl$WindowInputEventReceiver.onInputEvent(ViewRootImpl.java:4902)
  11-02 23:22:42.330: ERROR/AndroidRuntime(25830):     at android.view.InputEventReceiver.dispatchInputEvent(InputEventReceiver.java:179)
  11-02 23:22:42.330: ERROR/AndroidRuntime(25830):     at android.view.InputEventReceiver.nativeConsumeBatchedInputEvents(Native Method)
  11-02 23:22:42.330: ERROR/AndroidRuntime(25830):     at android.view.InputEventReceiver.consumeBatchedInputEvents(InputEventReceiver.java:171)
  11-02 23:22:42.330: ERROR/AndroidRuntime(25830):     at android.view.ViewRootImpl.doConsumeBatchedInput(ViewRootImpl.java:4870)
  11-02 23:22:42.330: ERROR/AndroidRuntime(25830):     at android.view.ViewRootImpl$ConsumeBatchedInputRunnable.run(ViewRootImpl.java:4924)
  11-02 23:22:42.330: ERROR/AndroidRuntime(25830):     at android.view.Choreographer$CallbackRecord.run(Choreographer.java:776)
  11-02 23:22:42.330: ERROR/AndroidRuntime(25830):     at android.view.Choreographer.doCallbacks(Choreographer.java:579)
  11-02 23:22:42.330: ERROR/AndroidRuntime(25830):     at android.view.Choreographer.doFrame(Choreographer.java:546)
  11-02 23:22:42.330: ERROR/AndroidRuntime(25830):     at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:762)
  11-02 23:22:42.330: ERROR/AndroidRuntime(25830):     at android.os.Handler.handleCallback(Handler.java:725)
  11-02 23:22:42.330: ERROR/AndroidRuntime(25830):     at android.os.Handler.dispatchMessage(Handler.java:92)
  11-02 23:22:42.330: ERROR/AndroidRuntime(25830):     at android.os.Looper.loop(Looper.java:153)
  11-02 23:22:42.330: ERROR/AndroidRuntime(25830):     at android.app.ActivityThread.main(ActivityThread.java:5297)
  11-02 23:22:42.330: ERROR/AndroidRuntime(25830):     at java.lang.reflect.Method.invokeNative(Native Method)
  11-02 23:22:42.330: ERROR/AndroidRuntime(25830):     at java.lang.reflect.Method.invoke(Method.java:511)
  11-02 23:22:42.330: ERROR/AndroidRuntime(25830):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:833)
  11-02 23:22:42.330: ERROR/AndroidRuntime(25830):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:600)
  11-02 23:22:42.330: ERROR/AndroidRuntime(25830):     at dalvik.system.NativeStart.main(Native Method)
  </code></pre>