I try to modify the Spinner content across the AsyncTaks but I can\'t and the Logcat is wrote \"09-19 16:36:11.189: ERROR/ERROR THE(6078): Only the original thread that created
As mentioned by Peter, you cannot access the views using doInBackground()
. You can do that inside onPostExecute()
however. That is where you are supposed to work with the results doInBackground()
return as far as I know.
I ran into this issue and fixed it by moving the view modification code to onPostExecute()
.
For those of you who are starting to pick up Android development:
- doInBackground()
: whatever insides happen in another thread (in the background) different from the main/ original thread your views/ fragment/ activity operates on (this is the whole point of AsyncTask
==> you cannot touch the views!
- onPostExecute()
: now background stuffs are done, here it's back on the main/ thread thread ==> you can touch the views now!