AsyncTask Domination

Mikael Magnusson
I am a developer
Published in
1 min readNov 2, 2015

I’m currently working on a project that is using the MediaPlayer to play MP3 files, and in my main Activity I’m using an AsyncTask to continuously update the SeekBar. But I kept running into a weird bug.

Whenever my download service would start and fire away a new AsyncTask to get an RSS feed nothing would happen. That is, until I flipped the phone and forced a configuration change.

The problem?

When first introduced, AsyncTasks were executed serially on a single background thread. Starting with DONUT, this was changed to a pool of threads allowing multiple tasks to operate in parallel. Starting with HONEYCOMB, tasks are executed on a single thread to avoid common application errors caused by parallel execution.

As per the Google’s documentation. So after three lines of code changes everything is peachy again.

(Originally published 2013–10–09)

--

--