title: Avoiding RejectedExecutionException in Android 4.4 when app uses list
body: <p>In Android 4.4 there seems to be a change in the code that causes list icons to be loaded using AsyncTasks. The result is that many of my users on Android 4.4 get <code>RejectedExecutionException</code> since the queue size limit is exceeded.</p>
  
  <p>A clever user at <a href="https://code.google.com/p/android/issues/detail?id=63162" rel="noreferrer">Code Google</a> discovered this, and explained it in this way:</p>
  
  <blockquote>
    <p>ResolverActivity will throw RejectedExecutionException on Android 4.4.</p>
    
    <p>I viewed the code of latest ResolverActivity and noticed that in ResolveListAdapter.bindView method it is using new LoadIconTask().execute(info), this should be the root cause. LoadIconTask is a subclass of AsyncTask, too many AsyncTask running at the same time will cause RejectedExecutionException.</p>
  </blockquote>
  
  <p>The ResolverActivity change can be found at the <a href="https://github.com/android/platform_frameworks_base/commit/0256c6f8d31c95f730d286b9e2ebae94736f7098#diff-b6453074da02963c87148311784ef154L635" rel="noreferrer">Android GitHub repo</a>. </p>
  
  <p>My app currently has 82 stack traces for <code>RejectedExecutionException</code>, all of which are for Android 4.4. Example start of stack:</p>
  
  <pre><code>java.util.concurrent.RejectedExecutionException: Task android.os.AsyncTask$3@41d44580 rejected from java.util.concurrent.ThreadPoolExecutor@41a575c0[Running, pool size = 5, active threads = 5, queued tasks = 128, completed tasks = 140]
   at java.util.concurrent.ThreadPoolExecutor$AbortPolicy.rejectedExecution(ThreadPoolExecutor.java:2011)
   at java.util.concurrent.ThreadPoolExecutor.reject(ThreadPoolExecutor.java:793)
   at java.util.concurrent.ThreadPoolExecutor.execute(ThreadPoolExecutor.java:1339)
   at android.os.AsyncTask.executeOnExecutor(AsyncTask.java:590)
   at android.os.AsyncTask.execute(AsyncTask.java:535)
   at com.android.internal.app.ResolverActivity$ResolveListAdapter.bindView(ResolverActivity.java:716)
   at com.android.internal.app.ResolverActivity$ResolveListAdapter.getView(ResolverActivity.java:702)
   at android.widget.AbsListView.obtainView(AbsListView.java:2255)
  ...
  </code></pre>
  
  <p>Is there any way to sidestep or handle this change?</p>