[android-developers] Re: AsyncTask in Android 4.0
On Friday, April 20, 2012 3:16:35 PM UTC-4, Nathan wrote:
Still adjusting to the changes in Android 4.0 regarding AsyncTask.
If I understand right, the default behavior of execute is changing to one single thread pool with only one thread? With the reason cited that programmers are not capable of handling a bigger threadpool (I'm paraphrasing).
public abstract class ThreadPoolAsyncTask<Params, Progress, Result> extends AsyncTask<Params, Progress, Result> {
/*
* This is a helper method to allow ICS AsyncTask to run in a thread pool,
* without break API compatability with pre-ICS devices.
* If you don't want a threadpool use the default AsyncTask since that is the
* default for ICS. If you don't want a threadpool for pre-ICS (API level < 13)
* then you need to wrote your own AsyncTask. Use the AsyncTask.java as a good starting point.
*/
public void executeOnThreadPool(Params...params) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
this.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, params);
} else {
this.execute(params);
}
}
}
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home