why img.setImageBitmap(bitmap) is already run on UI thread
Because you wrote it in onPostExecute()
method of AsyncTask. In AsyncTask
, the methods like onPreExecute()
and onPostExecute()
always run on your main UI thread, while only doInBackground() runs on a separate thread...